diff options
author | Sebastien Lucas <sebastien.lucas@gmail.com> | 2009-02-12 23:52:52 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2009-02-12 23:52:52 +0000 |
commit | 6af3c226c3e7af638ddd60284ebc6e8d5f5644ec (patch) | |
tree | 43f25328937bd38bec4f9ae69fa1172dedbbd9cf /libavcodec/x86 | |
parent | dd44d9e316c17f473eff9f4a5a94ad0d7adb157e (diff) | |
download | ffmpeg-6af3c226c3e7af638ddd60284ebc6e8d5f5644ec.tar.gz |
add MMX version of vp6_filter_diag
original patch by Sebastien Lucas sebastien.lucas _at_ gmail _dot_ com
Originally committed as revision 17194 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/x86')
-rw-r--r-- | libavcodec/x86/dsputil_mmx.c | 5 | ||||
-rw-r--r-- | libavcodec/x86/vp6dsp_mmx.c | 108 | ||||
-rw-r--r-- | libavcodec/x86/vp6dsp_mmx.h | 30 |
3 files changed, 143 insertions, 0 deletions
diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 4b18873ed3..4d0503df9a 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -31,6 +31,7 @@ #include "mmx.h" #include "vp3dsp_mmx.h" #include "vp3dsp_sse2.h" +#include "vp6dsp_mmx.h" #include "idct_xvid.h" //#undef NDEBUG @@ -2688,6 +2689,10 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->h264_idct_add8 = ff_h264_idct_add8_mmx; c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx; + if (CONFIG_VP6_DECODER) { + c->vp6_filter_diag4 = ff_vp6_filter_diag4_mmx; + } + if (mm_flags & FF_MM_MMXEXT) { c->prefetch = prefetch_mmx2; diff --git a/libavcodec/x86/vp6dsp_mmx.c b/libavcodec/x86/vp6dsp_mmx.c new file mode 100644 index 0000000000..39e40d568e --- /dev/null +++ b/libavcodec/x86/vp6dsp_mmx.c @@ -0,0 +1,108 @@ +/** + * @file libavcodec/x86/vp6dsp_mmx.c + * MMX-optimized functions for the VP6 decoder + * + * Copyright (C) 2009 Sebastien Lucas <sebastien.lucas@gmail.com> + * + * 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 "libavutil/x86_cpu.h" +#include "libavcodec/dsputil.h" +#include "dsputil_mmx.h" +#include "vp6dsp_mmx.h" + + +#define DIAG4_MMX(in1,in2,in3,in4) \ + "movq "#in1"(%0), %%mm0 \n\t" \ + "movq "#in2"(%0), %%mm1 \n\t" \ + "movq %%mm0, %%mm3 \n\t" \ + "movq %%mm1, %%mm4 \n\t" \ + "punpcklbw %%mm7, %%mm0 \n\t" \ + "punpcklbw %%mm7, %%mm1 \n\t" \ + "punpckhbw %%mm7, %%mm3 \n\t" \ + "punpckhbw %%mm7, %%mm4 \n\t" \ + "pmullw 0(%2), %%mm0 \n\t" /* src[x-8 ] * biweight [0] */ \ + "pmullw 8(%2), %%mm1 \n\t" /* src[x ] * biweight [1] */ \ + "pmullw 0(%2), %%mm3 \n\t" /* src[x-8 ] * biweight [0] */ \ + "pmullw 8(%2), %%mm4 \n\t" /* src[x ] * biweight [1] */ \ + "paddw %%mm1, %%mm0 \n\t" \ + "paddw %%mm4, %%mm3 \n\t" \ + "movq "#in3"(%0), %%mm1 \n\t" \ + "movq "#in4"(%0), %%mm2 \n\t" \ + "movq %%mm1, %%mm4 \n\t" \ + "movq %%mm2, %%mm5 \n\t" \ + "punpcklbw %%mm7, %%mm1 \n\t" \ + "punpcklbw %%mm7, %%mm2 \n\t" \ + "punpckhbw %%mm7, %%mm4 \n\t" \ + "punpckhbw %%mm7, %%mm5 \n\t" \ + "pmullw 16(%2), %%mm1 \n\t" /* src[x+8 ] * biweight [2] */ \ + "pmullw 24(%2), %%mm2 \n\t" /* src[x+16] * biweight [3] */ \ + "pmullw 16(%2), %%mm4 \n\t" /* src[x+8 ] * biweight [2] */ \ + "pmullw 24(%2), %%mm5 \n\t" /* src[x+16] * biweight [3] */ \ + "paddw %%mm2, %%mm1 \n\t" \ + "paddw %%mm5, %%mm4 \n\t" \ + "paddsw %%mm1, %%mm0 \n\t" \ + "paddsw %%mm4, %%mm3 \n\t" \ + "paddsw %%mm6, %%mm0 \n\t" /* Add 64 */ \ + "paddsw %%mm6, %%mm3 \n\t" /* Add 64 */ \ + "psraw $7, %%mm0 \n\t" \ + "psraw $7, %%mm3 \n\t" \ + "packuswb %%mm3, %%mm0 \n\t" \ + "movq %%mm0, (%1) \n\t" + +void ff_vp6_filter_diag4_mmx(uint8_t *dst, uint8_t *src, int stride, + const int16_t *h_weights, const int16_t *v_weights) +{ + uint8_t tmp[8*11], *t = tmp; + int16_t weights[4*4]; + int i; + src -= stride; + + for (i=0; i<4*4; i++) + weights[i] = h_weights[i>>2]; + + __asm__ volatile( + "pxor %%mm7, %%mm7 \n\t" + "movq "MANGLE(ff_pw_64)", %%mm6 \n\t" + "1: \n\t" + DIAG4_MMX(-1,0,1,2) + "add $8, %1 \n\t" + "add %3, %0 \n\t" + "decl %4 \n\t" + "jnz 1b \n\t" + : "+r"(src), "+r"(t) + : "r"(weights), "r"((x86_reg)stride), "r"(11) + : "memory"); + + t = tmp + 8; + for (i=0; i<4*4; i++) + weights[i] = v_weights[i>>2]; + + __asm__ volatile( + "pxor %%mm7, %%mm7 \n\t" + "movq "MANGLE(ff_pw_64)", %%mm6 \n\t" + "1: \n\t" + DIAG4_MMX(-8,0,8,16) + "add $8, %0 \n\t" + "add %3, %1 \n\t" + "decl %4 \n\t" + "jnz 1b \n\t" + : "+r"(t), "+r"(dst) + : "r"(weights), "r"((x86_reg)stride), "r"(8) + : "memory"); +} diff --git a/libavcodec/x86/vp6dsp_mmx.h b/libavcodec/x86/vp6dsp_mmx.h new file mode 100644 index 0000000000..743bc4361d --- /dev/null +++ b/libavcodec/x86/vp6dsp_mmx.h @@ -0,0 +1,30 @@ +/* + * vp6dsp MMX function declarations + * Copyright (c) 2009 Sebastien Lucas <sebastien.lucas@gmail.com> + * + * 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_X86_VP6DSP_MMX_H +#define AVCODEC_X86_VP6DSP_MMX_H + +#include <stdint.h> + +void ff_vp6_filter_diag4_mmx(uint8_t *dst, uint8_t *src, int stride, + const int16_t *h_weights,const int16_t *v_weights); + +#endif /* AVCODEC_X86_VP6DSP_MMX_H */ |