00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 #include "mathops.h"
00029
00030 #include "bit_depth_template.c"
00031
00032 static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright,
00033 ptrdiff_t _stride)
00034 {
00035 pixel *src = (pixel*)_src;
00036 int stride = _stride>>(sizeof(pixel)-1);
00037 const pixel4 a= AV_RN4PA(src-stride);
00038
00039 AV_WN4PA(src+0*stride, a);
00040 AV_WN4PA(src+1*stride, a);
00041 AV_WN4PA(src+2*stride, a);
00042 AV_WN4PA(src+3*stride, a);
00043 }
00044
00045 static void FUNCC(pred4x4_horizontal)(uint8_t *_src, const uint8_t *topright,
00046 ptrdiff_t _stride)
00047 {
00048 pixel *src = (pixel*)_src;
00049 int stride = _stride>>(sizeof(pixel)-1);
00050 AV_WN4PA(src+0*stride, PIXEL_SPLAT_X4(src[-1+0*stride]));
00051 AV_WN4PA(src+1*stride, PIXEL_SPLAT_X4(src[-1+1*stride]));
00052 AV_WN4PA(src+2*stride, PIXEL_SPLAT_X4(src[-1+2*stride]));
00053 AV_WN4PA(src+3*stride, PIXEL_SPLAT_X4(src[-1+3*stride]));
00054 }
00055
00056 static void FUNCC(pred4x4_dc)(uint8_t *_src, const uint8_t *topright,
00057 ptrdiff_t _stride)
00058 {
00059 pixel *src = (pixel*)_src;
00060 int stride = _stride>>(sizeof(pixel)-1);
00061 const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride]
00062 + src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 4) >>3;
00063 const pixel4 a = PIXEL_SPLAT_X4(dc);
00064
00065 AV_WN4PA(src+0*stride, a);
00066 AV_WN4PA(src+1*stride, a);
00067 AV_WN4PA(src+2*stride, a);
00068 AV_WN4PA(src+3*stride, a);
00069 }
00070
00071 static void FUNCC(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright,
00072 ptrdiff_t _stride)
00073 {
00074 pixel *src = (pixel*)_src;
00075 int stride = _stride>>(sizeof(pixel)-1);
00076 const int dc= ( src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2;
00077 const pixel4 a = PIXEL_SPLAT_X4(dc);
00078
00079 AV_WN4PA(src+0*stride, a);
00080 AV_WN4PA(src+1*stride, a);
00081 AV_WN4PA(src+2*stride, a);
00082 AV_WN4PA(src+3*stride, a);
00083 }
00084
00085 static void FUNCC(pred4x4_top_dc)(uint8_t *_src, const uint8_t *topright,
00086 ptrdiff_t _stride)
00087 {
00088 pixel *src = (pixel*)_src;
00089 int stride = _stride>>(sizeof(pixel)-1);
00090 const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + 2) >>2;
00091 const pixel4 a = PIXEL_SPLAT_X4(dc);
00092
00093 AV_WN4PA(src+0*stride, a);
00094 AV_WN4PA(src+1*stride, a);
00095 AV_WN4PA(src+2*stride, a);
00096 AV_WN4PA(src+3*stride, a);
00097 }
00098
00099 static void FUNCC(pred4x4_128_dc)(uint8_t *_src, const uint8_t *topright,
00100 ptrdiff_t _stride)
00101 {
00102 pixel *src = (pixel*)_src;
00103 int stride = _stride>>(sizeof(pixel)-1);
00104 const pixel4 a = PIXEL_SPLAT_X4(1<<(BIT_DEPTH-1));
00105
00106 AV_WN4PA(src+0*stride, a);
00107 AV_WN4PA(src+1*stride, a);
00108 AV_WN4PA(src+2*stride, a);
00109 AV_WN4PA(src+3*stride, a);
00110 }
00111
00112 static void FUNCC(pred4x4_127_dc)(uint8_t *_src, const uint8_t *topright,
00113 ptrdiff_t _stride)
00114 {
00115 pixel *src = (pixel*)_src;
00116 int stride = _stride>>(sizeof(pixel)-1);
00117 const pixel4 a = PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))-1);
00118
00119 AV_WN4PA(src+0*stride, a);
00120 AV_WN4PA(src+1*stride, a);
00121 AV_WN4PA(src+2*stride, a);
00122 AV_WN4PA(src+3*stride, a);
00123 }
00124
00125 static void FUNCC(pred4x4_129_dc)(uint8_t *_src, const uint8_t *topright,
00126 ptrdiff_t _stride)
00127 {
00128 pixel *src = (pixel*)_src;
00129 int stride = _stride>>(sizeof(pixel)-1);
00130 const pixel4 a = PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))+1);
00131
00132 AV_WN4PA(src+0*stride, a);
00133 AV_WN4PA(src+1*stride, a);
00134 AV_WN4PA(src+2*stride, a);
00135 AV_WN4PA(src+3*stride, a);
00136 }
00137
00138
00139 #define LOAD_TOP_RIGHT_EDGE\
00140 const unsigned av_unused t4 = topright[0];\
00141 const unsigned av_unused t5 = topright[1];\
00142 const unsigned av_unused t6 = topright[2];\
00143 const unsigned av_unused t7 = topright[3];\
00144
00145 #define LOAD_DOWN_LEFT_EDGE\
00146 const unsigned av_unused l4 = src[-1+4*stride];\
00147 const unsigned av_unused l5 = src[-1+5*stride];\
00148 const unsigned av_unused l6 = src[-1+6*stride];\
00149 const unsigned av_unused l7 = src[-1+7*stride];\
00150
00151 #define LOAD_LEFT_EDGE\
00152 const unsigned av_unused l0 = src[-1+0*stride];\
00153 const unsigned av_unused l1 = src[-1+1*stride];\
00154 const unsigned av_unused l2 = src[-1+2*stride];\
00155 const unsigned av_unused l3 = src[-1+3*stride];\
00156
00157 #define LOAD_TOP_EDGE\
00158 const unsigned av_unused t0 = src[ 0-1*stride];\
00159 const unsigned av_unused t1 = src[ 1-1*stride];\
00160 const unsigned av_unused t2 = src[ 2-1*stride];\
00161 const unsigned av_unused t3 = src[ 3-1*stride];\
00162
00163 static void FUNCC(pred4x4_down_right)(uint8_t *_src, const uint8_t *topright,
00164 ptrdiff_t _stride)
00165 {
00166 pixel *src = (pixel*)_src;
00167 int stride = _stride>>(sizeof(pixel)-1);
00168 const int lt= src[-1-1*stride];
00169 LOAD_TOP_EDGE
00170 LOAD_LEFT_EDGE
00171
00172 src[0+3*stride]=(l3 + 2*l2 + l1 + 2)>>2;
00173 src[0+2*stride]=
00174 src[1+3*stride]=(l2 + 2*l1 + l0 + 2)>>2;
00175 src[0+1*stride]=
00176 src[1+2*stride]=
00177 src[2+3*stride]=(l1 + 2*l0 + lt + 2)>>2;
00178 src[0+0*stride]=
00179 src[1+1*stride]=
00180 src[2+2*stride]=
00181 src[3+3*stride]=(l0 + 2*lt + t0 + 2)>>2;
00182 src[1+0*stride]=
00183 src[2+1*stride]=
00184 src[3+2*stride]=(lt + 2*t0 + t1 + 2)>>2;
00185 src[2+0*stride]=
00186 src[3+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
00187 src[3+0*stride]=(t1 + 2*t2 + t3 + 2)>>2;
00188 }
00189
00190 static void FUNCC(pred4x4_down_left)(uint8_t *_src, const uint8_t *_topright,
00191 ptrdiff_t _stride)
00192 {
00193 pixel *src = (pixel*)_src;
00194 const pixel *topright = (const pixel*)_topright;
00195 int stride = _stride>>(sizeof(pixel)-1);
00196 LOAD_TOP_EDGE
00197 LOAD_TOP_RIGHT_EDGE
00198
00199
00200 src[0+0*stride]=(t0 + t2 + 2*t1 + 2)>>2;
00201 src[1+0*stride]=
00202 src[0+1*stride]=(t1 + t3 + 2*t2 + 2)>>2;
00203 src[2+0*stride]=
00204 src[1+1*stride]=
00205 src[0+2*stride]=(t2 + t4 + 2*t3 + 2)>>2;
00206 src[3+0*stride]=
00207 src[2+1*stride]=
00208 src[1+2*stride]=
00209 src[0+3*stride]=(t3 + t5 + 2*t4 + 2)>>2;
00210 src[3+1*stride]=
00211 src[2+2*stride]=
00212 src[1+3*stride]=(t4 + t6 + 2*t5 + 2)>>2;
00213 src[3+2*stride]=
00214 src[2+3*stride]=(t5 + t7 + 2*t6 + 2)>>2;
00215 src[3+3*stride]=(t6 + 3*t7 + 2)>>2;
00216 }
00217
00218 static void FUNCC(pred4x4_vertical_right)(uint8_t *_src,
00219 const uint8_t *topright,
00220 ptrdiff_t _stride)
00221 {
00222 pixel *src = (pixel*)_src;
00223 int stride = _stride>>(sizeof(pixel)-1);
00224 const int lt= src[-1-1*stride];
00225 LOAD_TOP_EDGE
00226 LOAD_LEFT_EDGE
00227
00228 src[0+0*stride]=
00229 src[1+2*stride]=(lt + t0 + 1)>>1;
00230 src[1+0*stride]=
00231 src[2+2*stride]=(t0 + t1 + 1)>>1;
00232 src[2+0*stride]=
00233 src[3+2*stride]=(t1 + t2 + 1)>>1;
00234 src[3+0*stride]=(t2 + t3 + 1)>>1;
00235 src[0+1*stride]=
00236 src[1+3*stride]=(l0 + 2*lt + t0 + 2)>>2;
00237 src[1+1*stride]=
00238 src[2+3*stride]=(lt + 2*t0 + t1 + 2)>>2;
00239 src[2+1*stride]=
00240 src[3+3*stride]=(t0 + 2*t1 + t2 + 2)>>2;
00241 src[3+1*stride]=(t1 + 2*t2 + t3 + 2)>>2;
00242 src[0+2*stride]=(lt + 2*l0 + l1 + 2)>>2;
00243 src[0+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
00244 }
00245
00246 static void FUNCC(pred4x4_vertical_left)(uint8_t *_src,
00247 const uint8_t *_topright,
00248 ptrdiff_t _stride)
00249 {
00250 pixel *src = (pixel*)_src;
00251 const pixel *topright = (const pixel*)_topright;
00252 int stride = _stride>>(sizeof(pixel)-1);
00253 LOAD_TOP_EDGE
00254 LOAD_TOP_RIGHT_EDGE
00255
00256 src[0+0*stride]=(t0 + t1 + 1)>>1;
00257 src[1+0*stride]=
00258 src[0+2*stride]=(t1 + t2 + 1)>>1;
00259 src[2+0*stride]=
00260 src[1+2*stride]=(t2 + t3 + 1)>>1;
00261 src[3+0*stride]=
00262 src[2+2*stride]=(t3 + t4+ 1)>>1;
00263 src[3+2*stride]=(t4 + t5+ 1)>>1;
00264 src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
00265 src[1+1*stride]=
00266 src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
00267 src[2+1*stride]=
00268 src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
00269 src[3+1*stride]=
00270 src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
00271 src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
00272 }
00273
00274 static void FUNCC(pred4x4_horizontal_up)(uint8_t *_src, const uint8_t *topright,
00275 ptrdiff_t _stride)
00276 {
00277 pixel *src = (pixel*)_src;
00278 int stride = _stride>>(sizeof(pixel)-1);
00279 LOAD_LEFT_EDGE
00280
00281 src[0+0*stride]=(l0 + l1 + 1)>>1;
00282 src[1+0*stride]=(l0 + 2*l1 + l2 + 2)>>2;
00283 src[2+0*stride]=
00284 src[0+1*stride]=(l1 + l2 + 1)>>1;
00285 src[3+0*stride]=
00286 src[1+1*stride]=(l1 + 2*l2 + l3 + 2)>>2;
00287 src[2+1*stride]=
00288 src[0+2*stride]=(l2 + l3 + 1)>>1;
00289 src[3+1*stride]=
00290 src[1+2*stride]=(l2 + 2*l3 + l3 + 2)>>2;
00291 src[3+2*stride]=
00292 src[1+3*stride]=
00293 src[0+3*stride]=
00294 src[2+2*stride]=
00295 src[2+3*stride]=
00296 src[3+3*stride]=l3;
00297 }
00298
00299 static void FUNCC(pred4x4_horizontal_down)(uint8_t *_src,
00300 const uint8_t *topright,
00301 ptrdiff_t _stride)
00302 {
00303 pixel *src = (pixel*)_src;
00304 int stride = _stride>>(sizeof(pixel)-1);
00305 const int lt= src[-1-1*stride];
00306 LOAD_TOP_EDGE
00307 LOAD_LEFT_EDGE
00308
00309 src[0+0*stride]=
00310 src[2+1*stride]=(lt + l0 + 1)>>1;
00311 src[1+0*stride]=
00312 src[3+1*stride]=(l0 + 2*lt + t0 + 2)>>2;
00313 src[2+0*stride]=(lt + 2*t0 + t1 + 2)>>2;
00314 src[3+0*stride]=(t0 + 2*t1 + t2 + 2)>>2;
00315 src[0+1*stride]=
00316 src[2+2*stride]=(l0 + l1 + 1)>>1;
00317 src[1+1*stride]=
00318 src[3+2*stride]=(lt + 2*l0 + l1 + 2)>>2;
00319 src[0+2*stride]=
00320 src[2+3*stride]=(l1 + l2+ 1)>>1;
00321 src[1+2*stride]=
00322 src[3+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
00323 src[0+3*stride]=(l2 + l3 + 1)>>1;
00324 src[1+3*stride]=(l1 + 2*l2 + l3 + 2)>>2;
00325 }
00326
00327 static void FUNCC(pred16x16_vertical)(uint8_t *_src, ptrdiff_t _stride)
00328 {
00329 int i;
00330 pixel *src = (pixel*)_src;
00331 int stride = _stride>>(sizeof(pixel)-1);
00332 const pixel4 a = AV_RN4PA(((pixel4*)(src-stride))+0);
00333 const pixel4 b = AV_RN4PA(((pixel4*)(src-stride))+1);
00334 const pixel4 c = AV_RN4PA(((pixel4*)(src-stride))+2);
00335 const pixel4 d = AV_RN4PA(((pixel4*)(src-stride))+3);
00336
00337 for(i=0; i<16; i++){
00338 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
00339 AV_WN4PA(((pixel4*)(src+i*stride))+1, b);
00340 AV_WN4PA(((pixel4*)(src+i*stride))+2, c);
00341 AV_WN4PA(((pixel4*)(src+i*stride))+3, d);
00342 }
00343 }
00344
00345 static void FUNCC(pred16x16_horizontal)(uint8_t *_src, ptrdiff_t stride)
00346 {
00347 int i;
00348 pixel *src = (pixel*)_src;
00349 stride >>= sizeof(pixel)-1;
00350
00351 for(i=0; i<16; i++){
00352 const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]);
00353
00354 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
00355 AV_WN4PA(((pixel4*)(src+i*stride))+1, a);
00356 AV_WN4PA(((pixel4*)(src+i*stride))+2, a);
00357 AV_WN4PA(((pixel4*)(src+i*stride))+3, a);
00358 }
00359 }
00360
00361 #define PREDICT_16x16_DC(v)\
00362 for(i=0; i<16; i++){\
00363 AV_WN4PA(src+ 0, v);\
00364 AV_WN4PA(src+ 4, v);\
00365 AV_WN4PA(src+ 8, v);\
00366 AV_WN4PA(src+12, v);\
00367 src += stride;\
00368 }
00369
00370 static void FUNCC(pred16x16_dc)(uint8_t *_src, ptrdiff_t stride)
00371 {
00372 int i, dc=0;
00373 pixel *src = (pixel*)_src;
00374 pixel4 dcsplat;
00375 stride >>= sizeof(pixel)-1;
00376
00377 for(i=0;i<16; i++){
00378 dc+= src[-1+i*stride];
00379 }
00380
00381 for(i=0;i<16; i++){
00382 dc+= src[i-stride];
00383 }
00384
00385 dcsplat = PIXEL_SPLAT_X4((dc+16)>>5);
00386 PREDICT_16x16_DC(dcsplat);
00387 }
00388
00389 static void FUNCC(pred16x16_left_dc)(uint8_t *_src, ptrdiff_t stride)
00390 {
00391 int i, dc=0;
00392 pixel *src = (pixel*)_src;
00393 pixel4 dcsplat;
00394 stride >>= sizeof(pixel)-1;
00395
00396 for(i=0;i<16; i++){
00397 dc+= src[-1+i*stride];
00398 }
00399
00400 dcsplat = PIXEL_SPLAT_X4((dc+8)>>4);
00401 PREDICT_16x16_DC(dcsplat);
00402 }
00403
00404 static void FUNCC(pred16x16_top_dc)(uint8_t *_src, ptrdiff_t stride)
00405 {
00406 int i, dc=0;
00407 pixel *src = (pixel*)_src;
00408 pixel4 dcsplat;
00409 stride >>= sizeof(pixel)-1;
00410
00411 for(i=0;i<16; i++){
00412 dc+= src[i-stride];
00413 }
00414
00415 dcsplat = PIXEL_SPLAT_X4((dc+8)>>4);
00416 PREDICT_16x16_DC(dcsplat);
00417 }
00418
00419 #define PRED16x16_X(n, v) \
00420 static void FUNCC(pred16x16_##n##_dc)(uint8_t *_src, ptrdiff_t stride)\
00421 {\
00422 int i;\
00423 pixel *src = (pixel*)_src;\
00424 stride >>= sizeof(pixel)-1;\
00425 PREDICT_16x16_DC(PIXEL_SPLAT_X4(v));\
00426 }
00427
00428 PRED16x16_X(127, (1<<(BIT_DEPTH-1))-1)
00429 PRED16x16_X(128, (1<<(BIT_DEPTH-1))+0)
00430 PRED16x16_X(129, (1<<(BIT_DEPTH-1))+1)
00431
00432 static inline void FUNCC(pred16x16_plane_compat)(uint8_t *_src,
00433 ptrdiff_t _stride,
00434 const int svq3,
00435 const int rv40)
00436 {
00437 int i, j, k;
00438 int a;
00439 INIT_CLIP
00440 pixel *src = (pixel*)_src;
00441 int stride = _stride>>(sizeof(pixel)-1);
00442 const pixel * const src0 = src +7-stride;
00443 const pixel * src1 = src +8*stride-1;
00444 const pixel * src2 = src1-2*stride;
00445 int H = src0[1] - src0[-1];
00446 int V = src1[0] - src2[ 0];
00447 for(k=2; k<=8; ++k) {
00448 src1 += stride; src2 -= stride;
00449 H += k*(src0[k] - src0[-k]);
00450 V += k*(src1[0] - src2[ 0]);
00451 }
00452 if(svq3){
00453 H = ( 5*(H/4) ) / 16;
00454 V = ( 5*(V/4) ) / 16;
00455
00456
00457 i = H; H = V; V = i;
00458 }else if(rv40){
00459 H = ( H + (H>>2) ) >> 4;
00460 V = ( V + (V>>2) ) >> 4;
00461 }else{
00462 H = ( 5*H+32 ) >> 6;
00463 V = ( 5*V+32 ) >> 6;
00464 }
00465
00466 a = 16*(src1[0] + src2[16] + 1) - 7*(V+H);
00467 for(j=16; j>0; --j) {
00468 int b = a;
00469 a += V;
00470 for(i=-16; i<0; i+=4) {
00471 src[16+i] = CLIP((b ) >> 5);
00472 src[17+i] = CLIP((b+ H) >> 5);
00473 src[18+i] = CLIP((b+2*H) >> 5);
00474 src[19+i] = CLIP((b+3*H) >> 5);
00475 b += 4*H;
00476 }
00477 src += stride;
00478 }
00479 }
00480
00481 static void FUNCC(pred16x16_plane)(uint8_t *src, ptrdiff_t stride)
00482 {
00483 FUNCC(pred16x16_plane_compat)(src, stride, 0, 0);
00484 }
00485
00486 static void FUNCC(pred8x8_vertical)(uint8_t *_src, ptrdiff_t _stride)
00487 {
00488 int i;
00489 pixel *src = (pixel*)_src;
00490 int stride = _stride>>(sizeof(pixel)-1);
00491 const pixel4 a= AV_RN4PA(((pixel4*)(src-stride))+0);
00492 const pixel4 b= AV_RN4PA(((pixel4*)(src-stride))+1);
00493
00494 for(i=0; i<8; i++){
00495 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
00496 AV_WN4PA(((pixel4*)(src+i*stride))+1, b);
00497 }
00498 }
00499
00500 static void FUNCC(pred8x16_vertical)(uint8_t *_src, ptrdiff_t _stride)
00501 {
00502 int i;
00503 pixel *src = (pixel*)_src;
00504 int stride = _stride>>(sizeof(pixel)-1);
00505 const pixel4 a= AV_RN4PA(((pixel4*)(src-stride))+0);
00506 const pixel4 b= AV_RN4PA(((pixel4*)(src-stride))+1);
00507
00508 for(i=0; i<16; i++){
00509 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
00510 AV_WN4PA(((pixel4*)(src+i*stride))+1, b);
00511 }
00512 }
00513
00514 static void FUNCC(pred8x8_horizontal)(uint8_t *_src, ptrdiff_t stride)
00515 {
00516 int i;
00517 pixel *src = (pixel*)_src;
00518 stride >>= sizeof(pixel)-1;
00519
00520 for(i=0; i<8; i++){
00521 const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]);
00522 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
00523 AV_WN4PA(((pixel4*)(src+i*stride))+1, a);
00524 }
00525 }
00526
00527 static void FUNCC(pred8x16_horizontal)(uint8_t *_src, ptrdiff_t stride)
00528 {
00529 int i;
00530 pixel *src = (pixel*)_src;
00531 stride >>= sizeof(pixel)-1;
00532 for(i=0; i<16; i++){
00533 const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]);
00534 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
00535 AV_WN4PA(((pixel4*)(src+i*stride))+1, a);
00536 }
00537 }
00538
00539 #define PRED8x8_X(n, v)\
00540 static void FUNCC(pred8x8_##n##_dc)(uint8_t *_src, ptrdiff_t stride)\
00541 {\
00542 int i;\
00543 const pixel4 a = PIXEL_SPLAT_X4(v);\
00544 pixel *src = (pixel*)_src;\
00545 stride >>= sizeof(pixel)-1;\
00546 for(i=0; i<8; i++){\
00547 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);\
00548 AV_WN4PA(((pixel4*)(src+i*stride))+1, a);\
00549 }\
00550 }
00551
00552 PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1)
00553 PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0)
00554 PRED8x8_X(129, (1<<(BIT_DEPTH-1))+1)
00555
00556 static void FUNCC(pred8x16_128_dc)(uint8_t *_src, ptrdiff_t stride)
00557 {
00558 FUNCC(pred8x8_128_dc)(_src, stride);
00559 FUNCC(pred8x8_128_dc)(_src+8*stride, stride);
00560 }
00561
00562 static void FUNCC(pred8x8_left_dc)(uint8_t *_src, ptrdiff_t stride)
00563 {
00564 int i;
00565 int dc0, dc2;
00566 pixel4 dc0splat, dc2splat;
00567 pixel *src = (pixel*)_src;
00568 stride >>= sizeof(pixel)-1;
00569
00570 dc0=dc2=0;
00571 for(i=0;i<4; i++){
00572 dc0+= src[-1+i*stride];
00573 dc2+= src[-1+(i+4)*stride];
00574 }
00575 dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2);
00576 dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
00577
00578 for(i=0; i<4; i++){
00579 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
00580 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc0splat);
00581 }
00582 for(i=4; i<8; i++){
00583 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc2splat);
00584 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc2splat);
00585 }
00586 }
00587
00588 static void FUNCC(pred8x16_left_dc)(uint8_t *_src, ptrdiff_t stride)
00589 {
00590 FUNCC(pred8x8_left_dc)(_src, stride);
00591 FUNCC(pred8x8_left_dc)(_src+8*stride, stride);
00592 }
00593
00594 static void FUNCC(pred8x8_top_dc)(uint8_t *_src, ptrdiff_t stride)
00595 {
00596 int i;
00597 int dc0, dc1;
00598 pixel4 dc0splat, dc1splat;
00599 pixel *src = (pixel*)_src;
00600 stride >>= sizeof(pixel)-1;
00601
00602 dc0=dc1=0;
00603 for(i=0;i<4; i++){
00604 dc0+= src[i-stride];
00605 dc1+= src[4+i-stride];
00606 }
00607 dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2);
00608 dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
00609
00610 for(i=0; i<4; i++){
00611 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
00612 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
00613 }
00614 for(i=4; i<8; i++){
00615 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
00616 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
00617 }
00618 }
00619
00620 static void FUNCC(pred8x16_top_dc)(uint8_t *_src, ptrdiff_t stride)
00621 {
00622 int i;
00623 int dc0, dc1;
00624 pixel4 dc0splat, dc1splat;
00625 pixel *src = (pixel*)_src;
00626 stride >>= sizeof(pixel)-1;
00627
00628 dc0=dc1=0;
00629 for(i=0;i<4; i++){
00630 dc0+= src[i-stride];
00631 dc1+= src[4+i-stride];
00632 }
00633 dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2);
00634 dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
00635
00636 for(i=0; i<16; i++){
00637 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
00638 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
00639 }
00640 }
00641
00642 static void FUNCC(pred8x8_dc)(uint8_t *_src, ptrdiff_t stride)
00643 {
00644 int i;
00645 int dc0, dc1, dc2;
00646 pixel4 dc0splat, dc1splat, dc2splat, dc3splat;
00647 pixel *src = (pixel*)_src;
00648 stride >>= sizeof(pixel)-1;
00649
00650 dc0=dc1=dc2=0;
00651 for(i=0;i<4; i++){
00652 dc0+= src[-1+i*stride] + src[i-stride];
00653 dc1+= src[4+i-stride];
00654 dc2+= src[-1+(i+4)*stride];
00655 }
00656 dc0splat = PIXEL_SPLAT_X4((dc0 + 4)>>3);
00657 dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
00658 dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
00659 dc3splat = PIXEL_SPLAT_X4((dc1 + dc2 + 4)>>3);
00660
00661 for(i=0; i<4; i++){
00662 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
00663 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
00664 }
00665 for(i=4; i<8; i++){
00666 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc2splat);
00667 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc3splat);
00668 }
00669 }
00670
00671 static void FUNCC(pred8x16_dc)(uint8_t *_src, ptrdiff_t stride)
00672 {
00673 int i;
00674 int dc0, dc1, dc2, dc3, dc4;
00675 pixel4 dc0splat, dc1splat, dc2splat, dc3splat, dc4splat, dc5splat, dc6splat, dc7splat;
00676 pixel *src = (pixel*)_src;
00677 stride >>= sizeof(pixel)-1;
00678
00679 dc0=dc1=dc2=dc3=dc4=0;
00680 for(i=0;i<4; i++){
00681 dc0+= src[-1+i*stride] + src[i-stride];
00682 dc1+= src[4+i-stride];
00683 dc2+= src[-1+(i+4)*stride];
00684 dc3+= src[-1+(i+8)*stride];
00685 dc4+= src[-1+(i+12)*stride];
00686 }
00687 dc0splat = PIXEL_SPLAT_X4((dc0 + 4)>>3);
00688 dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
00689 dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
00690 dc3splat = PIXEL_SPLAT_X4((dc1 + dc2 + 4)>>3);
00691 dc4splat = PIXEL_SPLAT_X4((dc3 + 2)>>2);
00692 dc5splat = PIXEL_SPLAT_X4((dc1 + dc3 + 4)>>3);
00693 dc6splat = PIXEL_SPLAT_X4((dc4 + 2)>>2);
00694 dc7splat = PIXEL_SPLAT_X4((dc1 + dc4 + 4)>>3);
00695
00696 for(i=0; i<4; i++){
00697 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
00698 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
00699 }
00700 for(i=4; i<8; i++){
00701 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc2splat);
00702 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc3splat);
00703 }
00704 for(i=8; i<12; i++){
00705 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc4splat);
00706 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc5splat);
00707 }
00708 for(i=12; i<16; i++){
00709 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc6splat);
00710 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc7splat);
00711 }
00712 }
00713
00714
00715 static void FUNC(pred8x8_mad_cow_dc_l0t)(uint8_t *src, ptrdiff_t stride)
00716 {
00717 FUNCC(pred8x8_top_dc)(src, stride);
00718 FUNCC(pred4x4_dc)(src, NULL, stride);
00719 }
00720
00721 static void FUNC(pred8x16_mad_cow_dc_l0t)(uint8_t *src, ptrdiff_t stride)
00722 {
00723 FUNCC(pred8x16_top_dc)(src, stride);
00724 FUNCC(pred4x4_dc)(src, NULL, stride);
00725 }
00726
00727 static void FUNC(pred8x8_mad_cow_dc_0lt)(uint8_t *src, ptrdiff_t stride)
00728 {
00729 FUNCC(pred8x8_dc)(src, stride);
00730 FUNCC(pred4x4_top_dc)(src, NULL, stride);
00731 }
00732
00733 static void FUNC(pred8x16_mad_cow_dc_0lt)(uint8_t *src, ptrdiff_t stride)
00734 {
00735 FUNCC(pred8x16_dc)(src, stride);
00736 FUNCC(pred4x4_top_dc)(src, NULL, stride);
00737 }
00738
00739 static void FUNC(pred8x8_mad_cow_dc_l00)(uint8_t *src, ptrdiff_t stride)
00740 {
00741 FUNCC(pred8x8_left_dc)(src, stride);
00742 FUNCC(pred4x4_128_dc)(src + 4*stride , NULL, stride);
00743 FUNCC(pred4x4_128_dc)(src + 4*stride + 4*sizeof(pixel), NULL, stride);
00744 }
00745
00746 static void FUNC(pred8x16_mad_cow_dc_l00)(uint8_t *src, ptrdiff_t stride)
00747 {
00748 FUNCC(pred8x16_left_dc)(src, stride);
00749 FUNCC(pred4x4_128_dc)(src + 4*stride , NULL, stride);
00750 FUNCC(pred4x4_128_dc)(src + 4*stride + 4*sizeof(pixel), NULL, stride);
00751 }
00752
00753 static void FUNC(pred8x8_mad_cow_dc_0l0)(uint8_t *src, ptrdiff_t stride)
00754 {
00755 FUNCC(pred8x8_left_dc)(src, stride);
00756 FUNCC(pred4x4_128_dc)(src , NULL, stride);
00757 FUNCC(pred4x4_128_dc)(src + 4*sizeof(pixel), NULL, stride);
00758 }
00759
00760 static void FUNC(pred8x16_mad_cow_dc_0l0)(uint8_t *src, ptrdiff_t stride)
00761 {
00762 FUNCC(pred8x16_left_dc)(src, stride);
00763 FUNCC(pred4x4_128_dc)(src , NULL, stride);
00764 FUNCC(pred4x4_128_dc)(src + 4*sizeof(pixel), NULL, stride);
00765 }
00766
00767 static void FUNCC(pred8x8_plane)(uint8_t *_src, ptrdiff_t _stride)
00768 {
00769 int j, k;
00770 int a;
00771 INIT_CLIP
00772 pixel *src = (pixel*)_src;
00773 int stride = _stride>>(sizeof(pixel)-1);
00774 const pixel * const src0 = src +3-stride;
00775 const pixel * src1 = src +4*stride-1;
00776 const pixel * src2 = src1-2*stride;
00777 int H = src0[1] - src0[-1];
00778 int V = src1[0] - src2[ 0];
00779 for(k=2; k<=4; ++k) {
00780 src1 += stride; src2 -= stride;
00781 H += k*(src0[k] - src0[-k]);
00782 V += k*(src1[0] - src2[ 0]);
00783 }
00784 H = ( 17*H+16 ) >> 5;
00785 V = ( 17*V+16 ) >> 5;
00786
00787 a = 16*(src1[0] + src2[8]+1) - 3*(V+H);
00788 for(j=8; j>0; --j) {
00789 int b = a;
00790 a += V;
00791 src[0] = CLIP((b ) >> 5);
00792 src[1] = CLIP((b+ H) >> 5);
00793 src[2] = CLIP((b+2*H) >> 5);
00794 src[3] = CLIP((b+3*H) >> 5);
00795 src[4] = CLIP((b+4*H) >> 5);
00796 src[5] = CLIP((b+5*H) >> 5);
00797 src[6] = CLIP((b+6*H) >> 5);
00798 src[7] = CLIP((b+7*H) >> 5);
00799 src += stride;
00800 }
00801 }
00802
00803 static void FUNCC(pred8x16_plane)(uint8_t *_src, ptrdiff_t _stride)
00804 {
00805 int j, k;
00806 int a;
00807 INIT_CLIP
00808 pixel *src = (pixel*)_src;
00809 int stride = _stride>>(sizeof(pixel)-1);
00810 const pixel * const src0 = src +3-stride;
00811 const pixel * src1 = src +8*stride-1;
00812 const pixel * src2 = src1-2*stride;
00813 int H = src0[1] - src0[-1];
00814 int V = src1[0] - src2[ 0];
00815
00816 for (k = 2; k <= 4; ++k) {
00817 src1 += stride; src2 -= stride;
00818 H += k*(src0[k] - src0[-k]);
00819 V += k*(src1[0] - src2[ 0]);
00820 }
00821 for (; k <= 8; ++k) {
00822 src1 += stride; src2 -= stride;
00823 V += k*(src1[0] - src2[0]);
00824 }
00825
00826 H = (17*H+16) >> 5;
00827 V = (5*V+32) >> 6;
00828
00829 a = 16*(src1[0] + src2[8] + 1) - 7*V - 3*H;
00830 for(j=16; j>0; --j) {
00831 int b = a;
00832 a += V;
00833 src[0] = CLIP((b ) >> 5);
00834 src[1] = CLIP((b+ H) >> 5);
00835 src[2] = CLIP((b+2*H) >> 5);
00836 src[3] = CLIP((b+3*H) >> 5);
00837 src[4] = CLIP((b+4*H) >> 5);
00838 src[5] = CLIP((b+5*H) >> 5);
00839 src[6] = CLIP((b+6*H) >> 5);
00840 src[7] = CLIP((b+7*H) >> 5);
00841 src += stride;
00842 }
00843 }
00844
00845 #define SRC(x,y) src[(x)+(y)*stride]
00846 #define PL(y) \
00847 const int l##y = (SRC(-1,y-1) + 2*SRC(-1,y) + SRC(-1,y+1) + 2) >> 2;
00848 #define PREDICT_8x8_LOAD_LEFT \
00849 const int l0 = ((has_topleft ? SRC(-1,-1) : SRC(-1,0)) \
00850 + 2*SRC(-1,0) + SRC(-1,1) + 2) >> 2; \
00851 PL(1) PL(2) PL(3) PL(4) PL(5) PL(6) \
00852 const int l7 av_unused = (SRC(-1,6) + 3*SRC(-1,7) + 2) >> 2
00853
00854 #define PT(x) \
00855 const int t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
00856 #define PREDICT_8x8_LOAD_TOP \
00857 const int t0 = ((has_topleft ? SRC(-1,-1) : SRC(0,-1)) \
00858 + 2*SRC(0,-1) + SRC(1,-1) + 2) >> 2; \
00859 PT(1) PT(2) PT(3) PT(4) PT(5) PT(6) \
00860 const int t7 av_unused = ((has_topright ? SRC(8,-1) : SRC(7,-1)) \
00861 + 2*SRC(7,-1) + SRC(6,-1) + 2) >> 2
00862
00863 #define PTR(x) \
00864 t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
00865 #define PREDICT_8x8_LOAD_TOPRIGHT \
00866 int t8, t9, t10, t11, t12, t13, t14, t15; \
00867 if(has_topright) { \
00868 PTR(8) PTR(9) PTR(10) PTR(11) PTR(12) PTR(13) PTR(14) \
00869 t15 = (SRC(14,-1) + 3*SRC(15,-1) + 2) >> 2; \
00870 } else t8=t9=t10=t11=t12=t13=t14=t15= SRC(7,-1);
00871
00872 #define PREDICT_8x8_LOAD_TOPLEFT \
00873 const int lt = (SRC(-1,0) + 2*SRC(-1,-1) + SRC(0,-1) + 2) >> 2
00874
00875 #define PREDICT_8x8_DC(v) \
00876 int y; \
00877 for( y = 0; y < 8; y++ ) { \
00878 AV_WN4PA(((pixel4*)src)+0, v); \
00879 AV_WN4PA(((pixel4*)src)+1, v); \
00880 src += stride; \
00881 }
00882
00883 static void FUNCC(pred8x8l_128_dc)(uint8_t *_src, int has_topleft,
00884 int has_topright, ptrdiff_t _stride)
00885 {
00886 pixel *src = (pixel*)_src;
00887 int stride = _stride>>(sizeof(pixel)-1);
00888
00889 PREDICT_8x8_DC(PIXEL_SPLAT_X4(1<<(BIT_DEPTH-1)));
00890 }
00891 static void FUNCC(pred8x8l_left_dc)(uint8_t *_src, int has_topleft,
00892 int has_topright, ptrdiff_t _stride)
00893 {
00894 pixel *src = (pixel*)_src;
00895 int stride = _stride>>(sizeof(pixel)-1);
00896
00897 PREDICT_8x8_LOAD_LEFT;
00898 const pixel4 dc = PIXEL_SPLAT_X4((l0+l1+l2+l3+l4+l5+l6+l7+4) >> 3);
00899 PREDICT_8x8_DC(dc);
00900 }
00901 static void FUNCC(pred8x8l_top_dc)(uint8_t *_src, int has_topleft,
00902 int has_topright, ptrdiff_t _stride)
00903 {
00904 pixel *src = (pixel*)_src;
00905 int stride = _stride>>(sizeof(pixel)-1);
00906
00907 PREDICT_8x8_LOAD_TOP;
00908 const pixel4 dc = PIXEL_SPLAT_X4((t0+t1+t2+t3+t4+t5+t6+t7+4) >> 3);
00909 PREDICT_8x8_DC(dc);
00910 }
00911 static void FUNCC(pred8x8l_dc)(uint8_t *_src, int has_topleft,
00912 int has_topright, ptrdiff_t _stride)
00913 {
00914 pixel *src = (pixel*)_src;
00915 int stride = _stride>>(sizeof(pixel)-1);
00916
00917 PREDICT_8x8_LOAD_LEFT;
00918 PREDICT_8x8_LOAD_TOP;
00919 const pixel4 dc = PIXEL_SPLAT_X4((l0+l1+l2+l3+l4+l5+l6+l7
00920 +t0+t1+t2+t3+t4+t5+t6+t7+8) >> 4);
00921 PREDICT_8x8_DC(dc);
00922 }
00923 static void FUNCC(pred8x8l_horizontal)(uint8_t *_src, int has_topleft,
00924 int has_topright, ptrdiff_t _stride)
00925 {
00926 pixel *src = (pixel*)_src;
00927 int stride = _stride>>(sizeof(pixel)-1);
00928 pixel4 a;
00929
00930 PREDICT_8x8_LOAD_LEFT;
00931 #define ROW(y) a = PIXEL_SPLAT_X4(l##y); \
00932 AV_WN4PA(src+y*stride, a); \
00933 AV_WN4PA(src+y*stride+4, a);
00934 ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
00935 #undef ROW
00936 }
00937 static void FUNCC(pred8x8l_vertical)(uint8_t *_src, int has_topleft,
00938 int has_topright, ptrdiff_t _stride)
00939 {
00940 int y;
00941 pixel *src = (pixel*)_src;
00942 int stride = _stride>>(sizeof(pixel)-1);
00943 pixel4 a, b;
00944
00945 PREDICT_8x8_LOAD_TOP;
00946 src[0] = t0;
00947 src[1] = t1;
00948 src[2] = t2;
00949 src[3] = t3;
00950 src[4] = t4;
00951 src[5] = t5;
00952 src[6] = t6;
00953 src[7] = t7;
00954 a = AV_RN4PA(((pixel4*)src)+0);
00955 b = AV_RN4PA(((pixel4*)src)+1);
00956 for( y = 1; y < 8; y++ ) {
00957 AV_WN4PA(((pixel4*)(src+y*stride))+0, a);
00958 AV_WN4PA(((pixel4*)(src+y*stride))+1, b);
00959 }
00960 }
00961 static void FUNCC(pred8x8l_down_left)(uint8_t *_src, int has_topleft,
00962 int has_topright, ptrdiff_t _stride)
00963 {
00964 pixel *src = (pixel*)_src;
00965 int stride = _stride>>(sizeof(pixel)-1);
00966 PREDICT_8x8_LOAD_TOP;
00967 PREDICT_8x8_LOAD_TOPRIGHT;
00968 SRC(0,0)= (t0 + 2*t1 + t2 + 2) >> 2;
00969 SRC(0,1)=SRC(1,0)= (t1 + 2*t2 + t3 + 2) >> 2;
00970 SRC(0,2)=SRC(1,1)=SRC(2,0)= (t2 + 2*t3 + t4 + 2) >> 2;
00971 SRC(0,3)=SRC(1,2)=SRC(2,1)=SRC(3,0)= (t3 + 2*t4 + t5 + 2) >> 2;
00972 SRC(0,4)=SRC(1,3)=SRC(2,2)=SRC(3,1)=SRC(4,0)= (t4 + 2*t5 + t6 + 2) >> 2;
00973 SRC(0,5)=SRC(1,4)=SRC(2,3)=SRC(3,2)=SRC(4,1)=SRC(5,0)= (t5 + 2*t6 + t7 + 2) >> 2;
00974 SRC(0,6)=SRC(1,5)=SRC(2,4)=SRC(3,3)=SRC(4,2)=SRC(5,1)=SRC(6,0)= (t6 + 2*t7 + t8 + 2) >> 2;
00975 SRC(0,7)=SRC(1,6)=SRC(2,5)=SRC(3,4)=SRC(4,3)=SRC(5,2)=SRC(6,1)=SRC(7,0)= (t7 + 2*t8 + t9 + 2) >> 2;
00976 SRC(1,7)=SRC(2,6)=SRC(3,5)=SRC(4,4)=SRC(5,3)=SRC(6,2)=SRC(7,1)= (t8 + 2*t9 + t10 + 2) >> 2;
00977 SRC(2,7)=SRC(3,6)=SRC(4,5)=SRC(5,4)=SRC(6,3)=SRC(7,2)= (t9 + 2*t10 + t11 + 2) >> 2;
00978 SRC(3,7)=SRC(4,6)=SRC(5,5)=SRC(6,4)=SRC(7,3)= (t10 + 2*t11 + t12 + 2) >> 2;
00979 SRC(4,7)=SRC(5,6)=SRC(6,5)=SRC(7,4)= (t11 + 2*t12 + t13 + 2) >> 2;
00980 SRC(5,7)=SRC(6,6)=SRC(7,5)= (t12 + 2*t13 + t14 + 2) >> 2;
00981 SRC(6,7)=SRC(7,6)= (t13 + 2*t14 + t15 + 2) >> 2;
00982 SRC(7,7)= (t14 + 3*t15 + 2) >> 2;
00983 }
00984 static void FUNCC(pred8x8l_down_right)(uint8_t *_src, int has_topleft,
00985 int has_topright, ptrdiff_t _stride)
00986 {
00987 pixel *src = (pixel*)_src;
00988 int stride = _stride>>(sizeof(pixel)-1);
00989 PREDICT_8x8_LOAD_TOP;
00990 PREDICT_8x8_LOAD_LEFT;
00991 PREDICT_8x8_LOAD_TOPLEFT;
00992 SRC(0,7)= (l7 + 2*l6 + l5 + 2) >> 2;
00993 SRC(0,6)=SRC(1,7)= (l6 + 2*l5 + l4 + 2) >> 2;
00994 SRC(0,5)=SRC(1,6)=SRC(2,7)= (l5 + 2*l4 + l3 + 2) >> 2;
00995 SRC(0,4)=SRC(1,5)=SRC(2,6)=SRC(3,7)= (l4 + 2*l3 + l2 + 2) >> 2;
00996 SRC(0,3)=SRC(1,4)=SRC(2,5)=SRC(3,6)=SRC(4,7)= (l3 + 2*l2 + l1 + 2) >> 2;
00997 SRC(0,2)=SRC(1,3)=SRC(2,4)=SRC(3,5)=SRC(4,6)=SRC(5,7)= (l2 + 2*l1 + l0 + 2) >> 2;
00998 SRC(0,1)=SRC(1,2)=SRC(2,3)=SRC(3,4)=SRC(4,5)=SRC(5,6)=SRC(6,7)= (l1 + 2*l0 + lt + 2) >> 2;
00999 SRC(0,0)=SRC(1,1)=SRC(2,2)=SRC(3,3)=SRC(4,4)=SRC(5,5)=SRC(6,6)=SRC(7,7)= (l0 + 2*lt + t0 + 2) >> 2;
01000 SRC(1,0)=SRC(2,1)=SRC(3,2)=SRC(4,3)=SRC(5,4)=SRC(6,5)=SRC(7,6)= (lt + 2*t0 + t1 + 2) >> 2;
01001 SRC(2,0)=SRC(3,1)=SRC(4,2)=SRC(5,3)=SRC(6,4)=SRC(7,5)= (t0 + 2*t1 + t2 + 2) >> 2;
01002 SRC(3,0)=SRC(4,1)=SRC(5,2)=SRC(6,3)=SRC(7,4)= (t1 + 2*t2 + t3 + 2) >> 2;
01003 SRC(4,0)=SRC(5,1)=SRC(6,2)=SRC(7,3)= (t2 + 2*t3 + t4 + 2) >> 2;
01004 SRC(5,0)=SRC(6,1)=SRC(7,2)= (t3 + 2*t4 + t5 + 2) >> 2;
01005 SRC(6,0)=SRC(7,1)= (t4 + 2*t5 + t6 + 2) >> 2;
01006 SRC(7,0)= (t5 + 2*t6 + t7 + 2) >> 2;
01007 }
01008 static void FUNCC(pred8x8l_vertical_right)(uint8_t *_src, int has_topleft,
01009 int has_topright, ptrdiff_t _stride)
01010 {
01011 pixel *src = (pixel*)_src;
01012 int stride = _stride>>(sizeof(pixel)-1);
01013 PREDICT_8x8_LOAD_TOP;
01014 PREDICT_8x8_LOAD_LEFT;
01015 PREDICT_8x8_LOAD_TOPLEFT;
01016 SRC(0,6)= (l5 + 2*l4 + l3 + 2) >> 2;
01017 SRC(0,7)= (l6 + 2*l5 + l4 + 2) >> 2;
01018 SRC(0,4)=SRC(1,6)= (l3 + 2*l2 + l1 + 2) >> 2;
01019 SRC(0,5)=SRC(1,7)= (l4 + 2*l3 + l2 + 2) >> 2;
01020 SRC(0,2)=SRC(1,4)=SRC(2,6)= (l1 + 2*l0 + lt + 2) >> 2;
01021 SRC(0,3)=SRC(1,5)=SRC(2,7)= (l2 + 2*l1 + l0 + 2) >> 2;
01022 SRC(0,1)=SRC(1,3)=SRC(2,5)=SRC(3,7)= (l0 + 2*lt + t0 + 2) >> 2;
01023 SRC(0,0)=SRC(1,2)=SRC(2,4)=SRC(3,6)= (lt + t0 + 1) >> 1;
01024 SRC(1,1)=SRC(2,3)=SRC(3,5)=SRC(4,7)= (lt + 2*t0 + t1 + 2) >> 2;
01025 SRC(1,0)=SRC(2,2)=SRC(3,4)=SRC(4,6)= (t0 + t1 + 1) >> 1;
01026 SRC(2,1)=SRC(3,3)=SRC(4,5)=SRC(5,7)= (t0 + 2*t1 + t2 + 2) >> 2;
01027 SRC(2,0)=SRC(3,2)=SRC(4,4)=SRC(5,6)= (t1 + t2 + 1) >> 1;
01028 SRC(3,1)=SRC(4,3)=SRC(5,5)=SRC(6,7)= (t1 + 2*t2 + t3 + 2) >> 2;
01029 SRC(3,0)=SRC(4,2)=SRC(5,4)=SRC(6,6)= (t2 + t3 + 1) >> 1;
01030 SRC(4,1)=SRC(5,3)=SRC(6,5)=SRC(7,7)= (t2 + 2*t3 + t4 + 2) >> 2;
01031 SRC(4,0)=SRC(5,2)=SRC(6,4)=SRC(7,6)= (t3 + t4 + 1) >> 1;
01032 SRC(5,1)=SRC(6,3)=SRC(7,5)= (t3 + 2*t4 + t5 + 2) >> 2;
01033 SRC(5,0)=SRC(6,2)=SRC(7,4)= (t4 + t5 + 1) >> 1;
01034 SRC(6,1)=SRC(7,3)= (t4 + 2*t5 + t6 + 2) >> 2;
01035 SRC(6,0)=SRC(7,2)= (t5 + t6 + 1) >> 1;
01036 SRC(7,1)= (t5 + 2*t6 + t7 + 2) >> 2;
01037 SRC(7,0)= (t6 + t7 + 1) >> 1;
01038 }
01039 static void FUNCC(pred8x8l_horizontal_down)(uint8_t *_src, int has_topleft,
01040 int has_topright, ptrdiff_t _stride)
01041 {
01042 pixel *src = (pixel*)_src;
01043 int stride = _stride>>(sizeof(pixel)-1);
01044 PREDICT_8x8_LOAD_TOP;
01045 PREDICT_8x8_LOAD_LEFT;
01046 PREDICT_8x8_LOAD_TOPLEFT;
01047 SRC(0,7)= (l6 + l7 + 1) >> 1;
01048 SRC(1,7)= (l5 + 2*l6 + l7 + 2) >> 2;
01049 SRC(0,6)=SRC(2,7)= (l5 + l6 + 1) >> 1;
01050 SRC(1,6)=SRC(3,7)= (l4 + 2*l5 + l6 + 2) >> 2;
01051 SRC(0,5)=SRC(2,6)=SRC(4,7)= (l4 + l5 + 1) >> 1;
01052 SRC(1,5)=SRC(3,6)=SRC(5,7)= (l3 + 2*l4 + l5 + 2) >> 2;
01053 SRC(0,4)=SRC(2,5)=SRC(4,6)=SRC(6,7)= (l3 + l4 + 1) >> 1;
01054 SRC(1,4)=SRC(3,5)=SRC(5,6)=SRC(7,7)= (l2 + 2*l3 + l4 + 2) >> 2;
01055 SRC(0,3)=SRC(2,4)=SRC(4,5)=SRC(6,6)= (l2 + l3 + 1) >> 1;
01056 SRC(1,3)=SRC(3,4)=SRC(5,5)=SRC(7,6)= (l1 + 2*l2 + l3 + 2) >> 2;
01057 SRC(0,2)=SRC(2,3)=SRC(4,4)=SRC(6,5)= (l1 + l2 + 1) >> 1;
01058 SRC(1,2)=SRC(3,3)=SRC(5,4)=SRC(7,5)= (l0 + 2*l1 + l2 + 2) >> 2;
01059 SRC(0,1)=SRC(2,2)=SRC(4,3)=SRC(6,4)= (l0 + l1 + 1) >> 1;
01060 SRC(1,1)=SRC(3,2)=SRC(5,3)=SRC(7,4)= (lt + 2*l0 + l1 + 2) >> 2;
01061 SRC(0,0)=SRC(2,1)=SRC(4,2)=SRC(6,3)= (lt + l0 + 1) >> 1;
01062 SRC(1,0)=SRC(3,1)=SRC(5,2)=SRC(7,3)= (l0 + 2*lt + t0 + 2) >> 2;
01063 SRC(2,0)=SRC(4,1)=SRC(6,2)= (t1 + 2*t0 + lt + 2) >> 2;
01064 SRC(3,0)=SRC(5,1)=SRC(7,2)= (t2 + 2*t1 + t0 + 2) >> 2;
01065 SRC(4,0)=SRC(6,1)= (t3 + 2*t2 + t1 + 2) >> 2;
01066 SRC(5,0)=SRC(7,1)= (t4 + 2*t3 + t2 + 2) >> 2;
01067 SRC(6,0)= (t5 + 2*t4 + t3 + 2) >> 2;
01068 SRC(7,0)= (t6 + 2*t5 + t4 + 2) >> 2;
01069 }
01070 static void FUNCC(pred8x8l_vertical_left)(uint8_t *_src, int has_topleft,
01071 int has_topright, ptrdiff_t _stride)
01072 {
01073 pixel *src = (pixel*)_src;
01074 int stride = _stride>>(sizeof(pixel)-1);
01075 PREDICT_8x8_LOAD_TOP;
01076 PREDICT_8x8_LOAD_TOPRIGHT;
01077 SRC(0,0)= (t0 + t1 + 1) >> 1;
01078 SRC(0,1)= (t0 + 2*t1 + t2 + 2) >> 2;
01079 SRC(0,2)=SRC(1,0)= (t1 + t2 + 1) >> 1;
01080 SRC(0,3)=SRC(1,1)= (t1 + 2*t2 + t3 + 2) >> 2;
01081 SRC(0,4)=SRC(1,2)=SRC(2,0)= (t2 + t3 + 1) >> 1;
01082 SRC(0,5)=SRC(1,3)=SRC(2,1)= (t2 + 2*t3 + t4 + 2) >> 2;
01083 SRC(0,6)=SRC(1,4)=SRC(2,2)=SRC(3,0)= (t3 + t4 + 1) >> 1;
01084 SRC(0,7)=SRC(1,5)=SRC(2,3)=SRC(3,1)= (t3 + 2*t4 + t5 + 2) >> 2;
01085 SRC(1,6)=SRC(2,4)=SRC(3,2)=SRC(4,0)= (t4 + t5 + 1) >> 1;
01086 SRC(1,7)=SRC(2,5)=SRC(3,3)=SRC(4,1)= (t4 + 2*t5 + t6 + 2) >> 2;
01087 SRC(2,6)=SRC(3,4)=SRC(4,2)=SRC(5,0)= (t5 + t6 + 1) >> 1;
01088 SRC(2,7)=SRC(3,5)=SRC(4,3)=SRC(5,1)= (t5 + 2*t6 + t7 + 2) >> 2;
01089 SRC(3,6)=SRC(4,4)=SRC(5,2)=SRC(6,0)= (t6 + t7 + 1) >> 1;
01090 SRC(3,7)=SRC(4,5)=SRC(5,3)=SRC(6,1)= (t6 + 2*t7 + t8 + 2) >> 2;
01091 SRC(4,6)=SRC(5,4)=SRC(6,2)=SRC(7,0)= (t7 + t8 + 1) >> 1;
01092 SRC(4,7)=SRC(5,5)=SRC(6,3)=SRC(7,1)= (t7 + 2*t8 + t9 + 2) >> 2;
01093 SRC(5,6)=SRC(6,4)=SRC(7,2)= (t8 + t9 + 1) >> 1;
01094 SRC(5,7)=SRC(6,5)=SRC(7,3)= (t8 + 2*t9 + t10 + 2) >> 2;
01095 SRC(6,6)=SRC(7,4)= (t9 + t10 + 1) >> 1;
01096 SRC(6,7)=SRC(7,5)= (t9 + 2*t10 + t11 + 2) >> 2;
01097 SRC(7,6)= (t10 + t11 + 1) >> 1;
01098 SRC(7,7)= (t10 + 2*t11 + t12 + 2) >> 2;
01099 }
01100 static void FUNCC(pred8x8l_horizontal_up)(uint8_t *_src, int has_topleft,
01101 int has_topright, ptrdiff_t _stride)
01102 {
01103 pixel *src = (pixel*)_src;
01104 int stride = _stride>>(sizeof(pixel)-1);
01105 PREDICT_8x8_LOAD_LEFT;
01106 SRC(0,0)= (l0 + l1 + 1) >> 1;
01107 SRC(1,0)= (l0 + 2*l1 + l2 + 2) >> 2;
01108 SRC(0,1)=SRC(2,0)= (l1 + l2 + 1) >> 1;
01109 SRC(1,1)=SRC(3,0)= (l1 + 2*l2 + l3 + 2) >> 2;
01110 SRC(0,2)=SRC(2,1)=SRC(4,0)= (l2 + l3 + 1) >> 1;
01111 SRC(1,2)=SRC(3,1)=SRC(5,0)= (l2 + 2*l3 + l4 + 2) >> 2;
01112 SRC(0,3)=SRC(2,2)=SRC(4,1)=SRC(6,0)= (l3 + l4 + 1) >> 1;
01113 SRC(1,3)=SRC(3,2)=SRC(5,1)=SRC(7,0)= (l3 + 2*l4 + l5 + 2) >> 2;
01114 SRC(0,4)=SRC(2,3)=SRC(4,2)=SRC(6,1)= (l4 + l5 + 1) >> 1;
01115 SRC(1,4)=SRC(3,3)=SRC(5,2)=SRC(7,1)= (l4 + 2*l5 + l6 + 2) >> 2;
01116 SRC(0,5)=SRC(2,4)=SRC(4,3)=SRC(6,2)= (l5 + l6 + 1) >> 1;
01117 SRC(1,5)=SRC(3,4)=SRC(5,3)=SRC(7,2)= (l5 + 2*l6 + l7 + 2) >> 2;
01118 SRC(0,6)=SRC(2,5)=SRC(4,4)=SRC(6,3)= (l6 + l7 + 1) >> 1;
01119 SRC(1,6)=SRC(3,5)=SRC(5,4)=SRC(7,3)= (l6 + 3*l7 + 2) >> 2;
01120 SRC(0,7)=SRC(1,7)=SRC(2,6)=SRC(2,7)=SRC(3,6)=
01121 SRC(3,7)=SRC(4,5)=SRC(4,6)=SRC(4,7)=SRC(5,5)=
01122 SRC(5,6)=SRC(5,7)=SRC(6,4)=SRC(6,5)=SRC(6,6)=
01123 SRC(6,7)=SRC(7,4)=SRC(7,5)=SRC(7,6)=SRC(7,7)= l7;
01124 }
01125 #undef PREDICT_8x8_LOAD_LEFT
01126 #undef PREDICT_8x8_LOAD_TOP
01127 #undef PREDICT_8x8_LOAD_TOPLEFT
01128 #undef PREDICT_8x8_LOAD_TOPRIGHT
01129 #undef PREDICT_8x8_DC
01130 #undef PTR
01131 #undef PT
01132 #undef PL
01133 #undef SRC
01134
01135 static void FUNCC(pred4x4_vertical_add)(uint8_t *_pix, const DCTELEM *_block,
01136 ptrdiff_t stride)
01137 {
01138 int i;
01139 pixel *pix = (pixel*)_pix;
01140 const dctcoef *block = (const dctcoef*)_block;
01141 stride >>= sizeof(pixel)-1;
01142 pix -= stride;
01143 for(i=0; i<4; i++){
01144 pixel v = pix[0];
01145 pix[1*stride]= v += block[0];
01146 pix[2*stride]= v += block[4];
01147 pix[3*stride]= v += block[8];
01148 pix[4*stride]= v + block[12];
01149 pix++;
01150 block++;
01151 }
01152 }
01153
01154 static void FUNCC(pred4x4_horizontal_add)(uint8_t *_pix, const DCTELEM *_block,
01155 ptrdiff_t stride)
01156 {
01157 int i;
01158 pixel *pix = (pixel*)_pix;
01159 const dctcoef *block = (const dctcoef*)_block;
01160 stride >>= sizeof(pixel)-1;
01161 for(i=0; i<4; i++){
01162 pixel v = pix[-1];
01163 pix[0]= v += block[0];
01164 pix[1]= v += block[1];
01165 pix[2]= v += block[2];
01166 pix[3]= v + block[3];
01167 pix+= stride;
01168 block+= 4;
01169 }
01170 }
01171
01172 static void FUNCC(pred8x8l_vertical_add)(uint8_t *_pix, const DCTELEM *_block,
01173 ptrdiff_t stride)
01174 {
01175 int i;
01176 pixel *pix = (pixel*)_pix;
01177 const dctcoef *block = (const dctcoef*)_block;
01178 stride >>= sizeof(pixel)-1;
01179 pix -= stride;
01180 for(i=0; i<8; i++){
01181 pixel v = pix[0];
01182 pix[1*stride]= v += block[0];
01183 pix[2*stride]= v += block[8];
01184 pix[3*stride]= v += block[16];
01185 pix[4*stride]= v += block[24];
01186 pix[5*stride]= v += block[32];
01187 pix[6*stride]= v += block[40];
01188 pix[7*stride]= v += block[48];
01189 pix[8*stride]= v + block[56];
01190 pix++;
01191 block++;
01192 }
01193 }
01194
01195 static void FUNCC(pred8x8l_horizontal_add)(uint8_t *_pix, const DCTELEM *_block,
01196 ptrdiff_t stride)
01197 {
01198 int i;
01199 pixel *pix = (pixel*)_pix;
01200 const dctcoef *block = (const dctcoef*)_block;
01201 stride >>= sizeof(pixel)-1;
01202 for(i=0; i<8; i++){
01203 pixel v = pix[-1];
01204 pix[0]= v += block[0];
01205 pix[1]= v += block[1];
01206 pix[2]= v += block[2];
01207 pix[3]= v += block[3];
01208 pix[4]= v += block[4];
01209 pix[5]= v += block[5];
01210 pix[6]= v += block[6];
01211 pix[7]= v + block[7];
01212 pix+= stride;
01213 block+= 8;
01214 }
01215 }
01216
01217 static void FUNCC(pred16x16_vertical_add)(uint8_t *pix, const int *block_offset,
01218 const DCTELEM *block,
01219 ptrdiff_t stride)
01220 {
01221 int i;
01222 for(i=0; i<16; i++)
01223 FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
01224 }
01225
01226 static void FUNCC(pred16x16_horizontal_add)(uint8_t *pix,
01227 const int *block_offset,
01228 const DCTELEM *block,
01229 ptrdiff_t stride)
01230 {
01231 int i;
01232 for(i=0; i<16; i++)
01233 FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
01234 }
01235
01236 static void FUNCC(pred8x8_vertical_add)(uint8_t *pix, const int *block_offset,
01237 const DCTELEM *block, ptrdiff_t stride)
01238 {
01239 int i;
01240 for(i=0; i<4; i++)
01241 FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
01242 }
01243
01244 static void FUNCC(pred8x16_vertical_add)(uint8_t *pix, const int *block_offset,
01245 const DCTELEM *block, ptrdiff_t stride)
01246 {
01247 int i;
01248 for(i=0; i<4; i++)
01249 FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
01250 for(i=4; i<8; i++)
01251 FUNCC(pred4x4_vertical_add)(pix + block_offset[i+4], block + i*16*sizeof(pixel), stride);
01252 }
01253
01254 static void FUNCC(pred8x8_horizontal_add)(uint8_t *pix, const int *block_offset,
01255 const DCTELEM *block,
01256 ptrdiff_t stride)
01257 {
01258 int i;
01259 for(i=0; i<4; i++)
01260 FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
01261 }
01262
01263 static void FUNCC(pred8x16_horizontal_add)(uint8_t *pix,
01264 const int *block_offset,
01265 const DCTELEM *block, ptrdiff_t stride)
01266 {
01267 int i;
01268 for(i=0; i<4; i++)
01269 FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
01270 for(i=4; i<8; i++)
01271 FUNCC(pred4x4_horizontal_add)(pix + block_offset[i+4], block + i*16*sizeof(pixel), stride);
01272 }