dsputil: Split off quarterpel bits into their own context
authorDiego Biurrun <diego@biurrun.de>
Wed, 8 Jan 2014 13:00:10 +0000 (14:00 +0100)
committerDiego Biurrun <diego@biurrun.de>
Thu, 29 May 2014 13:48:31 +0000 (06:48 -0700)
28 files changed:
configure
libavcodec/Makefile
libavcodec/cavs.c
libavcodec/cavsdsp.h
libavcodec/dsputil.c
libavcodec/dsputil.h
libavcodec/h263dec.c
libavcodec/h264.h
libavcodec/h264_mb.c
libavcodec/h264qpel.h
libavcodec/motion_est.c
libavcodec/mpegvideo.c
libavcodec/mpegvideo.h
libavcodec/mpegvideo_enc.c
libavcodec/mpegvideo_motion.c
libavcodec/mss2.c
libavcodec/qpel_template.c [moved from libavcodec/dsputil_template.c with 98% similarity]
libavcodec/qpeldsp.c [copied from libavcodec/dsputil.c with 52% similarity]
libavcodec/qpeldsp.h [new file with mode: 0644]
libavcodec/rv34.c
libavcodec/rv34dsp.h
libavcodec/vc1dec.c
libavcodec/vc1dsp.c
libavcodec/wmv2dsp.h
libavcodec/x86/Makefile
libavcodec/x86/dsputil_init.c
libavcodec/x86/qpeldsp.asm [moved from libavcodec/x86/mpeg4qpel.asm with 99% similarity]
libavcodec/x86/qpeldsp_init.c [copied from libavcodec/x86/dsputil_init.c with 84% similarity]

index a7a3ac2..9c6109e 100755 (executable)
--- a/configure
+++ b/configure
@@ -1551,6 +1551,7 @@ CONFIG_EXTRA="
     mpegvideo
     mpegvideoenc
     nettle
+    qpeldsp
     rangecoder
     riffdec
     riffenc
@@ -1704,7 +1705,7 @@ rdft_select="fft"
 mpegaudio_select="mpegaudiodsp"
 mpegaudiodsp_select="dct"
 mpegvideo_select="dsputil hpeldsp videodsp"
-mpegvideoenc_select="dsputil mpegvideo"
+mpegvideoenc_select="dsputil mpegvideo qpeldsp"
 
 # decoders / encoders
 aac_decoder_select="mdct sinewin"
@@ -1730,7 +1731,7 @@ atrac3p_decoder_select="mdct sinewin"
 bink_decoder_select="dsputil hpeldsp"
 binkaudio_dct_decoder_select="mdct rdft dct sinewin"
 binkaudio_rdft_decoder_select="mdct rdft sinewin"
-cavs_decoder_select="dsputil golomb h264chroma videodsp"
+cavs_decoder_select="dsputil golomb h264chroma qpeldsp videodsp"
 cllc_decoder_select="dsputil"
 comfortnoise_encoder_select="lpc"
 cook_decoder_select="dsputil mdct sinewin"
@@ -1766,7 +1767,7 @@ g2m_decoder_deps="zlib"
 g2m_decoder_select="dsputil"
 h261_decoder_select="error_resilience mpegvideo"
 h261_encoder_select="aandcttables mpegvideoenc"
-h263_decoder_select="error_resilience h263_parser h263dsp mpegvideo"
+h263_decoder_select="error_resilience h263_parser h263dsp mpegvideo qpeldsp"
 h263_encoder_select="aandcttables h263dsp mpegvideoenc"
 h263i_decoder_select="h263_decoder"
 h263p_encoder_select="h263_encoder"
@@ -1818,7 +1819,7 @@ msmpeg4v2_decoder_select="h263_decoder"
 msmpeg4v2_encoder_select="h263_encoder"
 msmpeg4v3_decoder_select="h263_decoder"
 msmpeg4v3_encoder_select="h263_encoder"
-mss2_decoder_select="error_resilience vc1_decoder"
+mss2_decoder_select="error_resilience qpeldsp vc1_decoder"
 mxpeg_decoder_select="mjpeg_decoder"
 nellymoser_decoder_select="mdct sinewin"
 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
@@ -1860,7 +1861,7 @@ twinvq_decoder_select="mdct lsp sinewin"
 utvideo_decoder_select="dsputil"
 utvideo_encoder_select="dsputil huffman huffyuvencdsp"
 vble_decoder_select="huffyuvdsp"
-vc1_decoder_select="error_resilience h263_decoder h264chroma h264qpel intrax8"
+vc1_decoder_select="error_resilience h263_decoder h264chroma h264qpel intrax8 qpeldsp"
 vc1image_decoder_select="vc1_decoder"
 vorbis_decoder_select="mdct"
 vorbis_encoder_select="mdct"
@@ -1936,8 +1937,8 @@ wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
 
 # parsers
 h264_parser_select="h264_decoder"
-mpeg4video_parser_select="error_resilience h263dsp mpegvideo"
 mpegvideo_parser_select="error_resilience mpegvideo"
+mpeg4video_parser_select="error_resilience h263dsp mpegvideo qpeldsp"
 vc1_parser_select="mpegvideo"
 
 # external libraries
index 7060979..a61e673 100644 (file)
@@ -63,6 +63,7 @@ OBJS-$(CONFIG_MPEGVIDEO)               += mpegvideo.o mpegvideo_motion.o \
                                           mpegutils.o
 OBJS-$(CONFIG_MPEGVIDEOENC)            += mpegvideo_enc.o mpeg12data.o  \
                                           motion_est.o ratecontrol.o
+OBJS-$(CONFIG_QPELDSP)                 += qpeldsp.o
 OBJS-$(CONFIG_RANGECODER)              += rangecoder.o
 RDFT-OBJS-$(CONFIG_HARDCODED_TABLES)   += sin_tables.o
 OBJS-$(CONFIG_RDFT)                    += rdft.o $(RDFT-OBJS-yes)
index 4166b9e..3f21dcc 100644 (file)
@@ -30,6 +30,7 @@
 #include "golomb.h"
 #include "h264chroma.h"
 #include "mathops.h"
+#include "qpeldsp.h"
 #include "cavs.h"
 
 static const uint8_t alpha_tab[64] = {
index 333bd10..248afd5 100644 (file)
@@ -23,7 +23,9 @@
 #define AVCODEC_CAVSDSP_H
 
 #include <stdint.h>
-#include "dsputil.h"
+
+#include "avcodec.h"
+#include "qpeldsp.h"
 
 typedef struct CAVSDSPContext {
     qpel_mc_func put_cavs_qpel_pixels_tab[2][16];
index 89c0da4..aba2a43 100644 (file)
@@ -48,9 +48,6 @@ uint32_t ff_square_tab[512] = { 0, };
 #undef BIT_DEPTH
 
 #define BIT_DEPTH 8
-#include "hpel_template.c"
-#include "tpel_template.c"
-#include "dsputil_template.c"
 #include "dsputilenc_template.c"
 
 /* Input permutation for the simple_idct_mmx */
@@ -485,701 +482,6 @@ void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
     }
 }
 
-#define QPEL_MC(r, OPNAME, RND, OP)                                           \
-static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src,       \
-                                            int dstStride, int srcStride,     \
-                                            int h)                            \
-{                                                                             \
-    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;                           \
-    int i;                                                                    \
-                                                                              \
-    for (i = 0; i < h; i++) {                                                 \
-        OP(dst[0], (src[0] + src[1]) * 20 - (src[0] + src[2]) * 6 + (src[1] + src[3]) * 3 - (src[2] + src[4])); \
-        OP(dst[1], (src[1] + src[2]) * 20 - (src[0] + src[3]) * 6 + (src[0] + src[4]) * 3 - (src[1] + src[5])); \
-        OP(dst[2], (src[2] + src[3]) * 20 - (src[1] + src[4]) * 6 + (src[0] + src[5]) * 3 - (src[0] + src[6])); \
-        OP(dst[3], (src[3] + src[4]) * 20 - (src[2] + src[5]) * 6 + (src[1] + src[6]) * 3 - (src[0] + src[7])); \
-        OP(dst[4], (src[4] + src[5]) * 20 - (src[3] + src[6]) * 6 + (src[2] + src[7]) * 3 - (src[1] + src[8])); \
-        OP(dst[5], (src[5] + src[6]) * 20 - (src[4] + src[7]) * 6 + (src[3] + src[8]) * 3 - (src[2] + src[8])); \
-        OP(dst[6], (src[6] + src[7]) * 20 - (src[5] + src[8]) * 6 + (src[4] + src[8]) * 3 - (src[3] + src[7])); \
-        OP(dst[7], (src[7] + src[8]) * 20 - (src[6] + src[8]) * 6 + (src[5] + src[7]) * 3 - (src[4] + src[6])); \
-        dst += dstStride;                                                     \
-        src += srcStride;                                                     \
-    }                                                                         \
-}                                                                             \
-                                                                              \
-static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src,       \
-                                            int dstStride, int srcStride)     \
-{                                                                             \
-    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;                           \
-    const int w = 8;                                                          \
-    int i;                                                                    \
-                                                                              \
-    for (i = 0; i < w; i++) {                                                 \
-        const int src0 = src[0 * srcStride];                                  \
-        const int src1 = src[1 * srcStride];                                  \
-        const int src2 = src[2 * srcStride];                                  \
-        const int src3 = src[3 * srcStride];                                  \
-        const int src4 = src[4 * srcStride];                                  \
-        const int src5 = src[5 * srcStride];                                  \
-        const int src6 = src[6 * srcStride];                                  \
-        const int src7 = src[7 * srcStride];                                  \
-        const int src8 = src[8 * srcStride];                                  \
-        OP(dst[0 * dstStride], (src0 + src1) * 20 - (src0 + src2) * 6 + (src1 + src3) * 3 - (src2 + src4)); \
-        OP(dst[1 * dstStride], (src1 + src2) * 20 - (src0 + src3) * 6 + (src0 + src4) * 3 - (src1 + src5)); \
-        OP(dst[2 * dstStride], (src2 + src3) * 20 - (src1 + src4) * 6 + (src0 + src5) * 3 - (src0 + src6)); \
-        OP(dst[3 * dstStride], (src3 + src4) * 20 - (src2 + src5) * 6 + (src1 + src6) * 3 - (src0 + src7)); \
-        OP(dst[4 * dstStride], (src4 + src5) * 20 - (src3 + src6) * 6 + (src2 + src7) * 3 - (src1 + src8)); \
-        OP(dst[5 * dstStride], (src5 + src6) * 20 - (src4 + src7) * 6 + (src3 + src8) * 3 - (src2 + src8)); \
-        OP(dst[6 * dstStride], (src6 + src7) * 20 - (src5 + src8) * 6 + (src4 + src8) * 3 - (src3 + src7)); \
-        OP(dst[7 * dstStride], (src7 + src8) * 20 - (src6 + src8) * 6 + (src5 + src7) * 3 - (src4 + src6)); \
-        dst++;                                                                \
-        src++;                                                                \
-    }                                                                         \
-}                                                                             \
-                                                                              \
-static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src,      \
-                                             int dstStride, int srcStride,    \
-                                             int h)                           \
-{                                                                             \
-    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;                           \
-    int i;                                                                    \
-                                                                              \
-    for (i = 0; i < h; i++) {                                                 \
-        OP(dst[0],  (src[0]  + src[1])  * 20 - (src[0]  + src[2])  * 6 + (src[1]  + src[3])  * 3 - (src[2]  + src[4]));  \
-        OP(dst[1],  (src[1]  + src[2])  * 20 - (src[0]  + src[3])  * 6 + (src[0]  + src[4])  * 3 - (src[1]  + src[5]));  \
-        OP(dst[2],  (src[2]  + src[3])  * 20 - (src[1]  + src[4])  * 6 + (src[0]  + src[5])  * 3 - (src[0]  + src[6]));  \
-        OP(dst[3],  (src[3]  + src[4])  * 20 - (src[2]  + src[5])  * 6 + (src[1]  + src[6])  * 3 - (src[0]  + src[7]));  \
-        OP(dst[4],  (src[4]  + src[5])  * 20 - (src[3]  + src[6])  * 6 + (src[2]  + src[7])  * 3 - (src[1]  + src[8]));  \
-        OP(dst[5],  (src[5]  + src[6])  * 20 - (src[4]  + src[7])  * 6 + (src[3]  + src[8])  * 3 - (src[2]  + src[9]));  \
-        OP(dst[6],  (src[6]  + src[7])  * 20 - (src[5]  + src[8])  * 6 + (src[4]  + src[9])  * 3 - (src[3]  + src[10])); \
-        OP(dst[7],  (src[7]  + src[8])  * 20 - (src[6]  + src[9])  * 6 + (src[5]  + src[10]) * 3 - (src[4]  + src[11])); \
-        OP(dst[8],  (src[8]  + src[9])  * 20 - (src[7]  + src[10]) * 6 + (src[6]  + src[11]) * 3 - (src[5]  + src[12])); \
-        OP(dst[9],  (src[9]  + src[10]) * 20 - (src[8]  + src[11]) * 6 + (src[7]  + src[12]) * 3 - (src[6]  + src[13])); \
-        OP(dst[10], (src[10] + src[11]) * 20 - (src[9]  + src[12]) * 6 + (src[8]  + src[13]) * 3 - (src[7]  + src[14])); \
-        OP(dst[11], (src[11] + src[12]) * 20 - (src[10] + src[13]) * 6 + (src[9]  + src[14]) * 3 - (src[8]  + src[15])); \
-        OP(dst[12], (src[12] + src[13]) * 20 - (src[11] + src[14]) * 6 + (src[10] + src[15]) * 3 - (src[9]  + src[16])); \
-        OP(dst[13], (src[13] + src[14]) * 20 - (src[12] + src[15]) * 6 + (src[11] + src[16]) * 3 - (src[10] + src[16])); \
-        OP(dst[14], (src[14] + src[15]) * 20 - (src[13] + src[16]) * 6 + (src[12] + src[16]) * 3 - (src[11] + src[15])); \
-        OP(dst[15], (src[15] + src[16]) * 20 - (src[14] + src[16]) * 6 + (src[13] + src[15]) * 3 - (src[12] + src[14])); \
-        dst += dstStride;                                                     \
-        src += srcStride;                                                     \
-    }                                                                         \
-}                                                                             \
-                                                                              \
-static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src,      \
-                                             int dstStride, int srcStride)    \
-{                                                                             \
-    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;                           \
-    const int w = 16;                                                         \
-    int i;                                                                    \
-                                                                              \
-    for (i = 0; i < w; i++) {                                                 \
-        const int src0  = src[0  * srcStride];                                \
-        const int src1  = src[1  * srcStride];                                \
-        const int src2  = src[2  * srcStride];                                \
-        const int src3  = src[3  * srcStride];                                \
-        const int src4  = src[4  * srcStride];                                \
-        const int src5  = src[5  * srcStride];                                \
-        const int src6  = src[6  * srcStride];                                \
-        const int src7  = src[7  * srcStride];                                \
-        const int src8  = src[8  * srcStride];                                \
-        const int src9  = src[9  * srcStride];                                \
-        const int src10 = src[10 * srcStride];                                \
-        const int src11 = src[11 * srcStride];                                \
-        const int src12 = src[12 * srcStride];                                \
-        const int src13 = src[13 * srcStride];                                \
-        const int src14 = src[14 * srcStride];                                \
-        const int src15 = src[15 * srcStride];                                \
-        const int src16 = src[16 * srcStride];                                \
-        OP(dst[0  * dstStride], (src0  + src1)  * 20 - (src0  + src2)  * 6 + (src1  + src3)  * 3 - (src2  + src4));  \
-        OP(dst[1  * dstStride], (src1  + src2)  * 20 - (src0  + src3)  * 6 + (src0  + src4)  * 3 - (src1  + src5));  \
-        OP(dst[2  * dstStride], (src2  + src3)  * 20 - (src1  + src4)  * 6 + (src0  + src5)  * 3 - (src0  + src6));  \
-        OP(dst[3  * dstStride], (src3  + src4)  * 20 - (src2  + src5)  * 6 + (src1  + src6)  * 3 - (src0  + src7));  \
-        OP(dst[4  * dstStride], (src4  + src5)  * 20 - (src3  + src6)  * 6 + (src2  + src7)  * 3 - (src1  + src8));  \
-        OP(dst[5  * dstStride], (src5  + src6)  * 20 - (src4  + src7)  * 6 + (src3  + src8)  * 3 - (src2  + src9));  \
-        OP(dst[6  * dstStride], (src6  + src7)  * 20 - (src5  + src8)  * 6 + (src4  + src9)  * 3 - (src3  + src10)); \
-        OP(dst[7  * dstStride], (src7  + src8)  * 20 - (src6  + src9)  * 6 + (src5  + src10) * 3 - (src4  + src11)); \
-        OP(dst[8  * dstStride], (src8  + src9)  * 20 - (src7  + src10) * 6 + (src6  + src11) * 3 - (src5  + src12)); \
-        OP(dst[9  * dstStride], (src9  + src10) * 20 - (src8  + src11) * 6 + (src7  + src12) * 3 - (src6  + src13)); \
-        OP(dst[10 * dstStride], (src10 + src11) * 20 - (src9  + src12) * 6 + (src8  + src13) * 3 - (src7  + src14)); \
-        OP(dst[11 * dstStride], (src11 + src12) * 20 - (src10 + src13) * 6 + (src9  + src14) * 3 - (src8  + src15)); \
-        OP(dst[12 * dstStride], (src12 + src13) * 20 - (src11 + src14) * 6 + (src10 + src15) * 3 - (src9  + src16)); \
-        OP(dst[13 * dstStride], (src13 + src14) * 20 - (src12 + src15) * 6 + (src11 + src16) * 3 - (src10 + src16)); \
-        OP(dst[14 * dstStride], (src14 + src15) * 20 - (src13 + src16) * 6 + (src12 + src16) * 3 - (src11 + src15)); \
-        OP(dst[15 * dstStride], (src15 + src16) * 20 - (src14 + src16) * 6 + (src13 + src15) * 3 - (src12 + src14)); \
-        dst++;                                                                \
-        src++;                                                                \
-    }                                                                         \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t half[64];                                                         \
-                                                                              \
-    put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);             \
-    OPNAME ## pixels8_l2_8(dst, src, half, stride, stride, 8, 8);             \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);             \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t half[64];                                                         \
-                                                                              \
-    put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);             \
-    OPNAME ## pixels8_l2_8(dst, src + 1, half, stride, stride, 8, 8);         \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t half[64];                                                         \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);                   \
-    OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8);                \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);                   \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t half[64];                                                         \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);                   \
-    OPNAME ## pixels8_l2_8(dst, full + 16, half, stride, 16, 8, 8);           \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src,            \
-                                       ptrdiff_t stride)                      \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfV[64];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);                  \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l4_8(dst, full, halfH, halfV, halfHV,                   \
-                           stride, 16, 8, 8, 8, 8);                           \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);              \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);              \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src,            \
-                                       ptrdiff_t stride)                      \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfV[64];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16);              \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l4_8(dst, full + 1, halfH, halfV, halfHV,               \
-                           stride, 16, 8, 8, 8, 8);                           \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9);          \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);              \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src,            \
-                                       ptrdiff_t stride)                      \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfV[64];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);                  \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l4_8(dst, full + 16, halfH + 8, halfV, halfHV,          \
-                           stride, 16, 8, 8, 8, 8);                           \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);              \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8);          \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src,            \
-                                       ptrdiff_t stride)                      \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfV[64];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16);              \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l4_8(dst, full + 17, halfH + 8, halfV, halfHV,          \
-                           stride, 16, 8, 8, 8, 8);                           \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9);          \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8);          \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);            \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);              \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);            \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8);          \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src,            \
-                                       ptrdiff_t stride)                      \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfV[64];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);                  \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);              \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);              \
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);                   \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src,            \
-                                       ptrdiff_t stride)                      \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-    uint8_t halfV[64];                                                        \
-    uint8_t halfHV[64];                                                       \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16);              \
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
-    OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);              \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t full[16 * 9];                                                     \
-    uint8_t halfH[72];                                                        \
-                                                                              \
-    copy_block9(full, src, 16, stride, 9);                                    \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
-    put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9);          \
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);                   \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src,                \
-                                   ptrdiff_t stride)                          \
-{                                                                             \
-    uint8_t halfH[72];                                                        \
-                                                                              \
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);            \
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);                   \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t half[256];                                                        \
-                                                                              \
-    put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);          \
-    OPNAME ## pixels16_l2_8(dst, src, half, stride, stride, 16, 16);          \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);           \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t half[256];                                                        \
-                                                                              \
-    put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);          \
-    OPNAME ## pixels16_l2_8(dst, src + 1, half, stride, stride, 16, 16);      \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t half[256];                                                        \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);                 \
-    OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16);             \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);                  \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t half[256];                                                        \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);                 \
-    OPNAME ## pixels16_l2_8(dst, full + 24, half, stride, 24, 16, 16);        \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src,           \
-                                        ptrdiff_t stride)                     \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfV[256];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);                \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l4_8(dst, full, halfH, halfV, halfHV,                  \
-                            stride, 24, 16, 16, 16, 16);                      \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);          \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);          \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src,           \
-                                        ptrdiff_t stride)                     \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfV[256];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24);            \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l4_8(dst, full + 1, halfH, halfV, halfHV,              \
-                            stride, 24, 16, 16, 16, 16);                      \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17);      \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);          \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src,           \
-                                        ptrdiff_t stride)                     \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfV[256];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);                \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l4_8(dst, full + 24, halfH + 16, halfV, halfHV,        \
-                            stride, 24, 16, 16, 16, 16);                      \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);          \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16);     \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src,           \
-                                        ptrdiff_t stride)                     \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfV[256];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24);            \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l4_8(dst, full + 25, halfH + 16, halfV, halfHV,        \
-                            stride, 24, 16, 16, 16, 16);                      \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17);      \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16);     \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);         \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);          \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);         \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16);     \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src,           \
-                                        ptrdiff_t stride)                     \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfV[256];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);                \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);          \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);          \
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);                 \
-}                                                                             \
-                                                                              \
-void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src,           \
-                                        ptrdiff_t stride)                     \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-    uint8_t halfV[256];                                                       \
-    uint8_t halfHV[256];                                                      \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24);            \
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
-    OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);          \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t full[24 * 17];                                                    \
-    uint8_t halfH[272];                                                       \
-                                                                              \
-    copy_block17(full, src, 24, stride, 17);                                  \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
-    put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17);      \
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);                 \
-}                                                                             \
-                                                                              \
-static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src,               \
-                                    ptrdiff_t stride)                         \
-{                                                                             \
-    uint8_t halfH[272];                                                       \
-                                                                              \
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);         \
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);                 \
-}
-
-#define op_avg(a, b)        a = (((a) + cm[((b) + 16) >> 5] + 1) >> 1)
-#define op_avg_no_rnd(a, b) a = (((a) + cm[((b) + 15) >> 5])     >> 1)
-#define op_put(a, b)        a = cm[((b) + 16) >> 5]
-#define op_put_no_rnd(a, b) a = cm[((b) + 15) >> 5]
-
-QPEL_MC(0, put_, _, op_put)
-QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd)
-QPEL_MC(0, avg_, _, op_avg)
-
-#undef op_avg
-#undef op_put
-#undef op_put_no_rnd
-
-void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
-    put_pixels8_8_c(dst, src, stride, 8);
-}
-
-void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
-    avg_pixels8_8_c(dst, src, stride, 8);
-}
-
-void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
-    put_pixels16_8_c(dst, src, stride, 16);
-}
-
-void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
-    avg_pixels16_8_c(dst, src, stride, 16);
-}
-
-#define put_qpel8_mc00_c         ff_put_pixels8x8_c
-#define avg_qpel8_mc00_c         ff_avg_pixels8x8_c
-#define put_qpel16_mc00_c        ff_put_pixels16x16_c
-#define avg_qpel16_mc00_c        ff_avg_pixels16x16_c
-#define put_no_rnd_qpel8_mc00_c  ff_put_pixels8x8_c
-#define put_no_rnd_qpel16_mc00_c ff_put_pixels16x16_c
-
-void ff_put_pixels8_l2_8(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
-                         int dst_stride, int src_stride1, int src_stride2,
-                         int h)
-{
-    put_pixels8_l2_8(dst, src1, src2, dst_stride, src_stride1, src_stride2, h);
-
-}
-
 static inline int pix_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
                               int line_size, int h)
 {
@@ -2198,35 +1500,6 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
     c->pix_abs[1][2] = pix_abs8_y2_c;
     c->pix_abs[1][3] = pix_abs8_xy2_c;
 
-#define dspfunc(PFX, IDX, NUM)                              \
-    c->PFX ## _pixels_tab[IDX][0]  = PFX ## NUM ## _mc00_c; \
-    c->PFX ## _pixels_tab[IDX][1]  = PFX ## NUM ## _mc10_c; \
-    c->PFX ## _pixels_tab[IDX][2]  = PFX ## NUM ## _mc20_c; \
-    c->PFX ## _pixels_tab[IDX][3]  = PFX ## NUM ## _mc30_c; \
-    c->PFX ## _pixels_tab[IDX][4]  = PFX ## NUM ## _mc01_c; \
-    c->PFX ## _pixels_tab[IDX][5]  = PFX ## NUM ## _mc11_c; \
-    c->PFX ## _pixels_tab[IDX][6]  = PFX ## NUM ## _mc21_c; \
-    c->PFX ## _pixels_tab[IDX][7]  = PFX ## NUM ## _mc31_c; \
-    c->PFX ## _pixels_tab[IDX][8]  = PFX ## NUM ## _mc02_c; \
-    c->PFX ## _pixels_tab[IDX][9]  = PFX ## NUM ## _mc12_c; \
-    c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
-    c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
-    c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
-    c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
-    c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
-    c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
-
-    dspfunc(put_qpel, 0, 16);
-    dspfunc(put_qpel, 1, 8);
-
-    dspfunc(put_no_rnd_qpel, 0, 16);
-    dspfunc(put_no_rnd_qpel, 1, 8);
-
-    dspfunc(avg_qpel, 0, 16);
-    dspfunc(avg_qpel, 1, 8);
-
-#undef dspfunc
-
 #define SET_CMP_FUNC(name)                      \
     c->name[0] = name ## 16_c;                  \
     c->name[1] = name ## 8x8_c;
index ec4eb29..d7c2c24 100644 (file)
 
 extern uint32_t ff_square_tab[512];
 
-void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
-void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
-void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
-void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
-
-void ff_put_pixels8_l2_8(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
-                         int dst_stride, int src_stride1, int src_stride2,
-                         int h);
-
 void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
               int dxx, int dxy, int dyx, int dyy, int shift, int r,
               int width, int height);
@@ -64,33 +55,9 @@ void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
  * Block sizes for op_pixels_func are 8x4,8x8 16x8 16x16.
  * h for op_pixels_func is limited to { width / 2, width },
  * but never larger than 16 and never smaller than 4. */
-typedef void (*qpel_mc_func)(uint8_t *dst /* align width (8 or 16) */,
-                             uint8_t *src /* align 1 */, ptrdiff_t stride);
-
 typedef void (*op_fill_func)(uint8_t *block /* align width (8 or 16) */,
                              uint8_t value, int line_size, int h);
 
-#define DEF_OLD_QPEL(name)                                                     \
-    void ff_put_        ## name(uint8_t *dst /* align width (8 or 16) */,      \
-                                uint8_t *src /* align 1 */, ptrdiff_t stride); \
-    void ff_put_no_rnd_ ## name(uint8_t *dst /* align width (8 or 16) */,      \
-                                uint8_t *src /* align 1 */, ptrdiff_t stride); \
-    void ff_avg_        ## name(uint8_t *dst /* align width (8 or 16) */,      \
-                                uint8_t *src /* align 1 */, ptrdiff_t stride);
-
-DEF_OLD_QPEL(qpel16_mc11_old_c)
-DEF_OLD_QPEL(qpel16_mc31_old_c)
-DEF_OLD_QPEL(qpel16_mc12_old_c)
-DEF_OLD_QPEL(qpel16_mc32_old_c)
-DEF_OLD_QPEL(qpel16_mc13_old_c)
-DEF_OLD_QPEL(qpel16_mc33_old_c)
-DEF_OLD_QPEL(qpel8_mc11_old_c)
-DEF_OLD_QPEL(qpel8_mc31_old_c)
-DEF_OLD_QPEL(qpel8_mc12_old_c)
-DEF_OLD_QPEL(qpel8_mc32_old_c)
-DEF_OLD_QPEL(qpel8_mc13_old_c)
-DEF_OLD_QPEL(qpel8_mc33_old_c)
-
 struct MpegEncContext;
 /* Motion estimation:
  * h is limited to { width / 2, width, 2 * width },
@@ -174,10 +141,6 @@ typedef struct DSPContext {
     me_cmp_func ildct_cmp[6]; // only width 16 used
     me_cmp_func frame_skip_cmp[6]; // only width 8 used
 
-    qpel_mc_func put_qpel_pixels_tab[2][16];
-    qpel_mc_func avg_qpel_pixels_tab[2][16];
-    qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
-
     me_cmp_func pix_abs[2][4];
 
     void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w);
index c380983..f70feb9 100644 (file)
@@ -36,6 +36,7 @@
 #include "mpeg4video_parser.h"
 #include "mpegvideo.h"
 #include "msmpeg4.h"
+#include "qpeldsp.h"
 #include "thread.h"
 
 av_cold int ff_h263_decode_init(AVCodecContext *avctx)
@@ -116,6 +117,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
             return ret;
 
     ff_h263dsp_init(&s->h263dsp);
+    ff_qpeldsp_init(&s->qdsp);
     ff_h263_decode_init_vlc();
 
     return 0;
@@ -461,9 +463,9 @@ int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     avctx->has_b_frames = !s->low_delay;
 
 #define SET_QPEL_FUNC(postfix1, postfix2)                           \
-    s->dsp.put_        ## postfix1 = ff_put_        ## postfix2;    \
-    s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;    \
-    s->dsp.avg_        ## postfix1 = ff_avg_        ## postfix2;
+    s->qdsp.put_        ## postfix1 = ff_put_        ## postfix2;   \
+    s->qdsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;   \
+    s->qdsp.avg_        ## postfix1 = ff_avg_        ## postfix2;
 
     if (s->workaround_bugs & FF_BUG_STD_QPEL) {
         SET_QPEL_FUNC(qpel_pixels_tab[0][5], qpel16_mc11_old_c)
@@ -527,11 +529,11 @@ int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     }
 
     if ((!s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
-        s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
-        s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
+        s->me.qpel_put = s->qdsp.put_qpel_pixels_tab;
+        s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab;
     } else {
-        s->me.qpel_put = s->dsp.put_no_rnd_qpel_pixels_tab;
-        s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
+        s->me.qpel_put = s->qdsp.put_no_rnd_qpel_pixels_tab;
+        s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab;
     }
 
     if ((ret = ff_MPV_frame_start(s, avctx)) < 0)
index e259d0d..3e99832 100644 (file)
@@ -39,6 +39,7 @@
 #include "h264qpel.h"
 #include "mpegutils.h"
 #include "parser.h"
+#include "qpeldsp.h"
 #include "rectangle.h"
 #include "videodsp.h"
 
index 67d9202..61d68ab 100644 (file)
@@ -32,6 +32,7 @@
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "h264.h"
+#include "qpeldsp.h"
 #include "svq3.h"
 #include "thread.h"
 
index 202e97d..97ce195 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef AVCODEC_H264QPEL_H
 #define AVCODEC_H264QPEL_H
 
-#include "dsputil.h"
+#include "qpeldsp.h"
 
 typedef struct H264QpelContext {
     qpel_mc_func put_h264_qpel_pixels_tab[4][16];
index ebc8917..9677e04 100644 (file)
@@ -329,9 +329,11 @@ int ff_init_me(MpegEncContext *s){
 /*FIXME s->no_rounding b_type*/
     if(s->flags&CODEC_FLAG_QPEL){
         c->sub_motion_search= qpel_motion_search;
-        c->qpel_avg= s->dsp.avg_qpel_pixels_tab;
-        if(s->no_rounding) c->qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;
-        else               c->qpel_put= s->dsp.put_qpel_pixels_tab;
+        c->qpel_avg = s->qdsp.avg_qpel_pixels_tab;
+        if (s->no_rounding)
+            c->qpel_put = s->qdsp.put_no_rnd_qpel_pixels_tab;
+        else
+            c->qpel_put = s->qdsp.put_qpel_pixels_tab;
     }else{
         if(c->avctx->me_sub_cmp&FF_CMP_CHROMA)
             c->sub_motion_search= hpel_motion_search;
@@ -622,9 +624,9 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
                 dxy = ((my4 & 3) << 2) | (mx4 & 3);
 
                 if(s->no_rounding)
-                    s->dsp.put_no_rnd_qpel_pixels_tab[1][dxy](dest_y   , ref    , stride);
+                    s->qdsp.put_no_rnd_qpel_pixels_tab[1][dxy](dest_y, ref, stride);
                 else
-                    s->dsp.put_qpel_pixels_tab       [1][dxy](dest_y   , ref    , stride);
+                    s->qdsp.put_qpel_pixels_tab[1][dxy](dest_y, ref, stride);
             }else{
                 uint8_t *ref= c->ref[block][0] + (mx4>>1) + (my4>>1)*stride;
                 dxy = ((my4 & 1) << 1) | (mx4 & 1);
@@ -1208,14 +1210,14 @@ static inline int check_bidir_mv(MpegEncContext * s,
         src_y = motion_fy >> 2;
 
         ptr = ref_data[0] + (src_y * stride) + src_x;
-        s->dsp.put_qpel_pixels_tab[0][dxy](dest_y    , ptr    , stride);
+        s->qdsp.put_qpel_pixels_tab[0][dxy](dest_y, ptr, stride);
 
         dxy = ((motion_by & 3) << 2) | (motion_bx & 3);
         src_x = motion_bx >> 2;
         src_y = motion_by >> 2;
 
         ptr = ref2_data[0] + (src_y * stride) + src_x;
-        s->dsp.avg_qpel_pixels_tab[size][dxy](dest_y    , ptr    , stride);
+        s->qdsp.avg_qpel_pixels_tab[size][dxy](dest_y, ptr, stride);
     }else{
         dxy = ((motion_fy & 1) << 1) | (motion_fx & 1);
         src_x = motion_fx >> 1;
index 5f591cc..49bc70c 100644 (file)
@@ -40,6 +40,7 @@
 #include "mpegvideo.h"
 #include "mjpegenc.h"
 #include "msmpeg4.h"
+#include "qpeldsp.h"
 #include "xvmc_internal.h"
 #include "thread.h"
 #include <limits.h>
index dfd8b28..a0114fd 100644 (file)
@@ -38,6 +38,7 @@
 #include "ratecontrol.h"
 #include "parser.h"
 #include "mpeg12data.h"
+#include "qpeldsp.h"
 #include "rl.h"
 #include "thread.h"
 #include "videodsp.h"
@@ -348,6 +349,7 @@ typedef struct MpegEncContext {
 
     DSPContext dsp;             ///< pointers for accelerated dsp functions
     HpelDSPContext hdsp;
+    QpelDSPContext qdsp;
     VideoDSPContext vdsp;
     H263DSPContext h263dsp;
     int f_code;                 ///< forward MV resolution
index c6b7cc8..3550fde 100644 (file)
@@ -46,6 +46,7 @@
 #include "mpegutils.h"
 #include "mjpegenc.h"
 #include "msmpeg4.h"
+#include "qpeldsp.h"
 #include "faandct.h"
 #include "thread.h"
 #include "aandcttab.h"
@@ -687,6 +688,8 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
     if (ARCH_X86)
         ff_MPV_encode_init_x86(s);
 
+    ff_qpeldsp_init(&s->qdsp);
+
     s->avctx->coded_frame = s->current_picture.f;
 
     if (s->msmpeg4_version) {
@@ -1944,10 +1947,10 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
 
         if ((!s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
             op_pix  = s->hdsp.put_pixels_tab;
-            op_qpix = s->dsp.put_qpel_pixels_tab;
+            op_qpix = s->qdsp.put_qpel_pixels_tab;
         } else {
             op_pix  = s->hdsp.put_no_rnd_pixels_tab;
-            op_qpix = s->dsp.put_no_rnd_qpel_pixels_tab;
+            op_qpix = s->qdsp.put_no_rnd_qpel_pixels_tab;
         }
 
         if (s->mv_dir & MV_DIR_FORWARD) {
@@ -1955,7 +1958,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
                           s->last_picture.f->data,
                           op_pix, op_qpix);
             op_pix  = s->hdsp.avg_pixels_tab;
-            op_qpix = s->dsp.avg_qpel_pixels_tab;
+            op_qpix = s->qdsp.avg_qpel_pixels_tab;
         }
         if (s->mv_dir & MV_DIR_BACKWARD) {
             ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 1,
index 1289da1..c57a26d 100644 (file)
@@ -31,6 +31,7 @@
 #include "mpegvideo.h"
 #include "mjpegenc.h"
 #include "msmpeg4.h"
+#include "qpeldsp.h"
 #include <limits.h>
 
 static void gmc1_motion(MpegEncContext *s,
index 6f9391f..1f5dcc3 100644 (file)
@@ -27,6 +27,7 @@
 #include "error_resilience.h"
 #include "internal.h"
 #include "msmpeg4data.h"
+#include "qpeldsp.h"
 #include "vc1.h"
 #include "mss12.h"
 #include "mss2dsp.h"
@@ -37,6 +38,7 @@ typedef struct MSS2Context {
     AVFrame       *last_pic;
     MSS12Context   c;
     MSS2DSPContext dsp;
+    QpelDSPContext qdsp;
     SliceContext   sc[2];
 } MSS2Context;
 
@@ -787,8 +789,8 @@ static av_cold int wmv9_init(AVCodecContext *avctx)
         return ret;
 
     /* error concealment */
-    v->s.me.qpel_put = v->s.dsp.put_qpel_pixels_tab;
-    v->s.me.qpel_avg = v->s.dsp.avg_qpel_pixels_tab;
+    v->s.me.qpel_put = v->s.qdsp.put_qpel_pixels_tab;
+    v->s.me.qpel_avg = v->s.qdsp.avg_qpel_pixels_tab;
 
     return 0;
 }
@@ -827,6 +829,7 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx)
         return ret;
     }
     ff_mss2dsp_init(&ctx->dsp);
+    ff_qpeldsp_init(&ctx->qdsp);
 
     avctx->pix_fmt = c->free_colours == 127 ? AV_PIX_FMT_RGB555
                                             : AV_PIX_FMT_RGB24;
similarity index 98%
rename from libavcodec/dsputil_template.c
rename to libavcodec/qpel_template.c
index 7a8eb22..2106160 100644 (file)
@@ -1,9 +1,5 @@
 /*
- * DSP utils
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
+ * quarterpel DSP function templates
  *
  * This file is part of Libav.
  *
@@ -24,7 +20,7 @@
 
 /**
  * @file
- * DSP utils
+ * quarterpel DSP function templates
  */
 
 #define PIXOP2(OPNAME, OP)                                              \
similarity index 52%
copy from libavcodec/dsputil.c
copy to libavcodec/qpeldsp.c
index 89c0da4..7b51ce2 100644 (file)
@@ -1,9 +1,5 @@
 /*
- * DSP utils
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
+ * quarterpel DSP functions
  *
  * This file is part of Libav.
  *
 
 /**
  * @file
- * DSP utils
+ * quarterpel DSP functions
  */
 
+#include <stddef.h>
+#include <stdint.h>
+
+#include "config.h"
 #include "libavutil/attributes.h"
-#include "libavutil/imgutils.h"
-#include "avcodec.h"
 #include "copy_block.h"
-#include "dct.h"
-#include "dsputil.h"
-#include "simple_idct.h"
-#include "faandct.h"
-#include "faanidct.h"
-#include "imgconvert.h"
-#include "mathops.h"
-#include "mpegvideo.h"
-#include "config.h"
-
-uint32_t ff_square_tab[512] = { 0, };
-
-#define BIT_DEPTH 16
-#include "dsputilenc_template.c"
-#undef BIT_DEPTH
+#include "qpeldsp.h"
 
 #define BIT_DEPTH 8
 #include "hpel_template.c"
 #include "tpel_template.c"
-#include "dsputil_template.c"
-#include "dsputilenc_template.c"
-
-/* Input permutation for the simple_idct_mmx */
-static const uint8_t simple_mmx_permutation[64] = {
-    0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
-    0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
-    0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
-    0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
-    0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
-    0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
-    0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
-    0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
-};
-
-static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 };
-
-av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st,
-                               const uint8_t *src_scantable)
-{
-    int i, end;
-
-    st->scantable = src_scantable;
-
-    for (i = 0; i < 64; i++) {
-        int j = src_scantable[i];
-        st->permutated[i] = permutation[j];
-    }
-
-    end = -1;
-    for (i = 0; i < 64; i++) {
-        int j = st->permutated[i];
-        if (j > end)
-            end = j;
-        st->raster_end[i] = end;
-    }
-}
-
-av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
-                                           int idct_permutation_type)
-{
-    int i;
-
-    switch (idct_permutation_type) {
-    case FF_NO_IDCT_PERM:
-        for (i = 0; i < 64; i++)
-            idct_permutation[i] = i;
-        break;
-    case FF_LIBMPEG2_IDCT_PERM:
-        for (i = 0; i < 64; i++)
-            idct_permutation[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
-        break;
-    case FF_SIMPLE_IDCT_PERM:
-        for (i = 0; i < 64; i++)
-            idct_permutation[i] = simple_mmx_permutation[i];
-        break;
-    case FF_TRANSPOSE_IDCT_PERM:
-        for (i = 0; i < 64; i++)
-            idct_permutation[i] = ((i & 7) << 3) | (i >> 3);
-        break;
-    case FF_PARTTRANS_IDCT_PERM:
-        for (i = 0; i < 64; i++)
-            idct_permutation[i] = (i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3);
-        break;
-    case FF_SSE2_IDCT_PERM:
-        for (i = 0; i < 64; i++)
-            idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7];
-        break;
-    default:
-        av_log(NULL, AV_LOG_ERROR,
-               "Internal error, IDCT permutation not set\n");
-    }
-}
-
-static int pix_sum_c(uint8_t *pix, int line_size)
-{
-    int s = 0, i, j;
-
-    for (i = 0; i < 16; i++) {
-        for (j = 0; j < 16; j += 8) {
-            s   += pix[0];
-            s   += pix[1];
-            s   += pix[2];
-            s   += pix[3];
-            s   += pix[4];
-            s   += pix[5];
-            s   += pix[6];
-            s   += pix[7];
-            pix += 8;
-        }
-        pix += line_size - 16;
-    }
-    return s;
-}
-
-static int pix_norm1_c(uint8_t *pix, int line_size)
-{
-    int s = 0, i, j;
-    uint32_t *sq = ff_square_tab + 256;
-
-    for (i = 0; i < 16; i++) {
-        for (j = 0; j < 16; j += 8) {
-#if 0
-            s += sq[pix[0]];
-            s += sq[pix[1]];
-            s += sq[pix[2]];
-            s += sq[pix[3]];
-            s += sq[pix[4]];
-            s += sq[pix[5]];
-            s += sq[pix[6]];
-            s += sq[pix[7]];
-#else
-#if HAVE_FAST_64BIT
-            register uint64_t x = *(uint64_t *) pix;
-            s += sq[x         & 0xff];
-            s += sq[(x >>  8) & 0xff];
-            s += sq[(x >> 16) & 0xff];
-            s += sq[(x >> 24) & 0xff];
-            s += sq[(x >> 32) & 0xff];
-            s += sq[(x >> 40) & 0xff];
-            s += sq[(x >> 48) & 0xff];
-            s += sq[(x >> 56) & 0xff];
-#else
-            register uint32_t x = *(uint32_t *) pix;
-            s += sq[x         & 0xff];
-            s += sq[(x >>  8) & 0xff];
-            s += sq[(x >> 16) & 0xff];
-            s += sq[(x >> 24) & 0xff];
-            x  = *(uint32_t *) (pix + 4);
-            s += sq[x         & 0xff];
-            s += sq[(x >>  8) & 0xff];
-            s += sq[(x >> 16) & 0xff];
-            s += sq[(x >> 24) & 0xff];
-#endif
-#endif
-            pix += 8;
-        }
-        pix += line_size - 16;
-    }
-    return s;
-}
-
-static void bswap_buf(uint32_t *dst, const uint32_t *src, int w)
-{
-    int i;
-
-    for (i = 0; i + 8 <= w; i += 8) {
-        dst[i + 0] = av_bswap32(src[i + 0]);
-        dst[i + 1] = av_bswap32(src[i + 1]);
-        dst[i + 2] = av_bswap32(src[i + 2]);
-        dst[i + 3] = av_bswap32(src[i + 3]);
-        dst[i + 4] = av_bswap32(src[i + 4]);
-        dst[i + 5] = av_bswap32(src[i + 5]);
-        dst[i + 6] = av_bswap32(src[i + 6]);
-        dst[i + 7] = av_bswap32(src[i + 7]);
-    }
-    for (; i < w; i++)
-        dst[i + 0] = av_bswap32(src[i + 0]);
-}
-
-static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len)
-{
-    while (len--)
-        *dst++ = av_bswap16(*src++);
-}
-
-static int sse4_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
-                  int line_size, int h)
-{
-    int s = 0, i;
-    uint32_t *sq = ff_square_tab + 256;
-
-    for (i = 0; i < h; i++) {
-        s    += sq[pix1[0] - pix2[0]];
-        s    += sq[pix1[1] - pix2[1]];
-        s    += sq[pix1[2] - pix2[2]];
-        s    += sq[pix1[3] - pix2[3]];
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int sse8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
-                  int line_size, int h)
-{
-    int s = 0, i;
-    uint32_t *sq = ff_square_tab + 256;
-
-    for (i = 0; i < h; i++) {
-        s    += sq[pix1[0] - pix2[0]];
-        s    += sq[pix1[1] - pix2[1]];
-        s    += sq[pix1[2] - pix2[2]];
-        s    += sq[pix1[3] - pix2[3]];
-        s    += sq[pix1[4] - pix2[4]];
-        s    += sq[pix1[5] - pix2[5]];
-        s    += sq[pix1[6] - pix2[6]];
-        s    += sq[pix1[7] - pix2[7]];
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int sse16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
-                   int line_size, int h)
-{
-    int s = 0, i;
-    uint32_t *sq = ff_square_tab + 256;
-
-    for (i = 0; i < h; i++) {
-        s += sq[pix1[0]  - pix2[0]];
-        s += sq[pix1[1]  - pix2[1]];
-        s += sq[pix1[2]  - pix2[2]];
-        s += sq[pix1[3]  - pix2[3]];
-        s += sq[pix1[4]  - pix2[4]];
-        s += sq[pix1[5]  - pix2[5]];
-        s += sq[pix1[6]  - pix2[6]];
-        s += sq[pix1[7]  - pix2[7]];
-        s += sq[pix1[8]  - pix2[8]];
-        s += sq[pix1[9]  - pix2[9]];
-        s += sq[pix1[10] - pix2[10]];
-        s += sq[pix1[11] - pix2[11]];
-        s += sq[pix1[12] - pix2[12]];
-        s += sq[pix1[13] - pix2[13]];
-        s += sq[pix1[14] - pix2[14]];
-        s += sq[pix1[15] - pix2[15]];
-
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static void diff_pixels_c(int16_t *restrict block, const uint8_t *s1,
-                          const uint8_t *s2, int stride)
-{
-    int i;
-
-    /* read the pixels */
-    for (i = 0; i < 8; i++) {
-        block[0] = s1[0] - s2[0];
-        block[1] = s1[1] - s2[1];
-        block[2] = s1[2] - s2[2];
-        block[3] = s1[3] - s2[3];
-        block[4] = s1[4] - s2[4];
-        block[5] = s1[5] - s2[5];
-        block[6] = s1[6] - s2[6];
-        block[7] = s1[7] - s2[7];
-        s1      += stride;
-        s2      += stride;
-        block   += 8;
-    }
-}
-
-static void put_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
-                                 int line_size)
-{
-    int i;
-
-    /* read the pixels */
-    for (i = 0; i < 8; i++) {
-        pixels[0] = av_clip_uint8(block[0]);
-        pixels[1] = av_clip_uint8(block[1]);
-        pixels[2] = av_clip_uint8(block[2]);
-        pixels[3] = av_clip_uint8(block[3]);
-        pixels[4] = av_clip_uint8(block[4]);
-        pixels[5] = av_clip_uint8(block[5]);
-        pixels[6] = av_clip_uint8(block[6]);
-        pixels[7] = av_clip_uint8(block[7]);
-
-        pixels += line_size;
-        block  += 8;
-    }
-}
-
-static void put_signed_pixels_clamped_c(const int16_t *block,
-                                        uint8_t *restrict pixels,
-                                        int line_size)
-{
-    int i, j;
-
-    for (i = 0; i < 8; i++) {
-        for (j = 0; j < 8; j++) {
-            if (*block < -128)
-                *pixels = 0;
-            else if (*block > 127)
-                *pixels = 255;
-            else
-                *pixels = (uint8_t) (*block + 128);
-            block++;
-            pixels++;
-        }
-        pixels += (line_size - 8);
-    }
-}
-
-static void add_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
-                                 int line_size)
-{
-    int i;
-
-    /* read the pixels */
-    for (i = 0; i < 8; i++) {
-        pixels[0] = av_clip_uint8(pixels[0] + block[0]);
-        pixels[1] = av_clip_uint8(pixels[1] + block[1]);
-        pixels[2] = av_clip_uint8(pixels[2] + block[2]);
-        pixels[3] = av_clip_uint8(pixels[3] + block[3]);
-        pixels[4] = av_clip_uint8(pixels[4] + block[4]);
-        pixels[5] = av_clip_uint8(pixels[5] + block[5]);
-        pixels[6] = av_clip_uint8(pixels[6] + block[6]);
-        pixels[7] = av_clip_uint8(pixels[7] + block[7]);
-        pixels   += line_size;
-        block    += 8;
-    }
-}
-
-static int sum_abs_dctelem_c(int16_t *block)
-{
-    int sum = 0, i;
-
-    for (i = 0; i < 64; i++)
-        sum += FFABS(block[i]);
-    return sum;
-}
-
-static void fill_block16_c(uint8_t *block, uint8_t value, int line_size, int h)
-{
-    int i;
-
-    for (i = 0; i < h; i++) {
-        memset(block, value, 16);
-        block += line_size;
-    }
-}
-
-static void fill_block8_c(uint8_t *block, uint8_t value, int line_size, int h)
-{
-    int i;
-
-    for (i = 0; i < h; i++) {
-        memset(block, value, 8);
-        block += line_size;
-    }
-}
-
-#define avg2(a, b) ((a + b + 1) >> 1)
-#define avg4(a, b, c, d) ((a + b + c + d + 2) >> 2)
-
-static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h,
-                   int x16, int y16, int rounder)
-{
-    const int A = (16 - x16) * (16 - y16);
-    const int B = (x16)      * (16 - y16);
-    const int C = (16 - x16) * (y16);
-    const int D = (x16)      * (y16);
-    int i;
-
-    for (i = 0; i < h; i++) {
-        dst[0] = (A * src[0] + B * src[1] + C * src[stride + 0] + D * src[stride + 1] + rounder) >> 8;
-        dst[1] = (A * src[1] + B * src[2] + C * src[stride + 1] + D * src[stride + 2] + rounder) >> 8;
-        dst[2] = (A * src[2] + B * src[3] + C * src[stride + 2] + D * src[stride + 3] + rounder) >> 8;
-        dst[3] = (A * src[3] + B * src[4] + C * src[stride + 3] + D * src[stride + 4] + rounder) >> 8;
-        dst[4] = (A * src[4] + B * src[5] + C * src[stride + 4] + D * src[stride + 5] + rounder) >> 8;
-        dst[5] = (A * src[5] + B * src[6] + C * src[stride + 5] + D * src[stride + 6] + rounder) >> 8;
-        dst[6] = (A * src[6] + B * src[7] + C * src[stride + 6] + D * src[stride + 7] + rounder) >> 8;
-        dst[7] = (A * src[7] + B * src[8] + C * src[stride + 7] + D * src[stride + 8] + rounder) >> 8;
-        dst   += stride;
-        src   += stride;
-    }
-}
-
-void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
-              int dxx, int dxy, int dyx, int dyy, int shift, int r,
-              int width, int height)
-{
-    int y, vx, vy;
-    const int s = 1 << shift;
-
-    width--;
-    height--;
-
-    for (y = 0; y < h; y++) {
-        int x;
-
-        vx = ox;
-        vy = oy;
-        for (x = 0; x < 8; x++) { // FIXME: optimize
-            int index;
-            int src_x  = vx >> 16;
-            int src_y  = vy >> 16;
-            int frac_x = src_x & (s - 1);
-            int frac_y = src_y & (s - 1);
-
-            src_x >>= shift;
-            src_y >>= shift;
-
-            if ((unsigned) src_x < width) {
-                if ((unsigned) src_y < height) {
-                    index = src_x + src_y * stride;
-                    dst[y * stride + x] =
-                        ((src[index]                        * (s - frac_x) +
-                          src[index + 1]          * frac_x) * (s - frac_y) +
-                         (src[index + stride]               * (s - frac_x) +
-                          src[index + stride + 1] * frac_x) *      frac_y  +
-                         r) >> (shift * 2);
-                } else {
-                    index = src_x + av_clip(src_y, 0, height) * stride;
-                    dst[y * stride + x] =
-                        ((src[index]               * (s - frac_x) +
-                          src[index + 1] * frac_x) *  s           +
-                         r) >> (shift * 2);
-                }
-            } else {
-                if ((unsigned) src_y < height) {
-                    index = av_clip(src_x, 0, width) + src_y * stride;
-                    dst[y * stride + x] =
-                        ((src[index]                    * (s - frac_y) +
-                          src[index + stride] * frac_y) *  s           +
-                         r) >> (shift * 2);
-                } else {
-                    index = av_clip(src_x, 0, width) +
-                            av_clip(src_y, 0, height) * stride;
-                    dst[y * stride + x] = src[index];
-                }
-            }
-
-            vx += dxx;
-            vy += dyx;
-        }
-        ox += dxy;
-        oy += dyy;
-    }
-}
+#include "qpel_template.c"
 
 #define QPEL_MC(r, OPNAME, RND, OP)                                           \
 static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src,       \
@@ -1133,7 +684,6 @@ static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src,               \
 }
 
 #define op_avg(a, b)        a = (((a) + cm[((b) + 16) >> 5] + 1) >> 1)
-#define op_avg_no_rnd(a, b) a = (((a) + cm[((b) + 15) >> 5])     >> 1)
 #define op_put(a, b)        a = cm[((b) + 16) >> 5]
 #define op_put_no_rnd(a, b) a = cm[((b) + 15) >> 5]
 
@@ -1180,1024 +730,8 @@ void ff_put_pixels8_l2_8(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
 
 }
 
-static inline int pix_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
-                              int line_size, int h)
-{
-    int s = 0, i;
-
-    for (i = 0; i < h; i++) {
-        s    += abs(pix1[0]  - pix2[0]);
-        s    += abs(pix1[1]  - pix2[1]);
-        s    += abs(pix1[2]  - pix2[2]);
-        s    += abs(pix1[3]  - pix2[3]);
-        s    += abs(pix1[4]  - pix2[4]);
-        s    += abs(pix1[5]  - pix2[5]);
-        s    += abs(pix1[6]  - pix2[6]);
-        s    += abs(pix1[7]  - pix2[7]);
-        s    += abs(pix1[8]  - pix2[8]);
-        s    += abs(pix1[9]  - pix2[9]);
-        s    += abs(pix1[10] - pix2[10]);
-        s    += abs(pix1[11] - pix2[11]);
-        s    += abs(pix1[12] - pix2[12]);
-        s    += abs(pix1[13] - pix2[13]);
-        s    += abs(pix1[14] - pix2[14]);
-        s    += abs(pix1[15] - pix2[15]);
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs16_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
-                          int line_size, int h)
-{
-    int s = 0, i;
-
-    for (i = 0; i < h; i++) {
-        s    += abs(pix1[0]  - avg2(pix2[0],  pix2[1]));
-        s    += abs(pix1[1]  - avg2(pix2[1],  pix2[2]));
-        s    += abs(pix1[2]  - avg2(pix2[2],  pix2[3]));
-        s    += abs(pix1[3]  - avg2(pix2[3],  pix2[4]));
-        s    += abs(pix1[4]  - avg2(pix2[4],  pix2[5]));
-        s    += abs(pix1[5]  - avg2(pix2[5],  pix2[6]));
-        s    += abs(pix1[6]  - avg2(pix2[6],  pix2[7]));
-        s    += abs(pix1[7]  - avg2(pix2[7],  pix2[8]));
-        s    += abs(pix1[8]  - avg2(pix2[8],  pix2[9]));
-        s    += abs(pix1[9]  - avg2(pix2[9],  pix2[10]));
-        s    += abs(pix1[10] - avg2(pix2[10], pix2[11]));
-        s    += abs(pix1[11] - avg2(pix2[11], pix2[12]));
-        s    += abs(pix1[12] - avg2(pix2[12], pix2[13]));
-        s    += abs(pix1[13] - avg2(pix2[13], pix2[14]));
-        s    += abs(pix1[14] - avg2(pix2[14], pix2[15]));
-        s    += abs(pix1[15] - avg2(pix2[15], pix2[16]));
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs16_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
-                          int line_size, int h)
-{
-    int s = 0, i;
-    uint8_t *pix3 = pix2 + line_size;
-
-    for (i = 0; i < h; i++) {
-        s    += abs(pix1[0]  - avg2(pix2[0],  pix3[0]));
-        s    += abs(pix1[1]  - avg2(pix2[1],  pix3[1]));
-        s    += abs(pix1[2]  - avg2(pix2[2],  pix3[2]));
-        s    += abs(pix1[3]  - avg2(pix2[3],  pix3[3]));
-        s    += abs(pix1[4]  - avg2(pix2[4],  pix3[4]));
-        s    += abs(pix1[5]  - avg2(pix2[5],  pix3[5]));
-        s    += abs(pix1[6]  - avg2(pix2[6],  pix3[6]));
-        s    += abs(pix1[7]  - avg2(pix2[7],  pix3[7]));
-        s    += abs(pix1[8]  - avg2(pix2[8],  pix3[8]));
-        s    += abs(pix1[9]  - avg2(pix2[9],  pix3[9]));
-        s    += abs(pix1[10] - avg2(pix2[10], pix3[10]));
-        s    += abs(pix1[11] - avg2(pix2[11], pix3[11]));
-        s    += abs(pix1[12] - avg2(pix2[12], pix3[12]));
-        s    += abs(pix1[13] - avg2(pix2[13], pix3[13]));
-        s    += abs(pix1[14] - avg2(pix2[14], pix3[14]));
-        s    += abs(pix1[15] - avg2(pix2[15], pix3[15]));
-        pix1 += line_size;
-        pix2 += line_size;
-        pix3 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs16_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
-                           int line_size, int h)
-{
-    int s = 0, i;
-    uint8_t *pix3 = pix2 + line_size;
-
-    for (i = 0; i < h; i++) {
-        s    += abs(pix1[0]  - avg4(pix2[0],  pix2[1],  pix3[0],  pix3[1]));
-        s    += abs(pix1[1]  - avg4(pix2[1],  pix2[2],  pix3[1],  pix3[2]));
-        s    += abs(pix1[2]  - avg4(pix2[2],  pix2[3],  pix3[2],  pix3[3]));
-        s    += abs(pix1[3]  - avg4(pix2[3],  pix2[4],  pix3[3],  pix3[4]));
-        s    += abs(pix1[4]  - avg4(pix2[4],  pix2[5],  pix3[4],  pix3[5]));
-        s    += abs(pix1[5]  - avg4(pix2[5],  pix2[6],  pix3[5],  pix3[6]));
-        s    += abs(pix1[6]  - avg4(pix2[6],  pix2[7],  pix3[6],  pix3[7]));
-        s    += abs(pix1[7]  - avg4(pix2[7],  pix2[8],  pix3[7],  pix3[8]));
-        s    += abs(pix1[8]  - avg4(pix2[8],  pix2[9],  pix3[8],  pix3[9]));
-        s    += abs(pix1[9]  - avg4(pix2[9],  pix2[10], pix3[9],  pix3[10]));
-        s    += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11]));
-        s    += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12]));
-        s    += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13]));
-        s    += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14]));
-        s    += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15]));
-        s    += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16]));
-        pix1 += line_size;
-        pix2 += line_size;
-        pix3 += line_size;
-    }
-    return s;
-}
-
-static inline int pix_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
-                             int line_size, int h)
-{
-    int s = 0, i;
-
-    for (i = 0; i < h; i++) {
-        s    += abs(pix1[0] - pix2[0]);
-        s    += abs(pix1[1] - pix2[1]);
-        s    += abs(pix1[2] - pix2[2]);
-        s    += abs(pix1[3] - pix2[3]);
-        s    += abs(pix1[4] - pix2[4]);
-        s    += abs(pix1[5] - pix2[5]);
-        s    += abs(pix1[6] - pix2[6]);
-        s    += abs(pix1[7] - pix2[7]);
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs8_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
-                         int line_size, int h)
-{
-    int s = 0, i;
-
-    for (i = 0; i < h; i++) {
-        s    += abs(pix1[0] - avg2(pix2[0], pix2[1]));
-        s    += abs(pix1[1] - avg2(pix2[1], pix2[2]));
-        s    += abs(pix1[2] - avg2(pix2[2], pix2[3]));
-        s    += abs(pix1[3] - avg2(pix2[3], pix2[4]));
-        s    += abs(pix1[4] - avg2(pix2[4], pix2[5]));
-        s    += abs(pix1[5] - avg2(pix2[5], pix2[6]));
-        s    += abs(pix1[6] - avg2(pix2[6], pix2[7]));
-        s    += abs(pix1[7] - avg2(pix2[7], pix2[8]));
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs8_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
-                         int line_size, int h)
-{
-    int s = 0, i;
-    uint8_t *pix3 = pix2 + line_size;
-
-    for (i = 0; i < h; i++) {
-        s    += abs(pix1[0] - avg2(pix2[0], pix3[0]));
-        s    += abs(pix1[1] - avg2(pix2[1], pix3[1]));
-        s    += abs(pix1[2] - avg2(pix2[2], pix3[2]));
-        s    += abs(pix1[3] - avg2(pix2[3], pix3[3]));
-        s    += abs(pix1[4] - avg2(pix2[4], pix3[4]));
-        s    += abs(pix1[5] - avg2(pix2[5], pix3[5]));
-        s    += abs(pix1[6] - avg2(pix2[6], pix3[6]));
-        s    += abs(pix1[7] - avg2(pix2[7], pix3[7]));
-        pix1 += line_size;
-        pix2 += line_size;
-        pix3 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs8_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
-                          int line_size, int h)
+av_cold void ff_qpeldsp_init(QpelDSPContext *c)
 {
-    int s = 0, i;
-    uint8_t *pix3 = pix2 + line_size;
-
-    for (i = 0; i < h; i++) {
-        s    += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
-        s    += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
-        s    += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
-        s    += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
-        s    += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
-        s    += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
-        s    += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
-        s    += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
-        pix1 += line_size;
-        pix2 += line_size;
-        pix3 += line_size;
-    }
-    return s;
-}
-
-static int nsse16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, int stride, int h)
-{
-    int score1 = 0, score2 = 0, x, y;
-
-    for (y = 0; y < h; y++) {
-        for (x = 0; x < 16; x++)
-            score1 += (s1[x] - s2[x]) * (s1[x] - s2[x]);
-        if (y + 1 < h) {
-            for (x = 0; x < 15; x++)
-                score2 += FFABS(s1[x]     - s1[x + stride] -
-                                s1[x + 1] + s1[x + stride + 1]) -
-                          FFABS(s2[x]     - s2[x + stride] -
-                                s2[x + 1] + s2[x + stride + 1]);
-        }
-        s1 += stride;
-        s2 += stride;
-    }
-
-    if (c)
-        return score1 + FFABS(score2) * c->avctx->nsse_weight;
-    else
-        return score1 + FFABS(score2) * 8;
-}
-
-static int nsse8_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, int stride, int h)
-{
-    int score1 = 0, score2 = 0, x, y;
-
-    for (y = 0; y < h; y++) {
-        for (x = 0; x < 8; x++)
-            score1 += (s1[x] - s2[x]) * (s1[x] - s2[x]);
-        if (y + 1 < h) {
-            for (x = 0; x < 7; x++)
-                score2 += FFABS(s1[x]     - s1[x + stride] -
-                                s1[x + 1] + s1[x + stride + 1]) -
-                          FFABS(s2[x]     - s2[x + stride] -
-                                s2[x + 1] + s2[x + stride + 1]);
-        }
-        s1 += stride;
-        s2 += stride;
-    }
-
-    if (c)
-        return score1 + FFABS(score2) * c->avctx->nsse_weight;
-    else
-        return score1 + FFABS(score2) * 8;
-}
-
-static int try_8x8basis_c(int16_t rem[64], int16_t weight[64],
-                          int16_t basis[64], int scale)
-{
-    int i;
-    unsigned int sum = 0;
-
-    for (i = 0; i < 8 * 8; i++) {
-        int b = rem[i] + ((basis[i] * scale +
-                           (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >>
-                          (BASIS_SHIFT - RECON_SHIFT));
-        int w = weight[i];
-        b >>= RECON_SHIFT;
-        assert(-512 < b && b < 512);
-
-        sum += (w * b) * (w * b) >> 4;
-    }
-    return sum >> 2;
-}
-
-static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale)
-{
-    int i;
-
-    for (i = 0; i < 8 * 8; i++)
-        rem[i] += (basis[i] * scale +
-                   (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >>
-                  (BASIS_SHIFT - RECON_SHIFT);
-}
-
-static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b,
-                    int stride, int h)
-{
-    return 0;
-}
-
-void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type)
-{
-    int i;
-
-    memset(cmp, 0, sizeof(void *) * 6);
-
-    for (i = 0; i < 6; i++) {
-        switch (type & 0xFF) {
-        case FF_CMP_SAD:
-            cmp[i] = c->sad[i];
-            break;
-        case FF_CMP_SATD:
-            cmp[i] = c->hadamard8_diff[i];
-            break;
-        case FF_CMP_SSE:
-            cmp[i] = c->sse[i];
-            break;
-        case FF_CMP_DCT:
-            cmp[i] = c->dct_sad[i];
-            break;
-        case FF_CMP_DCT264:
-            cmp[i] = c->dct264_sad[i];
-            break;
-        case FF_CMP_DCTMAX:
-            cmp[i] = c->dct_max[i];
-            break;
-        case FF_CMP_PSNR:
-            cmp[i] = c->quant_psnr[i];
-            break;
-        case FF_CMP_BIT:
-            cmp[i] = c->bit[i];
-            break;
-        case FF_CMP_RD:
-            cmp[i] = c->rd[i];
-            break;
-        case FF_CMP_VSAD:
-            cmp[i] = c->vsad[i];
-            break;
-        case FF_CMP_VSSE:
-            cmp[i] = c->vsse[i];
-            break;
-        case FF_CMP_ZERO:
-            cmp[i] = zero_cmp;
-            break;
-        case FF_CMP_NSSE:
-            cmp[i] = c->nsse[i];
-            break;
-        default:
-            av_log(NULL, AV_LOG_ERROR,
-                   "internal error in cmp function selection\n");
-        }
-    }
-}
-
-#define BUTTERFLY2(o1, o2, i1, i2)              \
-    o1 = (i1) + (i2);                           \
-    o2 = (i1) - (i2);
-
-#define BUTTERFLY1(x, y)                        \
-    {                                           \
-        int a, b;                               \
-        a = x;                                  \
-        b = y;                                  \
-        x = a + b;                              \
-        y = a - b;                              \
-    }
-
-#define BUTTERFLYA(x, y) (FFABS((x) + (y)) + FFABS((x) - (y)))
-
-static int hadamard8_diff8x8_c(MpegEncContext *s, uint8_t *dst,
-                               uint8_t *src, int stride, int h)
-{
-    int i, temp[64], sum = 0;
-
-    assert(h == 8);
-
-    for (i = 0; i < 8; i++) {
-        // FIXME: try pointer walks
-        BUTTERFLY2(temp[8 * i + 0], temp[8 * i + 1],
-                   src[stride * i + 0] - dst[stride * i + 0],
-                   src[stride * i + 1] - dst[stride * i + 1]);
-        BUTTERFLY2(temp[8 * i + 2], temp[8 * i + 3],
-                   src[stride * i + 2] - dst[stride * i + 2],
-                   src[stride * i + 3] - dst[stride * i + 3]);
-        BUTTERFLY2(temp[8 * i + 4], temp[8 * i + 5],
-                   src[stride * i + 4] - dst[stride * i + 4],
-                   src[stride * i + 5] - dst[stride * i + 5]);
-        BUTTERFLY2(temp[8 * i + 6], temp[8 * i + 7],
-                   src[stride * i + 6] - dst[stride * i + 6],
-                   src[stride * i + 7] - dst[stride * i + 7]);
-
-        BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 2]);
-        BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 3]);
-        BUTTERFLY1(temp[8 * i + 4], temp[8 * i + 6]);
-        BUTTERFLY1(temp[8 * i + 5], temp[8 * i + 7]);
-
-        BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 4]);
-        BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 5]);
-        BUTTERFLY1(temp[8 * i + 2], temp[8 * i + 6]);
-        BUTTERFLY1(temp[8 * i + 3], temp[8 * i + 7]);
-    }
-
-    for (i = 0; i < 8; i++) {
-        BUTTERFLY1(temp[8 * 0 + i], temp[8 * 1 + i]);
-        BUTTERFLY1(temp[8 * 2 + i], temp[8 * 3 + i]);
-        BUTTERFLY1(temp[8 * 4 + i], temp[8 * 5 + i]);
-        BUTTERFLY1(temp[8 * 6 + i], temp[8 * 7 + i]);
-
-        BUTTERFLY1(temp[8 * 0 + i], temp[8 * 2 + i]);
-        BUTTERFLY1(temp[8 * 1 + i], temp[8 * 3 + i]);
-        BUTTERFLY1(temp[8 * 4 + i], temp[8 * 6 + i]);
-        BUTTERFLY1(temp[8 * 5 + i], temp[8 * 7 + i]);
-
-        sum += BUTTERFLYA(temp[8 * 0 + i], temp[8 * 4 + i]) +
-               BUTTERFLYA(temp[8 * 1 + i], temp[8 * 5 + i]) +
-               BUTTERFLYA(temp[8 * 2 + i], temp[8 * 6 + i]) +
-               BUTTERFLYA(temp[8 * 3 + i], temp[8 * 7 + i]);
-    }
-    return sum;
-}
-
-static int hadamard8_intra8x8_c(MpegEncContext *s, uint8_t *src,
-                                uint8_t *dummy, int stride, int h)
-{
-    int i, temp[64], sum = 0;
-
-    assert(h == 8);
-
-    for (i = 0; i < 8; i++) {
-        // FIXME: try pointer walks
-        BUTTERFLY2(temp[8 * i + 0], temp[8 * i + 1],
-                   src[stride * i + 0], src[stride * i + 1]);
-        BUTTERFLY2(temp[8 * i + 2], temp[8 * i + 3],
-                   src[stride * i + 2], src[stride * i + 3]);
-        BUTTERFLY2(temp[8 * i + 4], temp[8 * i + 5],
-                   src[stride * i + 4], src[stride * i + 5]);
-        BUTTERFLY2(temp[8 * i + 6], temp[8 * i + 7],
-                   src[stride * i + 6], src[stride * i + 7]);
-
-        BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 2]);
-        BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 3]);
-        BUTTERFLY1(temp[8 * i + 4], temp[8 * i + 6]);
-        BUTTERFLY1(temp[8 * i + 5], temp[8 * i + 7]);
-
-        BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 4]);
-        BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 5]);
-        BUTTERFLY1(temp[8 * i + 2], temp[8 * i + 6]);
-        BUTTERFLY1(temp[8 * i + 3], temp[8 * i + 7]);
-    }
-
-    for (i = 0; i < 8; i++) {
-        BUTTERFLY1(temp[8 * 0 + i], temp[8 * 1 + i]);
-        BUTTERFLY1(temp[8 * 2 + i], temp[8 * 3 + i]);
-        BUTTERFLY1(temp[8 * 4 + i], temp[8 * 5 + i]);
-        BUTTERFLY1(temp[8 * 6 + i], temp[8 * 7 + i]);
-
-        BUTTERFLY1(temp[8 * 0 + i], temp[8 * 2 + i]);
-        BUTTERFLY1(temp[8 * 1 + i], temp[8 * 3 + i]);
-        BUTTERFLY1(temp[8 * 4 + i], temp[8 * 6 + i]);
-        BUTTERFLY1(temp[8 * 5 + i], temp[8 * 7 + i]);
-
-        sum +=
-            BUTTERFLYA(temp[8 * 0 + i], temp[8 * 4 + i])
-            + BUTTERFLYA(temp[8 * 1 + i], temp[8 * 5 + i])
-            + BUTTERFLYA(temp[8 * 2 + i], temp[8 * 6 + i])
-            + BUTTERFLYA(temp[8 * 3 + i], temp[8 * 7 + i]);
-    }
-
-    sum -= FFABS(temp[8 * 0] + temp[8 * 4]); // -mean
-
-    return sum;
-}
-
-static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1,
-                        uint8_t *src2, int stride, int h)
-{
-    LOCAL_ALIGNED_16(int16_t, temp, [64]);
-
-    assert(h == 8);
-
-    s->dsp.diff_pixels(temp, src1, src2, stride);
-    s->dsp.fdct(temp);
-    return s->dsp.sum_abs_dctelem(temp);
-}
-
-#if CONFIG_GPL
-#define DCT8_1D                                         \
-    {                                                   \
-        const int s07 = SRC(0) + SRC(7);                \
-        const int s16 = SRC(1) + SRC(6);                \
-        const int s25 = SRC(2) + SRC(5);                \
-        const int s34 = SRC(3) + SRC(4);                \
-        const int a0  = s07 + s34;                      \
-        const int a1  = s16 + s25;                      \
-        const int a2  = s07 - s34;                      \
-        const int a3  = s16 - s25;                      \
-        const int d07 = SRC(0) - SRC(7);                \
-        const int d16 = SRC(1) - SRC(6);                \
-        const int d25 = SRC(2) - SRC(5);                \
-        const int d34 = SRC(3) - SRC(4);                \
-        const int a4  = d16 + d25 + (d07 + (d07 >> 1)); \
-        const int a5  = d07 - d34 - (d25 + (d25 >> 1)); \
-        const int a6  = d07 + d34 - (d16 + (d16 >> 1)); \
-        const int a7  = d16 - d25 + (d34 + (d34 >> 1)); \
-        DST(0, a0 + a1);                                \
-        DST(1, a4 + (a7 >> 2));                         \
-        DST(2, a2 + (a3 >> 1));                         \
-        DST(3, a5 + (a6 >> 2));                         \
-        DST(4, a0 - a1);                                \
-        DST(5, a6 - (a5 >> 2));                         \
-        DST(6, (a2 >> 1) - a3);                         \
-        DST(7, (a4 >> 2) - a7);                         \
-    }
-
-static int dct264_sad8x8_c(MpegEncContext *s, uint8_t *src1,
-                           uint8_t *src2, int stride, int h)
-{
-    int16_t dct[8][8];
-    int i, sum = 0;
-
-    s->dsp.diff_pixels(dct[0], src1, src2, stride);
-
-#define SRC(x) dct[i][x]
-#define DST(x, v) dct[i][x] = v
-    for (i = 0; i < 8; i++)
-        DCT8_1D
-#undef SRC
-#undef DST
-
-#define SRC(x) dct[x][i]
-#define DST(x, v) sum += FFABS(v)
-        for (i = 0; i < 8; i++)
-            DCT8_1D
-#undef SRC
-#undef DST
-            return sum;
-}
-#endif
-
-static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1,
-                        uint8_t *src2, int stride, int h)
-{
-    LOCAL_ALIGNED_16(int16_t, temp, [64]);
-    int sum = 0, i;
-
-    assert(h == 8);
-
-    s->dsp.diff_pixels(temp, src1, src2, stride);
-    s->dsp.fdct(temp);
-
-    for (i = 0; i < 64; i++)
-        sum = FFMAX(sum, FFABS(temp[i]));
-
-    return sum;
-}
-
-static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1,
-                           uint8_t *src2, int stride, int h)
-{
-    LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]);
-    int16_t *const bak = temp + 64;
-    int sum = 0, i;
-
-    assert(h == 8);
-    s->mb_intra = 0;
-
-    s->dsp.diff_pixels(temp, src1, src2, stride);
-
-    memcpy(bak, temp, 64 * sizeof(int16_t));
-
-    s->block_last_index[0 /* FIXME */] =
-        s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
-    s->dct_unquantize_inter(s, temp, 0, s->qscale);
-    ff_simple_idct_8(temp); // FIXME
-
-    for (i = 0; i < 64; i++)
-        sum += (temp[i] - bak[i]) * (temp[i] - bak[i]);
-
-    return sum;
-}
-
-static int rd8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
-                   int stride, int h)
-{
-    const uint8_t *scantable = s->intra_scantable.permutated;
-    LOCAL_ALIGNED_16(int16_t, temp, [64]);
-    LOCAL_ALIGNED_16(uint8_t, lsrc1, [64]);
-    LOCAL_ALIGNED_16(uint8_t, lsrc2, [64]);
-    int i, last, run, bits, level, distortion, start_i;
-    const int esc_length = s->ac_esc_length;
-    uint8_t *length, *last_length;
-
-    assert(h == 8);
-
-    copy_block8(lsrc1, src1, 8, stride, 8);
-    copy_block8(lsrc2, src2, 8, stride, 8);
-
-    s->dsp.diff_pixels(temp, lsrc1, lsrc2, 8);
-
-    s->block_last_index[0 /* FIXME */] =
-    last                               =
-        s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
-
-    bits = 0;
-
-    if (s->mb_intra) {
-        start_i     = 1;
-        length      = s->intra_ac_vlc_length;
-        last_length = s->intra_ac_vlc_last_length;
-        bits       += s->luma_dc_vlc_length[temp[0] + 256]; // FIXME: chroma
-    } else {
-        start_i     = 0;
-        length      = s->inter_ac_vlc_length;
-        last_length = s->inter_ac_vlc_last_length;
-    }
-
-    if (last >= start_i) {
-        run = 0;
-        for (i = start_i; i < last; i++) {
-            int j = scantable[i];
-            level = temp[j];
-
-            if (level) {
-                level += 64;
-                if ((level & (~127)) == 0)
-                    bits += length[UNI_AC_ENC_INDEX(run, level)];
-                else
-                    bits += esc_length;
-                run = 0;
-            } else
-                run++;
-        }
-        i = scantable[last];
-
-        level = temp[i] + 64;
-
-        assert(level - 64);
-
-        if ((level & (~127)) == 0) {
-            bits += last_length[UNI_AC_ENC_INDEX(run, level)];
-        } else
-            bits += esc_length;
-    }
-
-    if (last >= 0) {
-        if (s->mb_intra)
-            s->dct_unquantize_intra(s, temp, 0, s->qscale);
-        else
-            s->dct_unquantize_inter(s, temp, 0, s->qscale);
-    }
-
-    s->dsp.idct_add(lsrc2, 8, temp);
-
-    distortion = s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);
-
-    return distortion + ((bits * s->qscale * s->qscale * 109 + 64) >> 7);
-}
-
-static int bit8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
-                    int stride, int h)
-{
-    const uint8_t *scantable = s->intra_scantable.permutated;
-    LOCAL_ALIGNED_16(int16_t, temp, [64]);
-    int i, last, run, bits, level, start_i;
-    const int esc_length = s->ac_esc_length;
-    uint8_t *length, *last_length;
-
-    assert(h == 8);
-
-    s->dsp.diff_pixels(temp, src1, src2, stride);
-
-    s->block_last_index[0 /* FIXME */] =
-    last                               =
-        s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
-
-    bits = 0;
-
-    if (s->mb_intra) {
-        start_i     = 1;
-        length      = s->intra_ac_vlc_length;
-        last_length = s->intra_ac_vlc_last_length;
-        bits       += s->luma_dc_vlc_length[temp[0] + 256]; // FIXME: chroma
-    } else {
-        start_i     = 0;
-        length      = s->inter_ac_vlc_length;
-        last_length = s->inter_ac_vlc_last_length;
-    }
-
-    if (last >= start_i) {
-        run = 0;
-        for (i = start_i; i < last; i++) {
-            int j = scantable[i];
-            level = temp[j];
-
-            if (level) {
-                level += 64;
-                if ((level & (~127)) == 0)
-                    bits += length[UNI_AC_ENC_INDEX(run, level)];
-                else
-                    bits += esc_length;
-                run = 0;
-            } else
-                run++;
-        }
-        i = scantable[last];
-
-        level = temp[i] + 64;
-
-        assert(level - 64);
-
-        if ((level & (~127)) == 0)
-            bits += last_length[UNI_AC_ENC_INDEX(run, level)];
-        else
-            bits += esc_length;
-    }
-
-    return bits;
-}
-
-#define VSAD_INTRA(size)                                                \
-static int vsad_intra ## size ## _c(MpegEncContext *c,                  \
-                                    uint8_t *s, uint8_t *dummy,         \
-                                    int stride, int h)                  \
-{                                                                       \
-    int score = 0, x, y;                                                \
-                                                                        \
-    for (y = 1; y < h; y++) {                                           \
-        for (x = 0; x < size; x += 4) {                                 \
-            score += FFABS(s[x]     - s[x + stride])     +              \
-                     FFABS(s[x + 1] - s[x + stride + 1]) +              \
-                     FFABS(s[x + 2] - s[x + 2 + stride]) +              \
-                     FFABS(s[x + 3] - s[x + 3 + stride]);               \
-        }                                                               \
-        s += stride;                                                    \
-    }                                                                   \
-                                                                        \
-    return score;                                                       \
-}
-VSAD_INTRA(8)
-VSAD_INTRA(16)
-
-static int vsad16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2,
-                    int stride, int h)
-{
-    int score = 0, x, y;
-
-    for (y = 1; y < h; y++) {
-        for (x = 0; x < 16; x++)
-            score += FFABS(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]);
-        s1 += stride;
-        s2 += stride;
-    }
-
-    return score;
-}
-
-#define SQ(a) ((a) * (a))
-#define VSSE_INTRA(size)                                                \
-static int vsse_intra ## size ## _c(MpegEncContext *c,                  \
-                                    uint8_t *s, uint8_t *dummy,         \
-                                    int stride, int h)                  \
-{                                                                       \
-    int score = 0, x, y;                                                \
-                                                                        \
-    for (y = 1; y < h; y++) {                                           \
-        for (x = 0; x < size; x += 4) {                                 \
-            score += SQ(s[x]     - s[x + stride]) +                     \
-                     SQ(s[x + 1] - s[x + stride + 1]) +                 \
-                     SQ(s[x + 2] - s[x + stride + 2]) +                 \
-                     SQ(s[x + 3] - s[x + stride + 3]);                  \
-        }                                                               \
-        s += stride;                                                    \
-    }                                                                   \
-                                                                        \
-    return score;                                                       \
-}
-VSSE_INTRA(8)
-VSSE_INTRA(16)
-
-static int vsse16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2,
-                    int stride, int h)
-{
-    int score = 0, x, y;
-
-    for (y = 1; y < h; y++) {
-        for (x = 0; x < 16; x++)
-            score += SQ(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]);
-        s1 += stride;
-        s2 += stride;
-    }
-
-    return score;
-}
-
-#define WRAPPER8_16_SQ(name8, name16)                                   \
-static int name16(MpegEncContext *s, uint8_t *dst, uint8_t *src,        \
-                  int stride, int h)                                    \
-{                                                                       \
-    int score = 0;                                                      \
-                                                                        \
-    score += name8(s, dst, src, stride, 8);                             \
-    score += name8(s, dst + 8, src + 8, stride, 8);                     \
-    if (h == 16) {                                                      \
-        dst   += 8 * stride;                                            \
-        src   += 8 * stride;                                            \
-        score += name8(s, dst, src, stride, 8);                         \
-        score += name8(s, dst + 8, src + 8, stride, 8);                 \
-    }                                                                   \
-    return score;                                                       \
-}
-
-WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
-WRAPPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
-WRAPPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
-#if CONFIG_GPL
-WRAPPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
-#endif
-WRAPPER8_16_SQ(dct_max8x8_c, dct_max16_c)
-WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
-WRAPPER8_16_SQ(rd8x8_c, rd16_c)
-WRAPPER8_16_SQ(bit8x8_c, bit16_c)
-
-static inline uint32_t clipf_c_one(uint32_t a, uint32_t mini,
-                                   uint32_t maxi, uint32_t maxisign)
-{
-    if (a > mini)
-        return mini;
-    else if ((a ^ (1U << 31)) > maxisign)
-        return maxi;
-    else
-        return a;
-}
-
-static void vector_clipf_c_opposite_sign(float *dst, const float *src,
-                                         float *min, float *max, int len)
-{
-    int i;
-    uint32_t mini        = *(uint32_t *) min;
-    uint32_t maxi        = *(uint32_t *) max;
-    uint32_t maxisign    = maxi ^ (1U << 31);
-    uint32_t *dsti       = (uint32_t *) dst;
-    const uint32_t *srci = (const uint32_t *) src;
-
-    for (i = 0; i < len; i += 8) {
-        dsti[i + 0] = clipf_c_one(srci[i + 0], mini, maxi, maxisign);
-        dsti[i + 1] = clipf_c_one(srci[i + 1], mini, maxi, maxisign);
-        dsti[i + 2] = clipf_c_one(srci[i + 2], mini, maxi, maxisign);
-        dsti[i + 3] = clipf_c_one(srci[i + 3], mini, maxi, maxisign);
-        dsti[i + 4] = clipf_c_one(srci[i + 4], mini, maxi, maxisign);
-        dsti[i + 5] = clipf_c_one(srci[i + 5], mini, maxi, maxisign);
-        dsti[i + 6] = clipf_c_one(srci[i + 6], mini, maxi, maxisign);
-        dsti[i + 7] = clipf_c_one(srci[i + 7], mini, maxi, maxisign);
-    }
-}
-
-static void vector_clipf_c(float *dst, const float *src,
-                           float min, float max, int len)
-{
-    int i;
-
-    if (min < 0 && max > 0) {
-        vector_clipf_c_opposite_sign(dst, src, &min, &max, len);
-    } else {
-        for (i = 0; i < len; i += 8) {
-            dst[i]     = av_clipf(src[i], min, max);
-            dst[i + 1] = av_clipf(src[i + 1], min, max);
-            dst[i + 2] = av_clipf(src[i + 2], min, max);
-            dst[i + 3] = av_clipf(src[i + 3], min, max);
-            dst[i + 4] = av_clipf(src[i + 4], min, max);
-            dst[i + 5] = av_clipf(src[i + 5], min, max);
-            dst[i + 6] = av_clipf(src[i + 6], min, max);
-            dst[i + 7] = av_clipf(src[i + 7], min, max);
-        }
-    }
-}
-
-static int32_t scalarproduct_int16_c(const int16_t *v1, const int16_t *v2,
-                                     int order)
-{
-    int res = 0;
-
-    while (order--)
-        res += *v1++ **v2++;
-
-    return res;
-}
-
-static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min,
-                                int32_t max, unsigned int len)
-{
-    do {
-        *dst++ = av_clip(*src++, min, max);
-        *dst++ = av_clip(*src++, min, max);
-        *dst++ = av_clip(*src++, min, max);
-        *dst++ = av_clip(*src++, min, max);
-        *dst++ = av_clip(*src++, min, max);
-        *dst++ = av_clip(*src++, min, max);
-        *dst++ = av_clip(*src++, min, max);
-        *dst++ = av_clip(*src++, min, max);
-        len   -= 8;
-    } while (len > 0);
-}
-
-static void jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
-{
-    ff_j_rev_dct(block);
-    put_pixels_clamped_c(block, dest, line_size);
-}
-
-static void jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
-{
-    ff_j_rev_dct(block);
-    add_pixels_clamped_c(block, dest, line_size);
-}
-
-/* draw the edges of width 'w' of an image of size width, height */
-// FIXME: Check that this is OK for MPEG-4 interlaced.
-static void draw_edges_8_c(uint8_t *buf, int wrap, int width, int height,
-                           int w, int h, int sides)
-{
-    uint8_t *ptr = buf, *last_line;
-    int i;
-
-    /* left and right */
-    for (i = 0; i < height; i++) {
-        memset(ptr - w, ptr[0], w);
-        memset(ptr + width, ptr[width - 1], w);
-        ptr += wrap;
-    }
-
-    /* top and bottom + corners */
-    buf -= w;
-    last_line = buf + (height - 1) * wrap;
-    if (sides & EDGE_TOP)
-        for (i = 0; i < h; i++)
-            // top
-            memcpy(buf - (i + 1) * wrap, buf, width + w + w);
-    if (sides & EDGE_BOTTOM)
-        for (i = 0; i < h; i++)
-            // bottom
-            memcpy(last_line + (i + 1) * wrap, last_line, width + w + w);
-}
-
-static void clear_block_8_c(int16_t *block)
-{
-    memset(block, 0, sizeof(int16_t) * 64);
-}
-
-static void clear_blocks_8_c(int16_t *blocks)
-{
-    memset(blocks, 0, sizeof(int16_t) * 6 * 64);
-}
-
-/* init static data */
-av_cold void ff_dsputil_static_init(void)
-{
-    int i;
-
-    for (i = 0; i < 512; i++)
-        ff_square_tab[i] = (i - 256) * (i - 256);
-}
-
-av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
-{
-    const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
-
-#if CONFIG_ENCODERS
-    if (avctx->bits_per_raw_sample == 10) {
-        c->fdct    = ff_jpeg_fdct_islow_10;
-        c->fdct248 = ff_fdct248_islow_10;
-    } else {
-        if (avctx->dct_algo == FF_DCT_FASTINT) {
-            c->fdct    = ff_fdct_ifast;
-            c->fdct248 = ff_fdct_ifast248;
-        } else if (avctx->dct_algo == FF_DCT_FAAN) {
-            c->fdct    = ff_faandct;
-            c->fdct248 = ff_faandct248;
-        } else {
-            c->fdct    = ff_jpeg_fdct_islow_8; // slow/accurate/default
-            c->fdct248 = ff_fdct248_islow_8;
-        }
-    }
-#endif /* CONFIG_ENCODERS */
-
-    if (avctx->bits_per_raw_sample == 10) {
-        c->idct_put              = ff_simple_idct_put_10;
-        c->idct_add              = ff_simple_idct_add_10;
-        c->idct                  = ff_simple_idct_10;
-        c->idct_permutation_type = FF_NO_IDCT_PERM;
-    } else {
-        if (avctx->idct_algo == FF_IDCT_INT) {
-            c->idct_put              = jref_idct_put;
-            c->idct_add              = jref_idct_add;
-            c->idct                  = ff_j_rev_dct;
-            c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
-        } else if (avctx->idct_algo == FF_IDCT_FAAN) {
-            c->idct_put              = ff_faanidct_put;
-            c->idct_add              = ff_faanidct_add;
-            c->idct                  = ff_faanidct;
-            c->idct_permutation_type = FF_NO_IDCT_PERM;
-        } else { // accurate/default
-            c->idct_put              = ff_simple_idct_put_8;
-            c->idct_add              = ff_simple_idct_add_8;
-            c->idct                  = ff_simple_idct_8;
-            c->idct_permutation_type = FF_NO_IDCT_PERM;
-        }
-    }
-
-    c->diff_pixels = diff_pixels_c;
-
-    c->put_pixels_clamped        = put_pixels_clamped_c;
-    c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
-    c->add_pixels_clamped        = add_pixels_clamped_c;
-
-    c->sum_abs_dctelem = sum_abs_dctelem_c;
-
-    c->gmc1 = gmc1_c;
-    c->gmc  = ff_gmc_c;
-
-    c->pix_sum   = pix_sum_c;
-    c->pix_norm1 = pix_norm1_c;
-
-    c->fill_block_tab[0] = fill_block16_c;
-    c->fill_block_tab[1] = fill_block8_c;
-
-    /* TODO [0] 16  [1] 8 */
-    c->pix_abs[0][0] = pix_abs16_c;
-    c->pix_abs[0][1] = pix_abs16_x2_c;
-    c->pix_abs[0][2] = pix_abs16_y2_c;
-    c->pix_abs[0][3] = pix_abs16_xy2_c;
-    c->pix_abs[1][0] = pix_abs8_c;
-    c->pix_abs[1][1] = pix_abs8_x2_c;
-    c->pix_abs[1][2] = pix_abs8_y2_c;
-    c->pix_abs[1][3] = pix_abs8_xy2_c;
-
 #define dspfunc(PFX, IDX, NUM)                              \
     c->PFX ## _pixels_tab[IDX][0]  = PFX ## NUM ## _mc00_c; \
     c->PFX ## _pixels_tab[IDX][1]  = PFX ## NUM ## _mc10_c; \
@@ -2225,76 +759,6 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
     dspfunc(avg_qpel, 0, 16);
     dspfunc(avg_qpel, 1, 8);
 
-#undef dspfunc
-
-#define SET_CMP_FUNC(name)                      \
-    c->name[0] = name ## 16_c;                  \
-    c->name[1] = name ## 8x8_c;
-
-    SET_CMP_FUNC(hadamard8_diff)
-    c->hadamard8_diff[4] = hadamard8_intra16_c;
-    c->hadamard8_diff[5] = hadamard8_intra8x8_c;
-    SET_CMP_FUNC(dct_sad)
-    SET_CMP_FUNC(dct_max)
-#if CONFIG_GPL
-    SET_CMP_FUNC(dct264_sad)
-#endif
-    c->sad[0] = pix_abs16_c;
-    c->sad[1] = pix_abs8_c;
-    c->sse[0] = sse16_c;
-    c->sse[1] = sse8_c;
-    c->sse[2] = sse4_c;
-    SET_CMP_FUNC(quant_psnr)
-    SET_CMP_FUNC(rd)
-    SET_CMP_FUNC(bit)
-    c->vsad[0] = vsad16_c;
-    c->vsad[4] = vsad_intra16_c;
-    c->vsad[5] = vsad_intra8_c;
-    c->vsse[0] = vsse16_c;
-    c->vsse[4] = vsse_intra16_c;
-    c->vsse[5] = vsse_intra8_c;
-    c->nsse[0] = nsse16_c;
-    c->nsse[1] = nsse8_c;
-
-    c->bswap_buf   = bswap_buf;
-    c->bswap16_buf = bswap16_buf;
-
-    c->try_8x8basis = try_8x8basis_c;
-    c->add_8x8basis = add_8x8basis_c;
-
-    c->scalarproduct_int16 = scalarproduct_int16_c;
-    c->vector_clip_int32   = vector_clip_int32_c;
-    c->vector_clipf        = vector_clipf_c;
-
-    c->shrink[0] = av_image_copy_plane;
-    c->shrink[1] = ff_shrink22;
-    c->shrink[2] = ff_shrink44;
-    c->shrink[3] = ff_shrink88;
-
-    c->draw_edges = draw_edges_8_c;
-
-    c->clear_block  = clear_block_8_c;
-    c->clear_blocks = clear_blocks_8_c;
-
-    switch (avctx->bits_per_raw_sample) {
-    case 9:
-    case 10:
-        c->get_pixels = get_pixels_16_c;
-        break;
-    default:
-        c->get_pixels = get_pixels_8_c;
-        break;
-    }
-
-    if (ARCH_ARM)
-        ff_dsputil_init_arm(c, avctx, high_bit_depth);
-    if (ARCH_BFIN)
-        ff_dsputil_init_bfin(c, avctx, high_bit_depth);
-    if (ARCH_PPC)
-        ff_dsputil_init_ppc(c, avctx, high_bit_depth);
     if (ARCH_X86)
-        ff_dsputil_init_x86(c, avctx, high_bit_depth);
-
-    ff_init_scantable_permutation(c->idct_permutation,
-                                  c->idct_permutation_type);
+        ff_qpeldsp_init_x86(c);
 }
diff --git a/libavcodec/qpeldsp.h b/libavcodec/qpeldsp.h
new file mode 100644 (file)
index 0000000..a750ff8
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * quarterpel DSP functions
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * quarterpel DSP functions
+ */
+
+#ifndef AVCODEC_QPELDSP_H
+#define AVCODEC_QPELDSP_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+
+void ff_put_pixels8_l2_8(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
+                         int dst_stride, int src_stride1, int src_stride2,
+                         int h);
+
+#define DEF_OLD_QPEL(name)                                                     \
+    void ff_put_        ## name(uint8_t *dst /* align width (8 or 16) */,      \
+                                uint8_t *src /* align 1 */, ptrdiff_t stride); \
+    void ff_put_no_rnd_ ## name(uint8_t *dst /* align width (8 or 16) */,      \
+                                uint8_t *src /* align 1 */, ptrdiff_t stride); \
+    void ff_avg_        ## name(uint8_t *dst /* align width (8 or 16) */,      \
+                                uint8_t *src /* align 1 */, ptrdiff_t stride);
+
+DEF_OLD_QPEL(qpel16_mc11_old_c)
+DEF_OLD_QPEL(qpel16_mc31_old_c)
+DEF_OLD_QPEL(qpel16_mc12_old_c)
+DEF_OLD_QPEL(qpel16_mc32_old_c)
+DEF_OLD_QPEL(qpel16_mc13_old_c)
+DEF_OLD_QPEL(qpel16_mc33_old_c)
+DEF_OLD_QPEL(qpel8_mc11_old_c)
+DEF_OLD_QPEL(qpel8_mc31_old_c)
+DEF_OLD_QPEL(qpel8_mc12_old_c)
+DEF_OLD_QPEL(qpel8_mc32_old_c)
+DEF_OLD_QPEL(qpel8_mc13_old_c)
+DEF_OLD_QPEL(qpel8_mc33_old_c)
+
+typedef void (*qpel_mc_func)(uint8_t *dst /* align width (8 or 16) */,
+                             uint8_t *src /* align 1 */, ptrdiff_t stride);
+
+/**
+ * quarterpel DSP context
+ */
+typedef struct QpelDSPContext {
+    qpel_mc_func put_qpel_pixels_tab[2][16];
+    qpel_mc_func avg_qpel_pixels_tab[2][16];
+    qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
+} QpelDSPContext;
+
+void ff_qpeldsp_init(QpelDSPContext *c);
+
+void ff_qpeldsp_init_x86(QpelDSPContext *c);
+
+#endif /* AVCODEC_QPELDSP_H */
index 0720ffb..ba4cc67 100644 (file)
@@ -33,6 +33,7 @@
 #include "golomb.h"
 #include "internal.h"
 #include "mathops.h"
+#include "qpeldsp.h"
 #include "rectangle.h"
 #include "thread.h"
 
index 3d616ee..1aa80cf 100644 (file)
@@ -27,8 +27,8 @@
 #ifndef AVCODEC_RV34DSP_H
 #define AVCODEC_RV34DSP_H
 
-#include "dsputil.h"
 #include "h264chroma.h"
+#include "qpeldsp.h"
 
 typedef void (*rv40_weight_func)(uint8_t *dst/*align width (8 or 16)*/,
                                  uint8_t *src1/*align width (8 or 16)*/,
index 1b01d7e..c8a195c 100644 (file)
@@ -33,6 +33,7 @@
 #include "mpegvideo.h"
 #include "h263.h"
 #include "h264chroma.h"
+#include "qpeldsp.h"
 #include "vc1.h"
 #include "vc1data.h"
 #include "vc1acdata.h"
@@ -5603,6 +5604,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
     if (ff_vc1_init_common(v) < 0)
         return -1;
     ff_h264chroma_init(&v->h264chroma, 8);
+    ff_qpeldsp_init(&s->qdsp);
     ff_vc1dsp_init(&v->vc1dsp);
 
     if (avctx->codec_id == AV_CODEC_ID_WMV3 || avctx->codec_id == AV_CODEC_ID_WMV3IMAGE) {
@@ -5971,8 +5973,8 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
         s->current_picture_ptr->f->repeat_pict = v->rptfrm * 2;
     }
 
-    s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
-    s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
+    s->me.qpel_put = s->qdsp.put_qpel_pixels_tab;
+    s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab;
 
     if (avctx->hwaccel) {
         if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
index e112c7c..5adcb62 100644 (file)
@@ -26,8 +26,8 @@
  */
 
 #include "libavutil/common.h"
-#include "dsputil.h"
 #include "h264chroma.h"
+#include "qpeldsp.h"
 #include "vc1dsp.h"
 
 /* Apply overlap transform to horizontal edge */
index 935620d..f2f258e 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <stdint.h>
 
-#include "dsputil.h"
+#include "qpeldsp.h"
 
 typedef struct WMV2DSPContext {
     void (*idct_add)(uint8_t *dest, int line_size, int16_t *block);
index 1024226..5fddf3f 100644 (file)
@@ -20,6 +20,7 @@ OBJS-$(CONFIG_LPC)                     += x86/lpc.o
 OBJS-$(CONFIG_MPEGAUDIODSP)            += x86/mpegaudiodsp.o
 OBJS-$(CONFIG_MPEGVIDEO)               += x86/mpegvideo.o
 OBJS-$(CONFIG_MPEGVIDEOENC)            += x86/mpegvideoenc.o
+OBJS-$(CONFIG_QPELDSP)                 += x86/qpeldsp_init.o
 OBJS-$(CONFIG_VIDEODSP)                += x86/videodsp_init.o
 OBJS-$(CONFIG_VP3DSP)                  += x86/vp3dsp_init.o
 OBJS-$(CONFIG_XMM_CLOBBER_TEST)        += x86/w64xmmtest.o
@@ -44,13 +45,13 @@ OBJS-$(CONFIG_VP8_DECODER)             += x86/vp8dsp_init.o
 OBJS-$(CONFIG_VP9_DECODER)             += x86/vp9dsp_init.o
 
 MMX-OBJS-$(CONFIG_DSPUTIL)             += x86/dsputil_mmx.o             \
-                                          x86/fpel_mmx.o                \
                                           x86/idct_mmx_xvid.o           \
                                           x86/idct_sse2_xvid.o          \
                                           x86/simple_idct.o
 MMX-OBJS-$(CONFIG_HPELDSP)             += x86/fpel_mmx.o                \
                                           x86/hpeldsp_mmx.o
 MMX-OBJS-$(CONFIG_HUFFYUVDSP)          += x86/huffyuvdsp_mmx.o
+MMX-OBJS-$(CONFIG_QPELDSP)             += x86/fpel_mmx.o
 
 MMX-OBJS-$(CONFIG_SVQ1_ENCODER)        += x86/svq1enc_mmx.o
 MMX-OBJS-$(CONFIG_VC1_DECODER)         += x86/vc1dsp_mmx.o
@@ -61,10 +62,7 @@ YASM-OBJS                              += x86/deinterlace.o             \
 YASM-OBJS-$(CONFIG_AC3DSP)             += x86/ac3dsp.o
 YASM-OBJS-$(CONFIG_DCT)                += x86/dct32.o
 YASM-OBJS-$(CONFIG_DNXHD_ENCODER)      += x86/dnxhdenc.o
-YASM-OBJS-$(CONFIG_DSPUTIL)            += x86/dsputil.o                 \
-                                          x86/fpel.o                    \
-                                          x86/mpeg4qpel.o               \
-                                          x86/qpel.o
+YASM-OBJS-$(CONFIG_DSPUTIL)            += x86/dsputil.o
 YASM-OBJS-$(CONFIG_ENCODERS)           += x86/dsputilenc.o
 YASM-OBJS-$(CONFIG_FFT)                += x86/fft.o
 YASM-OBJS-$(CONFIG_H263DSP)            += x86/h263_loopfilter.o
@@ -86,6 +84,9 @@ YASM-OBJS-$(CONFIG_HPELDSP)            += x86/fpel.o                    \
                                           x86/hpeldsp.o
 YASM-OBJS-$(CONFIG_HUFFYUVDSP)         += x86/huffyuvdsp.o
 YASM-OBJS-$(CONFIG_MPEGAUDIODSP)       += x86/imdct36.o
+YASM-OBJS-$(CONFIG_QPELDSP)            += x86/qpeldsp.o                 \
+                                          x86/fpel.o                    \
+                                          x86/qpel.o
 YASM-OBJS-$(CONFIG_VIDEODSP)           += x86/videodsp.o
 YASM-OBJS-$(CONFIG_VP3DSP)             += x86/vp3dsp.o
 
dissimilarity index 83%
index 9b0788f..389e763 100644 (file)
-/*
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "libavutil/attributes.h"
-#include "libavutil/cpu.h"
-#include "libavutil/internal.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/avcodec.h"
-#include "libavcodec/dsputil.h"
-#include "libavcodec/pixels.h"
-#include "libavcodec/simple_idct.h"
-#include "libavcodec/version.h"
-#include "dsputil_x86.h"
-#include "fpel.h"
-#include "idct_xvid.h"
-
-void ff_put_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
-                              int dstStride, int src1Stride, int h);
-void ff_put_no_rnd_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1,
-                                     uint8_t *src2, int dstStride,
-                                     int src1Stride, int h);
-void ff_avg_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
-                              int dstStride, int src1Stride, int h);
-void ff_put_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
-                               int dstStride, int src1Stride, int h);
-void ff_avg_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
-                               int dstStride, int src1Stride, int h);
-void ff_put_no_rnd_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
-                                      int dstStride, int src1Stride, int h);
-void ff_put_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                          int dstStride, int srcStride, int h);
-void ff_avg_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                          int dstStride, int srcStride, int h);
-void ff_put_no_rnd_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                                 int dstStride, int srcStride,
-                                                 int h);
-void ff_put_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                         int dstStride, int srcStride, int h);
-void ff_avg_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                         int dstStride, int srcStride, int h);
-void ff_put_no_rnd_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                                int dstStride, int srcStride,
-                                                int h);
-void ff_put_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                          int dstStride, int srcStride);
-void ff_avg_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                          int dstStride, int srcStride);
-void ff_put_no_rnd_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                                 int dstStride, int srcStride);
-void ff_put_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                         int dstStride, int srcStride);
-void ff_avg_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                         int dstStride, int srcStride);
-void ff_put_no_rnd_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                                int dstStride, int srcStride);
-#define ff_put_no_rnd_pixels16_mmxext ff_put_pixels16_mmxext
-#define ff_put_no_rnd_pixels8_mmxext ff_put_pixels8_mmxext
-
-int32_t ff_scalarproduct_int16_mmxext(const int16_t *v1, const int16_t *v2,
-                                      int order);
-int32_t ff_scalarproduct_int16_sse2(const int16_t *v1, const int16_t *v2,
-                                    int order);
-
-void ff_bswap32_buf_ssse3(uint32_t *dst, const uint32_t *src, int w);
-void ff_bswap32_buf_sse2(uint32_t *dst, const uint32_t *src, int w);
-
-void ff_vector_clip_int32_mmx(int32_t *dst, const int32_t *src,
-                              int32_t min, int32_t max, unsigned int len);
-void ff_vector_clip_int32_sse2(int32_t *dst, const int32_t *src,
-                               int32_t min, int32_t max, unsigned int len);
-void ff_vector_clip_int32_int_sse2(int32_t *dst, const int32_t *src,
-                                   int32_t min, int32_t max, unsigned int len);
-void ff_vector_clip_int32_sse4(int32_t *dst, const int32_t *src,
-                               int32_t min, int32_t max, unsigned int len);
-
-#if HAVE_YASM
-
-CALL_2X_PIXELS(ff_avg_pixels16_mmxext, ff_avg_pixels8_mmxext, 8)
-CALL_2X_PIXELS(ff_put_pixels16_mmxext, ff_put_pixels8_mmxext, 8)
-
-#define QPEL_OP(OPNAME, RND, MMX)                                       \
-static void OPNAME ## qpel8_mc00_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    ff_ ## OPNAME ## pixels8_ ## MMX(dst, src, stride, 8);              \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc10_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t temp[8];                                                   \
-    uint8_t *const half = (uint8_t *) temp;                             \
-    ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8,        \
-                                                   stride, 8);          \
-    ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src, half,                 \
-                                        stride, stride, 8);             \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc20_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    ff_ ## OPNAME ## mpeg4_qpel8_h_lowpass_ ## MMX(dst, src, stride,    \
-                                                   stride, 8);          \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc30_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t temp[8];                                                   \
-    uint8_t *const half = (uint8_t *) temp;                             \
-    ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8,        \
-                                                   stride, 8);          \
-    ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src + 1, half, stride,     \
-                                        stride, 8);                     \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc01_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t temp[8];                                                   \
-    uint8_t *const half = (uint8_t *) temp;                             \
-    ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src,           \
-                                                   8, stride);          \
-    ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src, half,                 \
-                                        stride, stride, 8);             \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc02_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, src,            \
-                                                   stride, stride);     \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc03_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t temp[8];                                                   \
-    uint8_t *const half = (uint8_t *) temp;                             \
-    ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src,           \
-                                                   8, stride);          \
-    ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src + stride, half, stride,\
-                                        stride, 8);                     \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc11_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t half[8 + 9];                                               \
-    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
-                                                   stride, 9);          \
-    ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8,           \
-                                        stride, 9);                     \
-    ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV,             \
-                                        stride, 8, 8);                  \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc31_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t half[8 + 9];                                               \
-    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
-                                                   stride, 9);          \
-    ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8,       \
-                                        stride, 9);                     \
-    ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV,             \
-                                        stride, 8, 8);                  \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc13_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t half[8 + 9];                                               \
-    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
-                                                   stride, 9);          \
-    ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8,           \
-                                        stride, 9);                     \
-    ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH + 8, halfHV,         \
-                                        stride, 8, 8);                  \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc33_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t half[8 + 9];                                               \
-    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
-                                                   stride, 9);          \
-    ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8,       \
-                                        stride, 9);                     \
-    ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH + 8, halfHV,         \
-                                        stride, 8, 8);                  \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc21_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t half[8 + 9];                                               \
-    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
-                                                   stride, 9);          \
-    ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV,             \
-                                        stride, 8, 8);                  \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc23_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t half[8 + 9];                                               \
-    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
-                                                   stride, 9);          \
-    ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH + 8, halfHV,         \
-                                        stride, 8, 8);                  \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t half[8 + 9];                                               \
-    uint8_t *const halfH = (uint8_t *) half;                            \
-    ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
-                                                   stride, 9);          \
-    ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH,              \
-                                        8, stride, 9);                  \
-    ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH,          \
-                                                   stride, 8);          \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc32_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t half[8 + 9];                                               \
-    uint8_t *const halfH = (uint8_t *) half;                            \
-    ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
-                                                   stride, 9);          \
-    ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8,       \
-                                        stride, 9);                     \
-    ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH,          \
-                                                   stride, 8);          \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel8_mc22_ ## MMX(uint8_t *dst, uint8_t *src,    \
-                                         ptrdiff_t stride)              \
-{                                                                       \
-    uint64_t half[9];                                                   \
-    uint8_t *const halfH = (uint8_t *) half;                            \
-    ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
-                                                   stride, 9);          \
-    ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH,          \
-                                                   stride, 8);          \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc00_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    ff_ ## OPNAME ## pixels16_ ## MMX(dst, src, stride, 16);            \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc10_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t temp[32];                                                  \
-    uint8_t *const half = (uint8_t *) temp;                             \
-    ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16,      \
-                                                    stride, 16);        \
-    ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride,        \
-                                         stride, 16);                   \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc20_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    ff_ ## OPNAME ## mpeg4_qpel16_h_lowpass_ ## MMX(dst, src,           \
-                                                    stride, stride, 16);\
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc30_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t temp[32];                                                  \
-    uint8_t *const half = (uint8_t*) temp;                              \
-    ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16,      \
-                                                    stride, 16);        \
-    ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src + 1, half,            \
-                                         stride, stride, 16);           \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc01_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t temp[32];                                                  \
-    uint8_t *const half = (uint8_t *) temp;                             \
-    ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16,      \
-                                                    stride);            \
-    ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride,        \
-                                         stride, 16);                   \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc02_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, src,           \
-                                                    stride, stride);    \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc03_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t temp[32];                                                  \
-    uint8_t *const half = (uint8_t *) temp;                             \
-    ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16,      \
-                                                    stride);            \
-    ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src+stride, half,         \
-                                         stride, stride, 16);           \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc11_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
-                                                    stride, 17);        \
-    ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16,         \
-                                         stride, 17);                   \
-    ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH,      \
-                                                    16, 16);            \
-    ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV,            \
-                                         stride, 16, 16);               \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc31_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
-                                                    stride, 17);        \
-    ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16,     \
-                                         stride, 17);                   \
-    ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH,      \
-                                                    16, 16);            \
-    ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV,            \
-                                         stride, 16, 16);               \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc13_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
-                                                    stride, 17);        \
-    ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16,         \
-                                         stride, 17);                   \
-    ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH,      \
-                                                    16, 16);            \
-    ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH + 16, halfHV,       \
-                                         stride, 16, 16);               \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc33_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
-                                                    stride, 17);        \
-    ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16,     \
-                                         stride, 17);                   \
-    ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH,      \
-                                                    16, 16);            \
-    ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH + 16, halfHV,       \
-                                         stride, 16, 16);               \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc21_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
-                                                    stride, 17);        \
-    ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH,      \
-                                                    16, 16);            \
-    ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV,            \
-                                         stride, 16, 16);               \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc23_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
-    uint8_t *const halfHV = (uint8_t *) half;                           \
-    ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
-                                                    stride, 17);        \
-    ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH,      \
-                                                    16, 16);            \
-    ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH + 16, halfHV,       \
-                                         stride, 16, 16);               \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc12_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t half[17 * 2];                                              \
-    uint8_t *const halfH = (uint8_t *) half;                            \
-    ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
-                                                    stride, 17);        \
-    ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16,         \
-                                         stride, 17);                   \
-    ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH,         \
-                                                    stride, 16);        \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc32_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t half[17 * 2];                                              \
-    uint8_t *const halfH = (uint8_t *) half;                            \
-    ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
-                                                    stride, 17);        \
-    ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16,     \
-                                         stride, 17);                   \
-    ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH,         \
-                                                    stride, 16);        \
-}                                                                       \
-                                                                        \
-static void OPNAME ## qpel16_mc22_ ## MMX(uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
-{                                                                       \
-    uint64_t half[17 * 2];                                              \
-    uint8_t *const halfH = (uint8_t *) half;                            \
-    ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
-                                                    stride, 17);        \
-    ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH,         \
-                                                    stride, 16);        \
-}
-
-QPEL_OP(put_,        _,        mmxext)
-QPEL_OP(avg_,        _,        mmxext)
-QPEL_OP(put_no_rnd_, _no_rnd_, mmxext)
-
-#endif /* HAVE_YASM */
-
-#define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU, PREFIX)                          \
-do {                                                                         \
-    c->PFX ## _pixels_tab[IDX][ 0] = PREFIX ## PFX ## SIZE ## _mc00_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][ 1] = PREFIX ## PFX ## SIZE ## _mc10_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][ 2] = PREFIX ## PFX ## SIZE ## _mc20_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][ 3] = PREFIX ## PFX ## SIZE ## _mc30_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][ 4] = PREFIX ## PFX ## SIZE ## _mc01_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][ 5] = PREFIX ## PFX ## SIZE ## _mc11_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][ 6] = PREFIX ## PFX ## SIZE ## _mc21_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][ 7] = PREFIX ## PFX ## SIZE ## _mc31_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][ 8] = PREFIX ## PFX ## SIZE ## _mc02_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][ 9] = PREFIX ## PFX ## SIZE ## _mc12_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][10] = PREFIX ## PFX ## SIZE ## _mc22_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][11] = PREFIX ## PFX ## SIZE ## _mc32_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][12] = PREFIX ## PFX ## SIZE ## _mc03_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][13] = PREFIX ## PFX ## SIZE ## _mc13_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][14] = PREFIX ## PFX ## SIZE ## _mc23_ ## CPU; \
-    c->PFX ## _pixels_tab[IDX][15] = PREFIX ## PFX ## SIZE ## _mc33_ ## CPU; \
-} while (0)
-
-static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
-                                     int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_MMX_INLINE
-    c->put_pixels_clamped        = ff_put_pixels_clamped_mmx;
-    c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
-    c->add_pixels_clamped        = ff_add_pixels_clamped_mmx;
-
-    if (!high_bit_depth) {
-        c->clear_block  = ff_clear_block_mmx;
-        c->clear_blocks = ff_clear_blocks_mmx;
-        c->draw_edges   = ff_draw_edges_mmx;
-
-        switch (avctx->idct_algo) {
-        case FF_IDCT_AUTO:
-        case FF_IDCT_SIMPLEMMX:
-            c->idct_put              = ff_simple_idct_put_mmx;
-            c->idct_add              = ff_simple_idct_add_mmx;
-            c->idct                  = ff_simple_idct_mmx;
-            c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
-            break;
-        case FF_IDCT_XVIDMMX:
-            c->idct_put              = ff_idct_xvid_mmx_put;
-            c->idct_add              = ff_idct_xvid_mmx_add;
-            c->idct                  = ff_idct_xvid_mmx;
-            break;
-        }
-    }
-
-    c->gmc = ff_gmc_mmx;
-#endif /* HAVE_MMX_INLINE */
-
-#if HAVE_MMX_EXTERNAL
-    c->vector_clip_int32 = ff_vector_clip_int32_mmx;
-#endif /* HAVE_MMX_EXTERNAL */
-}
-
-static av_cold void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx,
-                                        int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_MMXEXT_INLINE
-    if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
-        c->idct_put = ff_idct_xvid_mmxext_put;
-        c->idct_add = ff_idct_xvid_mmxext_add;
-        c->idct     = ff_idct_xvid_mmxext;
-    }
-#endif /* HAVE_MMXEXT_INLINE */
-
-#if HAVE_MMXEXT_EXTERNAL
-    SET_QPEL_FUNCS(avg_qpel,        0, 16, mmxext, );
-    SET_QPEL_FUNCS(avg_qpel,        1,  8, mmxext, );
-
-    SET_QPEL_FUNCS(put_qpel,        0, 16, mmxext, );
-    SET_QPEL_FUNCS(put_qpel,        1,  8, mmxext, );
-    SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmxext, );
-    SET_QPEL_FUNCS(put_no_rnd_qpel, 1,  8, mmxext, );
-
-    c->scalarproduct_int16          = ff_scalarproduct_int16_mmxext;
-#endif /* HAVE_MMXEXT_EXTERNAL */
-}
-
-static av_cold void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx,
-                                     int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_SSE_INLINE
-    c->vector_clipf = ff_vector_clipf_sse;
-
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
-    /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
-    if (CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1)
-        return;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
-
-    if (!high_bit_depth) {
-        c->clear_block  = ff_clear_block_sse;
-        c->clear_blocks = ff_clear_blocks_sse;
-    }
-#endif /* HAVE_SSE_INLINE */
-}
-
-static av_cold void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx,
-                                      int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_SSE2_INLINE
-    if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
-        c->idct_put              = ff_idct_xvid_sse2_put;
-        c->idct_add              = ff_idct_xvid_sse2_add;
-        c->idct                  = ff_idct_xvid_sse2;
-        c->idct_permutation_type = FF_SSE2_IDCT_PERM;
-    }
-#endif /* HAVE_SSE2_INLINE */
-
-#if HAVE_SSE2_EXTERNAL
-    c->scalarproduct_int16          = ff_scalarproduct_int16_sse2;
-    if (cpu_flags & AV_CPU_FLAG_ATOM) {
-        c->vector_clip_int32 = ff_vector_clip_int32_int_sse2;
-    } else {
-        c->vector_clip_int32 = ff_vector_clip_int32_sse2;
-    }
-    c->bswap_buf = ff_bswap32_buf_sse2;
-#endif /* HAVE_SSE2_EXTERNAL */
-}
-
-static av_cold void dsputil_init_ssse3(DSPContext *c, AVCodecContext *avctx,
-                                       int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_SSSE3_EXTERNAL
-    c->bswap_buf = ff_bswap32_buf_ssse3;
-#endif /* HAVE_SSSE3_EXTERNAL */
-}
-
-static av_cold void dsputil_init_sse4(DSPContext *c, AVCodecContext *avctx,
-                                      int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_SSE4_EXTERNAL
-    c->vector_clip_int32 = ff_vector_clip_int32_sse4;
-#endif /* HAVE_SSE4_EXTERNAL */
-}
-
-av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,
-                                 unsigned high_bit_depth)
-{
-    int cpu_flags = av_get_cpu_flags();
-
-    if (X86_MMX(cpu_flags))
-        dsputil_init_mmx(c, avctx, cpu_flags, high_bit_depth);
-
-    if (X86_MMXEXT(cpu_flags))
-        dsputil_init_mmxext(c, avctx, cpu_flags, high_bit_depth);
-
-    if (X86_SSE(cpu_flags))
-        dsputil_init_sse(c, avctx, cpu_flags, high_bit_depth);
-
-    if (X86_SSE2(cpu_flags))
-        dsputil_init_sse2(c, avctx, cpu_flags, high_bit_depth);
-
-    if (EXTERNAL_SSSE3(cpu_flags))
-        dsputil_init_ssse3(c, avctx, cpu_flags, high_bit_depth);
-
-    if (EXTERNAL_SSE4(cpu_flags))
-        dsputil_init_sse4(c, avctx, cpu_flags, high_bit_depth);
-
-    if (CONFIG_ENCODERS)
-        ff_dsputilenc_init_mmx(c, avctx, high_bit_depth);
-}
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/internal.h"
+#include "libavutil/x86/cpu.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
+#include "libavcodec/simple_idct.h"
+#include "libavcodec/version.h"
+#include "dsputil_x86.h"
+#include "idct_xvid.h"
+
+int32_t ff_scalarproduct_int16_mmxext(const int16_t *v1, const int16_t *v2,
+                                      int order);
+int32_t ff_scalarproduct_int16_sse2(const int16_t *v1, const int16_t *v2,
+                                    int order);
+
+void ff_bswap32_buf_ssse3(uint32_t *dst, const uint32_t *src, int w);
+void ff_bswap32_buf_sse2(uint32_t *dst, const uint32_t *src, int w);
+
+void ff_vector_clip_int32_mmx(int32_t *dst, const int32_t *src,
+                              int32_t min, int32_t max, unsigned int len);
+void ff_vector_clip_int32_sse2(int32_t *dst, const int32_t *src,
+                               int32_t min, int32_t max, unsigned int len);
+void ff_vector_clip_int32_int_sse2(int32_t *dst, const int32_t *src,
+                                   int32_t min, int32_t max, unsigned int len);
+void ff_vector_clip_int32_sse4(int32_t *dst, const int32_t *src,
+                               int32_t min, int32_t max, unsigned int len);
+
+static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
+                                     int cpu_flags, unsigned high_bit_depth)
+{
+#if HAVE_MMX_INLINE
+    c->put_pixels_clamped        = ff_put_pixels_clamped_mmx;
+    c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
+    c->add_pixels_clamped        = ff_add_pixels_clamped_mmx;
+
+    if (!high_bit_depth) {
+        c->clear_block  = ff_clear_block_mmx;
+        c->clear_blocks = ff_clear_blocks_mmx;
+        c->draw_edges   = ff_draw_edges_mmx;
+
+        switch (avctx->idct_algo) {
+        case FF_IDCT_AUTO:
+        case FF_IDCT_SIMPLEMMX:
+            c->idct_put              = ff_simple_idct_put_mmx;
+            c->idct_add              = ff_simple_idct_add_mmx;
+            c->idct                  = ff_simple_idct_mmx;
+            c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
+            break;
+        case FF_IDCT_XVIDMMX:
+            c->idct_put              = ff_idct_xvid_mmx_put;
+            c->idct_add              = ff_idct_xvid_mmx_add;
+            c->idct                  = ff_idct_xvid_mmx;
+            break;
+        }
+    }
+
+    c->gmc = ff_gmc_mmx;
+#endif /* HAVE_MMX_INLINE */
+
+#if HAVE_MMX_EXTERNAL
+    c->vector_clip_int32 = ff_vector_clip_int32_mmx;
+#endif /* HAVE_MMX_EXTERNAL */
+}
+
+static av_cold void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx,
+                                        int cpu_flags, unsigned high_bit_depth)
+{
+#if HAVE_MMXEXT_INLINE
+    if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
+        c->idct_put = ff_idct_xvid_mmxext_put;
+        c->idct_add = ff_idct_xvid_mmxext_add;
+        c->idct     = ff_idct_xvid_mmxext;
+    }
+#endif /* HAVE_MMXEXT_INLINE */
+
+#if HAVE_MMXEXT_EXTERNAL
+    c->scalarproduct_int16          = ff_scalarproduct_int16_mmxext;
+#endif /* HAVE_MMXEXT_EXTERNAL */
+}
+
+static av_cold void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx,
+                                     int cpu_flags, unsigned high_bit_depth)
+{
+#if HAVE_SSE_INLINE
+    c->vector_clipf = ff_vector_clipf_sse;
+
+#if FF_API_XVMC
+FF_DISABLE_DEPRECATION_WARNINGS
+    /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
+    if (CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1)
+        return;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif /* FF_API_XVMC */
+
+    if (!high_bit_depth) {
+        c->clear_block  = ff_clear_block_sse;
+        c->clear_blocks = ff_clear_blocks_sse;
+    }
+#endif /* HAVE_SSE_INLINE */
+}
+
+static av_cold void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx,
+                                      int cpu_flags, unsigned high_bit_depth)
+{
+#if HAVE_SSE2_INLINE
+    if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
+        c->idct_put              = ff_idct_xvid_sse2_put;
+        c->idct_add              = ff_idct_xvid_sse2_add;
+        c->idct                  = ff_idct_xvid_sse2;
+        c->idct_permutation_type = FF_SSE2_IDCT_PERM;
+    }
+#endif /* HAVE_SSE2_INLINE */
+
+#if HAVE_SSE2_EXTERNAL
+    c->scalarproduct_int16          = ff_scalarproduct_int16_sse2;
+    if (cpu_flags & AV_CPU_FLAG_ATOM) {
+        c->vector_clip_int32 = ff_vector_clip_int32_int_sse2;
+    } else {
+        c->vector_clip_int32 = ff_vector_clip_int32_sse2;
+    }
+    c->bswap_buf = ff_bswap32_buf_sse2;
+#endif /* HAVE_SSE2_EXTERNAL */
+}
+
+static av_cold void dsputil_init_ssse3(DSPContext *c, AVCodecContext *avctx,
+                                       int cpu_flags, unsigned high_bit_depth)
+{
+#if HAVE_SSSE3_EXTERNAL
+    c->bswap_buf = ff_bswap32_buf_ssse3;
+#endif /* HAVE_SSSE3_EXTERNAL */
+}
+
+static av_cold void dsputil_init_sse4(DSPContext *c, AVCodecContext *avctx,
+                                      int cpu_flags, unsigned high_bit_depth)
+{
+#if HAVE_SSE4_EXTERNAL
+    c->vector_clip_int32 = ff_vector_clip_int32_sse4;
+#endif /* HAVE_SSE4_EXTERNAL */
+}
+
+av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,
+                                 unsigned high_bit_depth)
+{
+    int cpu_flags = av_get_cpu_flags();
+
+    if (X86_MMX(cpu_flags))
+        dsputil_init_mmx(c, avctx, cpu_flags, high_bit_depth);
+
+    if (X86_MMXEXT(cpu_flags))
+        dsputil_init_mmxext(c, avctx, cpu_flags, high_bit_depth);
+
+    if (X86_SSE(cpu_flags))
+        dsputil_init_sse(c, avctx, cpu_flags, high_bit_depth);
+
+    if (X86_SSE2(cpu_flags))
+        dsputil_init_sse2(c, avctx, cpu_flags, high_bit_depth);
+
+    if (EXTERNAL_SSSE3(cpu_flags))
+        dsputil_init_ssse3(c, avctx, cpu_flags, high_bit_depth);
+
+    if (EXTERNAL_SSE4(cpu_flags))
+        dsputil_init_sse4(c, avctx, cpu_flags, high_bit_depth);
+
+    if (CONFIG_ENCODERS)
+        ff_dsputilenc_init_mmx(c, avctx, high_bit_depth);
+}
similarity index 99%
rename from libavcodec/x86/mpeg4qpel.asm
rename to libavcodec/x86/qpeldsp.asm
index 2cdd84b..8f65550 100644 (file)
@@ -1,5 +1,6 @@
 ;******************************************************************************
-;* mpeg4 qpel
+;* quarterpel DSP functions
+;*
 ;* Copyright (c) 2008 Loren Merritt
 ;*
 ;* This file is part of Libav.
similarity index 84%
copy from libavcodec/x86/dsputil_init.c
copy to libavcodec/x86/qpeldsp_init.c
index 9b0788f..435b765 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * quarterpel DSP functions
+ *
  * This file is part of Libav.
  *
  * Libav is free software; you can redistribute it and/or
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stddef.h>
+#include <stdint.h>
+
 #include "config.h"
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/internal.h"
 #include "libavutil/x86/cpu.h"
-#include "libavcodec/avcodec.h"
-#include "libavcodec/dsputil.h"
 #include "libavcodec/pixels.h"
-#include "libavcodec/simple_idct.h"
-#include "libavcodec/version.h"
-#include "dsputil_x86.h"
+#include "libavcodec/qpeldsp.h"
 #include "fpel.h"
-#include "idct_xvid.h"
 
 void ff_put_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
                               int dstStride, int src1Stride, int h);
@@ -72,23 +71,6 @@ void ff_put_no_rnd_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
 #define ff_put_no_rnd_pixels16_mmxext ff_put_pixels16_mmxext
 #define ff_put_no_rnd_pixels8_mmxext ff_put_pixels8_mmxext
 
-int32_t ff_scalarproduct_int16_mmxext(const int16_t *v1, const int16_t *v2,
-                                      int order);
-int32_t ff_scalarproduct_int16_sse2(const int16_t *v1, const int16_t *v2,
-                                    int order);
-
-void ff_bswap32_buf_ssse3(uint32_t *dst, const uint32_t *src, int w);
-void ff_bswap32_buf_sse2(uint32_t *dst, const uint32_t *src, int w);
-
-void ff_vector_clip_int32_mmx(int32_t *dst, const int32_t *src,
-                              int32_t min, int32_t max, unsigned int len);
-void ff_vector_clip_int32_sse2(int32_t *dst, const int32_t *src,
-                               int32_t min, int32_t max, unsigned int len);
-void ff_vector_clip_int32_int_sse2(int32_t *dst, const int32_t *src,
-                                   int32_t min, int32_t max, unsigned int len);
-void ff_vector_clip_int32_sse4(int32_t *dst, const int32_t *src,
-                               int32_t min, int32_t max, unsigned int len);
-
 #if HAVE_YASM
 
 CALL_2X_PIXELS(ff_avg_pixels16_mmxext, ff_avg_pixels8_mmxext, 8)
@@ -501,150 +483,19 @@ do {                                                                         \
     c->PFX ## _pixels_tab[IDX][15] = PREFIX ## PFX ## SIZE ## _mc33_ ## CPU; \
 } while (0)
 
-static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
-                                     int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_MMX_INLINE
-    c->put_pixels_clamped        = ff_put_pixels_clamped_mmx;
-    c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
-    c->add_pixels_clamped        = ff_add_pixels_clamped_mmx;
-
-    if (!high_bit_depth) {
-        c->clear_block  = ff_clear_block_mmx;
-        c->clear_blocks = ff_clear_blocks_mmx;
-        c->draw_edges   = ff_draw_edges_mmx;
-
-        switch (avctx->idct_algo) {
-        case FF_IDCT_AUTO:
-        case FF_IDCT_SIMPLEMMX:
-            c->idct_put              = ff_simple_idct_put_mmx;
-            c->idct_add              = ff_simple_idct_add_mmx;
-            c->idct                  = ff_simple_idct_mmx;
-            c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
-            break;
-        case FF_IDCT_XVIDMMX:
-            c->idct_put              = ff_idct_xvid_mmx_put;
-            c->idct_add              = ff_idct_xvid_mmx_add;
-            c->idct                  = ff_idct_xvid_mmx;
-            break;
-        }
-    }
-
-    c->gmc = ff_gmc_mmx;
-#endif /* HAVE_MMX_INLINE */
-
-#if HAVE_MMX_EXTERNAL
-    c->vector_clip_int32 = ff_vector_clip_int32_mmx;
-#endif /* HAVE_MMX_EXTERNAL */
-}
-
-static av_cold void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx,
-                                        int cpu_flags, unsigned high_bit_depth)
+av_cold void ff_qpeldsp_init_x86(QpelDSPContext *c)
 {
-#if HAVE_MMXEXT_INLINE
-    if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
-        c->idct_put = ff_idct_xvid_mmxext_put;
-        c->idct_add = ff_idct_xvid_mmxext_add;
-        c->idct     = ff_idct_xvid_mmxext;
-    }
-#endif /* HAVE_MMXEXT_INLINE */
+    int cpu_flags = av_get_cpu_flags();
 
+    if (X86_MMXEXT(cpu_flags)) {
 #if HAVE_MMXEXT_EXTERNAL
-    SET_QPEL_FUNCS(avg_qpel,        0, 16, mmxext, );
-    SET_QPEL_FUNCS(avg_qpel,        1,  8, mmxext, );
-
-    SET_QPEL_FUNCS(put_qpel,        0, 16, mmxext, );
-    SET_QPEL_FUNCS(put_qpel,        1,  8, mmxext, );
-    SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmxext, );
-    SET_QPEL_FUNCS(put_no_rnd_qpel, 1,  8, mmxext, );
+        SET_QPEL_FUNCS(avg_qpel,        0, 16, mmxext, );
+        SET_QPEL_FUNCS(avg_qpel,        1,  8, mmxext, );
 
-    c->scalarproduct_int16          = ff_scalarproduct_int16_mmxext;
+        SET_QPEL_FUNCS(put_qpel,        0, 16, mmxext, );
+        SET_QPEL_FUNCS(put_qpel,        1,  8, mmxext, );
+        SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmxext, );
+        SET_QPEL_FUNCS(put_no_rnd_qpel, 1,  8, mmxext, );
 #endif /* HAVE_MMXEXT_EXTERNAL */
-}
-
-static av_cold void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx,
-                                     int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_SSE_INLINE
-    c->vector_clipf = ff_vector_clipf_sse;
-
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
-    /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
-    if (CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1)
-        return;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
-
-    if (!high_bit_depth) {
-        c->clear_block  = ff_clear_block_sse;
-        c->clear_blocks = ff_clear_blocks_sse;
-    }
-#endif /* HAVE_SSE_INLINE */
-}
-
-static av_cold void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx,
-                                      int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_SSE2_INLINE
-    if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
-        c->idct_put              = ff_idct_xvid_sse2_put;
-        c->idct_add              = ff_idct_xvid_sse2_add;
-        c->idct                  = ff_idct_xvid_sse2;
-        c->idct_permutation_type = FF_SSE2_IDCT_PERM;
     }
-#endif /* HAVE_SSE2_INLINE */
-
-#if HAVE_SSE2_EXTERNAL
-    c->scalarproduct_int16          = ff_scalarproduct_int16_sse2;
-    if (cpu_flags & AV_CPU_FLAG_ATOM) {
-        c->vector_clip_int32 = ff_vector_clip_int32_int_sse2;
-    } else {
-        c->vector_clip_int32 = ff_vector_clip_int32_sse2;
-    }
-    c->bswap_buf = ff_bswap32_buf_sse2;
-#endif /* HAVE_SSE2_EXTERNAL */
-}
-
-static av_cold void dsputil_init_ssse3(DSPContext *c, AVCodecContext *avctx,
-                                       int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_SSSE3_EXTERNAL
-    c->bswap_buf = ff_bswap32_buf_ssse3;
-#endif /* HAVE_SSSE3_EXTERNAL */
-}
-
-static av_cold void dsputil_init_sse4(DSPContext *c, AVCodecContext *avctx,
-                                      int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_SSE4_EXTERNAL
-    c->vector_clip_int32 = ff_vector_clip_int32_sse4;
-#endif /* HAVE_SSE4_EXTERNAL */
-}
-
-av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,
-                                 unsigned high_bit_depth)
-{
-    int cpu_flags = av_get_cpu_flags();
-
-    if (X86_MMX(cpu_flags))
-        dsputil_init_mmx(c, avctx, cpu_flags, high_bit_depth);
-
-    if (X86_MMXEXT(cpu_flags))
-        dsputil_init_mmxext(c, avctx, cpu_flags, high_bit_depth);
-
-    if (X86_SSE(cpu_flags))
-        dsputil_init_sse(c, avctx, cpu_flags, high_bit_depth);
-
-    if (X86_SSE2(cpu_flags))
-        dsputil_init_sse2(c, avctx, cpu_flags, high_bit_depth);
-
-    if (EXTERNAL_SSSE3(cpu_flags))
-        dsputil_init_ssse3(c, avctx, cpu_flags, high_bit_depth);
-
-    if (EXTERNAL_SSE4(cpu_flags))
-        dsputil_init_sse4(c, avctx, cpu_flags, high_bit_depth);
-
-    if (CONFIG_ENCODERS)
-        ff_dsputilenc_init_mmx(c, avctx, high_bit_depth);
 }