summaryrefslogtreecommitdiff
path: root/libavcodec/x86
diff options
context:
space:
mode:
authorZuxy Meng <zuxy.meng@gmail.com>2009-02-13 00:02:33 +0000
committerAurelien Jacobs <aurel@gnuage.org>2009-02-13 00:02:33 +0000
commitecb24904fe55e463cdef58a0d55f06b27133ccdf (patch)
tree1387693cc7e2ab797b55b3600febdc6042c7d94b /libavcodec/x86
parent6af3c226c3e7af638ddd60284ebc6e8d5f5644ec (diff)
add SSE2 version of vp6_filter_diag
original patch by Zuxy Meng zuxy.meng _at_ gmail _dot_ com Originally committed as revision 17195 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/x86')
-rw-r--r--libavcodec/x86/dsputil_mmx.c5
-rw-r--r--libavcodec/x86/vp6dsp_sse2.c98
-rw-r--r--libavcodec/x86/vp6dsp_sse2.h30
3 files changed, 133 insertions, 0 deletions
diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c
index 4d0503df9a..2f47f5fde9 100644
--- a/libavcodec/x86/dsputil_mmx.c
+++ b/libavcodec/x86/dsputil_mmx.c
@@ -32,6 +32,7 @@
#include "vp3dsp_mmx.h"
#include "vp3dsp_sse2.h"
#include "vp6dsp_mmx.h"
+#include "vp6dsp_sse2.h"
#include "idct_xvid.h"
//#undef NDEBUG
@@ -2901,6 +2902,10 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
H264_QPEL_FUNCS(3, 1, sse2);
H264_QPEL_FUNCS(3, 2, sse2);
H264_QPEL_FUNCS(3, 3, sse2);
+
+ if (CONFIG_VP6_DECODER) {
+ c->vp6_filter_diag4 = ff_vp6_filter_diag4_sse2;
+ }
}
#if HAVE_SSSE3
if(mm_flags & FF_MM_SSSE3){
diff --git a/libavcodec/x86/vp6dsp_sse2.c b/libavcodec/x86/vp6dsp_sse2.c
new file mode 100644
index 0000000000..c72a0cacb8
--- /dev/null
+++ b/libavcodec/x86/vp6dsp_sse2.c
@@ -0,0 +1,98 @@
+/**
+ * @file libavcodec/x86/vp6dsp_mmx.c
+ * SSE2-optimized functions for the VP6 decoder
+ *
+ * Copyright (C) 2009 Zuxy Meng <zuxy.meng@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_sse2.h"
+
+#define DIAG4_SSE2(in1,in2,in3,in4) \
+ "movq "#in1"(%0), %%xmm0 \n\t" \
+ "movq "#in2"(%0), %%xmm1 \n\t" \
+ "punpcklbw %%xmm7, %%xmm0 \n\t" \
+ "punpcklbw %%xmm7, %%xmm1 \n\t" \
+ "pmullw %%xmm4, %%xmm0 \n\t" /* src[x-8 ] * biweight [0] */ \
+ "pmullw %%xmm5, %%xmm1 \n\t" /* src[x ] * biweight [1] */ \
+ "paddw %%xmm1, %%xmm0 \n\t" \
+ "movq "#in3"(%0), %%xmm1 \n\t" \
+ "movq "#in4"(%0), %%xmm2 \n\t" \
+ "punpcklbw %%xmm7, %%xmm1 \n\t" \
+ "punpcklbw %%xmm7, %%xmm2 \n\t" \
+ "pmullw %%xmm6, %%xmm1 \n\t" /* src[x+8 ] * biweight [2] */ \
+ "pmullw %%xmm3, %%xmm2 \n\t" /* src[x+16] * biweight [3] */ \
+ "paddw %%xmm2, %%xmm1 \n\t" \
+ "paddsw %%xmm1, %%xmm0 \n\t" \
+ "paddsw "MANGLE(ff_pw_64)", %%xmm0 \n\t" /* Add 64 */ \
+ "psraw $7, %%xmm0 \n\t" \
+ "packuswb %%xmm0, %%xmm0 \n\t" \
+ "movq %%xmm0, (%1) \n\t" \
+
+void ff_vp6_filter_diag4_sse2(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;
+ src -= stride;
+
+ __asm__ volatile(
+ "pxor %%xmm7, %%xmm7 \n\t"
+ "movq %4, %%xmm3 \n\t"
+ "pshuflw $0, %%xmm3, %%xmm4 \n\t"
+ "punpcklqdq %%xmm4, %%xmm4 \n\t"
+ "pshuflw $85, %%xmm3, %%xmm5 \n\t"
+ "punpcklqdq %%xmm5, %%xmm5 \n\t"
+ "pshuflw $170, %%xmm3, %%xmm6 \n\t"
+ "punpcklqdq %%xmm6, %%xmm6 \n\t"
+ "pshuflw $255, %%xmm3, %%xmm3 \n\t"
+ "punpcklqdq %%xmm3, %%xmm3 \n\t"
+ "1: \n\t"
+ DIAG4_SSE2(-1,0,1,2)
+ "add $8, %1 \n\t"
+ "add %2, %0 \n\t"
+ "decl %3 \n\t"
+ "jnz 1b \n\t"
+ : "+r"(src), "+r"(t)
+ : "g"((x86_reg)stride), "r"(11), "m"(*(const int64_t*)h_weights)
+ : "memory");
+
+ t = tmp + 8;
+
+ __asm__ volatile(
+ "movq %4, %%xmm3 \n\t"
+ "pshuflw $0, %%xmm3, %%xmm4 \n\t"
+ "punpcklqdq %%xmm4, %%xmm4 \n\t"
+ "pshuflw $85, %%xmm3, %%xmm5 \n\t"
+ "punpcklqdq %%xmm5, %%xmm5 \n\t"
+ "pshuflw $170, %%xmm3, %%xmm6 \n\t"
+ "punpcklqdq %%xmm6, %%xmm6 \n\t"
+ "pshuflw $255, %%xmm3, %%xmm3 \n\t"
+ "punpcklqdq %%xmm3, %%xmm3 \n\t"
+ "1: \n\t"
+ DIAG4_SSE2(-8,0,8,16)
+ "add $8, %0 \n\t"
+ "add %2, %1 \n\t"
+ "decl %3 \n\t"
+ "jnz 1b \n\t"
+ : "+r"(t), "+r"(dst)
+ : "g"((x86_reg)stride), "r"(8), "m"(*(const int64_t*)v_weights)
+ : "memory");
+}
diff --git a/libavcodec/x86/vp6dsp_sse2.h b/libavcodec/x86/vp6dsp_sse2.h
new file mode 100644
index 0000000000..a30089a3e5
--- /dev/null
+++ b/libavcodec/x86/vp6dsp_sse2.h
@@ -0,0 +1,30 @@
+/*
+ * vp6dsp SSE2 function declarations
+ * Copyright (c) 2009 Zuxy Meng <zuxy.meng@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_SSE2_H
+#define AVCODEC_X86_VP6DSP_SSE2_H
+
+#include <stdint.h>
+
+void ff_vp6_filter_diag4_sse2(uint8_t *dst, uint8_t *src, int stride,
+ const int16_t *h_weights,const int16_t *v_weights);
+
+#endif /* AVCODEC_X86_VP6DSP_SSE2_H */