GCC Code Coverage Report
Directory: ../../../ffmpeg/ Exec Total Coverage
File: src/libavcodec/h264pred.c Lines: 274 280 97.9 %
Date: 2019-11-18 18:00:01 Branches: 120 257 46.7 %

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

1074
    switch (bit_depth) {
577
109
        case 9:
578











327
            H264_PRED(9)
579
109
            break;
580
141
        case 10:
581











423
            H264_PRED(10)
582
141
            break;
583
        case 12:
584
            H264_PRED(12)
585
            break;
586
        case 14:
587
            H264_PRED(14)
588
            break;
589
824
        default:
590
824
            av_assert0(bit_depth<=8);
591











2187
            H264_PRED(8)
592
824
            break;
593
    }
594
595
    if (ARCH_AARCH64)
596
        ff_h264_pred_init_aarch64(h, codec_id, bit_depth, chroma_format_idc);
597
    if (ARCH_ARM)
598
        ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc);
599
    if (ARCH_X86)
600
1074
        ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc);
601
    if (ARCH_MIPS)
602
        ff_h264_pred_init_mips(h, codec_id, bit_depth, chroma_format_idc);
603
1074
}