]> git.sesse.net Git - ffmpeg/blob - libavcodec/vp8dsp.c
vc1dec: improve hwaccel #ifdefs
[ffmpeg] / libavcodec / vp8dsp.c
1 /*
2  * Copyright (C) 2010 David Conrad
3  * Copyright (C) 2010 Ronald S. Bultje
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  * VP8 compatible video decoder
25  */
26
27 #include "libavutil/common.h"
28
29 #include "mathops.h"
30 #include "vp8dsp.h"
31
32 // TODO: Maybe add dequant
33 static void vp8_luma_dc_wht_c(int16_t block[4][4][16], int16_t dc[16])
34 {
35     int i, t0, t1, t2, t3;
36
37     for (i = 0; i < 4; i++) {
38         t0 = dc[0 * 4 + i] + dc[3 * 4 + i];
39         t1 = dc[1 * 4 + i] + dc[2 * 4 + i];
40         t2 = dc[1 * 4 + i] - dc[2 * 4 + i];
41         t3 = dc[0 * 4 + i] - dc[3 * 4 + i];
42
43         dc[0 * 4 + i] = t0 + t1;
44         dc[1 * 4 + i] = t3 + t2;
45         dc[2 * 4 + i] = t0 - t1;
46         dc[3 * 4 + i] = t3 - t2;
47     }
48
49     for (i = 0; i < 4; i++) {
50         t0 = dc[i * 4 + 0] + dc[i * 4 + 3] + 3; // rounding
51         t1 = dc[i * 4 + 1] + dc[i * 4 + 2];
52         t2 = dc[i * 4 + 1] - dc[i * 4 + 2];
53         t3 = dc[i * 4 + 0] - dc[i * 4 + 3] + 3; // rounding
54         dc[i * 4 + 0] = 0;
55         dc[i * 4 + 1] = 0;
56         dc[i * 4 + 2] = 0;
57         dc[i * 4 + 3] = 0;
58
59         block[i][0][0] = (t0 + t1) >> 3;
60         block[i][1][0] = (t3 + t2) >> 3;
61         block[i][2][0] = (t0 - t1) >> 3;
62         block[i][3][0] = (t3 - t2) >> 3;
63     }
64 }
65
66 static void vp8_luma_dc_wht_dc_c(int16_t block[4][4][16], int16_t dc[16])
67 {
68     int i, val = (dc[0] + 3) >> 3;
69     dc[0] = 0;
70
71     for (i = 0; i < 4; i++) {
72         block[i][0][0] = val;
73         block[i][1][0] = val;
74         block[i][2][0] = val;
75         block[i][3][0] = val;
76     }
77 }
78
79 #define MUL_20091(a) ((((a) * 20091) >> 16) + (a))
80 #define MUL_35468(a)  (((a) * 35468) >> 16)
81
82 static void vp8_idct_add_c(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
83 {
84     int i, t0, t1, t2, t3;
85     int16_t tmp[16];
86
87     for (i = 0; i < 4; i++) {
88         t0 = block[0 * 4 + i] + block[2 * 4 + i];
89         t1 = block[0 * 4 + i] - block[2 * 4 + i];
90         t2 = MUL_35468(block[1 * 4 + i]) - MUL_20091(block[3 * 4 + i]);
91         t3 = MUL_20091(block[1 * 4 + i]) + MUL_35468(block[3 * 4 + i]);
92         block[0 * 4 + i] = 0;
93         block[1 * 4 + i] = 0;
94         block[2 * 4 + i] = 0;
95         block[3 * 4 + i] = 0;
96
97         tmp[i * 4 + 0] = t0 + t3;
98         tmp[i * 4 + 1] = t1 + t2;
99         tmp[i * 4 + 2] = t1 - t2;
100         tmp[i * 4 + 3] = t0 - t3;
101     }
102
103     for (i = 0; i < 4; i++) {
104         t0 = tmp[0 * 4 + i] + tmp[2 * 4 + i];
105         t1 = tmp[0 * 4 + i] - tmp[2 * 4 + i];
106         t2 = MUL_35468(tmp[1 * 4 + i]) - MUL_20091(tmp[3 * 4 + i]);
107         t3 = MUL_20091(tmp[1 * 4 + i]) + MUL_35468(tmp[3 * 4 + i]);
108
109         dst[0] = av_clip_uint8(dst[0] + ((t0 + t3 + 4) >> 3));
110         dst[1] = av_clip_uint8(dst[1] + ((t1 + t2 + 4) >> 3));
111         dst[2] = av_clip_uint8(dst[2] + ((t1 - t2 + 4) >> 3));
112         dst[3] = av_clip_uint8(dst[3] + ((t0 - t3 + 4) >> 3));
113         dst   += stride;
114     }
115 }
116
117 static void vp8_idct_dc_add_c(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
118 {
119     int i, dc = (block[0] + 4) >> 3;
120     block[0] = 0;
121
122     for (i = 0; i < 4; i++) {
123         dst[0] = av_clip_uint8(dst[0] + dc);
124         dst[1] = av_clip_uint8(dst[1] + dc);
125         dst[2] = av_clip_uint8(dst[2] + dc);
126         dst[3] = av_clip_uint8(dst[3] + dc);
127         dst   += stride;
128     }
129 }
130
131 static void vp8_idct_dc_add4uv_c(uint8_t *dst, int16_t block[4][16],
132                                  ptrdiff_t stride)
133 {
134     vp8_idct_dc_add_c(dst + stride * 0 + 0, block[0], stride);
135     vp8_idct_dc_add_c(dst + stride * 0 + 4, block[1], stride);
136     vp8_idct_dc_add_c(dst + stride * 4 + 0, block[2], stride);
137     vp8_idct_dc_add_c(dst + stride * 4 + 4, block[3], stride);
138 }
139
140 static void vp8_idct_dc_add4y_c(uint8_t *dst, int16_t block[4][16],
141                                 ptrdiff_t stride)
142 {
143     vp8_idct_dc_add_c(dst +  0, block[0], stride);
144     vp8_idct_dc_add_c(dst +  4, block[1], stride);
145     vp8_idct_dc_add_c(dst +  8, block[2], stride);
146     vp8_idct_dc_add_c(dst + 12, block[3], stride);
147 }
148
149 // because I like only having two parameters to pass functions...
150 #define LOAD_PIXELS                                                           \
151     int av_unused p3 = p[-4 * stride];                                        \
152     int av_unused p2 = p[-3 * stride];                                        \
153     int av_unused p1 = p[-2 * stride];                                        \
154     int av_unused p0 = p[-1 * stride];                                        \
155     int av_unused q0 = p[ 0 * stride];                                        \
156     int av_unused q1 = p[ 1 * stride];                                        \
157     int av_unused q2 = p[ 2 * stride];                                        \
158     int av_unused q3 = p[ 3 * stride];
159
160 #define clip_int8(n) (cm[n + 0x80] - 0x80)
161
162 static av_always_inline void filter_common(uint8_t *p, ptrdiff_t stride,
163                                            int is4tap)
164 {
165     LOAD_PIXELS
166     int a, f1, f2;
167     const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
168
169     a = 3 * (q0 - p0);
170
171     if (is4tap)
172         a += clip_int8(p1 - q1);
173
174     a = clip_int8(a);
175
176     // We deviate from the spec here with c(a+3) >> 3
177     // since that's what libvpx does.
178     f1 = FFMIN(a + 4, 127) >> 3;
179     f2 = FFMIN(a + 3, 127) >> 3;
180
181     // Despite what the spec says, we do need to clamp here to
182     // be bitexact with libvpx.
183     p[-1 * stride] = cm[p0 + f2];
184     p[ 0 * stride] = cm[q0 - f1];
185
186     // only used for _inner on blocks without high edge variance
187     if (!is4tap) {
188         a = (f1 + 1) >> 1;
189         p[-2 * stride] = cm[p1 + a];
190         p[ 1 * stride] = cm[q1 - a];
191     }
192 }
193
194 static av_always_inline int simple_limit(uint8_t *p, ptrdiff_t stride, int flim)
195 {
196     LOAD_PIXELS
197     return 2 * FFABS(p0 - q0) + (FFABS(p1 - q1) >> 1) <= flim;
198 }
199
200 /**
201  * E - limit at the macroblock edge
202  * I - limit for interior difference
203  */
204 static av_always_inline int normal_limit(uint8_t *p, ptrdiff_t stride,
205                                          int E, int I)
206 {
207     LOAD_PIXELS
208     return simple_limit(p, stride, E) &&
209            FFABS(p3 - p2) <= I &&
210            FFABS(p2 - p1) <= I &&
211            FFABS(p1 - p0) <= I &&
212            FFABS(q3 - q2) <= I &&
213            FFABS(q2 - q1) <= I &&
214            FFABS(q1 - q0) <= I;
215 }
216
217 // high edge variance
218 static av_always_inline int hev(uint8_t *p, ptrdiff_t stride, int thresh)
219 {
220     LOAD_PIXELS
221     return FFABS(p1 - p0) > thresh || FFABS(q1 - q0) > thresh;
222 }
223
224 static av_always_inline void filter_mbedge(uint8_t *p, ptrdiff_t stride)
225 {
226     int a0, a1, a2, w;
227     const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
228
229     LOAD_PIXELS
230
231     w = clip_int8(p1 - q1);
232     w = clip_int8(w + 3 * (q0 - p0));
233
234     a0 = (27 * w + 63) >> 7;
235     a1 = (18 * w + 63) >> 7;
236     a2 =  (9 * w + 63) >> 7;
237
238     p[-3 * stride] = cm[p2 + a2];
239     p[-2 * stride] = cm[p1 + a1];
240     p[-1 * stride] = cm[p0 + a0];
241     p[ 0 * stride] = cm[q0 - a0];
242     p[ 1 * stride] = cm[q1 - a1];
243     p[ 2 * stride] = cm[q2 - a2];
244 }
245
246 #define LOOP_FILTER(dir, size, stridea, strideb, maybe_inline)                \
247 static maybe_inline                                                           \
248 void vp8_ ## dir ## _loop_filter ## size ## _c(uint8_t *dst,                  \
249                                                ptrdiff_t stride,              \
250                                                int flim_E, int flim_I,        \
251                                                int hev_thresh)                \
252 {                                                                             \
253     int i;                                                                    \
254     for (i = 0; i < size; i++)                                                \
255         if (normal_limit(dst + i * stridea, strideb, flim_E, flim_I)) {       \
256             if (hev(dst + i * stridea, strideb, hev_thresh))                  \
257                 filter_common(dst + i * stridea, strideb, 1);                 \
258             else                                                              \
259                 filter_mbedge(dst + i * stridea, strideb);                    \
260         }                                                                     \
261 }                                                                             \
262                                                                               \
263 static maybe_inline                                                           \
264 void vp8_ ## dir ## _loop_filter ## size ## _inner_c(uint8_t *dst,            \
265                                                      ptrdiff_t stride,        \
266                                                      int flim_E, int flim_I,  \
267                                                      int hev_thresh)          \
268 {                                                                             \
269     int i;                                                                    \
270     for (i = 0; i < size; i++)                                                \
271         if (normal_limit(dst + i * stridea, strideb, flim_E, flim_I)) {       \
272             int hv = hev(dst + i * stridea, strideb, hev_thresh);             \
273             if (hv)                                                           \
274                 filter_common(dst + i * stridea, strideb, 1);                 \
275             else                                                              \
276                 filter_common(dst + i * stridea, strideb, 0);                 \
277         }                                                                     \
278 }
279
280 LOOP_FILTER(v, 16, 1, stride, )
281 LOOP_FILTER(h, 16, stride, 1, )
282
283 #define UV_LOOP_FILTER(dir, stridea, strideb)                                 \
284 LOOP_FILTER(dir, 8, stridea, strideb, av_always_inline)                       \
285 static void vp8_ ## dir ## _loop_filter8uv_c(uint8_t *dstU, uint8_t *dstV,    \
286                                              ptrdiff_t stride, int fE,        \
287                                              int fI, int hev_thresh)          \
288 {                                                                             \
289     vp8_ ## dir ## _loop_filter8_c(dstU, stride, fE, fI, hev_thresh);         \
290     vp8_ ## dir ## _loop_filter8_c(dstV, stride, fE, fI, hev_thresh);         \
291 }                                                                             \
292                                                                               \
293 static void vp8_ ## dir ## _loop_filter8uv_inner_c(uint8_t *dstU,             \
294                                                    uint8_t *dstV,             \
295                                                    ptrdiff_t stride, int fE,  \
296                                                    int fI, int hev_thresh)    \
297 {                                                                             \
298     vp8_ ## dir ## _loop_filter8_inner_c(dstU, stride, fE, fI, hev_thresh);   \
299     vp8_ ## dir ## _loop_filter8_inner_c(dstV, stride, fE, fI, hev_thresh);   \
300 }
301
302 UV_LOOP_FILTER(v, 1, stride)
303 UV_LOOP_FILTER(h, stride, 1)
304
305 static void vp8_v_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, int flim)
306 {
307     int i;
308
309     for (i = 0; i < 16; i++)
310         if (simple_limit(dst + i, stride, flim))
311             filter_common(dst + i, stride, 1);
312 }
313
314 static void vp8_h_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, int flim)
315 {
316     int i;
317
318     for (i = 0; i < 16; i++)
319         if (simple_limit(dst + i * stride, 1, flim))
320             filter_common(dst + i * stride, 1, 1);
321 }
322
323 static const uint8_t subpel_filters[7][6] = {
324     { 0,  6, 123,  12,  1, 0 },
325     { 2, 11, 108,  36,  8, 1 },
326     { 0,  9,  93,  50,  6, 0 },
327     { 3, 16,  77,  77, 16, 3 },
328     { 0,  6,  50,  93,  9, 0 },
329     { 1,  8,  36, 108, 11, 2 },
330     { 0,  1,  12, 123,  6, 0 },
331 };
332
333 #define PUT_PIXELS(WIDTH)                                                     \
334 static void put_vp8_pixels ## WIDTH ## _c(uint8_t *dst, ptrdiff_t dststride,  \
335                                           uint8_t *src, ptrdiff_t srcstride,  \
336                                           int h, int x, int y)                \
337 {                                                                             \
338     int i;                                                                    \
339     for (i = 0; i < h; i++, dst += dststride, src += srcstride)               \
340         memcpy(dst, src, WIDTH);                                              \
341 }
342
343 PUT_PIXELS(16)
344 PUT_PIXELS(8)
345 PUT_PIXELS(4)
346
347 #define FILTER_6TAP(src, F, stride)                                           \
348     cm[(F[2] * src[x + 0 * stride] - F[1] * src[x - 1 * stride] +             \
349         F[0] * src[x - 2 * stride] + F[3] * src[x + 1 * stride] -             \
350         F[4] * src[x + 2 * stride] + F[5] * src[x + 3 * stride] + 64) >> 7]
351
352 #define FILTER_4TAP(src, F, stride)                                           \
353     cm[(F[2] * src[x + 0 * stride] - F[1] * src[x - 1 * stride] +             \
354         F[3] * src[x + 1 * stride] - F[4] * src[x + 2 * stride] + 64) >> 7]
355
356 #define VP8_EPEL_H(SIZE, TAPS)                                                \
357 static void put_vp8_epel ## SIZE ## _h ## TAPS ## _c(uint8_t *dst,            \
358                                                      ptrdiff_t dststride,     \
359                                                      uint8_t *src,            \
360                                                      ptrdiff_t srcstride,     \
361                                                      int h, int mx, int my)   \
362 {                                                                             \
363     const uint8_t *filter = subpel_filters[mx - 1];                           \
364     const uint8_t *cm     = ff_crop_tab + MAX_NEG_CROP;                       \
365     int x, y;                                                                 \
366     for (y = 0; y < h; y++) {                                                 \
367         for (x = 0; x < SIZE; x++)                                            \
368             dst[x] = FILTER_ ## TAPS ## TAP(src, filter, 1);                  \
369         dst += dststride;                                                     \
370         src += srcstride;                                                     \
371     }                                                                         \
372 }
373
374 #define VP8_EPEL_V(SIZE, TAPS)                                                \
375 static void put_vp8_epel ## SIZE ## _v ## TAPS ## _c(uint8_t *dst,            \
376                                                      ptrdiff_t dststride,     \
377                                                      uint8_t *src,            \
378                                                      ptrdiff_t srcstride,     \
379                                                      int h, int mx, int my)   \
380 {                                                                             \
381     const uint8_t *filter = subpel_filters[my - 1];                           \
382     const uint8_t *cm     = ff_crop_tab + MAX_NEG_CROP;                       \
383     int x, y;                                                                 \
384     for (y = 0; y < h; y++) {                                                 \
385         for (x = 0; x < SIZE; x++)                                            \
386             dst[x] = FILTER_ ## TAPS ## TAP(src, filter, srcstride);          \
387         dst += dststride;                                                     \
388         src += srcstride;                                                     \
389     }                                                                         \
390 }
391
392 #define VP8_EPEL_HV(SIZE, HTAPS, VTAPS)                                       \
393 static void                                                                   \
394 put_vp8_epel ## SIZE ## _h ## HTAPS ## v ## VTAPS ## _c(uint8_t *dst,         \
395                                                         ptrdiff_t dststride,  \
396                                                         uint8_t *src,         \
397                                                         ptrdiff_t srcstride,  \
398                                                         int h, int mx,        \
399                                                         int my)               \
400 {                                                                             \
401     const uint8_t *filter = subpel_filters[mx - 1];                           \
402     const uint8_t *cm     = ff_crop_tab + MAX_NEG_CROP;                       \
403     int x, y;                                                                 \
404     uint8_t tmp_array[(2 * SIZE + VTAPS - 1) * SIZE];                         \
405     uint8_t *tmp = tmp_array;                                                 \
406     src -= (2 - (VTAPS == 4)) * srcstride;                                    \
407                                                                               \
408     for (y = 0; y < h + VTAPS - 1; y++) {                                     \
409         for (x = 0; x < SIZE; x++)                                            \
410             tmp[x] = FILTER_ ## HTAPS ## TAP(src, filter, 1);                 \
411         tmp += SIZE;                                                          \
412         src += srcstride;                                                     \
413     }                                                                         \
414     tmp    = tmp_array + (2 - (VTAPS == 4)) * SIZE;                           \
415     filter = subpel_filters[my - 1];                                          \
416                                                                               \
417     for (y = 0; y < h; y++) {                                                 \
418         for (x = 0; x < SIZE; x++)                                            \
419             dst[x] = FILTER_ ## VTAPS ## TAP(tmp, filter, SIZE);              \
420         dst += dststride;                                                     \
421         tmp += SIZE;                                                          \
422     }                                                                         \
423 }
424
425 VP8_EPEL_H(16, 4)
426 VP8_EPEL_H(8,  4)
427 VP8_EPEL_H(4,  4)
428 VP8_EPEL_H(16, 6)
429 VP8_EPEL_H(8,  6)
430 VP8_EPEL_H(4,  6)
431 VP8_EPEL_V(16, 4)
432 VP8_EPEL_V(8,  4)
433 VP8_EPEL_V(4,  4)
434 VP8_EPEL_V(16, 6)
435 VP8_EPEL_V(8,  6)
436 VP8_EPEL_V(4,  6)
437
438 VP8_EPEL_HV(16, 4, 4)
439 VP8_EPEL_HV(8,  4, 4)
440 VP8_EPEL_HV(4,  4, 4)
441 VP8_EPEL_HV(16, 4, 6)
442 VP8_EPEL_HV(8,  4, 6)
443 VP8_EPEL_HV(4,  4, 6)
444 VP8_EPEL_HV(16, 6, 4)
445 VP8_EPEL_HV(8,  6, 4)
446 VP8_EPEL_HV(4,  6, 4)
447 VP8_EPEL_HV(16, 6, 6)
448 VP8_EPEL_HV(8,  6, 6)
449 VP8_EPEL_HV(4,  6, 6)
450
451 #define VP8_BILINEAR(SIZE)                                                    \
452 static void put_vp8_bilinear ## SIZE ## _h_c(uint8_t *dst, ptrdiff_t dstride, \
453                                              uint8_t *src, ptrdiff_t sstride, \
454                                              int h, int mx, int my)           \
455 {                                                                             \
456     int a = 8 - mx, b = mx;                                                   \
457     int x, y;                                                                 \
458     for (y = 0; y < h; y++) {                                                 \
459         for (x = 0; x < SIZE; x++)                                            \
460             dst[x] = (a * src[x] + b * src[x + 1] + 4) >> 3;                  \
461         dst += dstride;                                                       \
462         src += sstride;                                                       \
463     }                                                                         \
464 }                                                                             \
465                                                                               \
466 static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, ptrdiff_t dstride, \
467                                              uint8_t *src, ptrdiff_t sstride, \
468                                              int h, int mx, int my)           \
469 {                                                                             \
470     int c = 8 - my, d = my;                                                   \
471     int x, y;                                                                 \
472     for (y = 0; y < h; y++) {                                                 \
473         for (x = 0; x < SIZE; x++)                                            \
474             dst[x] = (c * src[x] + d * src[x + sstride] + 4) >> 3;            \
475         dst += dstride;                                                       \
476         src += sstride;                                                       \
477     }                                                                         \
478 }                                                                             \
479                                                                               \
480 static void put_vp8_bilinear ## SIZE ## _hv_c(uint8_t *dst,                   \
481                                               ptrdiff_t dstride,              \
482                                               uint8_t *src,                   \
483                                               ptrdiff_t sstride,              \
484                                               int h, int mx, int my)          \
485 {                                                                             \
486     int a = 8 - mx, b = mx;                                                   \
487     int c = 8 - my, d = my;                                                   \
488     int x, y;                                                                 \
489     uint8_t tmp_array[(2 * SIZE + 1) * SIZE];                                 \
490     uint8_t *tmp = tmp_array;                                                 \
491     for (y = 0; y < h + 1; y++) {                                             \
492         for (x = 0; x < SIZE; x++)                                            \
493             tmp[x] = (a * src[x] + b * src[x + 1] + 4) >> 3;                  \
494         tmp += SIZE;                                                          \
495         src += sstride;                                                       \
496     }                                                                         \
497     tmp = tmp_array;                                                          \
498     for (y = 0; y < h; y++) {                                                 \
499         for (x = 0; x < SIZE; x++)                                            \
500             dst[x] = (c * tmp[x] + d * tmp[x + SIZE] + 4) >> 3;               \
501         dst += dstride;                                                       \
502         tmp += SIZE;                                                          \
503     }                                                                         \
504 }
505
506 VP8_BILINEAR(16)
507 VP8_BILINEAR(8)
508 VP8_BILINEAR(4)
509
510 #define VP8_MC_FUNC(IDX, SIZE)                                                \
511     dsp->put_vp8_epel_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c;   \
512     dsp->put_vp8_epel_pixels_tab[IDX][0][1] = put_vp8_epel ## SIZE ## _h4_c;  \
513     dsp->put_vp8_epel_pixels_tab[IDX][0][2] = put_vp8_epel ## SIZE ## _h6_c;  \
514     dsp->put_vp8_epel_pixels_tab[IDX][1][0] = put_vp8_epel ## SIZE ## _v4_c;  \
515     dsp->put_vp8_epel_pixels_tab[IDX][1][1] = put_vp8_epel ## SIZE ## _h4v4_c; \
516     dsp->put_vp8_epel_pixels_tab[IDX][1][2] = put_vp8_epel ## SIZE ## _h6v4_c; \
517     dsp->put_vp8_epel_pixels_tab[IDX][2][0] = put_vp8_epel ## SIZE ## _v6_c;  \
518     dsp->put_vp8_epel_pixels_tab[IDX][2][1] = put_vp8_epel ## SIZE ## _h4v6_c; \
519     dsp->put_vp8_epel_pixels_tab[IDX][2][2] = put_vp8_epel ## SIZE ## _h6v6_c
520
521 #define VP8_BILINEAR_MC_FUNC(IDX, SIZE)                                       \
522     dsp->put_vp8_bilinear_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \
523     dsp->put_vp8_bilinear_pixels_tab[IDX][0][1] = put_vp8_bilinear ## SIZE ## _h_c; \
524     dsp->put_vp8_bilinear_pixels_tab[IDX][0][2] = put_vp8_bilinear ## SIZE ## _h_c; \
525     dsp->put_vp8_bilinear_pixels_tab[IDX][1][0] = put_vp8_bilinear ## SIZE ## _v_c; \
526     dsp->put_vp8_bilinear_pixels_tab[IDX][1][1] = put_vp8_bilinear ## SIZE ## _hv_c; \
527     dsp->put_vp8_bilinear_pixels_tab[IDX][1][2] = put_vp8_bilinear ## SIZE ## _hv_c; \
528     dsp->put_vp8_bilinear_pixels_tab[IDX][2][0] = put_vp8_bilinear ## SIZE ## _v_c; \
529     dsp->put_vp8_bilinear_pixels_tab[IDX][2][1] = put_vp8_bilinear ## SIZE ## _hv_c; \
530     dsp->put_vp8_bilinear_pixels_tab[IDX][2][2] = put_vp8_bilinear ## SIZE ## _hv_c
531
532 av_cold void ff_vp8dsp_init(VP8DSPContext *dsp)
533 {
534     dsp->vp8_luma_dc_wht    = vp8_luma_dc_wht_c;
535     dsp->vp8_luma_dc_wht_dc = vp8_luma_dc_wht_dc_c;
536     dsp->vp8_idct_add       = vp8_idct_add_c;
537     dsp->vp8_idct_dc_add    = vp8_idct_dc_add_c;
538     dsp->vp8_idct_dc_add4y  = vp8_idct_dc_add4y_c;
539     dsp->vp8_idct_dc_add4uv = vp8_idct_dc_add4uv_c;
540
541     dsp->vp8_v_loop_filter16y = vp8_v_loop_filter16_c;
542     dsp->vp8_h_loop_filter16y = vp8_h_loop_filter16_c;
543     dsp->vp8_v_loop_filter8uv = vp8_v_loop_filter8uv_c;
544     dsp->vp8_h_loop_filter8uv = vp8_h_loop_filter8uv_c;
545
546     dsp->vp8_v_loop_filter16y_inner = vp8_v_loop_filter16_inner_c;
547     dsp->vp8_h_loop_filter16y_inner = vp8_h_loop_filter16_inner_c;
548     dsp->vp8_v_loop_filter8uv_inner = vp8_v_loop_filter8uv_inner_c;
549     dsp->vp8_h_loop_filter8uv_inner = vp8_h_loop_filter8uv_inner_c;
550
551     dsp->vp8_v_loop_filter_simple = vp8_v_loop_filter_simple_c;
552     dsp->vp8_h_loop_filter_simple = vp8_h_loop_filter_simple_c;
553
554     VP8_MC_FUNC(0, 16);
555     VP8_MC_FUNC(1, 8);
556     VP8_MC_FUNC(2, 4);
557
558     VP8_BILINEAR_MC_FUNC(0, 16);
559     VP8_BILINEAR_MC_FUNC(1, 8);
560     VP8_BILINEAR_MC_FUNC(2, 4);
561
562     if (ARCH_ARM)
563         ff_vp8dsp_init_arm(dsp);
564     if (ARCH_PPC)
565         ff_vp8dsp_init_ppc(dsp);
566     if (ARCH_X86)
567         ff_vp8dsp_init_x86(dsp);
568 }