2 * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
3 * Copyright (c) 2003-2011 Michael Niedermayer <michaelni@gmx.at>
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 * H.264 / AVC / MPEG4 part10 prediction functions.
25 * @author Michael Niedermayer <michaelni@gmx.at>
30 #include "bit_depth_template.c"
32 static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int _stride){
33 pixel *src = (pixel*)_src;
34 int stride = _stride>>(sizeof(pixel)-1);
35 const pixel4 a= AV_RN4PA(src-stride);
37 AV_WN4PA(src+0*stride, a);
38 AV_WN4PA(src+1*stride, a);
39 AV_WN4PA(src+2*stride, a);
40 AV_WN4PA(src+3*stride, a);
43 static void FUNCC(pred4x4_horizontal)(uint8_t *_src, const uint8_t *topright, int _stride){
44 pixel *src = (pixel*)_src;
45 int stride = _stride>>(sizeof(pixel)-1);
46 AV_WN4PA(src+0*stride, PIXEL_SPLAT_X4(src[-1+0*stride]));
47 AV_WN4PA(src+1*stride, PIXEL_SPLAT_X4(src[-1+1*stride]));
48 AV_WN4PA(src+2*stride, PIXEL_SPLAT_X4(src[-1+2*stride]));
49 AV_WN4PA(src+3*stride, PIXEL_SPLAT_X4(src[-1+3*stride]));
52 static void FUNCC(pred4x4_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
53 pixel *src = (pixel*)_src;
54 int stride = _stride>>(sizeof(pixel)-1);
55 const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride]
56 + src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 4) >>3;
57 const pixel4 a = PIXEL_SPLAT_X4(dc);
59 AV_WN4PA(src+0*stride, a);
60 AV_WN4PA(src+1*stride, a);
61 AV_WN4PA(src+2*stride, a);
62 AV_WN4PA(src+3*stride, a);
65 static void FUNCC(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
66 pixel *src = (pixel*)_src;
67 int stride = _stride>>(sizeof(pixel)-1);
68 const int dc= ( src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2;
69 const pixel4 a = PIXEL_SPLAT_X4(dc);
71 AV_WN4PA(src+0*stride, a);
72 AV_WN4PA(src+1*stride, a);
73 AV_WN4PA(src+2*stride, a);
74 AV_WN4PA(src+3*stride, a);
77 static void FUNCC(pred4x4_top_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
78 pixel *src = (pixel*)_src;
79 int stride = _stride>>(sizeof(pixel)-1);
80 const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + 2) >>2;
81 const pixel4 a = PIXEL_SPLAT_X4(dc);
83 AV_WN4PA(src+0*stride, a);
84 AV_WN4PA(src+1*stride, a);
85 AV_WN4PA(src+2*stride, a);
86 AV_WN4PA(src+3*stride, a);
89 static void FUNCC(pred4x4_128_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
90 pixel *src = (pixel*)_src;
91 int stride = _stride>>(sizeof(pixel)-1);
92 const pixel4 a = PIXEL_SPLAT_X4(1<<(BIT_DEPTH-1));
94 AV_WN4PA(src+0*stride, a);
95 AV_WN4PA(src+1*stride, a);
96 AV_WN4PA(src+2*stride, a);
97 AV_WN4PA(src+3*stride, a);
100 static void FUNCC(pred4x4_127_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
101 pixel *src = (pixel*)_src;
102 int stride = _stride>>(sizeof(pixel)-1);
103 const pixel4 a = PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))-1);
105 AV_WN4PA(src+0*stride, a);
106 AV_WN4PA(src+1*stride, a);
107 AV_WN4PA(src+2*stride, a);
108 AV_WN4PA(src+3*stride, a);
111 static void FUNCC(pred4x4_129_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
112 pixel *src = (pixel*)_src;
113 int stride = _stride>>(sizeof(pixel)-1);
114 const pixel4 a = PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))+1);
116 AV_WN4PA(src+0*stride, a);
117 AV_WN4PA(src+1*stride, a);
118 AV_WN4PA(src+2*stride, a);
119 AV_WN4PA(src+3*stride, a);
123 #define LOAD_TOP_RIGHT_EDGE\
124 const unsigned av_unused t4 = topright[0];\
125 const unsigned av_unused t5 = topright[1];\
126 const unsigned av_unused t6 = topright[2];\
127 const unsigned av_unused t7 = topright[3];\
129 #define LOAD_DOWN_LEFT_EDGE\
130 const unsigned av_unused l4 = src[-1+4*stride];\
131 const unsigned av_unused l5 = src[-1+5*stride];\
132 const unsigned av_unused l6 = src[-1+6*stride];\
133 const unsigned av_unused l7 = src[-1+7*stride];\
135 #define LOAD_LEFT_EDGE\
136 const unsigned av_unused l0 = src[-1+0*stride];\
137 const unsigned av_unused l1 = src[-1+1*stride];\
138 const unsigned av_unused l2 = src[-1+2*stride];\
139 const unsigned av_unused l3 = src[-1+3*stride];\
141 #define LOAD_TOP_EDGE\
142 const unsigned av_unused t0 = src[ 0-1*stride];\
143 const unsigned av_unused t1 = src[ 1-1*stride];\
144 const unsigned av_unused t2 = src[ 2-1*stride];\
145 const unsigned av_unused t3 = src[ 3-1*stride];\
147 static void FUNCC(pred4x4_down_right)(uint8_t *_src, const uint8_t *topright, int _stride){
148 pixel *src = (pixel*)_src;
149 int stride = _stride>>(sizeof(pixel)-1);
150 const int lt= src[-1-1*stride];
154 src[0+3*stride]=(l3 + 2*l2 + l1 + 2)>>2;
156 src[1+3*stride]=(l2 + 2*l1 + l0 + 2)>>2;
159 src[2+3*stride]=(l1 + 2*l0 + lt + 2)>>2;
163 src[3+3*stride]=(l0 + 2*lt + t0 + 2)>>2;
166 src[3+2*stride]=(lt + 2*t0 + t1 + 2)>>2;
168 src[3+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
169 src[3+0*stride]=(t1 + 2*t2 + t3 + 2)>>2;
172 static void FUNCC(pred4x4_down_left)(uint8_t *_src, const uint8_t *_topright, int _stride){
173 pixel *src = (pixel*)_src;
174 const pixel *topright = (const pixel*)_topright;
175 int stride = _stride>>(sizeof(pixel)-1);
180 src[0+0*stride]=(t0 + t2 + 2*t1 + 2)>>2;
182 src[0+1*stride]=(t1 + t3 + 2*t2 + 2)>>2;
185 src[0+2*stride]=(t2 + t4 + 2*t3 + 2)>>2;
189 src[0+3*stride]=(t3 + t5 + 2*t4 + 2)>>2;
192 src[1+3*stride]=(t4 + t6 + 2*t5 + 2)>>2;
194 src[2+3*stride]=(t5 + t7 + 2*t6 + 2)>>2;
195 src[3+3*stride]=(t6 + 3*t7 + 2)>>2;
198 static void FUNCC(pred4x4_vertical_right)(uint8_t *_src, const uint8_t *topright, int _stride){
199 pixel *src = (pixel*)_src;
200 int stride = _stride>>(sizeof(pixel)-1);
201 const int lt= src[-1-1*stride];
206 src[1+2*stride]=(lt + t0 + 1)>>1;
208 src[2+2*stride]=(t0 + t1 + 1)>>1;
210 src[3+2*stride]=(t1 + t2 + 1)>>1;
211 src[3+0*stride]=(t2 + t3 + 1)>>1;
213 src[1+3*stride]=(l0 + 2*lt + t0 + 2)>>2;
215 src[2+3*stride]=(lt + 2*t0 + t1 + 2)>>2;
217 src[3+3*stride]=(t0 + 2*t1 + t2 + 2)>>2;
218 src[3+1*stride]=(t1 + 2*t2 + t3 + 2)>>2;
219 src[0+2*stride]=(lt + 2*l0 + l1 + 2)>>2;
220 src[0+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
223 static void FUNCC(pred4x4_vertical_left)(uint8_t *_src, const uint8_t *_topright, int _stride){
224 pixel *src = (pixel*)_src;
225 const pixel *topright = (const pixel*)_topright;
226 int stride = _stride>>(sizeof(pixel)-1);
230 src[0+0*stride]=(t0 + t1 + 1)>>1;
232 src[0+2*stride]=(t1 + t2 + 1)>>1;
234 src[1+2*stride]=(t2 + t3 + 1)>>1;
236 src[2+2*stride]=(t3 + t4+ 1)>>1;
237 src[3+2*stride]=(t4 + t5+ 1)>>1;
238 src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
240 src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
242 src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
244 src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
245 src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
248 static void FUNCC(pred4x4_horizontal_up)(uint8_t *_src, const uint8_t *topright, int _stride){
249 pixel *src = (pixel*)_src;
250 int stride = _stride>>(sizeof(pixel)-1);
253 src[0+0*stride]=(l0 + l1 + 1)>>1;
254 src[1+0*stride]=(l0 + 2*l1 + l2 + 2)>>2;
256 src[0+1*stride]=(l1 + l2 + 1)>>1;
258 src[1+1*stride]=(l1 + 2*l2 + l3 + 2)>>2;
260 src[0+2*stride]=(l2 + l3 + 1)>>1;
262 src[1+2*stride]=(l2 + 2*l3 + l3 + 2)>>2;
271 static void FUNCC(pred4x4_horizontal_down)(uint8_t *_src, const uint8_t *topright, int _stride){
272 pixel *src = (pixel*)_src;
273 int stride = _stride>>(sizeof(pixel)-1);
274 const int lt= src[-1-1*stride];
279 src[2+1*stride]=(lt + l0 + 1)>>1;
281 src[3+1*stride]=(l0 + 2*lt + t0 + 2)>>2;
282 src[2+0*stride]=(lt + 2*t0 + t1 + 2)>>2;
283 src[3+0*stride]=(t0 + 2*t1 + t2 + 2)>>2;
285 src[2+2*stride]=(l0 + l1 + 1)>>1;
287 src[3+2*stride]=(lt + 2*l0 + l1 + 2)>>2;
289 src[2+3*stride]=(l1 + l2+ 1)>>1;
291 src[3+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
292 src[0+3*stride]=(l2 + l3 + 1)>>1;
293 src[1+3*stride]=(l1 + 2*l2 + l3 + 2)>>2;
296 static void FUNCC(pred16x16_vertical)(uint8_t *_src, int _stride){
298 pixel *src = (pixel*)_src;
299 int stride = _stride>>(sizeof(pixel)-1);
300 const pixel4 a = AV_RN4PA(((pixel4*)(src-stride))+0);
301 const pixel4 b = AV_RN4PA(((pixel4*)(src-stride))+1);
302 const pixel4 c = AV_RN4PA(((pixel4*)(src-stride))+2);
303 const pixel4 d = AV_RN4PA(((pixel4*)(src-stride))+3);
306 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
307 AV_WN4PA(((pixel4*)(src+i*stride))+1, b);
308 AV_WN4PA(((pixel4*)(src+i*stride))+2, c);
309 AV_WN4PA(((pixel4*)(src+i*stride))+3, d);
313 static void FUNCC(pred16x16_horizontal)(uint8_t *_src, int stride){
315 pixel *src = (pixel*)_src;
316 stride >>= sizeof(pixel)-1;
319 const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]);
321 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
322 AV_WN4PA(((pixel4*)(src+i*stride))+1, a);
323 AV_WN4PA(((pixel4*)(src+i*stride))+2, a);
324 AV_WN4PA(((pixel4*)(src+i*stride))+3, a);
328 #define PREDICT_16x16_DC(v)\
329 for(i=0; i<16; i++){\
330 AV_WN4PA(src+ 0, v);\
331 AV_WN4PA(src+ 4, v);\
332 AV_WN4PA(src+ 8, v);\
333 AV_WN4PA(src+12, v);\
337 static void FUNCC(pred16x16_dc)(uint8_t *_src, int stride){
339 pixel *src = (pixel*)_src;
341 stride >>= sizeof(pixel)-1;
344 dc+= src[-1+i*stride];
351 dcsplat = PIXEL_SPLAT_X4((dc+16)>>5);
352 PREDICT_16x16_DC(dcsplat);
355 static void FUNCC(pred16x16_left_dc)(uint8_t *_src, int stride){
357 pixel *src = (pixel*)_src;
359 stride >>= sizeof(pixel)-1;
362 dc+= src[-1+i*stride];
365 dcsplat = PIXEL_SPLAT_X4((dc+8)>>4);
366 PREDICT_16x16_DC(dcsplat);
369 static void FUNCC(pred16x16_top_dc)(uint8_t *_src, int stride){
371 pixel *src = (pixel*)_src;
373 stride >>= sizeof(pixel)-1;
379 dcsplat = PIXEL_SPLAT_X4((dc+8)>>4);
380 PREDICT_16x16_DC(dcsplat);
383 #define PRED16x16_X(n, v) \
384 static void FUNCC(pred16x16_##n##_dc)(uint8_t *_src, int stride){\
386 pixel *src = (pixel*)_src;\
387 stride >>= sizeof(pixel)-1;\
388 PREDICT_16x16_DC(PIXEL_SPLAT_X4(v));\
391 PRED16x16_X(127, (1<<(BIT_DEPTH-1))-1);
392 PRED16x16_X(128, (1<<(BIT_DEPTH-1))+0);
393 PRED16x16_X(129, (1<<(BIT_DEPTH-1))+1);
395 static inline void FUNCC(pred16x16_plane_compat)(uint8_t *p_src, int p_stride, const int svq3, const int rv40){
399 pixel *src = (pixel*)p_src;
400 int stride = p_stride>>(sizeof(pixel)-1);
401 const pixel * const src0 = src +7-stride;
402 const pixel * src1 = src +8*stride-1;
403 const pixel * src2 = src1-2*stride; // == src+6*stride-1;
404 int H = src0[1] - src0[-1];
405 int V = src1[0] - src2[ 0];
406 for(k=2; k<=8; ++k) {
407 src1 += stride; src2 -= stride;
408 H += k*(src0[k] - src0[-k]);
409 V += k*(src1[0] - src2[ 0]);
412 H = ( 5*(H/4) ) / 16;
413 V = ( 5*(V/4) ) / 16;
415 /* required for 100% accuracy */
418 H = ( H + (H>>2) ) >> 4;
419 V = ( V + (V>>2) ) >> 4;
425 a = 16*(src1[0] + src2[16] + 1) - 7*(V+H);
426 for(j=16; j>0; --j) {
429 for(i=-16; i<0; i+=4) {
430 src[16+i] = CLIP((b ) >> 5);
431 src[17+i] = CLIP((b+ H) >> 5);
432 src[18+i] = CLIP((b+2*H) >> 5);
433 src[19+i] = CLIP((b+3*H) >> 5);
440 static void FUNCC(pred16x16_plane)(uint8_t *src, int stride){
441 FUNCC(pred16x16_plane_compat)(src, stride, 0, 0);
444 static void FUNCC(pred8x8_vertical)(uint8_t *_src, int _stride){
446 pixel *src = (pixel*)_src;
447 int stride = _stride>>(sizeof(pixel)-1);
448 const pixel4 a= AV_RN4PA(((pixel4*)(src-stride))+0);
449 const pixel4 b= AV_RN4PA(((pixel4*)(src-stride))+1);
452 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
453 AV_WN4PA(((pixel4*)(src+i*stride))+1, b);
457 static void FUNCC(pred8x16_vertical)(uint8_t *_src, int _stride){
459 pixel *src = (pixel*)_src;
460 int stride = _stride>>(sizeof(pixel)-1);
461 const pixel4 a= AV_RN4PA(((pixel4*)(src-stride))+0);
462 const pixel4 b= AV_RN4PA(((pixel4*)(src-stride))+1);
465 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
466 AV_WN4PA(((pixel4*)(src+i*stride))+1, b);
470 static void FUNCC(pred8x8_horizontal)(uint8_t *_src, int stride){
472 pixel *src = (pixel*)_src;
473 stride >>= sizeof(pixel)-1;
476 const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]);
477 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
478 AV_WN4PA(((pixel4*)(src+i*stride))+1, a);
482 static void FUNCC(pred8x16_horizontal)(uint8_t *_src, int stride){
484 pixel *src = (pixel*)_src;
485 stride >>= sizeof(pixel)-1;
487 const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]);
488 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
489 AV_WN4PA(((pixel4*)(src+i*stride))+1, a);
493 #define PRED8x8_X(n, v)\
494 static void FUNCC(pred8x8_##n##_dc)(uint8_t *_src, int stride){\
496 const pixel4 a = PIXEL_SPLAT_X4(v);\
497 pixel *src = (pixel*)_src;\
498 stride >>= sizeof(pixel)-1;\
500 AV_WN4PA(((pixel4*)(src+i*stride))+0, a);\
501 AV_WN4PA(((pixel4*)(src+i*stride))+1, a);\
505 PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1);
506 PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0);
507 PRED8x8_X(129, (1<<(BIT_DEPTH-1))+1);
509 static void FUNCC(pred8x16_128_dc)(uint8_t *_src, int stride){
510 FUNCC(pred8x8_128_dc)(_src, stride);
511 FUNCC(pred8x8_128_dc)(_src+8*stride, stride);
514 static void FUNCC(pred8x8_left_dc)(uint8_t *_src, int stride){
517 pixel4 dc0splat, dc2splat;
518 pixel *src = (pixel*)_src;
519 stride >>= sizeof(pixel)-1;
523 dc0+= src[-1+i*stride];
524 dc2+= src[-1+(i+4)*stride];
526 dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2);
527 dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
530 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
531 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc0splat);
534 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc2splat);
535 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc2splat);
539 static void FUNCC(pred8x16_left_dc)(uint8_t *_src, int stride){
540 FUNCC(pred8x8_left_dc)(_src, stride);
541 FUNCC(pred8x8_left_dc)(_src+8*stride, stride);
544 static void FUNCC(pred8x8_top_dc)(uint8_t *_src, int stride){
547 pixel4 dc0splat, dc1splat;
548 pixel *src = (pixel*)_src;
549 stride >>= sizeof(pixel)-1;
554 dc1+= src[4+i-stride];
556 dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2);
557 dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
560 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
561 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
564 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
565 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
569 static void FUNCC(pred8x16_top_dc)(uint8_t *_src, int stride){
572 pixel4 dc0splat, dc1splat;
573 pixel *src = (pixel*)_src;
574 stride >>= sizeof(pixel)-1;
579 dc1+= src[4+i-stride];
581 dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2);
582 dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
585 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
586 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
590 static void FUNCC(pred8x8_dc)(uint8_t *_src, int stride){
593 pixel4 dc0splat, dc1splat, dc2splat, dc3splat;
594 pixel *src = (pixel*)_src;
595 stride >>= sizeof(pixel)-1;
599 dc0+= src[-1+i*stride] + src[i-stride];
600 dc1+= src[4+i-stride];
601 dc2+= src[-1+(i+4)*stride];
603 dc0splat = PIXEL_SPLAT_X4((dc0 + 4)>>3);
604 dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
605 dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
606 dc3splat = PIXEL_SPLAT_X4((dc1 + dc2 + 4)>>3);
609 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
610 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
613 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc2splat);
614 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc3splat);
618 static void FUNCC(pred8x16_dc)(uint8_t *_src, int stride){
620 int dc0, dc1, dc2, dc3, dc4;
621 pixel4 dc0splat, dc1splat, dc2splat, dc3splat, dc4splat, dc5splat, dc6splat, dc7splat;
622 pixel *src = (pixel*)_src;
623 stride >>= sizeof(pixel)-1;
625 dc0=dc1=dc2=dc3=dc4=0;
627 dc0+= src[-1+i*stride] + src[i-stride];
628 dc1+= src[4+i-stride];
629 dc2+= src[-1+(i+4)*stride];
630 dc3+= src[-1+(i+8)*stride];
631 dc4+= src[-1+(i+12)*stride];
633 dc0splat = PIXEL_SPLAT_X4((dc0 + 4)>>3);
634 dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
635 dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
636 dc3splat = PIXEL_SPLAT_X4((dc1 + dc2 + 4)>>3);
637 dc4splat = PIXEL_SPLAT_X4((dc3 + 2)>>2);
638 dc5splat = PIXEL_SPLAT_X4((dc1 + dc3 + 4)>>3);
639 dc6splat = PIXEL_SPLAT_X4((dc4 + 2)>>2);
640 dc7splat = PIXEL_SPLAT_X4((dc1 + dc4 + 4)>>3);
643 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
644 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
647 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc2splat);
648 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc3splat);
651 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc4splat);
652 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc5splat);
654 for(i=12; i<16; i++){
655 AV_WN4PA(((pixel4*)(src+i*stride))+0, dc6splat);
656 AV_WN4PA(((pixel4*)(src+i*stride))+1, dc7splat);
660 //the following 4 function should not be optimized!
661 static void FUNC(pred8x8_mad_cow_dc_l0t)(uint8_t *src, int stride){
662 FUNCC(pred8x8_top_dc)(src, stride);
663 FUNCC(pred4x4_dc)(src, NULL, stride);
666 static void FUNC(pred8x8_mad_cow_dc_0lt)(uint8_t *src, int stride){
667 FUNCC(pred8x8_dc)(src, stride);
668 FUNCC(pred4x4_top_dc)(src, NULL, stride);
671 static void FUNC(pred8x8_mad_cow_dc_l00)(uint8_t *src, int stride){
672 FUNCC(pred8x8_left_dc)(src, stride);
673 FUNCC(pred4x4_128_dc)(src + 4*stride , NULL, stride);
674 FUNCC(pred4x4_128_dc)(src + 4*stride + 4*sizeof(pixel), NULL, stride);
677 static void FUNC(pred8x8_mad_cow_dc_0l0)(uint8_t *src, int stride){
678 FUNCC(pred8x8_left_dc)(src, stride);
679 FUNCC(pred4x4_128_dc)(src , NULL, stride);
680 FUNCC(pred4x4_128_dc)(src + 4*sizeof(pixel), NULL, stride);
683 static void FUNCC(pred8x8_plane)(uint8_t *_src, int _stride){
687 pixel *src = (pixel*)_src;
688 int stride = _stride>>(sizeof(pixel)-1);
689 const pixel * const src0 = src +3-stride;
690 const pixel * src1 = src +4*stride-1;
691 const pixel * src2 = src1-2*stride; // == src+2*stride-1;
692 int H = src0[1] - src0[-1];
693 int V = src1[0] - src2[ 0];
694 for(k=2; k<=4; ++k) {
695 src1 += stride; src2 -= stride;
696 H += k*(src0[k] - src0[-k]);
697 V += k*(src1[0] - src2[ 0]);
699 H = ( 17*H+16 ) >> 5;
700 V = ( 17*V+16 ) >> 5;
702 a = 16*(src1[0] + src2[8]+1) - 3*(V+H);
706 src[0] = CLIP((b ) >> 5);
707 src[1] = CLIP((b+ H) >> 5);
708 src[2] = CLIP((b+2*H) >> 5);
709 src[3] = CLIP((b+3*H) >> 5);
710 src[4] = CLIP((b+4*H) >> 5);
711 src[5] = CLIP((b+5*H) >> 5);
712 src[6] = CLIP((b+6*H) >> 5);
713 src[7] = CLIP((b+7*H) >> 5);
718 static void FUNCC(pred8x16_plane)(uint8_t *_src, int _stride){
722 pixel *src = (pixel*)_src;
723 int stride = _stride>>(sizeof(pixel)-1);
724 const pixel * const src0 = src +3-stride;
725 const pixel * src1 = src +8*stride-1;
726 const pixel * src2 = src1-2*stride; // == src+6*stride-1;
727 int H = src0[1] - src0[-1];
728 int V = src1[0] - src2[ 0];
730 for (k = 2; k <= 4; ++k) {
731 src1 += stride; src2 -= stride;
732 H += k*(src0[k] - src0[-k]);
733 V += k*(src1[0] - src2[ 0]);
735 for (; k <= 8; ++k) {
736 src1 += stride; src2 -= stride;
737 V += k*(src1[0] - src2[0]);
743 a = 16*(src1[0] + src2[8] + 1) - 7*V - 3*H;
744 for(j=16; j>0; --j) {
747 src[0] = CLIP((b ) >> 5);
748 src[1] = CLIP((b+ H) >> 5);
749 src[2] = CLIP((b+2*H) >> 5);
750 src[3] = CLIP((b+3*H) >> 5);
751 src[4] = CLIP((b+4*H) >> 5);
752 src[5] = CLIP((b+5*H) >> 5);
753 src[6] = CLIP((b+6*H) >> 5);
754 src[7] = CLIP((b+7*H) >> 5);
759 #define SRC(x,y) src[(x)+(y)*stride]
761 const int l##y = (SRC(-1,y-1) + 2*SRC(-1,y) + SRC(-1,y+1) + 2) >> 2;
762 #define PREDICT_8x8_LOAD_LEFT \
763 const int l0 = ((has_topleft ? SRC(-1,-1) : SRC(-1,0)) \
764 + 2*SRC(-1,0) + SRC(-1,1) + 2) >> 2; \
765 PL(1) PL(2) PL(3) PL(4) PL(5) PL(6) \
766 const int l7 av_unused = (SRC(-1,6) + 3*SRC(-1,7) + 2) >> 2
769 const int t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
770 #define PREDICT_8x8_LOAD_TOP \
771 const int t0 = ((has_topleft ? SRC(-1,-1) : SRC(0,-1)) \
772 + 2*SRC(0,-1) + SRC(1,-1) + 2) >> 2; \
773 PT(1) PT(2) PT(3) PT(4) PT(5) PT(6) \
774 const int t7 av_unused = ((has_topright ? SRC(8,-1) : SRC(7,-1)) \
775 + 2*SRC(7,-1) + SRC(6,-1) + 2) >> 2
778 t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
779 #define PREDICT_8x8_LOAD_TOPRIGHT \
780 int t8, t9, t10, t11, t12, t13, t14, t15; \
782 PTR(8) PTR(9) PTR(10) PTR(11) PTR(12) PTR(13) PTR(14) \
783 t15 = (SRC(14,-1) + 3*SRC(15,-1) + 2) >> 2; \
784 } else t8=t9=t10=t11=t12=t13=t14=t15= SRC(7,-1);
786 #define PREDICT_8x8_LOAD_TOPLEFT \
787 const int lt = (SRC(-1,0) + 2*SRC(-1,-1) + SRC(0,-1) + 2) >> 2
789 #define PREDICT_8x8_DC(v) \
791 for( y = 0; y < 8; y++ ) { \
792 AV_WN4PA(((pixel4*)src)+0, v); \
793 AV_WN4PA(((pixel4*)src)+1, v); \
797 static void FUNCC(pred8x8l_128_dc)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
799 pixel *src = (pixel*)_src;
800 int stride = _stride>>(sizeof(pixel)-1);
802 PREDICT_8x8_DC(PIXEL_SPLAT_X4(1<<(BIT_DEPTH-1)));
804 static void FUNCC(pred8x8l_left_dc)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
806 pixel *src = (pixel*)_src;
807 int stride = _stride>>(sizeof(pixel)-1);
809 PREDICT_8x8_LOAD_LEFT;
810 const pixel4 dc = PIXEL_SPLAT_X4((l0+l1+l2+l3+l4+l5+l6+l7+4) >> 3);
813 static void FUNCC(pred8x8l_top_dc)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
815 pixel *src = (pixel*)p_src;
816 int stride = p_stride>>(sizeof(pixel)-1);
818 PREDICT_8x8_LOAD_TOP;
819 const pixel4 dc = PIXEL_SPLAT_X4((t0+t1+t2+t3+t4+t5+t6+t7+4) >> 3);
822 static void FUNCC(pred8x8l_dc)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
824 pixel *src = (pixel*)p_src;
825 int stride = p_stride>>(sizeof(pixel)-1);
827 PREDICT_8x8_LOAD_LEFT;
828 PREDICT_8x8_LOAD_TOP;
829 const pixel4 dc = PIXEL_SPLAT_X4((l0+l1+l2+l3+l4+l5+l6+l7
830 +t0+t1+t2+t3+t4+t5+t6+t7+8) >> 4);
833 static void FUNCC(pred8x8l_horizontal)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
835 pixel *src = (pixel*)p_src;
836 int stride = p_stride>>(sizeof(pixel)-1);
839 PREDICT_8x8_LOAD_LEFT;
840 #define ROW(y) a = PIXEL_SPLAT_X4(l##y); \
841 AV_WN4PA(src+y*stride, a); \
842 AV_WN4PA(src+y*stride+4, a);
843 ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
846 static void FUNCC(pred8x8l_vertical)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
849 pixel *src = (pixel*)_src;
850 int stride = _stride>>(sizeof(pixel)-1);
853 PREDICT_8x8_LOAD_TOP;
862 a = AV_RN4PA(((pixel4*)src)+0);
863 b = AV_RN4PA(((pixel4*)src)+1);
864 for( y = 1; y < 8; y++ ) {
865 AV_WN4PA(((pixel4*)(src+y*stride))+0, a);
866 AV_WN4PA(((pixel4*)(src+y*stride))+1, b);
869 static void FUNCC(pred8x8l_down_left)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
871 pixel *src = (pixel*)p_src;
872 int stride = p_stride>>(sizeof(pixel)-1);
873 PREDICT_8x8_LOAD_TOP;
874 PREDICT_8x8_LOAD_TOPRIGHT;
875 SRC(0,0)= (t0 + 2*t1 + t2 + 2) >> 2;
876 SRC(0,1)=SRC(1,0)= (t1 + 2*t2 + t3 + 2) >> 2;
877 SRC(0,2)=SRC(1,1)=SRC(2,0)= (t2 + 2*t3 + t4 + 2) >> 2;
878 SRC(0,3)=SRC(1,2)=SRC(2,1)=SRC(3,0)= (t3 + 2*t4 + t5 + 2) >> 2;
879 SRC(0,4)=SRC(1,3)=SRC(2,2)=SRC(3,1)=SRC(4,0)= (t4 + 2*t5 + t6 + 2) >> 2;
880 SRC(0,5)=SRC(1,4)=SRC(2,3)=SRC(3,2)=SRC(4,1)=SRC(5,0)= (t5 + 2*t6 + t7 + 2) >> 2;
881 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;
882 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;
883 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;
884 SRC(2,7)=SRC(3,6)=SRC(4,5)=SRC(5,4)=SRC(6,3)=SRC(7,2)= (t9 + 2*t10 + t11 + 2) >> 2;
885 SRC(3,7)=SRC(4,6)=SRC(5,5)=SRC(6,4)=SRC(7,3)= (t10 + 2*t11 + t12 + 2) >> 2;
886 SRC(4,7)=SRC(5,6)=SRC(6,5)=SRC(7,4)= (t11 + 2*t12 + t13 + 2) >> 2;
887 SRC(5,7)=SRC(6,6)=SRC(7,5)= (t12 + 2*t13 + t14 + 2) >> 2;
888 SRC(6,7)=SRC(7,6)= (t13 + 2*t14 + t15 + 2) >> 2;
889 SRC(7,7)= (t14 + 3*t15 + 2) >> 2;
891 static void FUNCC(pred8x8l_down_right)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
893 pixel *src = (pixel*)p_src;
894 int stride = p_stride>>(sizeof(pixel)-1);
895 PREDICT_8x8_LOAD_TOP;
896 PREDICT_8x8_LOAD_LEFT;
897 PREDICT_8x8_LOAD_TOPLEFT;
898 SRC(0,7)= (l7 + 2*l6 + l5 + 2) >> 2;
899 SRC(0,6)=SRC(1,7)= (l6 + 2*l5 + l4 + 2) >> 2;
900 SRC(0,5)=SRC(1,6)=SRC(2,7)= (l5 + 2*l4 + l3 + 2) >> 2;
901 SRC(0,4)=SRC(1,5)=SRC(2,6)=SRC(3,7)= (l4 + 2*l3 + l2 + 2) >> 2;
902 SRC(0,3)=SRC(1,4)=SRC(2,5)=SRC(3,6)=SRC(4,7)= (l3 + 2*l2 + l1 + 2) >> 2;
903 SRC(0,2)=SRC(1,3)=SRC(2,4)=SRC(3,5)=SRC(4,6)=SRC(5,7)= (l2 + 2*l1 + l0 + 2) >> 2;
904 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;
905 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;
906 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;
907 SRC(2,0)=SRC(3,1)=SRC(4,2)=SRC(5,3)=SRC(6,4)=SRC(7,5)= (t0 + 2*t1 + t2 + 2) >> 2;
908 SRC(3,0)=SRC(4,1)=SRC(5,2)=SRC(6,3)=SRC(7,4)= (t1 + 2*t2 + t3 + 2) >> 2;
909 SRC(4,0)=SRC(5,1)=SRC(6,2)=SRC(7,3)= (t2 + 2*t3 + t4 + 2) >> 2;
910 SRC(5,0)=SRC(6,1)=SRC(7,2)= (t3 + 2*t4 + t5 + 2) >> 2;
911 SRC(6,0)=SRC(7,1)= (t4 + 2*t5 + t6 + 2) >> 2;
912 SRC(7,0)= (t5 + 2*t6 + t7 + 2) >> 2;
914 static void FUNCC(pred8x8l_vertical_right)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
916 pixel *src = (pixel*)p_src;
917 int stride = p_stride>>(sizeof(pixel)-1);
918 PREDICT_8x8_LOAD_TOP;
919 PREDICT_8x8_LOAD_LEFT;
920 PREDICT_8x8_LOAD_TOPLEFT;
921 SRC(0,6)= (l5 + 2*l4 + l3 + 2) >> 2;
922 SRC(0,7)= (l6 + 2*l5 + l4 + 2) >> 2;
923 SRC(0,4)=SRC(1,6)= (l3 + 2*l2 + l1 + 2) >> 2;
924 SRC(0,5)=SRC(1,7)= (l4 + 2*l3 + l2 + 2) >> 2;
925 SRC(0,2)=SRC(1,4)=SRC(2,6)= (l1 + 2*l0 + lt + 2) >> 2;
926 SRC(0,3)=SRC(1,5)=SRC(2,7)= (l2 + 2*l1 + l0 + 2) >> 2;
927 SRC(0,1)=SRC(1,3)=SRC(2,5)=SRC(3,7)= (l0 + 2*lt + t0 + 2) >> 2;
928 SRC(0,0)=SRC(1,2)=SRC(2,4)=SRC(3,6)= (lt + t0 + 1) >> 1;
929 SRC(1,1)=SRC(2,3)=SRC(3,5)=SRC(4,7)= (lt + 2*t0 + t1 + 2) >> 2;
930 SRC(1,0)=SRC(2,2)=SRC(3,4)=SRC(4,6)= (t0 + t1 + 1) >> 1;
931 SRC(2,1)=SRC(3,3)=SRC(4,5)=SRC(5,7)= (t0 + 2*t1 + t2 + 2) >> 2;
932 SRC(2,0)=SRC(3,2)=SRC(4,4)=SRC(5,6)= (t1 + t2 + 1) >> 1;
933 SRC(3,1)=SRC(4,3)=SRC(5,5)=SRC(6,7)= (t1 + 2*t2 + t3 + 2) >> 2;
934 SRC(3,0)=SRC(4,2)=SRC(5,4)=SRC(6,6)= (t2 + t3 + 1) >> 1;
935 SRC(4,1)=SRC(5,3)=SRC(6,5)=SRC(7,7)= (t2 + 2*t3 + t4 + 2) >> 2;
936 SRC(4,0)=SRC(5,2)=SRC(6,4)=SRC(7,6)= (t3 + t4 + 1) >> 1;
937 SRC(5,1)=SRC(6,3)=SRC(7,5)= (t3 + 2*t4 + t5 + 2) >> 2;
938 SRC(5,0)=SRC(6,2)=SRC(7,4)= (t4 + t5 + 1) >> 1;
939 SRC(6,1)=SRC(7,3)= (t4 + 2*t5 + t6 + 2) >> 2;
940 SRC(6,0)=SRC(7,2)= (t5 + t6 + 1) >> 1;
941 SRC(7,1)= (t5 + 2*t6 + t7 + 2) >> 2;
942 SRC(7,0)= (t6 + t7 + 1) >> 1;
944 static void FUNCC(pred8x8l_horizontal_down)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
946 pixel *src = (pixel*)p_src;
947 int stride = p_stride>>(sizeof(pixel)-1);
948 PREDICT_8x8_LOAD_TOP;
949 PREDICT_8x8_LOAD_LEFT;
950 PREDICT_8x8_LOAD_TOPLEFT;
951 SRC(0,7)= (l6 + l7 + 1) >> 1;
952 SRC(1,7)= (l5 + 2*l6 + l7 + 2) >> 2;
953 SRC(0,6)=SRC(2,7)= (l5 + l6 + 1) >> 1;
954 SRC(1,6)=SRC(3,7)= (l4 + 2*l5 + l6 + 2) >> 2;
955 SRC(0,5)=SRC(2,6)=SRC(4,7)= (l4 + l5 + 1) >> 1;
956 SRC(1,5)=SRC(3,6)=SRC(5,7)= (l3 + 2*l4 + l5 + 2) >> 2;
957 SRC(0,4)=SRC(2,5)=SRC(4,6)=SRC(6,7)= (l3 + l4 + 1) >> 1;
958 SRC(1,4)=SRC(3,5)=SRC(5,6)=SRC(7,7)= (l2 + 2*l3 + l4 + 2) >> 2;
959 SRC(0,3)=SRC(2,4)=SRC(4,5)=SRC(6,6)= (l2 + l3 + 1) >> 1;
960 SRC(1,3)=SRC(3,4)=SRC(5,5)=SRC(7,6)= (l1 + 2*l2 + l3 + 2) >> 2;
961 SRC(0,2)=SRC(2,3)=SRC(4,4)=SRC(6,5)= (l1 + l2 + 1) >> 1;
962 SRC(1,2)=SRC(3,3)=SRC(5,4)=SRC(7,5)= (l0 + 2*l1 + l2 + 2) >> 2;
963 SRC(0,1)=SRC(2,2)=SRC(4,3)=SRC(6,4)= (l0 + l1 + 1) >> 1;
964 SRC(1,1)=SRC(3,2)=SRC(5,3)=SRC(7,4)= (lt + 2*l0 + l1 + 2) >> 2;
965 SRC(0,0)=SRC(2,1)=SRC(4,2)=SRC(6,3)= (lt + l0 + 1) >> 1;
966 SRC(1,0)=SRC(3,1)=SRC(5,2)=SRC(7,3)= (l0 + 2*lt + t0 + 2) >> 2;
967 SRC(2,0)=SRC(4,1)=SRC(6,2)= (t1 + 2*t0 + lt + 2) >> 2;
968 SRC(3,0)=SRC(5,1)=SRC(7,2)= (t2 + 2*t1 + t0 + 2) >> 2;
969 SRC(4,0)=SRC(6,1)= (t3 + 2*t2 + t1 + 2) >> 2;
970 SRC(5,0)=SRC(7,1)= (t4 + 2*t3 + t2 + 2) >> 2;
971 SRC(6,0)= (t5 + 2*t4 + t3 + 2) >> 2;
972 SRC(7,0)= (t6 + 2*t5 + t4 + 2) >> 2;
974 static void FUNCC(pred8x8l_vertical_left)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
976 pixel *src = (pixel*)p_src;
977 int stride = p_stride>>(sizeof(pixel)-1);
978 PREDICT_8x8_LOAD_TOP;
979 PREDICT_8x8_LOAD_TOPRIGHT;
980 SRC(0,0)= (t0 + t1 + 1) >> 1;
981 SRC(0,1)= (t0 + 2*t1 + t2 + 2) >> 2;
982 SRC(0,2)=SRC(1,0)= (t1 + t2 + 1) >> 1;
983 SRC(0,3)=SRC(1,1)= (t1 + 2*t2 + t3 + 2) >> 2;
984 SRC(0,4)=SRC(1,2)=SRC(2,0)= (t2 + t3 + 1) >> 1;
985 SRC(0,5)=SRC(1,3)=SRC(2,1)= (t2 + 2*t3 + t4 + 2) >> 2;
986 SRC(0,6)=SRC(1,4)=SRC(2,2)=SRC(3,0)= (t3 + t4 + 1) >> 1;
987 SRC(0,7)=SRC(1,5)=SRC(2,3)=SRC(3,1)= (t3 + 2*t4 + t5 + 2) >> 2;
988 SRC(1,6)=SRC(2,4)=SRC(3,2)=SRC(4,0)= (t4 + t5 + 1) >> 1;
989 SRC(1,7)=SRC(2,5)=SRC(3,3)=SRC(4,1)= (t4 + 2*t5 + t6 + 2) >> 2;
990 SRC(2,6)=SRC(3,4)=SRC(4,2)=SRC(5,0)= (t5 + t6 + 1) >> 1;
991 SRC(2,7)=SRC(3,5)=SRC(4,3)=SRC(5,1)= (t5 + 2*t6 + t7 + 2) >> 2;
992 SRC(3,6)=SRC(4,4)=SRC(5,2)=SRC(6,0)= (t6 + t7 + 1) >> 1;
993 SRC(3,7)=SRC(4,5)=SRC(5,3)=SRC(6,1)= (t6 + 2*t7 + t8 + 2) >> 2;
994 SRC(4,6)=SRC(5,4)=SRC(6,2)=SRC(7,0)= (t7 + t8 + 1) >> 1;
995 SRC(4,7)=SRC(5,5)=SRC(6,3)=SRC(7,1)= (t7 + 2*t8 + t9 + 2) >> 2;
996 SRC(5,6)=SRC(6,4)=SRC(7,2)= (t8 + t9 + 1) >> 1;
997 SRC(5,7)=SRC(6,5)=SRC(7,3)= (t8 + 2*t9 + t10 + 2) >> 2;
998 SRC(6,6)=SRC(7,4)= (t9 + t10 + 1) >> 1;
999 SRC(6,7)=SRC(7,5)= (t9 + 2*t10 + t11 + 2) >> 2;
1000 SRC(7,6)= (t10 + t11 + 1) >> 1;
1001 SRC(7,7)= (t10 + 2*t11 + t12 + 2) >> 2;
1003 static void FUNCC(pred8x8l_horizontal_up)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
1005 pixel *src = (pixel*)p_src;
1006 int stride = p_stride>>(sizeof(pixel)-1);
1007 PREDICT_8x8_LOAD_LEFT;
1008 SRC(0,0)= (l0 + l1 + 1) >> 1;
1009 SRC(1,0)= (l0 + 2*l1 + l2 + 2) >> 2;
1010 SRC(0,1)=SRC(2,0)= (l1 + l2 + 1) >> 1;
1011 SRC(1,1)=SRC(3,0)= (l1 + 2*l2 + l3 + 2) >> 2;
1012 SRC(0,2)=SRC(2,1)=SRC(4,0)= (l2 + l3 + 1) >> 1;
1013 SRC(1,2)=SRC(3,1)=SRC(5,0)= (l2 + 2*l3 + l4 + 2) >> 2;
1014 SRC(0,3)=SRC(2,2)=SRC(4,1)=SRC(6,0)= (l3 + l4 + 1) >> 1;
1015 SRC(1,3)=SRC(3,2)=SRC(5,1)=SRC(7,0)= (l3 + 2*l4 + l5 + 2) >> 2;
1016 SRC(0,4)=SRC(2,3)=SRC(4,2)=SRC(6,1)= (l4 + l5 + 1) >> 1;
1017 SRC(1,4)=SRC(3,3)=SRC(5,2)=SRC(7,1)= (l4 + 2*l5 + l6 + 2) >> 2;
1018 SRC(0,5)=SRC(2,4)=SRC(4,3)=SRC(6,2)= (l5 + l6 + 1) >> 1;
1019 SRC(1,5)=SRC(3,4)=SRC(5,3)=SRC(7,2)= (l5 + 2*l6 + l7 + 2) >> 2;
1020 SRC(0,6)=SRC(2,5)=SRC(4,4)=SRC(6,3)= (l6 + l7 + 1) >> 1;
1021 SRC(1,6)=SRC(3,5)=SRC(5,4)=SRC(7,3)= (l6 + 3*l7 + 2) >> 2;
1022 SRC(0,7)=SRC(1,7)=SRC(2,6)=SRC(2,7)=SRC(3,6)=
1023 SRC(3,7)=SRC(4,5)=SRC(4,6)=SRC(4,7)=SRC(5,5)=
1024 SRC(5,6)=SRC(5,7)=SRC(6,4)=SRC(6,5)=SRC(6,6)=
1025 SRC(6,7)=SRC(7,4)=SRC(7,5)=SRC(7,6)=SRC(7,7)= l7;
1027 #undef PREDICT_8x8_LOAD_LEFT
1028 #undef PREDICT_8x8_LOAD_TOP
1029 #undef PREDICT_8x8_LOAD_TOPLEFT
1030 #undef PREDICT_8x8_LOAD_TOPRIGHT
1031 #undef PREDICT_8x8_DC
1037 static void FUNCC(pred4x4_vertical_add)(uint8_t *p_pix, const DCTELEM *p_block, int stride){
1039 pixel *pix = (pixel*)p_pix;
1040 const dctcoef *block = (const dctcoef*)p_block;
1041 stride >>= sizeof(pixel)-1;
1045 pix[1*stride]= v += block[0];
1046 pix[2*stride]= v += block[4];
1047 pix[3*stride]= v += block[8];
1048 pix[4*stride]= v + block[12];
1054 static void FUNCC(pred4x4_horizontal_add)(uint8_t *p_pix, const DCTELEM *p_block, int stride){
1056 pixel *pix = (pixel*)p_pix;
1057 const dctcoef *block = (const dctcoef*)p_block;
1058 stride >>= sizeof(pixel)-1;
1061 pix[0]= v += block[0];
1062 pix[1]= v += block[1];
1063 pix[2]= v += block[2];
1064 pix[3]= v + block[3];
1070 static void FUNCC(pred8x8l_vertical_add)(uint8_t *p_pix, const DCTELEM *p_block, int stride){
1072 pixel *pix = (pixel*)p_pix;
1073 const dctcoef *block = (const dctcoef*)p_block;
1074 stride >>= sizeof(pixel)-1;
1078 pix[1*stride]= v += block[0];
1079 pix[2*stride]= v += block[8];
1080 pix[3*stride]= v += block[16];
1081 pix[4*stride]= v += block[24];
1082 pix[5*stride]= v += block[32];
1083 pix[6*stride]= v += block[40];
1084 pix[7*stride]= v += block[48];
1085 pix[8*stride]= v + block[56];
1091 static void FUNCC(pred8x8l_horizontal_add)(uint8_t *p_pix, const DCTELEM *p_block, int stride){
1093 pixel *pix = (pixel*)p_pix;
1094 const dctcoef *block = (const dctcoef*)p_block;
1095 stride >>= sizeof(pixel)-1;
1098 pix[0]= v += block[0];
1099 pix[1]= v += block[1];
1100 pix[2]= v += block[2];
1101 pix[3]= v += block[3];
1102 pix[4]= v += block[4];
1103 pix[5]= v += block[5];
1104 pix[6]= v += block[6];
1105 pix[7]= v + block[7];
1111 static void FUNCC(pred16x16_vertical_add)(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
1114 FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
1117 static void FUNCC(pred16x16_horizontal_add)(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
1120 FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
1123 static void FUNCC(pred8x8_vertical_add)(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
1126 FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
1129 static void FUNCC(pred8x8_horizontal_add)(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
1132 FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);