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