2 * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
3 * Copyright (c) 2003 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>
29 #include "mpegvideo.h"
32 static void pred4x4_vertical_c(uint8_t *src
, uint8_t *topright
, int stride
){
33 const uint32_t a
= ((uint32_t*)(src
-stride
))[0];
34 ((uint32_t*)(src
+0*stride
))[0]= a
;
35 ((uint32_t*)(src
+1*stride
))[0]= a
;
36 ((uint32_t*)(src
+2*stride
))[0]= a
;
37 ((uint32_t*)(src
+3*stride
))[0]= a
;
40 static void pred4x4_horizontal_c(uint8_t *src
, uint8_t *topright
, int stride
){
41 ((uint32_t*)(src
+0*stride
))[0]= src
[-1+0*stride
]*0x01010101;
42 ((uint32_t*)(src
+1*stride
))[0]= src
[-1+1*stride
]*0x01010101;
43 ((uint32_t*)(src
+2*stride
))[0]= src
[-1+2*stride
]*0x01010101;
44 ((uint32_t*)(src
+3*stride
))[0]= src
[-1+3*stride
]*0x01010101;
47 static void pred4x4_dc_c(uint8_t *src
, uint8_t *topright
, int stride
){
48 const int dc
= ( src
[-stride
] + src
[1-stride
] + src
[2-stride
] + src
[3-stride
]
49 + src
[-1+0*stride
] + src
[-1+1*stride
] + src
[-1+2*stride
] + src
[-1+3*stride
] + 4) >>3;
51 ((uint32_t*)(src
+0*stride
))[0]=
52 ((uint32_t*)(src
+1*stride
))[0]=
53 ((uint32_t*)(src
+2*stride
))[0]=
54 ((uint32_t*)(src
+3*stride
))[0]= dc
* 0x01010101;
57 static void pred4x4_left_dc_c(uint8_t *src
, uint8_t *topright
, int stride
){
58 const int dc
= ( src
[-1+0*stride
] + src
[-1+1*stride
] + src
[-1+2*stride
] + src
[-1+3*stride
] + 2) >>2;
60 ((uint32_t*)(src
+0*stride
))[0]=
61 ((uint32_t*)(src
+1*stride
))[0]=
62 ((uint32_t*)(src
+2*stride
))[0]=
63 ((uint32_t*)(src
+3*stride
))[0]= dc
* 0x01010101;
66 static void pred4x4_top_dc_c(uint8_t *src
, uint8_t *topright
, int stride
){
67 const int dc
= ( src
[-stride
] + src
[1-stride
] + src
[2-stride
] + src
[3-stride
] + 2) >>2;
69 ((uint32_t*)(src
+0*stride
))[0]=
70 ((uint32_t*)(src
+1*stride
))[0]=
71 ((uint32_t*)(src
+2*stride
))[0]=
72 ((uint32_t*)(src
+3*stride
))[0]= dc
* 0x01010101;
75 static void pred4x4_128_dc_c(uint8_t *src
, uint8_t *topright
, int stride
){
76 ((uint32_t*)(src
+0*stride
))[0]=
77 ((uint32_t*)(src
+1*stride
))[0]=
78 ((uint32_t*)(src
+2*stride
))[0]=
79 ((uint32_t*)(src
+3*stride
))[0]= 128U*0x01010101U
;
83 #define LOAD_TOP_RIGHT_EDGE\
84 const int av_unused t4= topright[0];\
85 const int av_unused t5= topright[1];\
86 const int av_unused t6= topright[2];\
87 const int av_unused t7= topright[3];\
89 #define LOAD_DOWN_LEFT_EDGE\
90 const int av_unused l4= src[-1+4*stride];\
91 const int av_unused l5= src[-1+5*stride];\
92 const int av_unused l6= src[-1+6*stride];\
93 const int av_unused l7= src[-1+7*stride];\
95 #define LOAD_LEFT_EDGE\
96 const int av_unused l0= src[-1+0*stride];\
97 const int av_unused l1= src[-1+1*stride];\
98 const int av_unused l2= src[-1+2*stride];\
99 const int av_unused l3= src[-1+3*stride];\
101 #define LOAD_TOP_EDGE\
102 const int av_unused t0= src[ 0-1*stride];\
103 const int av_unused t1= src[ 1-1*stride];\
104 const int av_unused t2= src[ 2-1*stride];\
105 const int av_unused t3= src[ 3-1*stride];\
107 static void pred4x4_down_right_c(uint8_t *src, uint8_t *topright, int stride){
108 const int lt
= src
[-1-1*stride
];
112 src
[0+3*stride
]=(l3
+ 2*l2
+ l1
+ 2)>>2;
114 src
[1+3*stride
]=(l2
+ 2*l1
+ l0
+ 2)>>2;
117 src
[2+3*stride
]=(l1
+ 2*l0
+ lt
+ 2)>>2;
121 src
[3+3*stride
]=(l0
+ 2*lt
+ t0
+ 2)>>2;
124 src
[3+2*stride
]=(lt
+ 2*t0
+ t1
+ 2)>>2;
126 src
[3+1*stride
]=(t0
+ 2*t1
+ t2
+ 2)>>2;
127 src
[3+0*stride
]=(t1
+ 2*t2
+ t3
+ 2)>>2;
130 static void pred4x4_down_left_c(uint8_t *src
, uint8_t *topright
, int stride
){
135 src
[0+0*stride
]=(t0
+ t2
+ 2*t1
+ 2)>>2;
137 src
[0+1*stride
]=(t1
+ t3
+ 2*t2
+ 2)>>2;
140 src
[0+2*stride
]=(t2
+ t4
+ 2*t3
+ 2)>>2;
144 src
[0+3*stride
]=(t3
+ t5
+ 2*t4
+ 2)>>2;
147 src
[1+3*stride
]=(t4
+ t6
+ 2*t5
+ 2)>>2;
149 src
[2+3*stride
]=(t5
+ t7
+ 2*t6
+ 2)>>2;
150 src
[3+3*stride
]=(t6
+ 3*t7
+ 2)>>2;
153 static void pred4x4_down_left_svq3_c(uint8_t *src
, uint8_t *topright
, int stride
){
156 const av_unused
int unu0
= t0
;
157 const av_unused
int unu1
= l0
;
159 src
[0+0*stride
]=(l1
+ t1
)>>1;
161 src
[0+1*stride
]=(l2
+ t2
)>>1;
174 src
[3+3*stride
]=(l3
+ t3
)>>1;
177 static void pred4x4_down_left_rv40_c(uint8_t *src
, uint8_t *topright
, int stride
){
183 src
[0+0*stride
]=(t0
+ t2
+ 2*t1
+ 2 + l0
+ l2
+ 2*l1
+ 2)>>3;
185 src
[0+1*stride
]=(t1
+ t3
+ 2*t2
+ 2 + l1
+ l3
+ 2*l2
+ 2)>>3;
188 src
[0+2*stride
]=(t2
+ t4
+ 2*t3
+ 2 + l2
+ l4
+ 2*l3
+ 2)>>3;
192 src
[0+3*stride
]=(t3
+ t5
+ 2*t4
+ 2 + l3
+ l5
+ 2*l4
+ 2)>>3;
195 src
[1+3*stride
]=(t4
+ t6
+ 2*t5
+ 2 + l4
+ l6
+ 2*l5
+ 2)>>3;
197 src
[2+3*stride
]=(t5
+ t7
+ 2*t6
+ 2 + l5
+ l7
+ 2*l6
+ 2)>>3;
198 src
[3+3*stride
]=(t6
+ t7
+ 1 + l6
+ l7
+ 1)>>2;
201 static void pred4x4_down_left_rv40_notop_c(uint8_t *src
, uint8_t *topright
, int stride
){
205 src
[0+0*stride
]=(l0
+ l2
+ 2*l1
+ 2)>>2;
207 src
[0+1*stride
]=(l1
+ l3
+ 2*l2
+ 2)>>2;
210 src
[0+2*stride
]=(l2
+ l4
+ 2*l3
+ 2)>>2;
214 src
[0+3*stride
]=(l3
+ l5
+ 2*l4
+ 2)>>2;
217 src
[1+3*stride
]=(l4
+ l6
+ 2*l5
+ 2)>>2;
219 src
[2+3*stride
]=(l5
+ l7
+ 2*l6
+ 2)>>2;
220 src
[3+3*stride
]=(l6
+ l7
+ 1)>>1;
223 static void pred4x4_down_left_rv40_nodown_c(uint8_t *src
, uint8_t *topright
, int stride
){
228 src
[0+0*stride
]=(t0
+ t2
+ 2*t1
+ 2 + l0
+ l2
+ 2*l1
+ 2)>>3;
230 src
[0+1*stride
]=(t1
+ t3
+ 2*t2
+ 2 + l1
+ l3
+ 2*l2
+ 2)>>3;
233 src
[0+2*stride
]=(t2
+ t4
+ 2*t3
+ 2 + l2
+ 3*l3
+ 2)>>3;
237 src
[0+3*stride
]=(t3
+ t5
+ 2*t4
+ 2 + l3
*4 + 2)>>3;
240 src
[1+3*stride
]=(t4
+ t6
+ 2*t5
+ 2 + l3
*4 + 2)>>3;
242 src
[2+3*stride
]=(t5
+ t7
+ 2*t6
+ 2 + l3
*4 + 2)>>3;
243 src
[3+3*stride
]=(t6
+ t7
+ 1 + 2*l3
+ 1)>>2;
246 static void pred4x4_vertical_right_c(uint8_t *src
, uint8_t *topright
, int stride
){
247 const int lt
= src
[-1-1*stride
];
252 src
[1+2*stride
]=(lt
+ t0
+ 1)>>1;
254 src
[2+2*stride
]=(t0
+ t1
+ 1)>>1;
256 src
[3+2*stride
]=(t1
+ t2
+ 1)>>1;
257 src
[3+0*stride
]=(t2
+ t3
+ 1)>>1;
259 src
[1+3*stride
]=(l0
+ 2*lt
+ t0
+ 2)>>2;
261 src
[2+3*stride
]=(lt
+ 2*t0
+ t1
+ 2)>>2;
263 src
[3+3*stride
]=(t0
+ 2*t1
+ t2
+ 2)>>2;
264 src
[3+1*stride
]=(t1
+ 2*t2
+ t3
+ 2)>>2;
265 src
[0+2*stride
]=(lt
+ 2*l0
+ l1
+ 2)>>2;
266 src
[0+3*stride
]=(l0
+ 2*l1
+ l2
+ 2)>>2;
269 static void pred4x4_vertical_left_c(uint8_t *src
, uint8_t *topright
, int stride
){
273 src
[0+0*stride
]=(t0
+ t1
+ 1)>>1;
275 src
[0+2*stride
]=(t1
+ t2
+ 1)>>1;
277 src
[1+2*stride
]=(t2
+ t3
+ 1)>>1;
279 src
[2+2*stride
]=(t3
+ t4
+ 1)>>1;
280 src
[3+2*stride
]=(t4
+ t5
+ 1)>>1;
281 src
[0+1*stride
]=(t0
+ 2*t1
+ t2
+ 2)>>2;
283 src
[0+3*stride
]=(t1
+ 2*t2
+ t3
+ 2)>>2;
285 src
[1+3*stride
]=(t2
+ 2*t3
+ t4
+ 2)>>2;
287 src
[2+3*stride
]=(t3
+ 2*t4
+ t5
+ 2)>>2;
288 src
[3+3*stride
]=(t4
+ 2*t5
+ t6
+ 2)>>2;
291 static void pred4x4_vertical_left_rv40(uint8_t *src
, uint8_t *topright
, int stride
,
292 const int l0
, const int l1
, const int l2
, const int l3
, const int l4
){
296 src
[0+0*stride
]=(2*t0
+ 2*t1
+ l1
+ 2*l2
+ l3
+ 4)>>3;
298 src
[0+2*stride
]=(t1
+ t2
+ 1)>>1;
300 src
[1+2*stride
]=(t2
+ t3
+ 1)>>1;
302 src
[2+2*stride
]=(t3
+ t4
+ 1)>>1;
303 src
[3+2*stride
]=(t4
+ t5
+ 1)>>1;
304 src
[0+1*stride
]=(t0
+ 2*t1
+ t2
+ l2
+ 2*l3
+ l4
+ 4)>>3;
306 src
[0+3*stride
]=(t1
+ 2*t2
+ t3
+ 2)>>2;
308 src
[1+3*stride
]=(t2
+ 2*t3
+ t4
+ 2)>>2;
310 src
[2+3*stride
]=(t3
+ 2*t4
+ t5
+ 2)>>2;
311 src
[3+3*stride
]=(t4
+ 2*t5
+ t6
+ 2)>>2;
314 static void pred4x4_vertical_left_rv40_c(uint8_t *src
, uint8_t *topright
, int stride
){
318 pred4x4_vertical_left_rv40(src
, topright
, stride
, l0
, l1
, l2
, l3
, l4
);
321 static void pred4x4_vertical_left_rv40_nodown_c(uint8_t *src
, uint8_t *topright
, int stride
){
324 pred4x4_vertical_left_rv40(src
, topright
, stride
, l0
, l1
, l2
, l3
, l3
);
327 static void pred4x4_horizontal_up_c(uint8_t *src
, uint8_t *topright
, int stride
){
330 src
[0+0*stride
]=(l0
+ l1
+ 1)>>1;
331 src
[1+0*stride
]=(l0
+ 2*l1
+ l2
+ 2)>>2;
333 src
[0+1*stride
]=(l1
+ l2
+ 1)>>1;
335 src
[1+1*stride
]=(l1
+ 2*l2
+ l3
+ 2)>>2;
337 src
[0+2*stride
]=(l2
+ l3
+ 1)>>1;
339 src
[1+2*stride
]=(l2
+ 2*l3
+ l3
+ 2)>>2;
348 static void pred4x4_horizontal_up_rv40_c(uint8_t *src
, uint8_t *topright
, int stride
){
354 src
[0+0*stride
]=(t1
+ 2*t2
+ t3
+ 2*l0
+ 2*l1
+ 4)>>3;
355 src
[1+0*stride
]=(t2
+ 2*t3
+ t4
+ l0
+ 2*l1
+ l2
+ 4)>>3;
357 src
[0+1*stride
]=(t3
+ 2*t4
+ t5
+ 2*l1
+ 2*l2
+ 4)>>3;
359 src
[1+1*stride
]=(t4
+ 2*t5
+ t6
+ l1
+ 2*l2
+ l3
+ 4)>>3;
361 src
[0+2*stride
]=(t5
+ 2*t6
+ t7
+ 2*l2
+ 2*l3
+ 4)>>3;
363 src
[1+2*stride
]=(t6
+ 3*t7
+ l2
+ 3*l3
+ 4)>>3;
365 src
[1+3*stride
]=(l3
+ 2*l4
+ l5
+ 2)>>2;
367 src
[2+2*stride
]=(t6
+ t7
+ l3
+ l4
+ 2)>>2;
368 src
[2+3*stride
]=(l4
+ l5
+ 1)>>1;
369 src
[3+3*stride
]=(l4
+ 2*l5
+ l6
+ 2)>>2;
372 static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src
, uint8_t *topright
, int stride
){
377 src
[0+0*stride
]=(t1
+ 2*t2
+ t3
+ 2*l0
+ 2*l1
+ 4)>>3;
378 src
[1+0*stride
]=(t2
+ 2*t3
+ t4
+ l0
+ 2*l1
+ l2
+ 4)>>3;
380 src
[0+1*stride
]=(t3
+ 2*t4
+ t5
+ 2*l1
+ 2*l2
+ 4)>>3;
382 src
[1+1*stride
]=(t4
+ 2*t5
+ t6
+ l1
+ 2*l2
+ l3
+ 4)>>3;
384 src
[0+2*stride
]=(t5
+ 2*t6
+ t7
+ 2*l2
+ 2*l3
+ 4)>>3;
386 src
[1+2*stride
]=(t6
+ 3*t7
+ l2
+ 3*l3
+ 4)>>3;
390 src
[2+2*stride
]=(t6
+ t7
+ 2*l3
+ 2)>>2;
395 static void pred4x4_horizontal_down_c(uint8_t *src
, uint8_t *topright
, int stride
){
396 const int lt
= src
[-1-1*stride
];
401 src
[2+1*stride
]=(lt
+ l0
+ 1)>>1;
403 src
[3+1*stride
]=(l0
+ 2*lt
+ t0
+ 2)>>2;
404 src
[2+0*stride
]=(lt
+ 2*t0
+ t1
+ 2)>>2;
405 src
[3+0*stride
]=(t0
+ 2*t1
+ t2
+ 2)>>2;
407 src
[2+2*stride
]=(l0
+ l1
+ 1)>>1;
409 src
[3+2*stride
]=(lt
+ 2*l0
+ l1
+ 2)>>2;
411 src
[2+3*stride
]=(l1
+ l2
+ 1)>>1;
413 src
[3+3*stride
]=(l0
+ 2*l1
+ l2
+ 2)>>2;
414 src
[0+3*stride
]=(l2
+ l3
+ 1)>>1;
415 src
[1+3*stride
]=(l1
+ 2*l2
+ l3
+ 2)>>2;
418 static void pred16x16_vertical_c(uint8_t *src
, int stride
){
420 const uint32_t a
= ((uint32_t*)(src
-stride
))[0];
421 const uint32_t b
= ((uint32_t*)(src
-stride
))[1];
422 const uint32_t c
= ((uint32_t*)(src
-stride
))[2];
423 const uint32_t d
= ((uint32_t*)(src
-stride
))[3];
426 ((uint32_t*)(src
+i
*stride
))[0]= a
;
427 ((uint32_t*)(src
+i
*stride
))[1]= b
;
428 ((uint32_t*)(src
+i
*stride
))[2]= c
;
429 ((uint32_t*)(src
+i
*stride
))[3]= d
;
433 static void pred16x16_horizontal_c(uint8_t *src
, int stride
){
437 ((uint32_t*)(src
+i
*stride
))[0]=
438 ((uint32_t*)(src
+i
*stride
))[1]=
439 ((uint32_t*)(src
+i
*stride
))[2]=
440 ((uint32_t*)(src
+i
*stride
))[3]= src
[-1+i
*stride
]*0x01010101;
444 static void pred16x16_dc_c(uint8_t *src
, int stride
){
448 dc
+= src
[-1+i
*stride
];
455 dc
= 0x01010101*((dc
+ 16)>>5);
458 ((uint32_t*)(src
+i
*stride
))[0]=
459 ((uint32_t*)(src
+i
*stride
))[1]=
460 ((uint32_t*)(src
+i
*stride
))[2]=
461 ((uint32_t*)(src
+i
*stride
))[3]= dc
;
465 static void pred16x16_left_dc_c(uint8_t *src
, int stride
){
469 dc
+= src
[-1+i
*stride
];
472 dc
= 0x01010101*((dc
+ 8)>>4);
475 ((uint32_t*)(src
+i
*stride
))[0]=
476 ((uint32_t*)(src
+i
*stride
))[1]=
477 ((uint32_t*)(src
+i
*stride
))[2]=
478 ((uint32_t*)(src
+i
*stride
))[3]= dc
;
482 static void pred16x16_top_dc_c(uint8_t *src
, int stride
){
488 dc
= 0x01010101*((dc
+ 8)>>4);
491 ((uint32_t*)(src
+i
*stride
))[0]=
492 ((uint32_t*)(src
+i
*stride
))[1]=
493 ((uint32_t*)(src
+i
*stride
))[2]=
494 ((uint32_t*)(src
+i
*stride
))[3]= dc
;
498 static void pred16x16_128_dc_c(uint8_t *src
, int stride
){
502 ((uint32_t*)(src
+i
*stride
))[0]=
503 ((uint32_t*)(src
+i
*stride
))[1]=
504 ((uint32_t*)(src
+i
*stride
))[2]=
505 ((uint32_t*)(src
+i
*stride
))[3]= 0x01010101U
*128U;
509 static inline void pred16x16_plane_compat_c(uint8_t *src
, int stride
, const int svq3
, const int rv40
){
512 uint8_t *cm
= ff_cropTbl
+ MAX_NEG_CROP
;
513 const uint8_t * const src0
= src
+7-stride
;
514 const uint8_t *src1
= src
+8*stride
-1;
515 const uint8_t *src2
= src1
-2*stride
; // == src+6*stride-1;
516 int H
= src0
[1] - src0
[-1];
517 int V
= src1
[0] - src2
[ 0];
518 for(k
=2; k
<=8; ++k
) {
519 src1
+= stride
; src2
-= stride
;
520 H
+= k
*(src0
[k
] - src0
[-k
]);
521 V
+= k
*(src1
[0] - src2
[ 0]);
524 H
= ( 5*(H
/4) ) / 16;
525 V
= ( 5*(V
/4) ) / 16;
527 /* required for 100% accuracy */
530 H
= ( H
+ (H
>>2) ) >> 4;
531 V
= ( V
+ (V
>>2) ) >> 4;
537 a
= 16*(src1
[0] + src2
[16] + 1) - 7*(V
+H
);
538 for(j
=16; j
>0; --j
) {
541 for(i
=-16; i
<0; i
+=4) {
542 src
[16+i
] = cm
[ (b
) >> 5 ];
543 src
[17+i
] = cm
[ (b
+ H
) >> 5 ];
544 src
[18+i
] = cm
[ (b
+2*H
) >> 5 ];
545 src
[19+i
] = cm
[ (b
+3*H
) >> 5 ];
552 static void pred16x16_plane_c(uint8_t *src
, int stride
){
553 pred16x16_plane_compat_c(src
, stride
, 0, 0);
556 static void pred16x16_plane_svq3_c(uint8_t *src
, int stride
){
557 pred16x16_plane_compat_c(src
, stride
, 1, 0);
560 static void pred16x16_plane_rv40_c(uint8_t *src
, int stride
){
561 pred16x16_plane_compat_c(src
, stride
, 0, 1);
564 static void pred8x8_vertical_c(uint8_t *src
, int stride
){
566 const uint32_t a
= ((uint32_t*)(src
-stride
))[0];
567 const uint32_t b
= ((uint32_t*)(src
-stride
))[1];
570 ((uint32_t*)(src
+i
*stride
))[0]= a
;
571 ((uint32_t*)(src
+i
*stride
))[1]= b
;
575 static void pred8x8_horizontal_c(uint8_t *src
, int stride
){
579 ((uint32_t*)(src
+i
*stride
))[0]=
580 ((uint32_t*)(src
+i
*stride
))[1]= src
[-1+i
*stride
]*0x01010101;
584 static void pred8x8_128_dc_c(uint8_t *src
, int stride
){
588 ((uint32_t*)(src
+i
*stride
))[0]=
589 ((uint32_t*)(src
+i
*stride
))[1]= 0x01010101U
*128U;
593 static void pred8x8_left_dc_c(uint8_t *src
, int stride
){
599 dc0
+= src
[-1+i
*stride
];
600 dc2
+= src
[-1+(i
+4)*stride
];
602 dc0
= 0x01010101*((dc0
+ 2)>>2);
603 dc2
= 0x01010101*((dc2
+ 2)>>2);
606 ((uint32_t*)(src
+i
*stride
))[0]=
607 ((uint32_t*)(src
+i
*stride
))[1]= dc0
;
610 ((uint32_t*)(src
+i
*stride
))[0]=
611 ((uint32_t*)(src
+i
*stride
))[1]= dc2
;
615 static void pred8x8_left_dc_rv40_c(uint8_t *src
, int stride
){
621 dc0
+= src
[-1+i
*stride
];
622 dc0
= 0x01010101*((dc0
+ 4)>>3);
625 ((uint32_t*)(src
+i
*stride
))[0]=
626 ((uint32_t*)(src
+i
*stride
))[1]= dc0
;
630 static void pred8x8_top_dc_c(uint8_t *src
, int stride
){
637 dc1
+= src
[4+i
-stride
];
639 dc0
= 0x01010101*((dc0
+ 2)>>2);
640 dc1
= 0x01010101*((dc1
+ 2)>>2);
643 ((uint32_t*)(src
+i
*stride
))[0]= dc0
;
644 ((uint32_t*)(src
+i
*stride
))[1]= dc1
;
647 ((uint32_t*)(src
+i
*stride
))[0]= dc0
;
648 ((uint32_t*)(src
+i
*stride
))[1]= dc1
;
652 static void pred8x8_top_dc_rv40_c(uint8_t *src
, int stride
){
659 dc0
= 0x01010101*((dc0
+ 4)>>3);
662 ((uint32_t*)(src
+i
*stride
))[0]=
663 ((uint32_t*)(src
+i
*stride
))[1]= dc0
;
668 static void pred8x8_dc_c(uint8_t *src
, int stride
){
670 int dc0
, dc1
, dc2
, dc3
;
674 dc0
+= src
[-1+i
*stride
] + src
[i
-stride
];
675 dc1
+= src
[4+i
-stride
];
676 dc2
+= src
[-1+(i
+4)*stride
];
678 dc3
= 0x01010101*((dc1
+ dc2
+ 4)>>3);
679 dc0
= 0x01010101*((dc0
+ 4)>>3);
680 dc1
= 0x01010101*((dc1
+ 2)>>2);
681 dc2
= 0x01010101*((dc2
+ 2)>>2);
684 ((uint32_t*)(src
+i
*stride
))[0]= dc0
;
685 ((uint32_t*)(src
+i
*stride
))[1]= dc1
;
688 ((uint32_t*)(src
+i
*stride
))[0]= dc2
;
689 ((uint32_t*)(src
+i
*stride
))[1]= dc3
;
693 static void pred8x8_dc_rv40_c(uint8_t *src
, int stride
){
698 dc0
+= src
[-1+i
*stride
] + src
[i
-stride
];
699 dc0
+= src
[4+i
-stride
];
700 dc0
+= src
[-1+(i
+4)*stride
];
702 dc0
= 0x01010101*((dc0
+ 8)>>4);
705 ((uint32_t*)(src
+i
*stride
))[0]= dc0
;
706 ((uint32_t*)(src
+i
*stride
))[1]= dc0
;
709 ((uint32_t*)(src
+i
*stride
))[0]= dc0
;
710 ((uint32_t*)(src
+i
*stride
))[1]= dc0
;
714 static void pred8x8_plane_c(uint8_t *src
, int stride
){
717 uint8_t *cm
= ff_cropTbl
+ MAX_NEG_CROP
;
718 const uint8_t * const src0
= src
+3-stride
;
719 const uint8_t *src1
= src
+4*stride
-1;
720 const uint8_t *src2
= src1
-2*stride
; // == src+2*stride-1;
721 int H
= src0
[1] - src0
[-1];
722 int V
= src1
[0] - src2
[ 0];
723 for(k
=2; k
<=4; ++k
) {
724 src1
+= stride
; src2
-= stride
;
725 H
+= k
*(src0
[k
] - src0
[-k
]);
726 V
+= k
*(src1
[0] - src2
[ 0]);
728 H
= ( 17*H
+16 ) >> 5;
729 V
= ( 17*V
+16 ) >> 5;
731 a
= 16*(src1
[0] + src2
[8]+1) - 3*(V
+H
);
735 src
[0] = cm
[ (b
) >> 5 ];
736 src
[1] = cm
[ (b
+ H
) >> 5 ];
737 src
[2] = cm
[ (b
+2*H
) >> 5 ];
738 src
[3] = cm
[ (b
+3*H
) >> 5 ];
739 src
[4] = cm
[ (b
+4*H
) >> 5 ];
740 src
[5] = cm
[ (b
+5*H
) >> 5 ];
741 src
[6] = cm
[ (b
+6*H
) >> 5 ];
742 src
[7] = cm
[ (b
+7*H
) >> 5 ];
747 #define SRC(x,y) src[(x)+(y)*stride]
749 const int l##y = (SRC(-1,y-1) + 2*SRC(-1,y) + SRC(-1,y+1) + 2) >> 2;
750 #define PREDICT_8x8_LOAD_LEFT \
751 const int l0 = ((has_topleft ? SRC(-1,-1) : SRC(-1,0)) \
752 + 2*SRC(-1,0) + SRC(-1,1) + 2) >> 2; \
753 PL(1) PL(2) PL(3) PL(4) PL(5) PL(6) \
754 const int l7 av_unused = (SRC(-1,6) + 3*SRC(-1,7) + 2) >> 2
757 const int t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
758 #define PREDICT_8x8_LOAD_TOP \
759 const int t0 = ((has_topleft ? SRC(-1,-1) : SRC(0,-1)) \
760 + 2*SRC(0,-1) + SRC(1,-1) + 2) >> 2; \
761 PT(1) PT(2) PT(3) PT(4) PT(5) PT(6) \
762 const int t7 av_unused = ((has_topright ? SRC(8,-1) : SRC(7,-1)) \
763 + 2*SRC(7,-1) + SRC(6,-1) + 2) >> 2
766 t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
767 #define PREDICT_8x8_LOAD_TOPRIGHT \
768 int t8, t9, t10, t11, t12, t13, t14, t15; \
770 PTR(8) PTR(9) PTR(10) PTR(11) PTR(12) PTR(13) PTR(14) \
771 t15 = (SRC(14,-1) + 3*SRC(15,-1) + 2) >> 2; \
772 } else t8=t9=t10=t11=t12=t13=t14=t15= SRC(7,-1);
774 #define PREDICT_8x8_LOAD_TOPLEFT \
775 const int lt = (SRC(-1,0) + 2*SRC(-1,-1) + SRC(0,-1) + 2) >> 2
777 #define PREDICT_8x8_DC(v) \
779 for( y = 0; y < 8; y++ ) { \
780 ((uint32_t*)src)[0] = \
781 ((uint32_t*)src)[1] = v; \
785 static void pred8x8l_128_dc_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
787 PREDICT_8x8_DC(0x80808080);
789 static void pred8x8l_left_dc_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
791 PREDICT_8x8_LOAD_LEFT
;
792 const uint32_t dc
= ((l0
+l1
+l2
+l3
+l4
+l5
+l6
+l7
+4) >> 3) * 0x01010101;
795 static void pred8x8l_top_dc_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
797 PREDICT_8x8_LOAD_TOP
;
798 const uint32_t dc
= ((t0
+t1
+t2
+t3
+t4
+t5
+t6
+t7
+4) >> 3) * 0x01010101;
801 static void pred8x8l_dc_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
803 PREDICT_8x8_LOAD_LEFT
;
804 PREDICT_8x8_LOAD_TOP
;
805 const uint32_t dc
= ((l0
+l1
+l2
+l3
+l4
+l5
+l6
+l7
806 +t0
+t1
+t2
+t3
+t4
+t5
+t6
+t7
+8) >> 4) * 0x01010101;
809 static void pred8x8l_horizontal_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
811 PREDICT_8x8_LOAD_LEFT
;
812 #define ROW(y) ((uint32_t*)(src+y*stride))[0] =\
813 ((uint32_t*)(src+y*stride))[1] = 0x01010101 * l##y
814 ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
817 static void pred8x8l_vertical_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
820 PREDICT_8x8_LOAD_TOP
;
829 for( y
= 1; y
< 8; y
++ )
830 *(uint64_t*)(src
+y
*stride
) = *(uint64_t*)src
;
832 static void pred8x8l_down_left_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
834 PREDICT_8x8_LOAD_TOP
;
835 PREDICT_8x8_LOAD_TOPRIGHT
;
836 SRC(0,0)= (t0
+ 2*t1
+ t2
+ 2) >> 2;
837 SRC(0,1)=SRC(1,0)= (t1
+ 2*t2
+ t3
+ 2) >> 2;
838 SRC(0,2)=SRC(1,1)=SRC(2,0)= (t2
+ 2*t3
+ t4
+ 2) >> 2;
839 SRC(0,3)=SRC(1,2)=SRC(2,1)=SRC(3,0)= (t3
+ 2*t4
+ t5
+ 2) >> 2;
840 SRC(0,4)=SRC(1,3)=SRC(2,2)=SRC(3,1)=SRC(4,0)= (t4
+ 2*t5
+ t6
+ 2) >> 2;
841 SRC(0,5)=SRC(1,4)=SRC(2,3)=SRC(3,2)=SRC(4,1)=SRC(5,0)= (t5
+ 2*t6
+ t7
+ 2) >> 2;
842 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;
843 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;
844 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;
845 SRC(2,7)=SRC(3,6)=SRC(4,5)=SRC(5,4)=SRC(6,3)=SRC(7,2)= (t9
+ 2*t10
+ t11
+ 2) >> 2;
846 SRC(3,7)=SRC(4,6)=SRC(5,5)=SRC(6,4)=SRC(7,3)= (t10
+ 2*t11
+ t12
+ 2) >> 2;
847 SRC(4,7)=SRC(5,6)=SRC(6,5)=SRC(7,4)= (t11
+ 2*t12
+ t13
+ 2) >> 2;
848 SRC(5,7)=SRC(6,6)=SRC(7,5)= (t12
+ 2*t13
+ t14
+ 2) >> 2;
849 SRC(6,7)=SRC(7,6)= (t13
+ 2*t14
+ t15
+ 2) >> 2;
850 SRC(7,7)= (t14
+ 3*t15
+ 2) >> 2;
852 static void pred8x8l_down_right_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
854 PREDICT_8x8_LOAD_TOP
;
855 PREDICT_8x8_LOAD_LEFT
;
856 PREDICT_8x8_LOAD_TOPLEFT
;
857 SRC(0,7)= (l7
+ 2*l6
+ l5
+ 2) >> 2;
858 SRC(0,6)=SRC(1,7)= (l6
+ 2*l5
+ l4
+ 2) >> 2;
859 SRC(0,5)=SRC(1,6)=SRC(2,7)= (l5
+ 2*l4
+ l3
+ 2) >> 2;
860 SRC(0,4)=SRC(1,5)=SRC(2,6)=SRC(3,7)= (l4
+ 2*l3
+ l2
+ 2) >> 2;
861 SRC(0,3)=SRC(1,4)=SRC(2,5)=SRC(3,6)=SRC(4,7)= (l3
+ 2*l2
+ l1
+ 2) >> 2;
862 SRC(0,2)=SRC(1,3)=SRC(2,4)=SRC(3,5)=SRC(4,6)=SRC(5,7)= (l2
+ 2*l1
+ l0
+ 2) >> 2;
863 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;
864 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;
865 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;
866 SRC(2,0)=SRC(3,1)=SRC(4,2)=SRC(5,3)=SRC(6,4)=SRC(7,5)= (t0
+ 2*t1
+ t2
+ 2) >> 2;
867 SRC(3,0)=SRC(4,1)=SRC(5,2)=SRC(6,3)=SRC(7,4)= (t1
+ 2*t2
+ t3
+ 2) >> 2;
868 SRC(4,0)=SRC(5,1)=SRC(6,2)=SRC(7,3)= (t2
+ 2*t3
+ t4
+ 2) >> 2;
869 SRC(5,0)=SRC(6,1)=SRC(7,2)= (t3
+ 2*t4
+ t5
+ 2) >> 2;
870 SRC(6,0)=SRC(7,1)= (t4
+ 2*t5
+ t6
+ 2) >> 2;
871 SRC(7,0)= (t5
+ 2*t6
+ t7
+ 2) >> 2;
874 static void pred8x8l_vertical_right_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
876 PREDICT_8x8_LOAD_TOP
;
877 PREDICT_8x8_LOAD_LEFT
;
878 PREDICT_8x8_LOAD_TOPLEFT
;
879 SRC(0,6)= (l5
+ 2*l4
+ l3
+ 2) >> 2;
880 SRC(0,7)= (l6
+ 2*l5
+ l4
+ 2) >> 2;
881 SRC(0,4)=SRC(1,6)= (l3
+ 2*l2
+ l1
+ 2) >> 2;
882 SRC(0,5)=SRC(1,7)= (l4
+ 2*l3
+ l2
+ 2) >> 2;
883 SRC(0,2)=SRC(1,4)=SRC(2,6)= (l1
+ 2*l0
+ lt
+ 2) >> 2;
884 SRC(0,3)=SRC(1,5)=SRC(2,7)= (l2
+ 2*l1
+ l0
+ 2) >> 2;
885 SRC(0,1)=SRC(1,3)=SRC(2,5)=SRC(3,7)= (l0
+ 2*lt
+ t0
+ 2) >> 2;
886 SRC(0,0)=SRC(1,2)=SRC(2,4)=SRC(3,6)= (lt
+ t0
+ 1) >> 1;
887 SRC(1,1)=SRC(2,3)=SRC(3,5)=SRC(4,7)= (lt
+ 2*t0
+ t1
+ 2) >> 2;
888 SRC(1,0)=SRC(2,2)=SRC(3,4)=SRC(4,6)= (t0
+ t1
+ 1) >> 1;
889 SRC(2,1)=SRC(3,3)=SRC(4,5)=SRC(5,7)= (t0
+ 2*t1
+ t2
+ 2) >> 2;
890 SRC(2,0)=SRC(3,2)=SRC(4,4)=SRC(5,6)= (t1
+ t2
+ 1) >> 1;
891 SRC(3,1)=SRC(4,3)=SRC(5,5)=SRC(6,7)= (t1
+ 2*t2
+ t3
+ 2) >> 2;
892 SRC(3,0)=SRC(4,2)=SRC(5,4)=SRC(6,6)= (t2
+ t3
+ 1) >> 1;
893 SRC(4,1)=SRC(5,3)=SRC(6,5)=SRC(7,7)= (t2
+ 2*t3
+ t4
+ 2) >> 2;
894 SRC(4,0)=SRC(5,2)=SRC(6,4)=SRC(7,6)= (t3
+ t4
+ 1) >> 1;
895 SRC(5,1)=SRC(6,3)=SRC(7,5)= (t3
+ 2*t4
+ t5
+ 2) >> 2;
896 SRC(5,0)=SRC(6,2)=SRC(7,4)= (t4
+ t5
+ 1) >> 1;
897 SRC(6,1)=SRC(7,3)= (t4
+ 2*t5
+ t6
+ 2) >> 2;
898 SRC(6,0)=SRC(7,2)= (t5
+ t6
+ 1) >> 1;
899 SRC(7,1)= (t5
+ 2*t6
+ t7
+ 2) >> 2;
900 SRC(7,0)= (t6
+ t7
+ 1) >> 1;
902 static void pred8x8l_horizontal_down_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
904 PREDICT_8x8_LOAD_TOP
;
905 PREDICT_8x8_LOAD_LEFT
;
906 PREDICT_8x8_LOAD_TOPLEFT
;
907 SRC(0,7)= (l6
+ l7
+ 1) >> 1;
908 SRC(1,7)= (l5
+ 2*l6
+ l7
+ 2) >> 2;
909 SRC(0,6)=SRC(2,7)= (l5
+ l6
+ 1) >> 1;
910 SRC(1,6)=SRC(3,7)= (l4
+ 2*l5
+ l6
+ 2) >> 2;
911 SRC(0,5)=SRC(2,6)=SRC(4,7)= (l4
+ l5
+ 1) >> 1;
912 SRC(1,5)=SRC(3,6)=SRC(5,7)= (l3
+ 2*l4
+ l5
+ 2) >> 2;
913 SRC(0,4)=SRC(2,5)=SRC(4,6)=SRC(6,7)= (l3
+ l4
+ 1) >> 1;
914 SRC(1,4)=SRC(3,5)=SRC(5,6)=SRC(7,7)= (l2
+ 2*l3
+ l4
+ 2) >> 2;
915 SRC(0,3)=SRC(2,4)=SRC(4,5)=SRC(6,6)= (l2
+ l3
+ 1) >> 1;
916 SRC(1,3)=SRC(3,4)=SRC(5,5)=SRC(7,6)= (l1
+ 2*l2
+ l3
+ 2) >> 2;
917 SRC(0,2)=SRC(2,3)=SRC(4,4)=SRC(6,5)= (l1
+ l2
+ 1) >> 1;
918 SRC(1,2)=SRC(3,3)=SRC(5,4)=SRC(7,5)= (l0
+ 2*l1
+ l2
+ 2) >> 2;
919 SRC(0,1)=SRC(2,2)=SRC(4,3)=SRC(6,4)= (l0
+ l1
+ 1) >> 1;
920 SRC(1,1)=SRC(3,2)=SRC(5,3)=SRC(7,4)= (lt
+ 2*l0
+ l1
+ 2) >> 2;
921 SRC(0,0)=SRC(2,1)=SRC(4,2)=SRC(6,3)= (lt
+ l0
+ 1) >> 1;
922 SRC(1,0)=SRC(3,1)=SRC(5,2)=SRC(7,3)= (l0
+ 2*lt
+ t0
+ 2) >> 2;
923 SRC(2,0)=SRC(4,1)=SRC(6,2)= (t1
+ 2*t0
+ lt
+ 2) >> 2;
924 SRC(3,0)=SRC(5,1)=SRC(7,2)= (t2
+ 2*t1
+ t0
+ 2) >> 2;
925 SRC(4,0)=SRC(6,1)= (t3
+ 2*t2
+ t1
+ 2) >> 2;
926 SRC(5,0)=SRC(7,1)= (t4
+ 2*t3
+ t2
+ 2) >> 2;
927 SRC(6,0)= (t5
+ 2*t4
+ t3
+ 2) >> 2;
928 SRC(7,0)= (t6
+ 2*t5
+ t4
+ 2) >> 2;
930 static void pred8x8l_vertical_left_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
932 PREDICT_8x8_LOAD_TOP
;
933 PREDICT_8x8_LOAD_TOPRIGHT
;
934 SRC(0,0)= (t0
+ t1
+ 1) >> 1;
935 SRC(0,1)= (t0
+ 2*t1
+ t2
+ 2) >> 2;
936 SRC(0,2)=SRC(1,0)= (t1
+ t2
+ 1) >> 1;
937 SRC(0,3)=SRC(1,1)= (t1
+ 2*t2
+ t3
+ 2) >> 2;
938 SRC(0,4)=SRC(1,2)=SRC(2,0)= (t2
+ t3
+ 1) >> 1;
939 SRC(0,5)=SRC(1,3)=SRC(2,1)= (t2
+ 2*t3
+ t4
+ 2) >> 2;
940 SRC(0,6)=SRC(1,4)=SRC(2,2)=SRC(3,0)= (t3
+ t4
+ 1) >> 1;
941 SRC(0,7)=SRC(1,5)=SRC(2,3)=SRC(3,1)= (t3
+ 2*t4
+ t5
+ 2) >> 2;
942 SRC(1,6)=SRC(2,4)=SRC(3,2)=SRC(4,0)= (t4
+ t5
+ 1) >> 1;
943 SRC(1,7)=SRC(2,5)=SRC(3,3)=SRC(4,1)= (t4
+ 2*t5
+ t6
+ 2) >> 2;
944 SRC(2,6)=SRC(3,4)=SRC(4,2)=SRC(5,0)= (t5
+ t6
+ 1) >> 1;
945 SRC(2,7)=SRC(3,5)=SRC(4,3)=SRC(5,1)= (t5
+ 2*t6
+ t7
+ 2) >> 2;
946 SRC(3,6)=SRC(4,4)=SRC(5,2)=SRC(6,0)= (t6
+ t7
+ 1) >> 1;
947 SRC(3,7)=SRC(4,5)=SRC(5,3)=SRC(6,1)= (t6
+ 2*t7
+ t8
+ 2) >> 2;
948 SRC(4,6)=SRC(5,4)=SRC(6,2)=SRC(7,0)= (t7
+ t8
+ 1) >> 1;
949 SRC(4,7)=SRC(5,5)=SRC(6,3)=SRC(7,1)= (t7
+ 2*t8
+ t9
+ 2) >> 2;
950 SRC(5,6)=SRC(6,4)=SRC(7,2)= (t8
+ t9
+ 1) >> 1;
951 SRC(5,7)=SRC(6,5)=SRC(7,3)= (t8
+ 2*t9
+ t10
+ 2) >> 2;
952 SRC(6,6)=SRC(7,4)= (t9
+ t10
+ 1) >> 1;
953 SRC(6,7)=SRC(7,5)= (t9
+ 2*t10
+ t11
+ 2) >> 2;
954 SRC(7,6)= (t10
+ t11
+ 1) >> 1;
955 SRC(7,7)= (t10
+ 2*t11
+ t12
+ 2) >> 2;
957 static void pred8x8l_horizontal_up_c(uint8_t *src
, int has_topleft
, int has_topright
, int stride
)
959 PREDICT_8x8_LOAD_LEFT
;
960 SRC(0,0)= (l0
+ l1
+ 1) >> 1;
961 SRC(1,0)= (l0
+ 2*l1
+ l2
+ 2) >> 2;
962 SRC(0,1)=SRC(2,0)= (l1
+ l2
+ 1) >> 1;
963 SRC(1,1)=SRC(3,0)= (l1
+ 2*l2
+ l3
+ 2) >> 2;
964 SRC(0,2)=SRC(2,1)=SRC(4,0)= (l2
+ l3
+ 1) >> 1;
965 SRC(1,2)=SRC(3,1)=SRC(5,0)= (l2
+ 2*l3
+ l4
+ 2) >> 2;
966 SRC(0,3)=SRC(2,2)=SRC(4,1)=SRC(6,0)= (l3
+ l4
+ 1) >> 1;
967 SRC(1,3)=SRC(3,2)=SRC(5,1)=SRC(7,0)= (l3
+ 2*l4
+ l5
+ 2) >> 2;
968 SRC(0,4)=SRC(2,3)=SRC(4,2)=SRC(6,1)= (l4
+ l5
+ 1) >> 1;
969 SRC(1,4)=SRC(3,3)=SRC(5,2)=SRC(7,1)= (l4
+ 2*l5
+ l6
+ 2) >> 2;
970 SRC(0,5)=SRC(2,4)=SRC(4,3)=SRC(6,2)= (l5
+ l6
+ 1) >> 1;
971 SRC(1,5)=SRC(3,4)=SRC(5,3)=SRC(7,2)= (l5
+ 2*l6
+ l7
+ 2) >> 2;
972 SRC(0,6)=SRC(2,5)=SRC(4,4)=SRC(6,3)= (l6
+ l7
+ 1) >> 1;
973 SRC(1,6)=SRC(3,5)=SRC(5,4)=SRC(7,3)= (l6
+ 3*l7
+ 2) >> 2;
974 SRC(0,7)=SRC(1,7)=SRC(2,6)=SRC(2,7)=SRC(3,6)=
975 SRC(3,7)=SRC(4,5)=SRC(4,6)=SRC(4,7)=SRC(5,5)=
976 SRC(5,6)=SRC(5,7)=SRC(6,4)=SRC(6,5)=SRC(6,6)=
977 SRC(6,7)=SRC(7,4)=SRC(7,5)=SRC(7,6)=SRC(7,7)= l7
;
979 #undef PREDICT_8x8_LOAD_LEFT
980 #undef PREDICT_8x8_LOAD_TOP
981 #undef PREDICT_8x8_LOAD_TOPLEFT
982 #undef PREDICT_8x8_LOAD_TOPRIGHT
983 #undef PREDICT_8x8_DC
990 * Sets the intra prediction function pointers.
992 void ff_h264_pred_init(H264PredContext
*h
, int codec_id
){
993 // MpegEncContext * const s = &h->s;
995 if(codec_id
!= CODEC_ID_RV40
){
996 h
->pred4x4
[VERT_PRED
]= pred4x4_vertical_c
;
997 h
->pred4x4
[HOR_PRED
]= pred4x4_horizontal_c
;
998 h
->pred4x4
[DC_PRED
]= pred4x4_dc_c
;
999 if(codec_id
== CODEC_ID_SVQ3
)
1000 h
->pred4x4
[DIAG_DOWN_LEFT_PRED
]= pred4x4_down_left_svq3_c
;
1002 h
->pred4x4
[DIAG_DOWN_LEFT_PRED
]= pred4x4_down_left_c
;
1003 h
->pred4x4
[DIAG_DOWN_RIGHT_PRED
]= pred4x4_down_right_c
;
1004 h
->pred4x4
[VERT_RIGHT_PRED
]= pred4x4_vertical_right_c
;
1005 h
->pred4x4
[HOR_DOWN_PRED
]= pred4x4_horizontal_down_c
;
1006 h
->pred4x4
[VERT_LEFT_PRED
]= pred4x4_vertical_left_c
;
1007 h
->pred4x4
[HOR_UP_PRED
]= pred4x4_horizontal_up_c
;
1008 h
->pred4x4
[LEFT_DC_PRED
]= pred4x4_left_dc_c
;
1009 h
->pred4x4
[TOP_DC_PRED
]= pred4x4_top_dc_c
;
1010 h
->pred4x4
[DC_128_PRED
]= pred4x4_128_dc_c
;
1012 h
->pred4x4
[VERT_PRED
]= pred4x4_vertical_c
;
1013 h
->pred4x4
[HOR_PRED
]= pred4x4_horizontal_c
;
1014 h
->pred4x4
[DC_PRED
]= pred4x4_dc_c
;
1015 h
->pred4x4
[DIAG_DOWN_LEFT_PRED
]= pred4x4_down_left_rv40_c
;
1016 h
->pred4x4
[DIAG_DOWN_RIGHT_PRED
]= pred4x4_down_right_c
;
1017 h
->pred4x4
[VERT_RIGHT_PRED
]= pred4x4_vertical_right_c
;
1018 h
->pred4x4
[HOR_DOWN_PRED
]= pred4x4_horizontal_down_c
;
1019 h
->pred4x4
[VERT_LEFT_PRED
]= pred4x4_vertical_left_rv40_c
;
1020 h
->pred4x4
[HOR_UP_PRED
]= pred4x4_horizontal_up_rv40_c
;
1021 h
->pred4x4
[LEFT_DC_PRED
]= pred4x4_left_dc_c
;
1022 h
->pred4x4
[TOP_DC_PRED
]= pred4x4_top_dc_c
;
1023 h
->pred4x4
[DC_128_PRED
]= pred4x4_128_dc_c
;
1024 h
->pred4x4
[DIAG_DOWN_LEFT_PRED_RV40_NODOWN
]= pred4x4_down_left_rv40_nodown_c
;
1025 h
->pred4x4
[HOR_UP_PRED_RV40_NODOWN
]= pred4x4_horizontal_up_rv40_nodown_c
;
1026 h
->pred4x4
[VERT_LEFT_PRED_RV40_NODOWN
]= pred4x4_vertical_left_rv40_nodown_c
;
1029 h
->pred8x8l
[VERT_PRED
]= pred8x8l_vertical_c
;
1030 h
->pred8x8l
[HOR_PRED
]= pred8x8l_horizontal_c
;
1031 h
->pred8x8l
[DC_PRED
]= pred8x8l_dc_c
;
1032 h
->pred8x8l
[DIAG_DOWN_LEFT_PRED
]= pred8x8l_down_left_c
;
1033 h
->pred8x8l
[DIAG_DOWN_RIGHT_PRED
]= pred8x8l_down_right_c
;
1034 h
->pred8x8l
[VERT_RIGHT_PRED
]= pred8x8l_vertical_right_c
;
1035 h
->pred8x8l
[HOR_DOWN_PRED
]= pred8x8l_horizontal_down_c
;
1036 h
->pred8x8l
[VERT_LEFT_PRED
]= pred8x8l_vertical_left_c
;
1037 h
->pred8x8l
[HOR_UP_PRED
]= pred8x8l_horizontal_up_c
;
1038 h
->pred8x8l
[LEFT_DC_PRED
]= pred8x8l_left_dc_c
;
1039 h
->pred8x8l
[TOP_DC_PRED
]= pred8x8l_top_dc_c
;
1040 h
->pred8x8l
[DC_128_PRED
]= pred8x8l_128_dc_c
;
1042 h
->pred8x8
[VERT_PRED8x8
]= pred8x8_vertical_c
;
1043 h
->pred8x8
[HOR_PRED8x8
]= pred8x8_horizontal_c
;
1044 h
->pred8x8
[PLANE_PRED8x8
]= pred8x8_plane_c
;
1045 if(codec_id
!= CODEC_ID_RV40
){
1046 h
->pred8x8
[DC_PRED8x8
]= pred8x8_dc_c
;
1047 h
->pred8x8
[LEFT_DC_PRED8x8
]= pred8x8_left_dc_c
;
1048 h
->pred8x8
[TOP_DC_PRED8x8
]= pred8x8_top_dc_c
;
1050 h
->pred8x8
[DC_PRED8x8
]= pred8x8_dc_rv40_c
;
1051 h
->pred8x8
[LEFT_DC_PRED8x8
]= pred8x8_left_dc_rv40_c
;
1052 h
->pred8x8
[TOP_DC_PRED8x8
]= pred8x8_top_dc_rv40_c
;
1054 h
->pred8x8
[DC_128_PRED8x8
]= pred8x8_128_dc_c
;
1056 h
->pred16x16
[DC_PRED8x8
]= pred16x16_dc_c
;
1057 h
->pred16x16
[VERT_PRED8x8
]= pred16x16_vertical_c
;
1058 h
->pred16x16
[HOR_PRED8x8
]= pred16x16_horizontal_c
;
1059 h
->pred16x16
[PLANE_PRED8x8
]= pred16x16_plane_c
;
1062 h
->pred16x16
[PLANE_PRED8x8
]= pred16x16_plane_svq3_c
;
1065 h
->pred16x16
[PLANE_PRED8x8
]= pred16x16_plane_rv40_c
;
1068 h
->pred16x16
[PLANE_PRED8x8
]= pred16x16_plane_c
;
1070 h
->pred16x16
[LEFT_DC_PRED8x8
]= pred16x16_left_dc_c
;
1071 h
->pred16x16
[TOP_DC_PRED8x8
]= pred16x16_top_dc_c
;
1072 h
->pred16x16
[DC_128_PRED8x8
]= pred16x16_128_dc_c
;