Use ptrdiff_t instead of int for intra pred "stride" function parameter.
[ffmpeg.git] / libavcodec / h264pred.c
1 /*
2  * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
3  * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
4  *
5  * This file is part of Libav.
6  *
7  * Libav 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.
11  *
12  * Libav 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.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 /**
23  * @file
24  * H.264 / AVC / MPEG4 part10 prediction functions.
25  * @author Michael Niedermayer <michaelni@gmx.at>
26  */
27
28 #include "h264pred.h"
29
30 #define BIT_DEPTH 8
31 #include "h264pred_template.c"
32 #undef BIT_DEPTH
33
34 #define BIT_DEPTH 9
35 #include "h264pred_template.c"
36 #undef BIT_DEPTH
37
38 #define BIT_DEPTH 10
39 #include "h264pred_template.c"
40 #undef BIT_DEPTH
41
42 static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright,
43                                    ptrdiff_t stride)
44 {
45     const unsigned lt = src[-1-1*stride];
46     LOAD_TOP_EDGE
47     LOAD_TOP_RIGHT_EDGE
48     uint32_t v = PACK_4U8((lt + 2*t0 + t1 + 2) >> 2,
49                           (t0 + 2*t1 + t2 + 2) >> 2,
50                           (t1 + 2*t2 + t3 + 2) >> 2,
51                           (t2 + 2*t3 + t4 + 2) >> 2);
52
53     AV_WN32A(src+0*stride, v);
54     AV_WN32A(src+1*stride, v);
55     AV_WN32A(src+2*stride, v);
56     AV_WN32A(src+3*stride, v);
57 }
58
59 static void pred4x4_horizontal_vp8_c(uint8_t *src, const uint8_t *topright,
60                                      ptrdiff_t stride)
61 {
62     const unsigned lt = src[-1-1*stride];
63     LOAD_LEFT_EDGE
64
65     AV_WN32A(src+0*stride, ((lt + 2*l0 + l1 + 2) >> 2)*0x01010101);
66     AV_WN32A(src+1*stride, ((l0 + 2*l1 + l2 + 2) >> 2)*0x01010101);
67     AV_WN32A(src+2*stride, ((l1 + 2*l2 + l3 + 2) >> 2)*0x01010101);
68     AV_WN32A(src+3*stride, ((l2 + 2*l3 + l3 + 2) >> 2)*0x01010101);
69 }
70
71 static void pred4x4_down_left_svq3_c(uint8_t *src, const uint8_t *topright,
72                                      ptrdiff_t stride)
73 {
74     LOAD_TOP_EDGE
75     LOAD_LEFT_EDGE
76
77     src[0+0*stride]=(l1 + t1)>>1;
78     src[1+0*stride]=
79     src[0+1*stride]=(l2 + t2)>>1;
80     src[2+0*stride]=
81     src[1+1*stride]=
82     src[0+2*stride]=
83     src[3+0*stride]=
84     src[2+1*stride]=
85     src[1+2*stride]=
86     src[0+3*stride]=
87     src[3+1*stride]=
88     src[2+2*stride]=
89     src[1+3*stride]=
90     src[3+2*stride]=
91     src[2+3*stride]=
92     src[3+3*stride]=(l3 + t3)>>1;
93 }
94
95 static void pred4x4_down_left_rv40_c(uint8_t *src, const uint8_t *topright,
96                                      ptrdiff_t stride)
97 {
98     LOAD_TOP_EDGE
99     LOAD_TOP_RIGHT_EDGE
100     LOAD_LEFT_EDGE
101     LOAD_DOWN_LEFT_EDGE
102
103     src[0+0*stride]=(t0 + t2 + 2*t1 + 2 + l0 + l2 + 2*l1 + 2)>>3;
104     src[1+0*stride]=
105     src[0+1*stride]=(t1 + t3 + 2*t2 + 2 + l1 + l3 + 2*l2 + 2)>>3;
106     src[2+0*stride]=
107     src[1+1*stride]=
108     src[0+2*stride]=(t2 + t4 + 2*t3 + 2 + l2 + l4 + 2*l3 + 2)>>3;
109     src[3+0*stride]=
110     src[2+1*stride]=
111     src[1+2*stride]=
112     src[0+3*stride]=(t3 + t5 + 2*t4 + 2 + l3 + l5 + 2*l4 + 2)>>3;
113     src[3+1*stride]=
114     src[2+2*stride]=
115     src[1+3*stride]=(t4 + t6 + 2*t5 + 2 + l4 + l6 + 2*l5 + 2)>>3;
116     src[3+2*stride]=
117     src[2+3*stride]=(t5 + t7 + 2*t6 + 2 + l5 + l7 + 2*l6 + 2)>>3;
118     src[3+3*stride]=(t6 + t7 + 1 + l6 + l7 + 1)>>2;
119 }
120
121 static void pred4x4_down_left_rv40_nodown_c(uint8_t *src,
122                                             const uint8_t *topright,
123                                             ptrdiff_t stride)
124 {
125     LOAD_TOP_EDGE
126     LOAD_TOP_RIGHT_EDGE
127     LOAD_LEFT_EDGE
128
129     src[0+0*stride]=(t0 + t2 + 2*t1 + 2 + l0 + l2 + 2*l1 + 2)>>3;
130     src[1+0*stride]=
131     src[0+1*stride]=(t1 + t3 + 2*t2 + 2 + l1 + l3 + 2*l2 + 2)>>3;
132     src[2+0*stride]=
133     src[1+1*stride]=
134     src[0+2*stride]=(t2 + t4 + 2*t3 + 2 + l2 + 3*l3 + 2)>>3;
135     src[3+0*stride]=
136     src[2+1*stride]=
137     src[1+2*stride]=
138     src[0+3*stride]=(t3 + t5 + 2*t4 + 2 + l3*4 + 2)>>3;
139     src[3+1*stride]=
140     src[2+2*stride]=
141     src[1+3*stride]=(t4 + t6 + 2*t5 + 2 + l3*4 + 2)>>3;
142     src[3+2*stride]=
143     src[2+3*stride]=(t5 + t7 + 2*t6 + 2 + l3*4 + 2)>>3;
144     src[3+3*stride]=(t6 + t7 + 1 + 2*l3 + 1)>>2;
145 }
146
147 static void pred4x4_vertical_left_rv40(uint8_t *src, const uint8_t *topright,
148                                        ptrdiff_t stride,
149                                        const int l0, const int l1, const int l2,
150                                        const int l3, const int l4)
151 {
152     LOAD_TOP_EDGE
153     LOAD_TOP_RIGHT_EDGE
154
155     src[0+0*stride]=(2*t0 + 2*t1 + l1 + 2*l2 + l3 + 4)>>3;
156     src[1+0*stride]=
157     src[0+2*stride]=(t1 + t2 + 1)>>1;
158     src[2+0*stride]=
159     src[1+2*stride]=(t2 + t3 + 1)>>1;
160     src[3+0*stride]=
161     src[2+2*stride]=(t3 + t4+ 1)>>1;
162     src[3+2*stride]=(t4 + t5+ 1)>>1;
163     src[0+1*stride]=(t0 + 2*t1 + t2 + l2 + 2*l3 + l4 + 4)>>3;
164     src[1+1*stride]=
165     src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
166     src[2+1*stride]=
167     src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
168     src[3+1*stride]=
169     src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
170     src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
171 }
172
173 static void pred4x4_vertical_left_rv40_c(uint8_t *src, const uint8_t *topright,
174                                          ptrdiff_t stride)
175 {
176     LOAD_LEFT_EDGE
177     LOAD_DOWN_LEFT_EDGE
178
179     pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l4);
180 }
181
182 static void pred4x4_vertical_left_rv40_nodown_c(uint8_t *src,
183                                                 const uint8_t *topright,
184                                                 ptrdiff_t stride)
185 {
186     LOAD_LEFT_EDGE
187
188     pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l3);
189 }
190
191 static void pred4x4_vertical_left_vp8_c(uint8_t *src, const uint8_t *topright,
192                                         ptrdiff_t stride)
193 {
194     LOAD_TOP_EDGE
195     LOAD_TOP_RIGHT_EDGE
196
197     src[0+0*stride]=(t0 + t1 + 1)>>1;
198     src[1+0*stride]=
199     src[0+2*stride]=(t1 + t2 + 1)>>1;
200     src[2+0*stride]=
201     src[1+2*stride]=(t2 + t3 + 1)>>1;
202     src[3+0*stride]=
203     src[2+2*stride]=(t3 + t4 + 1)>>1;
204     src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
205     src[1+1*stride]=
206     src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
207     src[2+1*stride]=
208     src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
209     src[3+1*stride]=
210     src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
211     src[3+2*stride]=(t4 + 2*t5 + t6 + 2)>>2;
212     src[3+3*stride]=(t5 + 2*t6 + t7 + 2)>>2;
213 }
214
215 static void pred4x4_horizontal_up_rv40_c(uint8_t *src, const uint8_t *topright,
216                                          ptrdiff_t stride)
217 {
218     LOAD_LEFT_EDGE
219     LOAD_DOWN_LEFT_EDGE
220     LOAD_TOP_EDGE
221     LOAD_TOP_RIGHT_EDGE
222
223     src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;
224     src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;
225     src[2+0*stride]=
226     src[0+1*stride]=(t3 + 2*t4 + t5 + 2*l1 + 2*l2 + 4)>>3;
227     src[3+0*stride]=
228     src[1+1*stride]=(t4 + 2*t5 + t6 + l1 + 2*l2 + l3 + 4)>>3;
229     src[2+1*stride]=
230     src[0+2*stride]=(t5 + 2*t6 + t7 + 2*l2 + 2*l3 + 4)>>3;
231     src[3+1*stride]=
232     src[1+2*stride]=(t6 + 3*t7 + l2 + 3*l3 + 4)>>3;
233     src[3+2*stride]=
234     src[1+3*stride]=(l3 + 2*l4 + l5 + 2)>>2;
235     src[0+3*stride]=
236     src[2+2*stride]=(t6 + t7 + l3 + l4 + 2)>>2;
237     src[2+3*stride]=(l4 + l5 + 1)>>1;
238     src[3+3*stride]=(l4 + 2*l5 + l6 + 2)>>2;
239 }
240
241 static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src,
242                                                 const uint8_t *topright,
243                                                 ptrdiff_t stride)
244 {
245     LOAD_LEFT_EDGE
246     LOAD_TOP_EDGE
247     LOAD_TOP_RIGHT_EDGE
248
249     src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;
250     src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;
251     src[2+0*stride]=
252     src[0+1*stride]=(t3 + 2*t4 + t5 + 2*l1 + 2*l2 + 4)>>3;
253     src[3+0*stride]=
254     src[1+1*stride]=(t4 + 2*t5 + t6 + l1 + 2*l2 + l3 + 4)>>3;
255     src[2+1*stride]=
256     src[0+2*stride]=(t5 + 2*t6 + t7 + 2*l2 + 2*l3 + 4)>>3;
257     src[3+1*stride]=
258     src[1+2*stride]=(t6 + 3*t7 + l2 + 3*l3 + 4)>>3;
259     src[3+2*stride]=
260     src[1+3*stride]=l3;
261     src[0+3*stride]=
262     src[2+2*stride]=(t6 + t7 + 2*l3 + 2)>>2;
263     src[2+3*stride]=
264     src[3+3*stride]=l3;
265 }
266
267 static void pred4x4_tm_vp8_c(uint8_t *src, const uint8_t *topright,
268                              ptrdiff_t stride)
269 {
270     uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
271     uint8_t *top = src-stride;
272     int y;
273
274     for (y = 0; y < 4; y++) {
275         uint8_t *cm_in = cm + src[-1];
276         src[0] = cm_in[top[0]];
277         src[1] = cm_in[top[1]];
278         src[2] = cm_in[top[2]];
279         src[3] = cm_in[top[3]];
280         src += stride;
281     }
282 }
283
284 static void pred16x16_plane_svq3_c(uint8_t *src, ptrdiff_t stride)
285 {
286     pred16x16_plane_compat_8_c(src, stride, 1, 0);
287 }
288
289 static void pred16x16_plane_rv40_c(uint8_t *src, ptrdiff_t stride)
290 {
291     pred16x16_plane_compat_8_c(src, stride, 0, 1);
292 }
293
294 static void pred16x16_tm_vp8_c(uint8_t *src, ptrdiff_t stride)
295 {
296     uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
297     uint8_t *top = src-stride;
298     int y;
299
300     for (y = 0; y < 16; y++) {
301         uint8_t *cm_in = cm + src[-1];
302         src[0]  = cm_in[top[0]];
303         src[1]  = cm_in[top[1]];
304         src[2]  = cm_in[top[2]];
305         src[3]  = cm_in[top[3]];
306         src[4]  = cm_in[top[4]];
307         src[5]  = cm_in[top[5]];
308         src[6]  = cm_in[top[6]];
309         src[7]  = cm_in[top[7]];
310         src[8]  = cm_in[top[8]];
311         src[9]  = cm_in[top[9]];
312         src[10] = cm_in[top[10]];
313         src[11] = cm_in[top[11]];
314         src[12] = cm_in[top[12]];
315         src[13] = cm_in[top[13]];
316         src[14] = cm_in[top[14]];
317         src[15] = cm_in[top[15]];
318         src += stride;
319     }
320 }
321
322 static void pred8x8_left_dc_rv40_c(uint8_t *src, ptrdiff_t stride)
323 {
324     int i;
325     unsigned dc0;
326
327     dc0=0;
328     for(i=0;i<8; i++)
329         dc0+= src[-1+i*stride];
330     dc0= 0x01010101*((dc0 + 4)>>3);
331
332     for(i=0; i<8; i++){
333         ((uint32_t*)(src+i*stride))[0]=
334         ((uint32_t*)(src+i*stride))[1]= dc0;
335     }
336 }
337
338 static void pred8x8_top_dc_rv40_c(uint8_t *src, ptrdiff_t stride)
339 {
340     int i;
341     unsigned dc0;
342
343     dc0=0;
344     for(i=0;i<8; i++)
345         dc0+= src[i-stride];
346     dc0= 0x01010101*((dc0 + 4)>>3);
347
348     for(i=0; i<8; i++){
349         ((uint32_t*)(src+i*stride))[0]=
350         ((uint32_t*)(src+i*stride))[1]= dc0;
351     }
352 }
353
354 static void pred8x8_dc_rv40_c(uint8_t *src, ptrdiff_t stride)
355 {
356     int i;
357     unsigned dc0 = 0;
358
359     for(i=0;i<4; i++){
360         dc0+= src[-1+i*stride] + src[i-stride];
361         dc0+= src[4+i-stride];
362         dc0+= src[-1+(i+4)*stride];
363     }
364     dc0= 0x01010101*((dc0 + 8)>>4);
365
366     for(i=0; i<4; i++){
367         ((uint32_t*)(src+i*stride))[0]= dc0;
368         ((uint32_t*)(src+i*stride))[1]= dc0;
369     }
370     for(i=4; i<8; i++){
371         ((uint32_t*)(src+i*stride))[0]= dc0;
372         ((uint32_t*)(src+i*stride))[1]= dc0;
373     }
374 }
375
376 static void pred8x8_tm_vp8_c(uint8_t *src, ptrdiff_t stride)
377 {
378     uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
379     uint8_t *top = src-stride;
380     int y;
381
382     for (y = 0; y < 8; y++) {
383         uint8_t *cm_in = cm + src[-1];
384         src[0] = cm_in[top[0]];
385         src[1] = cm_in[top[1]];
386         src[2] = cm_in[top[2]];
387         src[3] = cm_in[top[3]];
388         src[4] = cm_in[top[4]];
389         src[5] = cm_in[top[5]];
390         src[6] = cm_in[top[6]];
391         src[7] = cm_in[top[7]];
392         src += stride;
393     }
394 }
395
396 /**
397  * Set the intra prediction function pointers.
398  */
399 void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth,
400                        const int chroma_format_idc)
401 {
402 //    MpegEncContext * const s = &h->s;
403
404 #undef FUNC
405 #undef FUNCC
406 #define FUNC(a, depth) a ## _ ## depth
407 #define FUNCC(a, depth) a ## _ ## depth ## _c
408 #define FUNCD(a) a ## _c
409
410 #define H264_PRED(depth) \
411     if(codec_id != AV_CODEC_ID_RV40){\
412         if(codec_id == AV_CODEC_ID_VP8) {\
413             h->pred4x4[VERT_PRED       ]= FUNCD(pred4x4_vertical_vp8);\
414             h->pred4x4[HOR_PRED        ]= FUNCD(pred4x4_horizontal_vp8);\
415         } else {\
416             h->pred4x4[VERT_PRED       ]= FUNCC(pred4x4_vertical          , depth);\
417             h->pred4x4[HOR_PRED        ]= FUNCC(pred4x4_horizontal        , depth);\
418         }\
419         h->pred4x4[DC_PRED             ]= FUNCC(pred4x4_dc                , depth);\
420         if(codec_id == AV_CODEC_ID_SVQ3)\
421             h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_svq3);\
422         else\
423             h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred4x4_down_left     , depth);\
424         h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right        , depth);\
425         h->pred4x4[VERT_RIGHT_PRED     ]= FUNCC(pred4x4_vertical_right    , depth);\
426         h->pred4x4[HOR_DOWN_PRED       ]= FUNCC(pred4x4_horizontal_down   , depth);\
427         if (codec_id == AV_CODEC_ID_VP8) {\
428             h->pred4x4[VERT_LEFT_PRED  ]= FUNCD(pred4x4_vertical_left_vp8);\
429         } else\
430             h->pred4x4[VERT_LEFT_PRED  ]= FUNCC(pred4x4_vertical_left     , depth);\
431         h->pred4x4[HOR_UP_PRED         ]= FUNCC(pred4x4_horizontal_up     , depth);\
432         if(codec_id != AV_CODEC_ID_VP8) {\
433             h->pred4x4[LEFT_DC_PRED    ]= FUNCC(pred4x4_left_dc           , depth);\
434             h->pred4x4[TOP_DC_PRED     ]= FUNCC(pred4x4_top_dc            , depth);\
435             h->pred4x4[DC_128_PRED     ]= FUNCC(pred4x4_128_dc            , depth);\
436         } else {\
437             h->pred4x4[TM_VP8_PRED     ]= FUNCD(pred4x4_tm_vp8);\
438             h->pred4x4[DC_127_PRED     ]= FUNCC(pred4x4_127_dc            , depth);\
439             h->pred4x4[DC_129_PRED     ]= FUNCC(pred4x4_129_dc            , depth);\
440             h->pred4x4[VERT_VP8_PRED   ]= FUNCC(pred4x4_vertical          , depth);\
441             h->pred4x4[HOR_VP8_PRED    ]= FUNCC(pred4x4_horizontal        , depth);\
442         }\
443     }else{\
444         h->pred4x4[VERT_PRED           ]= FUNCC(pred4x4_vertical          , depth);\
445         h->pred4x4[HOR_PRED            ]= FUNCC(pred4x4_horizontal        , depth);\
446         h->pred4x4[DC_PRED             ]= FUNCC(pred4x4_dc                , depth);\
447         h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_rv40);\
448         h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right        , depth);\
449         h->pred4x4[VERT_RIGHT_PRED     ]= FUNCC(pred4x4_vertical_right    , depth);\
450         h->pred4x4[HOR_DOWN_PRED       ]= FUNCC(pred4x4_horizontal_down   , depth);\
451         h->pred4x4[VERT_LEFT_PRED      ]= FUNCD(pred4x4_vertical_left_rv40);\
452         h->pred4x4[HOR_UP_PRED         ]= FUNCD(pred4x4_horizontal_up_rv40);\
453         h->pred4x4[LEFT_DC_PRED        ]= FUNCC(pred4x4_left_dc           , depth);\
454         h->pred4x4[TOP_DC_PRED         ]= FUNCC(pred4x4_top_dc            , depth);\
455         h->pred4x4[DC_128_PRED         ]= FUNCC(pred4x4_128_dc            , depth);\
456         h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_down_left_rv40_nodown);\
457         h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= FUNCD(pred4x4_horizontal_up_rv40_nodown);\
458         h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_vertical_left_rv40_nodown);\
459     }\
460 \
461     h->pred8x8l[VERT_PRED           ]= FUNCC(pred8x8l_vertical            , depth);\
462     h->pred8x8l[HOR_PRED            ]= FUNCC(pred8x8l_horizontal          , depth);\
463     h->pred8x8l[DC_PRED             ]= FUNCC(pred8x8l_dc                  , depth);\
464     h->pred8x8l[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred8x8l_down_left           , depth);\
465     h->pred8x8l[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred8x8l_down_right          , depth);\
466     h->pred8x8l[VERT_RIGHT_PRED     ]= FUNCC(pred8x8l_vertical_right      , depth);\
467     h->pred8x8l[HOR_DOWN_PRED       ]= FUNCC(pred8x8l_horizontal_down     , depth);\
468     h->pred8x8l[VERT_LEFT_PRED      ]= FUNCC(pred8x8l_vertical_left       , depth);\
469     h->pred8x8l[HOR_UP_PRED         ]= FUNCC(pred8x8l_horizontal_up       , depth);\
470     h->pred8x8l[LEFT_DC_PRED        ]= FUNCC(pred8x8l_left_dc             , depth);\
471     h->pred8x8l[TOP_DC_PRED         ]= FUNCC(pred8x8l_top_dc              , depth);\
472     h->pred8x8l[DC_128_PRED         ]= FUNCC(pred8x8l_128_dc              , depth);\
473 \
474     if (chroma_format_idc == 1) {\
475         h->pred8x8[VERT_PRED8x8   ]= FUNCC(pred8x8_vertical               , depth);\
476         h->pred8x8[HOR_PRED8x8    ]= FUNCC(pred8x8_horizontal             , depth);\
477     } else {\
478         h->pred8x8[VERT_PRED8x8   ]= FUNCC(pred8x16_vertical              , depth);\
479         h->pred8x8[HOR_PRED8x8    ]= FUNCC(pred8x16_horizontal            , depth);\
480     }\
481     if (codec_id != AV_CODEC_ID_VP8) {\
482         if (chroma_format_idc == 1) {\
483             h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane                , depth);\
484         } else {\
485             h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x16_plane               , depth);\
486         }\
487     } else\
488         h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\
489     if(codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP8){\
490         if (chroma_format_idc == 1) {\
491             h->pred8x8[DC_PRED8x8     ]= FUNCC(pred8x8_dc                     , depth);\
492             h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc                , depth);\
493             h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc                 , depth);\
494             h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\
495             h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\
496             h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\
497             h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\
498         } else {\
499             h->pred8x8[DC_PRED8x8     ]= FUNCC(pred8x16_dc                    , depth);\
500             h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x16_left_dc               , depth);\
501             h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x16_top_dc                , depth);\
502             h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_l0t, depth);\
503             h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_0lt, depth);\
504             h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_l00, depth);\
505             h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_0l0, depth);\
506         }\
507     }else{\
508         h->pred8x8[DC_PRED8x8     ]= FUNCD(pred8x8_dc_rv40);\
509         h->pred8x8[LEFT_DC_PRED8x8]= FUNCD(pred8x8_left_dc_rv40);\
510         h->pred8x8[TOP_DC_PRED8x8 ]= FUNCD(pred8x8_top_dc_rv40);\
511         if (codec_id == AV_CODEC_ID_VP8) {\
512             h->pred8x8[DC_127_PRED8x8]= FUNCC(pred8x8_127_dc              , depth);\
513             h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc              , depth);\
514         }\
515     }\
516     if (chroma_format_idc == 1) {\
517         h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc                 , depth);\
518     } else {\
519         h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x16_128_dc                , depth);\
520     }\
521 \
522     h->pred16x16[DC_PRED8x8     ]= FUNCC(pred16x16_dc                     , depth);\
523     h->pred16x16[VERT_PRED8x8   ]= FUNCC(pred16x16_vertical               , depth);\
524     h->pred16x16[HOR_PRED8x8    ]= FUNCC(pred16x16_horizontal             , depth);\
525     switch(codec_id){\
526     case AV_CODEC_ID_SVQ3:\
527        h->pred16x16[PLANE_PRED8x8  ]= FUNCD(pred16x16_plane_svq3);\
528        break;\
529     case AV_CODEC_ID_RV40:\
530        h->pred16x16[PLANE_PRED8x8  ]= FUNCD(pred16x16_plane_rv40);\
531        break;\
532     case AV_CODEC_ID_VP8:\
533        h->pred16x16[PLANE_PRED8x8  ]= FUNCD(pred16x16_tm_vp8);\
534        h->pred16x16[DC_127_PRED8x8]= FUNCC(pred16x16_127_dc               , depth);\
535        h->pred16x16[DC_129_PRED8x8]= FUNCC(pred16x16_129_dc               , depth);\
536        break;\
537     default:\
538        h->pred16x16[PLANE_PRED8x8  ]= FUNCC(pred16x16_plane               , depth);\
539        break;\
540     }\
541     h->pred16x16[LEFT_DC_PRED8x8]= FUNCC(pred16x16_left_dc                , depth);\
542     h->pred16x16[TOP_DC_PRED8x8 ]= FUNCC(pred16x16_top_dc                 , depth);\
543     h->pred16x16[DC_128_PRED8x8 ]= FUNCC(pred16x16_128_dc                 , depth);\
544 \
545     /* special lossless h/v prediction for h264 */ \
546     h->pred4x4_add  [VERT_PRED   ]= FUNCC(pred4x4_vertical_add            , depth);\
547     h->pred4x4_add  [ HOR_PRED   ]= FUNCC(pred4x4_horizontal_add          , depth);\
548     h->pred8x8l_add [VERT_PRED   ]= FUNCC(pred8x8l_vertical_add           , depth);\
549     h->pred8x8l_add [ HOR_PRED   ]= FUNCC(pred8x8l_horizontal_add         , depth);\
550     if (chroma_format_idc == 1) {\
551     h->pred8x8_add  [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add            , depth);\
552     h->pred8x8_add  [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add          , depth);\
553     } else {\
554         h->pred8x8_add  [VERT_PRED8x8]= FUNCC(pred8x16_vertical_add            , depth);\
555         h->pred8x8_add  [ HOR_PRED8x8]= FUNCC(pred8x16_horizontal_add          , depth);\
556     }\
557     h->pred16x16_add[VERT_PRED8x8]= FUNCC(pred16x16_vertical_add          , depth);\
558     h->pred16x16_add[ HOR_PRED8x8]= FUNCC(pred16x16_horizontal_add        , depth);\
559
560     switch (bit_depth) {
561         case 9:
562             H264_PRED(9)
563             break;
564         case 10:
565             H264_PRED(10)
566             break;
567         default:
568             H264_PRED(8)
569             break;
570     }
571
572     if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc);
573     if (ARCH_X86) ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc);
574 }