summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-11-08 17:25:13 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-11-08 17:42:56 +0100
commita30f7918b52d076c55a42bef3a731165b354bf08 (patch)
treef659d43c5ff88425e8d2c740dfe191da87e5988c /libavcodec
parentf8a9cf77040e1b2ed83206269ead11aa30afb98d (diff)
parent0338c396987c82b41d322630ea9712fe5f9561d6 (diff)
downloadffmpeg-a30f7918b52d076c55a42bef3a731165b354bf08.tar.gz
Merge commit '0338c396987c82b41d322630ea9712fe5f9561d6'
* commit '0338c396987c82b41d322630ea9712fe5f9561d6': dsputil: Split off H.263 bits into their own H263DSPContext Conflicts: configure libavcodec/mpegvideo.h libavcodec/mpegvideo_enc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/Makefile1
-rw-r--r--libavcodec/dsputil.c79
-rw-r--r--libavcodec/dsputil.h3
-rw-r--r--libavcodec/h263.c32
-rw-r--r--libavcodec/h263data.h5
-rw-r--r--libavcodec/h263dec.c1
-rw-r--r--libavcodec/h263dsp.c108
-rw-r--r--libavcodec/h263dsp.h34
-rw-r--r--libavcodec/mpegvideo.h3
-rw-r--r--libavcodec/mpegvideo_enc.c1
-rw-r--r--libavcodec/rv10.c1
-rw-r--r--libavcodec/x86/Makefile4
-rw-r--r--libavcodec/x86/dsputil_init.c8
-rw-r--r--libavcodec/x86/h263dsp_init.c39
14 files changed, 205 insertions, 114 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4283f8919a..d3b25bf630 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -50,6 +50,7 @@ OBJS-$(CONFIG_FFT) += avfft.o fft_fixed.o fft_float.o \
fft_fixed_32.o fft_init_table.o \
$(FFT-OBJS-yes)
OBJS-$(CONFIG_GOLOMB) += golomb.o
+OBJS-$(CONFIG_H263DSP) += h263dsp.o
OBJS-$(CONFIG_H264CHROMA) += h264chroma.o
OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o
OBJS-$(CONFIG_H264PRED) += h264pred.o
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index 17de1d4f6a..71c761073f 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -1516,80 +1516,6 @@ static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8);
}
-static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){
- if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
- int x;
- const int strength= ff_h263_loop_filter_strength[qscale];
-
- for(x=0; x<8; x++){
- int d1, d2, ad1;
- int p0= src[x-2*stride];
- int p1= src[x-1*stride];
- int p2= src[x+0*stride];
- int p3= src[x+1*stride];
- int d = (p0 - p3 + 4*(p2 - p1)) / 8;
-
- if (d<-2*strength) d1= 0;
- else if(d<- strength) d1=-2*strength - d;
- else if(d< strength) d1= d;
- else if(d< 2*strength) d1= 2*strength - d;
- else d1= 0;
-
- p1 += d1;
- p2 -= d1;
- if(p1&256) p1= ~(p1>>31);
- if(p2&256) p2= ~(p2>>31);
-
- src[x-1*stride] = p1;
- src[x+0*stride] = p2;
-
- ad1= FFABS(d1)>>1;
-
- d2= av_clip((p0-p3)/4, -ad1, ad1);
-
- src[x-2*stride] = p0 - d2;
- src[x+ stride] = p3 + d2;
- }
- }
-}
-
-static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){
- if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
- int y;
- const int strength= ff_h263_loop_filter_strength[qscale];
-
- for(y=0; y<8; y++){
- int d1, d2, ad1;
- int p0= src[y*stride-2];
- int p1= src[y*stride-1];
- int p2= src[y*stride+0];
- int p3= src[y*stride+1];
- int d = (p0 - p3 + 4*(p2 - p1)) / 8;
-
- if (d<-2*strength) d1= 0;
- else if(d<- strength) d1=-2*strength - d;
- else if(d< strength) d1= d;
- else if(d< 2*strength) d1= 2*strength - d;
- else d1= 0;
-
- p1 += d1;
- p2 -= d1;
- if(p1&256) p1= ~(p1>>31);
- if(p2&256) p2= ~(p2>>31);
-
- src[y*stride-1] = p1;
- src[y*stride+0] = p2;
-
- ad1= FFABS(d1)>>1;
-
- d2= av_clip((p0-p3)/4, -ad1, ad1);
-
- src[y*stride-2] = p0 - d2;
- src[y*stride+1] = p3 + d2;
- }
- }
-}
-
static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
int s, i;
@@ -2872,11 +2798,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->bswap_buf= bswap_buf;
c->bswap16_buf = bswap16_buf;
- if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
- c->h263_h_loop_filter= h263_h_loop_filter_c;
- c->h263_v_loop_filter= h263_v_loop_filter_c;
- }
-
c->try_8x8basis= try_8x8basis_c;
c->add_8x8basis= add_8x8basis_c;
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index b9f8bdec0c..0a8521d8a4 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -205,9 +205,6 @@ typedef struct DSPContext {
void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w);
void (*bswap16_buf)(uint16_t *dst, const uint16_t *src, int len);
- void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale);
- void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
-
/* assume len is a multiple of 8, and arrays are 16-byte aligned */
void (*vector_clipf)(float *dst /* align 16 */, const float *src /* align 16 */, float min, float max, int len /* align 16 */);
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index eda61f6c7b..dafc4ecbb5 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -152,8 +152,8 @@ void ff_h263_loop_filter(MpegEncContext * s){
*/
if (!IS_SKIP(s->current_picture.mb_type[xy])) {
qp_c= s->qscale;
- s->dsp.h263_v_loop_filter(dest_y+8*linesize , linesize, qp_c);
- s->dsp.h263_v_loop_filter(dest_y+8*linesize+8, linesize, qp_c);
+ s->h263dsp.h263_v_loop_filter(dest_y + 8 * linesize, linesize, qp_c);
+ s->h263dsp.h263_v_loop_filter(dest_y + 8 * linesize + 8, linesize, qp_c);
}else
qp_c= 0;
@@ -172,15 +172,15 @@ void ff_h263_loop_filter(MpegEncContext * s){
if(qp_tc){
const int chroma_qp= s->chroma_qscale_table[qp_tc];
- s->dsp.h263_v_loop_filter(dest_y , linesize, qp_tc);
- s->dsp.h263_v_loop_filter(dest_y+8, linesize, qp_tc);
+ s->h263dsp.h263_v_loop_filter(dest_y, linesize, qp_tc);
+ s->h263dsp.h263_v_loop_filter(dest_y + 8, linesize, qp_tc);
- s->dsp.h263_v_loop_filter(dest_cb , uvlinesize, chroma_qp);
- s->dsp.h263_v_loop_filter(dest_cr , uvlinesize, chroma_qp);
+ s->h263dsp.h263_v_loop_filter(dest_cb, uvlinesize, chroma_qp);
+ s->h263dsp.h263_v_loop_filter(dest_cr, uvlinesize, chroma_qp);
}
if(qp_tt)
- s->dsp.h263_h_loop_filter(dest_y-8*linesize+8 , linesize, qp_tt);
+ s->h263dsp.h263_h_loop_filter(dest_y - 8 * linesize + 8, linesize, qp_tt);
if(s->mb_x){
if (qp_tt || IS_SKIP(s->current_picture.mb_type[xy - 1 - s->mb_stride]))
@@ -190,17 +190,17 @@ void ff_h263_loop_filter(MpegEncContext * s){
if(qp_dt){
const int chroma_qp= s->chroma_qscale_table[qp_dt];
- s->dsp.h263_h_loop_filter(dest_y -8*linesize , linesize, qp_dt);
- s->dsp.h263_h_loop_filter(dest_cb-8*uvlinesize, uvlinesize, chroma_qp);
- s->dsp.h263_h_loop_filter(dest_cr-8*uvlinesize, uvlinesize, chroma_qp);
+ s->h263dsp.h263_h_loop_filter(dest_y - 8 * linesize, linesize, qp_dt);
+ s->h263dsp.h263_h_loop_filter(dest_cb - 8 * uvlinesize, uvlinesize, chroma_qp);
+ s->h263dsp.h263_h_loop_filter(dest_cr - 8 * uvlinesize, uvlinesize, chroma_qp);
}
}
}
if(qp_c){
- s->dsp.h263_h_loop_filter(dest_y +8, linesize, qp_c);
+ s->h263dsp.h263_h_loop_filter(dest_y + 8, linesize, qp_c);
if(s->mb_y + 1 == s->mb_height)
- s->dsp.h263_h_loop_filter(dest_y+8*linesize+8, linesize, qp_c);
+ s->h263dsp.h263_h_loop_filter(dest_y + 8 * linesize + 8, linesize, qp_c);
}
if(s->mb_x){
@@ -211,12 +211,12 @@ void ff_h263_loop_filter(MpegEncContext * s){
qp_lc = s->current_picture.qscale_table[xy - 1];
if(qp_lc){
- s->dsp.h263_h_loop_filter(dest_y, linesize, qp_lc);
+ s->h263dsp.h263_h_loop_filter(dest_y, linesize, qp_lc);
if(s->mb_y + 1 == s->mb_height){
const int chroma_qp= s->chroma_qscale_table[qp_lc];
- s->dsp.h263_h_loop_filter(dest_y +8* linesize, linesize, qp_lc);
- s->dsp.h263_h_loop_filter(dest_cb , uvlinesize, chroma_qp);
- s->dsp.h263_h_loop_filter(dest_cr , uvlinesize, chroma_qp);
+ s->h263dsp.h263_h_loop_filter(dest_y + 8 * linesize, linesize, qp_lc);
+ s->h263dsp.h263_h_loop_filter(dest_cb, uvlinesize, chroma_qp);
+ s->h263dsp.h263_h_loop_filter(dest_cr, uvlinesize, chroma_qp);
}
}
}
diff --git a/libavcodec/h263data.h b/libavcodec/h263data.h
index e245e2f635..1cd965f19a 100644
--- a/libavcodec/h263data.h
+++ b/libavcodec/h263data.h
@@ -272,11 +272,6 @@ const uint8_t ff_mba_length[7]={
6, 7, 9, 11, 13, 14, 14
};
-const uint8_t ff_h263_loop_filter_strength[32]={
-// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
- 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9,10,10,10,11,11,11,12,12,12
-};
-
const AVRational ff_h263_pixel_aspect[16]={
{0, 1},
{1, 1},
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index e7030d1cbb..15a9a42552 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -124,6 +124,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
+ ff_h263dsp_init(&s->h263dsp);
ff_h263_decode_init_vlc();
return 0;
diff --git a/libavcodec/h263dsp.c b/libavcodec/h263dsp.c
new file mode 100644
index 0000000000..a6a9347b59
--- /dev/null
+++ b/libavcodec/h263dsp.c
@@ -0,0 +1,108 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavutil/common.h"
+#include "config.h"
+#include "h263dsp.h"
+
+const uint8_t ff_h263_loop_filter_strength[32]={
+// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9,10,10,10,11,11,11,12,12,12
+};
+
+static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){
+ int y;
+ const int strength= ff_h263_loop_filter_strength[qscale];
+
+ for(y=0; y<8; y++){
+ int d1, d2, ad1;
+ int p0= src[y*stride-2];
+ int p1= src[y*stride-1];
+ int p2= src[y*stride+0];
+ int p3= src[y*stride+1];
+ int d = (p0 - p3 + 4*(p2 - p1)) / 8;
+
+ if (d<-2*strength) d1= 0;
+ else if(d<- strength) d1=-2*strength - d;
+ else if(d< strength) d1= d;
+ else if(d< 2*strength) d1= 2*strength - d;
+ else d1= 0;
+
+ p1 += d1;
+ p2 -= d1;
+ if(p1&256) p1= ~(p1>>31);
+ if(p2&256) p2= ~(p2>>31);
+
+ src[y*stride-1] = p1;
+ src[y*stride+0] = p2;
+
+ ad1= FFABS(d1)>>1;
+
+ d2= av_clip((p0-p3)/4, -ad1, ad1);
+
+ src[y*stride-2] = p0 - d2;
+ src[y*stride+1] = p3 + d2;
+ }
+}
+
+static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){
+ int x;
+ const int strength= ff_h263_loop_filter_strength[qscale];
+
+ for(x=0; x<8; x++){
+ int d1, d2, ad1;
+ int p0= src[x-2*stride];
+ int p1= src[x-1*stride];
+ int p2= src[x+0*stride];
+ int p3= src[x+1*stride];
+ int d = (p0 - p3 + 4*(p2 - p1)) / 8;
+
+ if (d<-2*strength) d1= 0;
+ else if(d<- strength) d1=-2*strength - d;
+ else if(d< strength) d1= d;
+ else if(d< 2*strength) d1= 2*strength - d;
+ else d1= 0;
+
+ p1 += d1;
+ p2 -= d1;
+ if(p1&256) p1= ~(p1>>31);
+ if(p2&256) p2= ~(p2>>31);
+
+ src[x-1*stride] = p1;
+ src[x+0*stride] = p2;
+
+ ad1= FFABS(d1)>>1;
+
+ d2= av_clip((p0-p3)/4, -ad1, ad1);
+
+ src[x-2*stride] = p0 - d2;
+ src[x+ stride] = p3 + d2;
+ }
+}
+
+av_cold void ff_h263dsp_init(H263DSPContext *ctx)
+{
+ ctx->h263_h_loop_filter = h263_h_loop_filter_c;
+ ctx->h263_v_loop_filter = h263_v_loop_filter_c;
+
+ if (ARCH_X86)
+ ff_h263dsp_init_x86(ctx);
+}
diff --git a/libavcodec/h263dsp.h b/libavcodec/h263dsp.h
new file mode 100644
index 0000000000..d2cc2ffe70
--- /dev/null
+++ b/libavcodec/h263dsp.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_H263DSP_H
+#define AVCODEC_H263DSP_H
+
+#include <stdint.h>
+
+extern const uint8_t ff_h263_loop_filter_strength[32];
+
+typedef struct H263DSPContext {
+ void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
+ void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale);
+} H263DSPContext;
+
+void ff_h263dsp_init(H263DSPContext *ctx);
+void ff_h263dsp_init_x86(H263DSPContext *ctx);
+
+#endif /* AVCODEC_H263DSP_H */
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 8ba13213c3..5c2607a060 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -33,6 +33,7 @@
#include "error_resilience.h"
#include "get_bits.h"
#include "h264chroma.h"
+#include "h263dsp.h"
#include "hpeldsp.h"
#include "put_bits.h"
#include "ratecontrol.h"
@@ -396,6 +397,7 @@ typedef struct MpegEncContext {
H264ChromaContext h264chroma;
HpelDSPContext hdsp;
VideoDSPContext vdsp;
+ H263DSPContext h263dsp;
int f_code; ///< forward MV resolution
int b_code; ///< backward MV resolution for B Frames (mpeg4)
int16_t (*p_mv_table_base)[2];
@@ -924,7 +926,6 @@ void ff_mpeg1_encode_slice_header(MpegEncContext *s);
extern const uint8_t ff_aic_dc_scale_table[32];
extern const uint8_t ff_h263_chroma_qscale_table[32];
-extern const uint8_t ff_h263_loop_filter_strength[32];
/* rv10.c */
void ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 6f50687064..ce010ecf05 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -221,6 +221,7 @@ av_cold int ff_dct_encode_init(MpegEncContext *s) {
if (ARCH_X86)
ff_dct_encode_init_x86(s);
+ ff_h263dsp_init(&s->h263dsp);
if (!s->dct_quantize)
s->dct_quantize = ff_dct_quantize_c;
if (!s->denoise_dct)
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 57ebdc577c..120a6d99a7 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -500,6 +500,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
+ ff_h263dsp_init(&s->h263dsp);
ff_h263_decode_init_vlc();
/* init rv vlc */
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index a352db1b09..fa281ddfc1 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -12,6 +12,7 @@ OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o \
x86/fdct.o \
x86/motion_est.o
OBJS-$(CONFIG_FFT) += x86/fft_init.o
+OBJS-$(CONFIG_H263DSP) += x86/h263dsp_init.o
OBJS-$(CONFIG_H264CHROMA) += x86/h264chroma_init.o
OBJS-$(CONFIG_H264DSP) += x86/h264dsp_init.o
OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred_init.o
@@ -68,8 +69,7 @@ YASM-OBJS-$(CONFIG_DSPUTIL) += x86/dsputil.o \
x86/qpel.o
YASM-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc.o
YASM-OBJS-$(CONFIG_FFT) += x86/fft.o
-YASM-OBJS-$(CONFIG_H263_DECODER) += x86/h263_loopfilter.o
-YASM-OBJS-$(CONFIG_H263_ENCODER) += x86/h263_loopfilter.o
+YASM-OBJS-$(CONFIG_H263DSP) += x86/h263_loopfilter.o
YASM-OBJS-$(CONFIG_H264CHROMA) += x86/h264_chromamc.o \
x86/h264_chromamc_10bit.o
YASM-OBJS-$(CONFIG_H264DSP) += x86/h264_deblock.o \
diff --git a/libavcodec/x86/dsputil_init.c b/libavcodec/x86/dsputil_init.c
index 2516f2a722..e5e756615a 100644
--- a/libavcodec/x86/dsputil_init.c
+++ b/libavcodec/x86/dsputil_init.c
@@ -71,9 +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
-void ff_h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale);
-void ff_h263_h_loop_filter_mmx(uint8_t *src, int stride, int qscale);
-
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,
@@ -556,11 +553,6 @@ static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
#endif /* HAVE_MMX_INLINE */
#if HAVE_MMX_EXTERNAL
- if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
- c->h263_v_loop_filter = ff_h263_v_loop_filter_mmx;
- c->h263_h_loop_filter = ff_h263_h_loop_filter_mmx;
- }
-
c->vector_clip_int32 = ff_vector_clip_int32_mmx;
#endif /* HAVE_MMX_EXTERNAL */
}
diff --git a/libavcodec/x86/h263dsp_init.c b/libavcodec/x86/h263dsp_init.c
new file mode 100644
index 0000000000..ab81063233
--- /dev/null
+++ b/libavcodec/x86/h263dsp_init.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013 Diego Biurrun <diego@biurrun.de>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/x86/cpu.h"
+#include "libavcodec/h263dsp.h"
+
+void ff_h263_h_loop_filter_mmx(uint8_t *src, int stride, int qscale);
+void ff_h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale);
+
+av_cold void ff_h263dsp_init_x86(H263DSPContext *c)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (EXTERNAL_MMX(cpu_flags)) {
+ c->h263_h_loop_filter = ff_h263_h_loop_filter_mmx;
+ c->h263_v_loop_filter = ff_h263_v_loop_filter_mmx;
+ }
+}