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