3 * Copyright (c) 2000, 2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
6 * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
8 * This file is part of Libav.
10 * Libav is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * Libav is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with Libav; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 #include "libavutil/attributes.h"
31 #include "libavutil/imgutils.h"
33 #include "copy_block.h"
36 #include "simple_idct.h"
39 #include "imgconvert.h"
41 #include "mpegvideo.h"
44 uint32_t ff_square_tab[512] = { 0, };
47 #include "dsputilenc_template.c"
51 #include "hpel_template.c"
52 #include "tpel_template.c"
53 #include "dsputil_template.c"
54 #include "dsputilenc_template.c"
56 const uint8_t ff_alternate_horizontal_scan[64] = {
57 0, 1, 2, 3, 8, 9, 16, 17,
58 10, 11, 4, 5, 6, 7, 15, 14,
59 13, 12, 19, 18, 24, 25, 32, 33,
60 26, 27, 20, 21, 22, 23, 28, 29,
61 30, 31, 34, 35, 40, 41, 48, 49,
62 42, 43, 36, 37, 38, 39, 44, 45,
63 46, 47, 50, 51, 56, 57, 58, 59,
64 52, 53, 54, 55, 60, 61, 62, 63,
67 const uint8_t ff_alternate_vertical_scan[64] = {
68 0, 8, 16, 24, 1, 9, 2, 10,
69 17, 25, 32, 40, 48, 56, 57, 49,
70 41, 33, 26, 18, 3, 11, 4, 12,
71 19, 27, 34, 42, 50, 58, 35, 43,
72 51, 59, 20, 28, 5, 13, 6, 14,
73 21, 29, 36, 44, 52, 60, 37, 45,
74 53, 61, 22, 30, 7, 15, 23, 31,
75 38, 46, 54, 62, 39, 47, 55, 63,
78 /* Input permutation for the simple_idct_mmx */
79 static const uint8_t simple_mmx_permutation[64] = {
80 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
81 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
82 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
83 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
84 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
85 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
86 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
87 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
90 static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 };
92 av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st,
93 const uint8_t *src_scantable)
97 st->scantable = src_scantable;
99 for (i = 0; i < 64; i++) {
100 int j = src_scantable[i];
101 st->permutated[i] = permutation[j];
105 for (i = 0; i < 64; i++) {
106 int j = st->permutated[i];
109 st->raster_end[i] = end;
113 av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
114 int idct_permutation_type)
118 switch (idct_permutation_type) {
119 case FF_NO_IDCT_PERM:
120 for (i = 0; i < 64; i++)
121 idct_permutation[i] = i;
123 case FF_LIBMPEG2_IDCT_PERM:
124 for (i = 0; i < 64; i++)
125 idct_permutation[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
127 case FF_SIMPLE_IDCT_PERM:
128 for (i = 0; i < 64; i++)
129 idct_permutation[i] = simple_mmx_permutation[i];
131 case FF_TRANSPOSE_IDCT_PERM:
132 for (i = 0; i < 64; i++)
133 idct_permutation[i] = ((i & 7) << 3) | (i >> 3);
135 case FF_PARTTRANS_IDCT_PERM:
136 for (i = 0; i < 64; i++)
137 idct_permutation[i] = (i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3);
139 case FF_SSE2_IDCT_PERM:
140 for (i = 0; i < 64; i++)
141 idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7];
144 av_log(NULL, AV_LOG_ERROR,
145 "Internal error, IDCT permutation not set\n");
149 static int pix_sum_c(uint8_t *pix, int line_size)
153 for (i = 0; i < 16; i++) {
154 for (j = 0; j < 16; j += 8) {
165 pix += line_size - 16;
170 static int pix_norm1_c(uint8_t *pix, int line_size)
173 uint32_t *sq = ff_square_tab + 256;
175 for (i = 0; i < 16; i++) {
176 for (j = 0; j < 16; j += 8) {
188 register uint64_t x = *(uint64_t *) pix;
190 s += sq[(x >> 8) & 0xff];
191 s += sq[(x >> 16) & 0xff];
192 s += sq[(x >> 24) & 0xff];
193 s += sq[(x >> 32) & 0xff];
194 s += sq[(x >> 40) & 0xff];
195 s += sq[(x >> 48) & 0xff];
196 s += sq[(x >> 56) & 0xff];
198 register uint32_t x = *(uint32_t *) pix;
200 s += sq[(x >> 8) & 0xff];
201 s += sq[(x >> 16) & 0xff];
202 s += sq[(x >> 24) & 0xff];
203 x = *(uint32_t *) (pix + 4);
205 s += sq[(x >> 8) & 0xff];
206 s += sq[(x >> 16) & 0xff];
207 s += sq[(x >> 24) & 0xff];
212 pix += line_size - 16;
217 static void bswap_buf(uint32_t *dst, const uint32_t *src, int w)
221 for (i = 0; i + 8 <= w; i += 8) {
222 dst[i + 0] = av_bswap32(src[i + 0]);
223 dst[i + 1] = av_bswap32(src[i + 1]);
224 dst[i + 2] = av_bswap32(src[i + 2]);
225 dst[i + 3] = av_bswap32(src[i + 3]);
226 dst[i + 4] = av_bswap32(src[i + 4]);
227 dst[i + 5] = av_bswap32(src[i + 5]);
228 dst[i + 6] = av_bswap32(src[i + 6]);
229 dst[i + 7] = av_bswap32(src[i + 7]);
232 dst[i + 0] = av_bswap32(src[i + 0]);
235 static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len)
238 *dst++ = av_bswap16(*src++);
241 static int sse4_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
242 int line_size, int h)
245 uint32_t *sq = ff_square_tab + 256;
247 for (i = 0; i < h; i++) {
248 s += sq[pix1[0] - pix2[0]];
249 s += sq[pix1[1] - pix2[1]];
250 s += sq[pix1[2] - pix2[2]];
251 s += sq[pix1[3] - pix2[3]];
258 static int sse8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
259 int line_size, int h)
262 uint32_t *sq = ff_square_tab + 256;
264 for (i = 0; i < h; i++) {
265 s += sq[pix1[0] - pix2[0]];
266 s += sq[pix1[1] - pix2[1]];
267 s += sq[pix1[2] - pix2[2]];
268 s += sq[pix1[3] - pix2[3]];
269 s += sq[pix1[4] - pix2[4]];
270 s += sq[pix1[5] - pix2[5]];
271 s += sq[pix1[6] - pix2[6]];
272 s += sq[pix1[7] - pix2[7]];
279 static int sse16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
280 int line_size, int h)
283 uint32_t *sq = ff_square_tab + 256;
285 for (i = 0; i < h; i++) {
286 s += sq[pix1[0] - pix2[0]];
287 s += sq[pix1[1] - pix2[1]];
288 s += sq[pix1[2] - pix2[2]];
289 s += sq[pix1[3] - pix2[3]];
290 s += sq[pix1[4] - pix2[4]];
291 s += sq[pix1[5] - pix2[5]];
292 s += sq[pix1[6] - pix2[6]];
293 s += sq[pix1[7] - pix2[7]];
294 s += sq[pix1[8] - pix2[8]];
295 s += sq[pix1[9] - pix2[9]];
296 s += sq[pix1[10] - pix2[10]];
297 s += sq[pix1[11] - pix2[11]];
298 s += sq[pix1[12] - pix2[12]];
299 s += sq[pix1[13] - pix2[13]];
300 s += sq[pix1[14] - pix2[14]];
301 s += sq[pix1[15] - pix2[15]];
309 static void diff_pixels_c(int16_t *restrict block, const uint8_t *s1,
310 const uint8_t *s2, int stride)
314 /* read the pixels */
315 for (i = 0; i < 8; i++) {
316 block[0] = s1[0] - s2[0];
317 block[1] = s1[1] - s2[1];
318 block[2] = s1[2] - s2[2];
319 block[3] = s1[3] - s2[3];
320 block[4] = s1[4] - s2[4];
321 block[5] = s1[5] - s2[5];
322 block[6] = s1[6] - s2[6];
323 block[7] = s1[7] - s2[7];
330 static void put_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
335 /* read the pixels */
336 for (i = 0; i < 8; i++) {
337 pixels[0] = av_clip_uint8(block[0]);
338 pixels[1] = av_clip_uint8(block[1]);
339 pixels[2] = av_clip_uint8(block[2]);
340 pixels[3] = av_clip_uint8(block[3]);
341 pixels[4] = av_clip_uint8(block[4]);
342 pixels[5] = av_clip_uint8(block[5]);
343 pixels[6] = av_clip_uint8(block[6]);
344 pixels[7] = av_clip_uint8(block[7]);
351 static void put_signed_pixels_clamped_c(const int16_t *block,
352 uint8_t *restrict pixels,
357 for (i = 0; i < 8; i++) {
358 for (j = 0; j < 8; j++) {
361 else if (*block > 127)
364 *pixels = (uint8_t) (*block + 128);
368 pixels += (line_size - 8);
372 static void add_pixels8_c(uint8_t *restrict pixels, int16_t *block,
377 for (i = 0; i < 8; i++) {
378 pixels[0] += block[0];
379 pixels[1] += block[1];
380 pixels[2] += block[2];
381 pixels[3] += block[3];
382 pixels[4] += block[4];
383 pixels[5] += block[5];
384 pixels[6] += block[6];
385 pixels[7] += block[7];
391 static void add_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
396 /* read the pixels */
397 for (i = 0; i < 8; i++) {
398 pixels[0] = av_clip_uint8(pixels[0] + block[0]);
399 pixels[1] = av_clip_uint8(pixels[1] + block[1]);
400 pixels[2] = av_clip_uint8(pixels[2] + block[2]);
401 pixels[3] = av_clip_uint8(pixels[3] + block[3]);
402 pixels[4] = av_clip_uint8(pixels[4] + block[4]);
403 pixels[5] = av_clip_uint8(pixels[5] + block[5]);
404 pixels[6] = av_clip_uint8(pixels[6] + block[6]);
405 pixels[7] = av_clip_uint8(pixels[7] + block[7]);
411 static int sum_abs_dctelem_c(int16_t *block)
415 for (i = 0; i < 64; i++)
416 sum += FFABS(block[i]);
420 static void fill_block16_c(uint8_t *block, uint8_t value, int line_size, int h)
424 for (i = 0; i < h; i++) {
425 memset(block, value, 16);
430 static void fill_block8_c(uint8_t *block, uint8_t value, int line_size, int h)
434 for (i = 0; i < h; i++) {
435 memset(block, value, 8);
440 #define avg2(a, b) ((a + b + 1) >> 1)
441 #define avg4(a, b, c, d) ((a + b + c + d + 2) >> 2)
443 static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h,
444 int x16, int y16, int rounder)
446 const int A = (16 - x16) * (16 - y16);
447 const int B = (x16) * (16 - y16);
448 const int C = (16 - x16) * (y16);
449 const int D = (x16) * (y16);
452 for (i = 0; i < h; i++) {
453 dst[0] = (A * src[0] + B * src[1] + C * src[stride + 0] + D * src[stride + 1] + rounder) >> 8;
454 dst[1] = (A * src[1] + B * src[2] + C * src[stride + 1] + D * src[stride + 2] + rounder) >> 8;
455 dst[2] = (A * src[2] + B * src[3] + C * src[stride + 2] + D * src[stride + 3] + rounder) >> 8;
456 dst[3] = (A * src[3] + B * src[4] + C * src[stride + 3] + D * src[stride + 4] + rounder) >> 8;
457 dst[4] = (A * src[4] + B * src[5] + C * src[stride + 4] + D * src[stride + 5] + rounder) >> 8;
458 dst[5] = (A * src[5] + B * src[6] + C * src[stride + 5] + D * src[stride + 6] + rounder) >> 8;
459 dst[6] = (A * src[6] + B * src[7] + C * src[stride + 6] + D * src[stride + 7] + rounder) >> 8;
460 dst[7] = (A * src[7] + B * src[8] + C * src[stride + 7] + D * src[stride + 8] + rounder) >> 8;
466 void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
467 int dxx, int dxy, int dyx, int dyy, int shift, int r,
468 int width, int height)
471 const int s = 1 << shift;
476 for (y = 0; y < h; y++) {
481 for (x = 0; x < 8; x++) { // FIXME: optimize
483 int src_x = vx >> 16;
484 int src_y = vy >> 16;
485 int frac_x = src_x & (s - 1);
486 int frac_y = src_y & (s - 1);
491 if ((unsigned) src_x < width) {
492 if ((unsigned) src_y < height) {
493 index = src_x + src_y * stride;
494 dst[y * stride + x] =
495 ((src[index] * (s - frac_x) +
496 src[index + 1] * frac_x) * (s - frac_y) +
497 (src[index + stride] * (s - frac_x) +
498 src[index + stride + 1] * frac_x) * frac_y +
501 index = src_x + av_clip(src_y, 0, height) * stride;
502 dst[y * stride + x] =
503 ((src[index] * (s - frac_x) +
504 src[index + 1] * frac_x) * s +
508 if ((unsigned) src_y < height) {
509 index = av_clip(src_x, 0, width) + src_y * stride;
510 dst[y * stride + x] =
511 ((src[index] * (s - frac_y) +
512 src[index + stride] * frac_y) * s +
515 index = av_clip(src_x, 0, width) +
516 av_clip(src_y, 0, height) * stride;
517 dst[y * stride + x] = src[index];
529 #define QPEL_MC(r, OPNAME, RND, OP) \
530 static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, \
531 int dstStride, int srcStride, \
534 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
537 for (i = 0; i < h; i++) { \
538 OP(dst[0], (src[0] + src[1]) * 20 - (src[0] + src[2]) * 6 + (src[1] + src[3]) * 3 - (src[2] + src[4])); \
539 OP(dst[1], (src[1] + src[2]) * 20 - (src[0] + src[3]) * 6 + (src[0] + src[4]) * 3 - (src[1] + src[5])); \
540 OP(dst[2], (src[2] + src[3]) * 20 - (src[1] + src[4]) * 6 + (src[0] + src[5]) * 3 - (src[0] + src[6])); \
541 OP(dst[3], (src[3] + src[4]) * 20 - (src[2] + src[5]) * 6 + (src[1] + src[6]) * 3 - (src[0] + src[7])); \
542 OP(dst[4], (src[4] + src[5]) * 20 - (src[3] + src[6]) * 6 + (src[2] + src[7]) * 3 - (src[1] + src[8])); \
543 OP(dst[5], (src[5] + src[6]) * 20 - (src[4] + src[7]) * 6 + (src[3] + src[8]) * 3 - (src[2] + src[8])); \
544 OP(dst[6], (src[6] + src[7]) * 20 - (src[5] + src[8]) * 6 + (src[4] + src[8]) * 3 - (src[3] + src[7])); \
545 OP(dst[7], (src[7] + src[8]) * 20 - (src[6] + src[8]) * 6 + (src[5] + src[7]) * 3 - (src[4] + src[6])); \
551 static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, \
552 int dstStride, int srcStride) \
554 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
558 for (i = 0; i < w; i++) { \
559 const int src0 = src[0 * srcStride]; \
560 const int src1 = src[1 * srcStride]; \
561 const int src2 = src[2 * srcStride]; \
562 const int src3 = src[3 * srcStride]; \
563 const int src4 = src[4 * srcStride]; \
564 const int src5 = src[5 * srcStride]; \
565 const int src6 = src[6 * srcStride]; \
566 const int src7 = src[7 * srcStride]; \
567 const int src8 = src[8 * srcStride]; \
568 OP(dst[0 * dstStride], (src0 + src1) * 20 - (src0 + src2) * 6 + (src1 + src3) * 3 - (src2 + src4)); \
569 OP(dst[1 * dstStride], (src1 + src2) * 20 - (src0 + src3) * 6 + (src0 + src4) * 3 - (src1 + src5)); \
570 OP(dst[2 * dstStride], (src2 + src3) * 20 - (src1 + src4) * 6 + (src0 + src5) * 3 - (src0 + src6)); \
571 OP(dst[3 * dstStride], (src3 + src4) * 20 - (src2 + src5) * 6 + (src1 + src6) * 3 - (src0 + src7)); \
572 OP(dst[4 * dstStride], (src4 + src5) * 20 - (src3 + src6) * 6 + (src2 + src7) * 3 - (src1 + src8)); \
573 OP(dst[5 * dstStride], (src5 + src6) * 20 - (src4 + src7) * 6 + (src3 + src8) * 3 - (src2 + src8)); \
574 OP(dst[6 * dstStride], (src6 + src7) * 20 - (src5 + src8) * 6 + (src4 + src8) * 3 - (src3 + src7)); \
575 OP(dst[7 * dstStride], (src7 + src8) * 20 - (src6 + src8) * 6 + (src5 + src7) * 3 - (src4 + src6)); \
581 static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, \
582 int dstStride, int srcStride, \
585 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
588 for (i = 0; i < h; i++) { \
589 OP(dst[0], (src[0] + src[1]) * 20 - (src[0] + src[2]) * 6 + (src[1] + src[3]) * 3 - (src[2] + src[4])); \
590 OP(dst[1], (src[1] + src[2]) * 20 - (src[0] + src[3]) * 6 + (src[0] + src[4]) * 3 - (src[1] + src[5])); \
591 OP(dst[2], (src[2] + src[3]) * 20 - (src[1] + src[4]) * 6 + (src[0] + src[5]) * 3 - (src[0] + src[6])); \
592 OP(dst[3], (src[3] + src[4]) * 20 - (src[2] + src[5]) * 6 + (src[1] + src[6]) * 3 - (src[0] + src[7])); \
593 OP(dst[4], (src[4] + src[5]) * 20 - (src[3] + src[6]) * 6 + (src[2] + src[7]) * 3 - (src[1] + src[8])); \
594 OP(dst[5], (src[5] + src[6]) * 20 - (src[4] + src[7]) * 6 + (src[3] + src[8]) * 3 - (src[2] + src[9])); \
595 OP(dst[6], (src[6] + src[7]) * 20 - (src[5] + src[8]) * 6 + (src[4] + src[9]) * 3 - (src[3] + src[10])); \
596 OP(dst[7], (src[7] + src[8]) * 20 - (src[6] + src[9]) * 6 + (src[5] + src[10]) * 3 - (src[4] + src[11])); \
597 OP(dst[8], (src[8] + src[9]) * 20 - (src[7] + src[10]) * 6 + (src[6] + src[11]) * 3 - (src[5] + src[12])); \
598 OP(dst[9], (src[9] + src[10]) * 20 - (src[8] + src[11]) * 6 + (src[7] + src[12]) * 3 - (src[6] + src[13])); \
599 OP(dst[10], (src[10] + src[11]) * 20 - (src[9] + src[12]) * 6 + (src[8] + src[13]) * 3 - (src[7] + src[14])); \
600 OP(dst[11], (src[11] + src[12]) * 20 - (src[10] + src[13]) * 6 + (src[9] + src[14]) * 3 - (src[8] + src[15])); \
601 OP(dst[12], (src[12] + src[13]) * 20 - (src[11] + src[14]) * 6 + (src[10] + src[15]) * 3 - (src[9] + src[16])); \
602 OP(dst[13], (src[13] + src[14]) * 20 - (src[12] + src[15]) * 6 + (src[11] + src[16]) * 3 - (src[10] + src[16])); \
603 OP(dst[14], (src[14] + src[15]) * 20 - (src[13] + src[16]) * 6 + (src[12] + src[16]) * 3 - (src[11] + src[15])); \
604 OP(dst[15], (src[15] + src[16]) * 20 - (src[14] + src[16]) * 6 + (src[13] + src[15]) * 3 - (src[12] + src[14])); \
610 static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, \
611 int dstStride, int srcStride) \
613 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
617 for (i = 0; i < w; i++) { \
618 const int src0 = src[0 * srcStride]; \
619 const int src1 = src[1 * srcStride]; \
620 const int src2 = src[2 * srcStride]; \
621 const int src3 = src[3 * srcStride]; \
622 const int src4 = src[4 * srcStride]; \
623 const int src5 = src[5 * srcStride]; \
624 const int src6 = src[6 * srcStride]; \
625 const int src7 = src[7 * srcStride]; \
626 const int src8 = src[8 * srcStride]; \
627 const int src9 = src[9 * srcStride]; \
628 const int src10 = src[10 * srcStride]; \
629 const int src11 = src[11 * srcStride]; \
630 const int src12 = src[12 * srcStride]; \
631 const int src13 = src[13 * srcStride]; \
632 const int src14 = src[14 * srcStride]; \
633 const int src15 = src[15 * srcStride]; \
634 const int src16 = src[16 * srcStride]; \
635 OP(dst[0 * dstStride], (src0 + src1) * 20 - (src0 + src2) * 6 + (src1 + src3) * 3 - (src2 + src4)); \
636 OP(dst[1 * dstStride], (src1 + src2) * 20 - (src0 + src3) * 6 + (src0 + src4) * 3 - (src1 + src5)); \
637 OP(dst[2 * dstStride], (src2 + src3) * 20 - (src1 + src4) * 6 + (src0 + src5) * 3 - (src0 + src6)); \
638 OP(dst[3 * dstStride], (src3 + src4) * 20 - (src2 + src5) * 6 + (src1 + src6) * 3 - (src0 + src7)); \
639 OP(dst[4 * dstStride], (src4 + src5) * 20 - (src3 + src6) * 6 + (src2 + src7) * 3 - (src1 + src8)); \
640 OP(dst[5 * dstStride], (src5 + src6) * 20 - (src4 + src7) * 6 + (src3 + src8) * 3 - (src2 + src9)); \
641 OP(dst[6 * dstStride], (src6 + src7) * 20 - (src5 + src8) * 6 + (src4 + src9) * 3 - (src3 + src10)); \
642 OP(dst[7 * dstStride], (src7 + src8) * 20 - (src6 + src9) * 6 + (src5 + src10) * 3 - (src4 + src11)); \
643 OP(dst[8 * dstStride], (src8 + src9) * 20 - (src7 + src10) * 6 + (src6 + src11) * 3 - (src5 + src12)); \
644 OP(dst[9 * dstStride], (src9 + src10) * 20 - (src8 + src11) * 6 + (src7 + src12) * 3 - (src6 + src13)); \
645 OP(dst[10 * dstStride], (src10 + src11) * 20 - (src9 + src12) * 6 + (src8 + src13) * 3 - (src7 + src14)); \
646 OP(dst[11 * dstStride], (src11 + src12) * 20 - (src10 + src13) * 6 + (src9 + src14) * 3 - (src8 + src15)); \
647 OP(dst[12 * dstStride], (src12 + src13) * 20 - (src11 + src14) * 6 + (src10 + src15) * 3 - (src9 + src16)); \
648 OP(dst[13 * dstStride], (src13 + src14) * 20 - (src12 + src15) * 6 + (src11 + src16) * 3 - (src10 + src16)); \
649 OP(dst[14 * dstStride], (src14 + src15) * 20 - (src13 + src16) * 6 + (src12 + src16) * 3 - (src11 + src15)); \
650 OP(dst[15 * dstStride], (src15 + src16) * 20 - (src14 + src16) * 6 + (src13 + src15) * 3 - (src12 + src14)); \
656 static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, \
661 put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8); \
662 OPNAME ## pixels8_l2_8(dst, src, half, stride, stride, 8, 8); \
665 static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, \
668 OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8); \
671 static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, \
676 put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8); \
677 OPNAME ## pixels8_l2_8(dst, src + 1, half, stride, stride, 8, 8); \
680 static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, \
683 uint8_t full[16 * 9]; \
686 copy_block9(full, src, 16, stride, 9); \
687 put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
688 OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8); \
691 static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, \
694 uint8_t full[16 * 9]; \
696 copy_block9(full, src, 16, stride, 9); \
697 OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16); \
700 static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, \
703 uint8_t full[16 * 9]; \
706 copy_block9(full, src, 16, stride, 9); \
707 put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
708 OPNAME ## pixels8_l2_8(dst, full + 16, half, stride, 16, 8, 8); \
711 void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, \
714 uint8_t full[16 * 9]; \
717 uint8_t halfHV[64]; \
719 copy_block9(full, src, 16, stride, 9); \
720 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
721 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
722 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
723 OPNAME ## pixels8_l4_8(dst, full, halfH, halfV, halfHV, \
724 stride, 16, 8, 8, 8, 8); \
727 static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, \
730 uint8_t full[16 * 9]; \
732 uint8_t halfHV[64]; \
734 copy_block9(full, src, 16, stride, 9); \
735 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
736 put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
737 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
738 OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
741 void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, \
744 uint8_t full[16 * 9]; \
747 uint8_t halfHV[64]; \
749 copy_block9(full, src, 16, stride, 9); \
750 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
751 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
752 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
753 OPNAME ## pixels8_l4_8(dst, full + 1, halfH, halfV, halfHV, \
754 stride, 16, 8, 8, 8, 8); \
757 static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, \
760 uint8_t full[16 * 9]; \
762 uint8_t halfHV[64]; \
764 copy_block9(full, src, 16, stride, 9); \
765 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
766 put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
767 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
768 OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
771 void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, \
774 uint8_t full[16 * 9]; \
777 uint8_t halfHV[64]; \
779 copy_block9(full, src, 16, stride, 9); \
780 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
781 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
782 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
783 OPNAME ## pixels8_l4_8(dst, full + 16, halfH + 8, halfV, halfHV, \
784 stride, 16, 8, 8, 8, 8); \
787 static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, \
790 uint8_t full[16 * 9]; \
792 uint8_t halfHV[64]; \
794 copy_block9(full, src, 16, stride, 9); \
795 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
796 put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
797 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
798 OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
801 void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, \
804 uint8_t full[16 * 9]; \
807 uint8_t halfHV[64]; \
809 copy_block9(full, src, 16, stride, 9); \
810 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
811 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
812 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
813 OPNAME ## pixels8_l4_8(dst, full + 17, halfH + 8, halfV, halfHV, \
814 stride, 16, 8, 8, 8, 8); \
817 static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, \
820 uint8_t full[16 * 9]; \
822 uint8_t halfHV[64]; \
824 copy_block9(full, src, 16, stride, 9); \
825 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
826 put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
827 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
828 OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
831 static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, \
835 uint8_t halfHV[64]; \
837 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
838 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
839 OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
842 static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, \
846 uint8_t halfHV[64]; \
848 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
849 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
850 OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
853 void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, \
856 uint8_t full[16 * 9]; \
859 uint8_t halfHV[64]; \
861 copy_block9(full, src, 16, stride, 9); \
862 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
863 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
864 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
865 OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8); \
868 static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, \
871 uint8_t full[16 * 9]; \
874 copy_block9(full, src, 16, stride, 9); \
875 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
876 put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
877 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
880 void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, \
883 uint8_t full[16 * 9]; \
886 uint8_t halfHV[64]; \
888 copy_block9(full, src, 16, stride, 9); \
889 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
890 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
891 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
892 OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8); \
895 static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, \
898 uint8_t full[16 * 9]; \
901 copy_block9(full, src, 16, stride, 9); \
902 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
903 put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
904 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
907 static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, \
912 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
913 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
916 static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, \
921 put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16); \
922 OPNAME ## pixels16_l2_8(dst, src, half, stride, stride, 16, 16); \
925 static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, \
928 OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16); \
931 static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, \
936 put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16); \
937 OPNAME ## pixels16_l2_8(dst, src + 1, half, stride, stride, 16, 16); \
940 static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, \
943 uint8_t full[24 * 17]; \
946 copy_block17(full, src, 24, stride, 17); \
947 put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
948 OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16); \
951 static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, \
954 uint8_t full[24 * 17]; \
956 copy_block17(full, src, 24, stride, 17); \
957 OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24); \
960 static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, \
963 uint8_t full[24 * 17]; \
966 copy_block17(full, src, 24, stride, 17); \
967 put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
968 OPNAME ## pixels16_l2_8(dst, full + 24, half, stride, 24, 16, 16); \
971 void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, \
974 uint8_t full[24 * 17]; \
975 uint8_t halfH[272]; \
976 uint8_t halfV[256]; \
977 uint8_t halfHV[256]; \
979 copy_block17(full, src, 24, stride, 17); \
980 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
981 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
982 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
983 OPNAME ## pixels16_l4_8(dst, full, halfH, halfV, halfHV, \
984 stride, 24, 16, 16, 16, 16); \
987 static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, \
990 uint8_t full[24 * 17]; \
991 uint8_t halfH[272]; \
992 uint8_t halfHV[256]; \
994 copy_block17(full, src, 24, stride, 17); \
995 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
996 put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
997 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
998 OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
1001 void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, \
1004 uint8_t full[24 * 17]; \
1005 uint8_t halfH[272]; \
1006 uint8_t halfV[256]; \
1007 uint8_t halfHV[256]; \
1009 copy_block17(full, src, 24, stride, 17); \
1010 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
1011 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
1012 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
1013 OPNAME ## pixels16_l4_8(dst, full + 1, halfH, halfV, halfHV, \
1014 stride, 24, 16, 16, 16, 16); \
1017 static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, \
1020 uint8_t full[24 * 17]; \
1021 uint8_t halfH[272]; \
1022 uint8_t halfHV[256]; \
1024 copy_block17(full, src, 24, stride, 17); \
1025 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
1026 put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
1027 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
1028 OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
1031 void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, \
1034 uint8_t full[24 * 17]; \
1035 uint8_t halfH[272]; \
1036 uint8_t halfV[256]; \
1037 uint8_t halfHV[256]; \
1039 copy_block17(full, src, 24, stride, 17); \
1040 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
1041 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
1042 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
1043 OPNAME ## pixels16_l4_8(dst, full + 24, halfH + 16, halfV, halfHV, \
1044 stride, 24, 16, 16, 16, 16); \
1047 static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, \
1050 uint8_t full[24 * 17]; \
1051 uint8_t halfH[272]; \
1052 uint8_t halfHV[256]; \
1054 copy_block17(full, src, 24, stride, 17); \
1055 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
1056 put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
1057 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
1058 OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
1061 void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, \
1064 uint8_t full[24 * 17]; \
1065 uint8_t halfH[272]; \
1066 uint8_t halfV[256]; \
1067 uint8_t halfHV[256]; \
1069 copy_block17(full, src, 24, stride, 17); \
1070 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
1071 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
1072 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
1073 OPNAME ## pixels16_l4_8(dst, full + 25, halfH + 16, halfV, halfHV, \
1074 stride, 24, 16, 16, 16, 16); \
1077 static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, \
1080 uint8_t full[24 * 17]; \
1081 uint8_t halfH[272]; \
1082 uint8_t halfHV[256]; \
1084 copy_block17(full, src, 24, stride, 17); \
1085 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
1086 put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
1087 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
1088 OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
1091 static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, \
1094 uint8_t halfH[272]; \
1095 uint8_t halfHV[256]; \
1097 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
1098 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
1099 OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
1102 static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, \
1105 uint8_t halfH[272]; \
1106 uint8_t halfHV[256]; \
1108 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
1109 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
1110 OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
1113 void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, \
1116 uint8_t full[24 * 17]; \
1117 uint8_t halfH[272]; \
1118 uint8_t halfV[256]; \
1119 uint8_t halfHV[256]; \
1121 copy_block17(full, src, 24, stride, 17); \
1122 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
1123 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
1124 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
1125 OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16); \
1128 static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, \
1131 uint8_t full[24 * 17]; \
1132 uint8_t halfH[272]; \
1134 copy_block17(full, src, 24, stride, 17); \
1135 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
1136 put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
1137 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
1140 void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, \
1143 uint8_t full[24 * 17]; \
1144 uint8_t halfH[272]; \
1145 uint8_t halfV[256]; \
1146 uint8_t halfHV[256]; \
1148 copy_block17(full, src, 24, stride, 17); \
1149 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
1150 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
1151 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
1152 OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16); \
1155 static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, \
1158 uint8_t full[24 * 17]; \
1159 uint8_t halfH[272]; \
1161 copy_block17(full, src, 24, stride, 17); \
1162 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
1163 put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
1164 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
1167 static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, \
1170 uint8_t halfH[272]; \
1172 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
1173 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
1176 #define op_avg(a, b) a = (((a) + cm[((b) + 16) >> 5] + 1) >> 1)
1177 #define op_avg_no_rnd(a, b) a = (((a) + cm[((b) + 15) >> 5]) >> 1)
1178 #define op_put(a, b) a = cm[((b) + 16) >> 5]
1179 #define op_put_no_rnd(a, b) a = cm[((b) + 15) >> 5]
1181 QPEL_MC(0, put_, _, op_put)
1182 QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd)
1183 QPEL_MC(0, avg_, _, op_avg)
1187 #undef op_put_no_rnd
1189 void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
1191 put_pixels8_8_c(dst, src, stride, 8);
1194 void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
1196 avg_pixels8_8_c(dst, src, stride, 8);
1199 void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
1201 put_pixels16_8_c(dst, src, stride, 16);
1204 void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
1206 avg_pixels16_8_c(dst, src, stride, 16);
1209 #define put_qpel8_mc00_c ff_put_pixels8x8_c
1210 #define avg_qpel8_mc00_c ff_avg_pixels8x8_c
1211 #define put_qpel16_mc00_c ff_put_pixels16x16_c
1212 #define avg_qpel16_mc00_c ff_avg_pixels16x16_c
1213 #define put_no_rnd_qpel8_mc00_c ff_put_pixels8x8_c
1214 #define put_no_rnd_qpel16_mc00_c ff_put_pixels16x16_c
1216 static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src,
1217 int dstStride, int srcStride, int h)
1219 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
1222 for (i = 0; i < h; i++) {
1223 dst[0] = cm[(9 * (src[0] + src[1]) - (src[-1] + src[2]) + 8) >> 4];
1224 dst[1] = cm[(9 * (src[1] + src[2]) - (src[0] + src[3]) + 8) >> 4];
1225 dst[2] = cm[(9 * (src[2] + src[3]) - (src[1] + src[4]) + 8) >> 4];
1226 dst[3] = cm[(9 * (src[3] + src[4]) - (src[2] + src[5]) + 8) >> 4];
1227 dst[4] = cm[(9 * (src[4] + src[5]) - (src[3] + src[6]) + 8) >> 4];
1228 dst[5] = cm[(9 * (src[5] + src[6]) - (src[4] + src[7]) + 8) >> 4];
1229 dst[6] = cm[(9 * (src[6] + src[7]) - (src[5] + src[8]) + 8) >> 4];
1230 dst[7] = cm[(9 * (src[7] + src[8]) - (src[6] + src[9]) + 8) >> 4];
1236 static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src,
1237 int dstStride, int srcStride, int w)
1239 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
1242 for (i = 0; i < w; i++) {
1243 const int src_1 = src[-srcStride];
1244 const int src0 = src[0];
1245 const int src1 = src[srcStride];
1246 const int src2 = src[2 * srcStride];
1247 const int src3 = src[3 * srcStride];
1248 const int src4 = src[4 * srcStride];
1249 const int src5 = src[5 * srcStride];
1250 const int src6 = src[6 * srcStride];
1251 const int src7 = src[7 * srcStride];
1252 const int src8 = src[8 * srcStride];
1253 const int src9 = src[9 * srcStride];
1254 dst[0 * dstStride] = cm[(9 * (src0 + src1) - (src_1 + src2) + 8) >> 4];
1255 dst[1 * dstStride] = cm[(9 * (src1 + src2) - (src0 + src3) + 8) >> 4];
1256 dst[2 * dstStride] = cm[(9 * (src2 + src3) - (src1 + src4) + 8) >> 4];
1257 dst[3 * dstStride] = cm[(9 * (src3 + src4) - (src2 + src5) + 8) >> 4];
1258 dst[4 * dstStride] = cm[(9 * (src4 + src5) - (src3 + src6) + 8) >> 4];
1259 dst[5 * dstStride] = cm[(9 * (src5 + src6) - (src4 + src7) + 8) >> 4];
1260 dst[6 * dstStride] = cm[(9 * (src6 + src7) - (src5 + src8) + 8) >> 4];
1261 dst[7 * dstStride] = cm[(9 * (src7 + src8) - (src6 + src9) + 8) >> 4];
1267 static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
1271 wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
1272 put_pixels8_l2_8(dst, src, half, stride, stride, 8, 8);
1275 static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
1277 wmv2_mspel8_h_lowpass(dst, src, stride, stride, 8);
1280 static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
1284 wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
1285 put_pixels8_l2_8(dst, src + 1, half, stride, stride, 8, 8);
1288 static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
1290 wmv2_mspel8_v_lowpass(dst, src, stride, stride, 8);
1293 static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
1299 wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
1300 wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8);
1301 wmv2_mspel8_v_lowpass(halfHV, halfH + 8, 8, 8, 8);
1302 put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
1305 static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
1311 wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
1312 wmv2_mspel8_v_lowpass(halfV, src + 1, 8, stride, 8);
1313 wmv2_mspel8_v_lowpass(halfHV, halfH + 8, 8, 8, 8);
1314 put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
1317 static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
1321 wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
1322 wmv2_mspel8_v_lowpass(dst, halfH + 8, stride, 8, 8);
1325 static inline int pix_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
1326 int line_size, int h)
1330 for (i = 0; i < h; i++) {
1331 s += abs(pix1[0] - pix2[0]);
1332 s += abs(pix1[1] - pix2[1]);
1333 s += abs(pix1[2] - pix2[2]);
1334 s += abs(pix1[3] - pix2[3]);
1335 s += abs(pix1[4] - pix2[4]);
1336 s += abs(pix1[5] - pix2[5]);
1337 s += abs(pix1[6] - pix2[6]);
1338 s += abs(pix1[7] - pix2[7]);
1339 s += abs(pix1[8] - pix2[8]);
1340 s += abs(pix1[9] - pix2[9]);
1341 s += abs(pix1[10] - pix2[10]);
1342 s += abs(pix1[11] - pix2[11]);
1343 s += abs(pix1[12] - pix2[12]);
1344 s += abs(pix1[13] - pix2[13]);
1345 s += abs(pix1[14] - pix2[14]);
1346 s += abs(pix1[15] - pix2[15]);
1353 static int pix_abs16_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
1354 int line_size, int h)
1358 for (i = 0; i < h; i++) {
1359 s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
1360 s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
1361 s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
1362 s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
1363 s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
1364 s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
1365 s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
1366 s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
1367 s += abs(pix1[8] - avg2(pix2[8], pix2[9]));
1368 s += abs(pix1[9] - avg2(pix2[9], pix2[10]));
1369 s += abs(pix1[10] - avg2(pix2[10], pix2[11]));
1370 s += abs(pix1[11] - avg2(pix2[11], pix2[12]));
1371 s += abs(pix1[12] - avg2(pix2[12], pix2[13]));
1372 s += abs(pix1[13] - avg2(pix2[13], pix2[14]));
1373 s += abs(pix1[14] - avg2(pix2[14], pix2[15]));
1374 s += abs(pix1[15] - avg2(pix2[15], pix2[16]));
1381 static int pix_abs16_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
1382 int line_size, int h)
1385 uint8_t *pix3 = pix2 + line_size;
1387 for (i = 0; i < h; i++) {
1388 s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
1389 s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
1390 s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
1391 s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
1392 s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
1393 s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
1394 s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
1395 s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
1396 s += abs(pix1[8] - avg2(pix2[8], pix3[8]));
1397 s += abs(pix1[9] - avg2(pix2[9], pix3[9]));
1398 s += abs(pix1[10] - avg2(pix2[10], pix3[10]));
1399 s += abs(pix1[11] - avg2(pix2[11], pix3[11]));
1400 s += abs(pix1[12] - avg2(pix2[12], pix3[12]));
1401 s += abs(pix1[13] - avg2(pix2[13], pix3[13]));
1402 s += abs(pix1[14] - avg2(pix2[14], pix3[14]));
1403 s += abs(pix1[15] - avg2(pix2[15], pix3[15]));
1411 static int pix_abs16_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
1412 int line_size, int h)
1415 uint8_t *pix3 = pix2 + line_size;
1417 for (i = 0; i < h; i++) {
1418 s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
1419 s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
1420 s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
1421 s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
1422 s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
1423 s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
1424 s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
1425 s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
1426 s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9]));
1427 s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10]));
1428 s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11]));
1429 s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12]));
1430 s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13]));
1431 s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14]));
1432 s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15]));
1433 s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16]));
1441 static inline int pix_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
1442 int line_size, int h)
1446 for (i = 0; i < h; i++) {
1447 s += abs(pix1[0] - pix2[0]);
1448 s += abs(pix1[1] - pix2[1]);
1449 s += abs(pix1[2] - pix2[2]);
1450 s += abs(pix1[3] - pix2[3]);
1451 s += abs(pix1[4] - pix2[4]);
1452 s += abs(pix1[5] - pix2[5]);
1453 s += abs(pix1[6] - pix2[6]);
1454 s += abs(pix1[7] - pix2[7]);
1461 static int pix_abs8_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
1462 int line_size, int h)
1466 for (i = 0; i < h; i++) {
1467 s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
1468 s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
1469 s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
1470 s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
1471 s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
1472 s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
1473 s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
1474 s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
1481 static int pix_abs8_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
1482 int line_size, int h)
1485 uint8_t *pix3 = pix2 + line_size;
1487 for (i = 0; i < h; i++) {
1488 s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
1489 s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
1490 s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
1491 s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
1492 s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
1493 s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
1494 s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
1495 s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
1503 static int pix_abs8_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
1504 int line_size, int h)
1507 uint8_t *pix3 = pix2 + line_size;
1509 for (i = 0; i < h; i++) {
1510 s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
1511 s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
1512 s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
1513 s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
1514 s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
1515 s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
1516 s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
1517 s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
1525 static int nsse16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, int stride, int h)
1527 int score1 = 0, score2 = 0, x, y;
1529 for (y = 0; y < h; y++) {
1530 for (x = 0; x < 16; x++)
1531 score1 += (s1[x] - s2[x]) * (s1[x] - s2[x]);
1533 for (x = 0; x < 15; x++)
1534 score2 += FFABS(s1[x] - s1[x + stride] -
1535 s1[x + 1] + s1[x + stride + 1]) -
1536 FFABS(s2[x] - s2[x + stride] -
1537 s2[x + 1] + s2[x + stride + 1]);
1544 return score1 + FFABS(score2) * c->avctx->nsse_weight;
1546 return score1 + FFABS(score2) * 8;
1549 static int nsse8_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, int stride, int h)
1551 int score1 = 0, score2 = 0, x, y;
1553 for (y = 0; y < h; y++) {
1554 for (x = 0; x < 8; x++)
1555 score1 += (s1[x] - s2[x]) * (s1[x] - s2[x]);
1557 for (x = 0; x < 7; x++)
1558 score2 += FFABS(s1[x] - s1[x + stride] -
1559 s1[x + 1] + s1[x + stride + 1]) -
1560 FFABS(s2[x] - s2[x + stride] -
1561 s2[x + 1] + s2[x + stride + 1]);
1568 return score1 + FFABS(score2) * c->avctx->nsse_weight;
1570 return score1 + FFABS(score2) * 8;
1573 static int try_8x8basis_c(int16_t rem[64], int16_t weight[64],
1574 int16_t basis[64], int scale)
1577 unsigned int sum = 0;
1579 for (i = 0; i < 8 * 8; i++) {
1580 int b = rem[i] + ((basis[i] * scale +
1581 (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >>
1582 (BASIS_SHIFT - RECON_SHIFT));
1585 assert(-512 < b && b < 512);
1587 sum += (w * b) * (w * b) >> 4;
1592 static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale)
1596 for (i = 0; i < 8 * 8; i++)
1597 rem[i] += (basis[i] * scale +
1598 (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >>
1599 (BASIS_SHIFT - RECON_SHIFT);
1602 static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b,
1608 void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type)
1612 memset(cmp, 0, sizeof(void *) * 6);
1614 for (i = 0; i < 6; i++) {
1615 switch (type & 0xFF) {
1620 cmp[i] = c->hadamard8_diff[i];
1626 cmp[i] = c->dct_sad[i];
1629 cmp[i] = c->dct264_sad[i];
1632 cmp[i] = c->dct_max[i];
1635 cmp[i] = c->quant_psnr[i];
1644 cmp[i] = c->vsad[i];
1647 cmp[i] = c->vsse[i];
1653 cmp[i] = c->nsse[i];
1656 av_log(NULL, AV_LOG_ERROR,
1657 "internal error in cmp function selection\n");
1662 #define BUTTERFLY2(o1, o2, i1, i2) \
1666 #define BUTTERFLY1(x, y) \
1675 #define BUTTERFLYA(x, y) (FFABS((x) + (y)) + FFABS((x) - (y)))
1677 static int hadamard8_diff8x8_c(MpegEncContext *s, uint8_t *dst,
1678 uint8_t *src, int stride, int h)
1680 int i, temp[64], sum = 0;
1684 for (i = 0; i < 8; i++) {
1685 // FIXME: try pointer walks
1686 BUTTERFLY2(temp[8 * i + 0], temp[8 * i + 1],
1687 src[stride * i + 0] - dst[stride * i + 0],
1688 src[stride * i + 1] - dst[stride * i + 1]);
1689 BUTTERFLY2(temp[8 * i + 2], temp[8 * i + 3],
1690 src[stride * i + 2] - dst[stride * i + 2],
1691 src[stride * i + 3] - dst[stride * i + 3]);
1692 BUTTERFLY2(temp[8 * i + 4], temp[8 * i + 5],
1693 src[stride * i + 4] - dst[stride * i + 4],
1694 src[stride * i + 5] - dst[stride * i + 5]);
1695 BUTTERFLY2(temp[8 * i + 6], temp[8 * i + 7],
1696 src[stride * i + 6] - dst[stride * i + 6],
1697 src[stride * i + 7] - dst[stride * i + 7]);
1699 BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 2]);
1700 BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 3]);
1701 BUTTERFLY1(temp[8 * i + 4], temp[8 * i + 6]);
1702 BUTTERFLY1(temp[8 * i + 5], temp[8 * i + 7]);
1704 BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 4]);
1705 BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 5]);
1706 BUTTERFLY1(temp[8 * i + 2], temp[8 * i + 6]);
1707 BUTTERFLY1(temp[8 * i + 3], temp[8 * i + 7]);
1710 for (i = 0; i < 8; i++) {
1711 BUTTERFLY1(temp[8 * 0 + i], temp[8 * 1 + i]);
1712 BUTTERFLY1(temp[8 * 2 + i], temp[8 * 3 + i]);
1713 BUTTERFLY1(temp[8 * 4 + i], temp[8 * 5 + i]);
1714 BUTTERFLY1(temp[8 * 6 + i], temp[8 * 7 + i]);
1716 BUTTERFLY1(temp[8 * 0 + i], temp[8 * 2 + i]);
1717 BUTTERFLY1(temp[8 * 1 + i], temp[8 * 3 + i]);
1718 BUTTERFLY1(temp[8 * 4 + i], temp[8 * 6 + i]);
1719 BUTTERFLY1(temp[8 * 5 + i], temp[8 * 7 + i]);
1721 sum += BUTTERFLYA(temp[8 * 0 + i], temp[8 * 4 + i]) +
1722 BUTTERFLYA(temp[8 * 1 + i], temp[8 * 5 + i]) +
1723 BUTTERFLYA(temp[8 * 2 + i], temp[8 * 6 + i]) +
1724 BUTTERFLYA(temp[8 * 3 + i], temp[8 * 7 + i]);
1729 static int hadamard8_intra8x8_c(MpegEncContext *s, uint8_t *src,
1730 uint8_t *dummy, int stride, int h)
1732 int i, temp[64], sum = 0;
1736 for (i = 0; i < 8; i++) {
1737 // FIXME: try pointer walks
1738 BUTTERFLY2(temp[8 * i + 0], temp[8 * i + 1],
1739 src[stride * i + 0], src[stride * i + 1]);
1740 BUTTERFLY2(temp[8 * i + 2], temp[8 * i + 3],
1741 src[stride * i + 2], src[stride * i + 3]);
1742 BUTTERFLY2(temp[8 * i + 4], temp[8 * i + 5],
1743 src[stride * i + 4], src[stride * i + 5]);
1744 BUTTERFLY2(temp[8 * i + 6], temp[8 * i + 7],
1745 src[stride * i + 6], src[stride * i + 7]);
1747 BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 2]);
1748 BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 3]);
1749 BUTTERFLY1(temp[8 * i + 4], temp[8 * i + 6]);
1750 BUTTERFLY1(temp[8 * i + 5], temp[8 * i + 7]);
1752 BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 4]);
1753 BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 5]);
1754 BUTTERFLY1(temp[8 * i + 2], temp[8 * i + 6]);
1755 BUTTERFLY1(temp[8 * i + 3], temp[8 * i + 7]);
1758 for (i = 0; i < 8; i++) {
1759 BUTTERFLY1(temp[8 * 0 + i], temp[8 * 1 + i]);
1760 BUTTERFLY1(temp[8 * 2 + i], temp[8 * 3 + i]);
1761 BUTTERFLY1(temp[8 * 4 + i], temp[8 * 5 + i]);
1762 BUTTERFLY1(temp[8 * 6 + i], temp[8 * 7 + i]);
1764 BUTTERFLY1(temp[8 * 0 + i], temp[8 * 2 + i]);
1765 BUTTERFLY1(temp[8 * 1 + i], temp[8 * 3 + i]);
1766 BUTTERFLY1(temp[8 * 4 + i], temp[8 * 6 + i]);
1767 BUTTERFLY1(temp[8 * 5 + i], temp[8 * 7 + i]);
1770 BUTTERFLYA(temp[8 * 0 + i], temp[8 * 4 + i])
1771 + BUTTERFLYA(temp[8 * 1 + i], temp[8 * 5 + i])
1772 + BUTTERFLYA(temp[8 * 2 + i], temp[8 * 6 + i])
1773 + BUTTERFLYA(temp[8 * 3 + i], temp[8 * 7 + i]);
1776 sum -= FFABS(temp[8 * 0] + temp[8 * 4]); // -mean
1781 static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1,
1782 uint8_t *src2, int stride, int h)
1784 LOCAL_ALIGNED_16(int16_t, temp, [64]);
1788 s->dsp.diff_pixels(temp, src1, src2, stride);
1790 return s->dsp.sum_abs_dctelem(temp);
1796 const int s07 = SRC(0) + SRC(7); \
1797 const int s16 = SRC(1) + SRC(6); \
1798 const int s25 = SRC(2) + SRC(5); \
1799 const int s34 = SRC(3) + SRC(4); \
1800 const int a0 = s07 + s34; \
1801 const int a1 = s16 + s25; \
1802 const int a2 = s07 - s34; \
1803 const int a3 = s16 - s25; \
1804 const int d07 = SRC(0) - SRC(7); \
1805 const int d16 = SRC(1) - SRC(6); \
1806 const int d25 = SRC(2) - SRC(5); \
1807 const int d34 = SRC(3) - SRC(4); \
1808 const int a4 = d16 + d25 + (d07 + (d07 >> 1)); \
1809 const int a5 = d07 - d34 - (d25 + (d25 >> 1)); \
1810 const int a6 = d07 + d34 - (d16 + (d16 >> 1)); \
1811 const int a7 = d16 - d25 + (d34 + (d34 >> 1)); \
1813 DST(1, a4 + (a7 >> 2)); \
1814 DST(2, a2 + (a3 >> 1)); \
1815 DST(3, a5 + (a6 >> 2)); \
1817 DST(5, a6 - (a5 >> 2)); \
1818 DST(6, (a2 >> 1) - a3); \
1819 DST(7, (a4 >> 2) - a7); \
1822 static int dct264_sad8x8_c(MpegEncContext *s, uint8_t *src1,
1823 uint8_t *src2, int stride, int h)
1828 s->dsp.diff_pixels(dct[0], src1, src2, stride);
1830 #define SRC(x) dct[i][x]
1831 #define DST(x, v) dct[i][x] = v
1832 for (i = 0; i < 8; i++)
1837 #define SRC(x) dct[x][i]
1838 #define DST(x, v) sum += FFABS(v)
1839 for (i = 0; i < 8; i++)
1847 static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1,
1848 uint8_t *src2, int stride, int h)
1850 LOCAL_ALIGNED_16(int16_t, temp, [64]);
1855 s->dsp.diff_pixels(temp, src1, src2, stride);
1858 for (i = 0; i < 64; i++)
1859 sum = FFMAX(sum, FFABS(temp[i]));
1864 static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1,
1865 uint8_t *src2, int stride, int h)
1867 LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]);
1868 int16_t *const bak = temp + 64;
1874 s->dsp.diff_pixels(temp, src1, src2, stride);
1876 memcpy(bak, temp, 64 * sizeof(int16_t));
1878 s->block_last_index[0 /* FIXME */] =
1879 s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
1880 s->dct_unquantize_inter(s, temp, 0, s->qscale);
1881 ff_simple_idct_8(temp); // FIXME
1883 for (i = 0; i < 64; i++)
1884 sum += (temp[i] - bak[i]) * (temp[i] - bak[i]);
1889 static int rd8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
1892 const uint8_t *scantable = s->intra_scantable.permutated;
1893 LOCAL_ALIGNED_16(int16_t, temp, [64]);
1894 LOCAL_ALIGNED_16(uint8_t, lsrc1, [64]);
1895 LOCAL_ALIGNED_16(uint8_t, lsrc2, [64]);
1896 int i, last, run, bits, level, distortion, start_i;
1897 const int esc_length = s->ac_esc_length;
1898 uint8_t *length, *last_length;
1902 copy_block8(lsrc1, src1, 8, stride, 8);
1903 copy_block8(lsrc2, src2, 8, stride, 8);
1905 s->dsp.diff_pixels(temp, lsrc1, lsrc2, 8);
1907 s->block_last_index[0 /* FIXME */] =
1909 s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
1915 length = s->intra_ac_vlc_length;
1916 last_length = s->intra_ac_vlc_last_length;
1917 bits += s->luma_dc_vlc_length[temp[0] + 256]; // FIXME: chroma
1920 length = s->inter_ac_vlc_length;
1921 last_length = s->inter_ac_vlc_last_length;
1924 if (last >= start_i) {
1926 for (i = start_i; i < last; i++) {
1927 int j = scantable[i];
1932 if ((level & (~127)) == 0)
1933 bits += length[UNI_AC_ENC_INDEX(run, level)];
1940 i = scantable[last];
1942 level = temp[i] + 64;
1946 if ((level & (~127)) == 0) {
1947 bits += last_length[UNI_AC_ENC_INDEX(run, level)];
1954 s->dct_unquantize_intra(s, temp, 0, s->qscale);
1956 s->dct_unquantize_inter(s, temp, 0, s->qscale);
1959 s->dsp.idct_add(lsrc2, 8, temp);
1961 distortion = s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);
1963 return distortion + ((bits * s->qscale * s->qscale * 109 + 64) >> 7);
1966 static int bit8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
1969 const uint8_t *scantable = s->intra_scantable.permutated;
1970 LOCAL_ALIGNED_16(int16_t, temp, [64]);
1971 int i, last, run, bits, level, start_i;
1972 const int esc_length = s->ac_esc_length;
1973 uint8_t *length, *last_length;
1977 s->dsp.diff_pixels(temp, src1, src2, stride);
1979 s->block_last_index[0 /* FIXME */] =
1981 s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
1987 length = s->intra_ac_vlc_length;
1988 last_length = s->intra_ac_vlc_last_length;
1989 bits += s->luma_dc_vlc_length[temp[0] + 256]; // FIXME: chroma
1992 length = s->inter_ac_vlc_length;
1993 last_length = s->inter_ac_vlc_last_length;
1996 if (last >= start_i) {
1998 for (i = start_i; i < last; i++) {
1999 int j = scantable[i];
2004 if ((level & (~127)) == 0)
2005 bits += length[UNI_AC_ENC_INDEX(run, level)];
2012 i = scantable[last];
2014 level = temp[i] + 64;
2018 if ((level & (~127)) == 0)
2019 bits += last_length[UNI_AC_ENC_INDEX(run, level)];
2027 #define VSAD_INTRA(size) \
2028 static int vsad_intra ## size ## _c(MpegEncContext *c, \
2029 uint8_t *s, uint8_t *dummy, \
2030 int stride, int h) \
2032 int score = 0, x, y; \
2034 for (y = 1; y < h; y++) { \
2035 for (x = 0; x < size; x += 4) { \
2036 score += FFABS(s[x] - s[x + stride]) + \
2037 FFABS(s[x + 1] - s[x + stride + 1]) + \
2038 FFABS(s[x + 2] - s[x + 2 + stride]) + \
2039 FFABS(s[x + 3] - s[x + 3 + stride]); \
2049 static int vsad16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2,
2052 int score = 0, x, y;
2054 for (y = 1; y < h; y++) {
2055 for (x = 0; x < 16; x++)
2056 score += FFABS(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]);
2064 #define SQ(a) ((a) * (a))
2065 #define VSSE_INTRA(size) \
2066 static int vsse_intra ## size ## _c(MpegEncContext *c, \
2067 uint8_t *s, uint8_t *dummy, \
2068 int stride, int h) \
2070 int score = 0, x, y; \
2072 for (y = 1; y < h; y++) { \
2073 for (x = 0; x < size; x += 4) { \
2074 score += SQ(s[x] - s[x + stride]) + \
2075 SQ(s[x + 1] - s[x + stride + 1]) + \
2076 SQ(s[x + 2] - s[x + stride + 2]) + \
2077 SQ(s[x + 3] - s[x + stride + 3]); \
2087 static int vsse16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2,
2090 int score = 0, x, y;
2092 for (y = 1; y < h; y++) {
2093 for (x = 0; x < 16; x++)
2094 score += SQ(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]);
2102 #define WRAPPER8_16_SQ(name8, name16) \
2103 static int name16(MpegEncContext *s, uint8_t *dst, uint8_t *src, \
2104 int stride, int h) \
2108 score += name8(s, dst, src, stride, 8); \
2109 score += name8(s, dst + 8, src + 8, stride, 8); \
2111 dst += 8 * stride; \
2112 src += 8 * stride; \
2113 score += name8(s, dst, src, stride, 8); \
2114 score += name8(s, dst + 8, src + 8, stride, 8); \
2119 WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
2120 WRAPPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
2121 WRAPPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
2123 WRAPPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
2125 WRAPPER8_16_SQ(dct_max8x8_c, dct_max16_c)
2126 WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
2127 WRAPPER8_16_SQ(rd8x8_c, rd16_c)
2128 WRAPPER8_16_SQ(bit8x8_c, bit16_c)
2130 static inline uint32_t clipf_c_one(uint32_t a, uint32_t mini,
2131 uint32_t maxi, uint32_t maxisign)
2135 else if ((a ^ (1U << 31)) > maxisign)
2141 static void vector_clipf_c_opposite_sign(float *dst, const float *src,
2142 float *min, float *max, int len)
2145 uint32_t mini = *(uint32_t *) min;
2146 uint32_t maxi = *(uint32_t *) max;
2147 uint32_t maxisign = maxi ^ (1U << 31);
2148 uint32_t *dsti = (uint32_t *) dst;
2149 const uint32_t *srci = (const uint32_t *) src;
2151 for (i = 0; i < len; i += 8) {
2152 dsti[i + 0] = clipf_c_one(srci[i + 0], mini, maxi, maxisign);
2153 dsti[i + 1] = clipf_c_one(srci[i + 1], mini, maxi, maxisign);
2154 dsti[i + 2] = clipf_c_one(srci[i + 2], mini, maxi, maxisign);
2155 dsti[i + 3] = clipf_c_one(srci[i + 3], mini, maxi, maxisign);
2156 dsti[i + 4] = clipf_c_one(srci[i + 4], mini, maxi, maxisign);
2157 dsti[i + 5] = clipf_c_one(srci[i + 5], mini, maxi, maxisign);
2158 dsti[i + 6] = clipf_c_one(srci[i + 6], mini, maxi, maxisign);
2159 dsti[i + 7] = clipf_c_one(srci[i + 7], mini, maxi, maxisign);
2163 static void vector_clipf_c(float *dst, const float *src,
2164 float min, float max, int len)
2168 if (min < 0 && max > 0) {
2169 vector_clipf_c_opposite_sign(dst, src, &min, &max, len);
2171 for (i = 0; i < len; i += 8) {
2172 dst[i] = av_clipf(src[i], min, max);
2173 dst[i + 1] = av_clipf(src[i + 1], min, max);
2174 dst[i + 2] = av_clipf(src[i + 2], min, max);
2175 dst[i + 3] = av_clipf(src[i + 3], min, max);
2176 dst[i + 4] = av_clipf(src[i + 4], min, max);
2177 dst[i + 5] = av_clipf(src[i + 5], min, max);
2178 dst[i + 6] = av_clipf(src[i + 6], min, max);
2179 dst[i + 7] = av_clipf(src[i + 7], min, max);
2184 static int32_t scalarproduct_int16_c(const int16_t *v1, const int16_t *v2,
2190 res += *v1++ **v2++;
2195 static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2,
2203 *v1++ += mul * *v3++;
2208 static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min,
2209 int32_t max, unsigned int len)
2212 *dst++ = av_clip(*src++, min, max);
2213 *dst++ = av_clip(*src++, min, max);
2214 *dst++ = av_clip(*src++, min, max);
2215 *dst++ = av_clip(*src++, min, max);
2216 *dst++ = av_clip(*src++, min, max);
2217 *dst++ = av_clip(*src++, min, max);
2218 *dst++ = av_clip(*src++, min, max);
2219 *dst++ = av_clip(*src++, min, max);
2224 static void jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
2226 ff_j_rev_dct(block);
2227 put_pixels_clamped_c(block, dest, line_size);
2230 static void jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
2232 ff_j_rev_dct(block);
2233 add_pixels_clamped_c(block, dest, line_size);
2236 /* draw the edges of width 'w' of an image of size width, height */
2237 // FIXME: Check that this is OK for MPEG-4 interlaced.
2238 static void draw_edges_8_c(uint8_t *buf, int wrap, int width, int height,
2239 int w, int h, int sides)
2241 uint8_t *ptr = buf, *last_line;
2244 /* left and right */
2245 for (i = 0; i < height; i++) {
2246 memset(ptr - w, ptr[0], w);
2247 memset(ptr + width, ptr[width - 1], w);
2251 /* top and bottom + corners */
2253 last_line = buf + (height - 1) * wrap;
2254 if (sides & EDGE_TOP)
2255 for (i = 0; i < h; i++)
2257 memcpy(buf - (i + 1) * wrap, buf, width + w + w);
2258 if (sides & EDGE_BOTTOM)
2259 for (i = 0; i < h; i++)
2261 memcpy(last_line + (i + 1) * wrap, last_line, width + w + w);
2264 static void clear_block_8_c(int16_t *block)
2266 memset(block, 0, sizeof(int16_t) * 64);
2269 static void clear_blocks_8_c(int16_t *blocks)
2271 memset(blocks, 0, sizeof(int16_t) * 6 * 64);
2274 /* init static data */
2275 av_cold void ff_dsputil_static_init(void)
2279 for (i = 0; i < 512; i++)
2280 ff_square_tab[i] = (i - 256) * (i - 256);
2283 av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
2285 const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
2288 if (avctx->bits_per_raw_sample == 10) {
2289 c->fdct = ff_jpeg_fdct_islow_10;
2290 c->fdct248 = ff_fdct248_islow_10;
2292 if (avctx->dct_algo == FF_DCT_FASTINT) {
2293 c->fdct = ff_fdct_ifast;
2294 c->fdct248 = ff_fdct_ifast248;
2295 } else if (avctx->dct_algo == FF_DCT_FAAN) {
2296 c->fdct = ff_faandct;
2297 c->fdct248 = ff_faandct248;
2299 c->fdct = ff_jpeg_fdct_islow_8; // slow/accurate/default
2300 c->fdct248 = ff_fdct248_islow_8;
2303 #endif /* CONFIG_ENCODERS */
2305 if (avctx->bits_per_raw_sample == 10) {
2306 c->idct_put = ff_simple_idct_put_10;
2307 c->idct_add = ff_simple_idct_add_10;
2308 c->idct = ff_simple_idct_10;
2309 c->idct_permutation_type = FF_NO_IDCT_PERM;
2311 if (avctx->idct_algo == FF_IDCT_INT) {
2312 c->idct_put = jref_idct_put;
2313 c->idct_add = jref_idct_add;
2314 c->idct = ff_j_rev_dct;
2315 c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
2316 } else if (avctx->idct_algo == FF_IDCT_FAAN) {
2317 c->idct_put = ff_faanidct_put;
2318 c->idct_add = ff_faanidct_add;
2319 c->idct = ff_faanidct;
2320 c->idct_permutation_type = FF_NO_IDCT_PERM;
2321 } else { // accurate/default
2322 c->idct_put = ff_simple_idct_put_8;
2323 c->idct_add = ff_simple_idct_add_8;
2324 c->idct = ff_simple_idct_8;
2325 c->idct_permutation_type = FF_NO_IDCT_PERM;
2329 c->diff_pixels = diff_pixels_c;
2331 c->put_pixels_clamped = put_pixels_clamped_c;
2332 c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
2333 c->add_pixels_clamped = add_pixels_clamped_c;
2335 c->sum_abs_dctelem = sum_abs_dctelem_c;
2340 c->pix_sum = pix_sum_c;
2341 c->pix_norm1 = pix_norm1_c;
2343 c->fill_block_tab[0] = fill_block16_c;
2344 c->fill_block_tab[1] = fill_block8_c;
2346 /* TODO [0] 16 [1] 8 */
2347 c->pix_abs[0][0] = pix_abs16_c;
2348 c->pix_abs[0][1] = pix_abs16_x2_c;
2349 c->pix_abs[0][2] = pix_abs16_y2_c;
2350 c->pix_abs[0][3] = pix_abs16_xy2_c;
2351 c->pix_abs[1][0] = pix_abs8_c;
2352 c->pix_abs[1][1] = pix_abs8_x2_c;
2353 c->pix_abs[1][2] = pix_abs8_y2_c;
2354 c->pix_abs[1][3] = pix_abs8_xy2_c;
2356 #define dspfunc(PFX, IDX, NUM) \
2357 c->PFX ## _pixels_tab[IDX][0] = PFX ## NUM ## _mc00_c; \
2358 c->PFX ## _pixels_tab[IDX][1] = PFX ## NUM ## _mc10_c; \
2359 c->PFX ## _pixels_tab[IDX][2] = PFX ## NUM ## _mc20_c; \
2360 c->PFX ## _pixels_tab[IDX][3] = PFX ## NUM ## _mc30_c; \
2361 c->PFX ## _pixels_tab[IDX][4] = PFX ## NUM ## _mc01_c; \
2362 c->PFX ## _pixels_tab[IDX][5] = PFX ## NUM ## _mc11_c; \
2363 c->PFX ## _pixels_tab[IDX][6] = PFX ## NUM ## _mc21_c; \
2364 c->PFX ## _pixels_tab[IDX][7] = PFX ## NUM ## _mc31_c; \
2365 c->PFX ## _pixels_tab[IDX][8] = PFX ## NUM ## _mc02_c; \
2366 c->PFX ## _pixels_tab[IDX][9] = PFX ## NUM ## _mc12_c; \
2367 c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
2368 c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
2369 c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
2370 c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
2371 c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
2372 c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
2374 dspfunc(put_qpel, 0, 16);
2375 dspfunc(put_qpel, 1, 8);
2377 dspfunc(put_no_rnd_qpel, 0, 16);
2378 dspfunc(put_no_rnd_qpel, 1, 8);
2380 dspfunc(avg_qpel, 0, 16);
2381 dspfunc(avg_qpel, 1, 8);
2385 c->put_mspel_pixels_tab[0] = ff_put_pixels8x8_c;
2386 c->put_mspel_pixels_tab[1] = put_mspel8_mc10_c;
2387 c->put_mspel_pixels_tab[2] = put_mspel8_mc20_c;
2388 c->put_mspel_pixels_tab[3] = put_mspel8_mc30_c;
2389 c->put_mspel_pixels_tab[4] = put_mspel8_mc02_c;
2390 c->put_mspel_pixels_tab[5] = put_mspel8_mc12_c;
2391 c->put_mspel_pixels_tab[6] = put_mspel8_mc22_c;
2392 c->put_mspel_pixels_tab[7] = put_mspel8_mc32_c;
2394 #define SET_CMP_FUNC(name) \
2395 c->name[0] = name ## 16_c; \
2396 c->name[1] = name ## 8x8_c;
2398 SET_CMP_FUNC(hadamard8_diff)
2399 c->hadamard8_diff[4] = hadamard8_intra16_c;
2400 c->hadamard8_diff[5] = hadamard8_intra8x8_c;
2401 SET_CMP_FUNC(dct_sad)
2402 SET_CMP_FUNC(dct_max)
2404 SET_CMP_FUNC(dct264_sad)
2406 c->sad[0] = pix_abs16_c;
2407 c->sad[1] = pix_abs8_c;
2408 c->sse[0] = sse16_c;
2411 SET_CMP_FUNC(quant_psnr)
2414 c->vsad[0] = vsad16_c;
2415 c->vsad[4] = vsad_intra16_c;
2416 c->vsad[5] = vsad_intra8_c;
2417 c->vsse[0] = vsse16_c;
2418 c->vsse[4] = vsse_intra16_c;
2419 c->vsse[5] = vsse_intra8_c;
2420 c->nsse[0] = nsse16_c;
2421 c->nsse[1] = nsse8_c;
2423 c->bswap_buf = bswap_buf;
2424 c->bswap16_buf = bswap16_buf;
2426 c->try_8x8basis = try_8x8basis_c;
2427 c->add_8x8basis = add_8x8basis_c;
2429 c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
2431 c->scalarproduct_int16 = scalarproduct_int16_c;
2432 c->vector_clip_int32 = vector_clip_int32_c;
2433 c->vector_clipf = vector_clipf_c;
2435 c->shrink[0] = av_image_copy_plane;
2436 c->shrink[1] = ff_shrink22;
2437 c->shrink[2] = ff_shrink44;
2438 c->shrink[3] = ff_shrink88;
2440 c->add_pixels8 = add_pixels8_c;
2442 c->draw_edges = draw_edges_8_c;
2444 c->clear_block = clear_block_8_c;
2445 c->clear_blocks = clear_blocks_8_c;
2447 switch (avctx->bits_per_raw_sample) {
2450 c->get_pixels = get_pixels_16_c;
2453 c->get_pixels = get_pixels_8_c;
2458 ff_dsputil_init_arm(c, avctx, high_bit_depth);
2460 ff_dsputil_init_bfin(c, avctx, high_bit_depth);
2462 ff_dsputil_init_ppc(c, avctx, high_bit_depth);
2464 ff_dsputil_init_x86(c, avctx, high_bit_depth);
2466 ff_init_scantable_permutation(c->idct_permutation,
2467 c->idct_permutation_type);