summaryrefslogtreecommitdiff
path: root/libavutil/x86
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-06-08 23:02:54 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-06-08 23:59:09 +0200
commit7e22514d98ecd56cc4e55dac7c813551e2152b80 (patch)
tree13c47e1e1215525323177a008d5406a7d61a418a /libavutil/x86
parente016e3c9d7ce1493b952bdd8232f7e03077469a3 (diff)
parent3b81a18ba30bf18bab78f56744d8f3e1e4060104 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: float_dsp: ppc: add a separate header for Altivec function prototypes ARM: fix float_dsp breakage from d5a7229 Add a float DSP framework to libavutil PPC: Move types_altivec.h and util_altivec.h from libavcodec to libavutil ARM: Move asm.S from libavcodec to libavutil vc1dsp: mark put/avg_vc1_mspel_mc() always_inline Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/x86')
-rw-r--r--libavutil/x86/Makefile3
-rw-r--r--libavutil/x86/float_dsp.asm55
-rw-r--r--libavutil/x86/float_dsp_init.c41
3 files changed, 99 insertions, 0 deletions
diff --git a/libavutil/x86/Makefile b/libavutil/x86/Makefile
index de8a341442..4546353669 100644
--- a/libavutil/x86/Makefile
+++ b/libavutil/x86/Makefile
@@ -1 +1,4 @@
OBJS += x86/cpu.o \
+ x86/float_dsp_init.o \
+
+YASM-OBJS += x86/float_dsp.o \
diff --git a/libavutil/x86/float_dsp.asm b/libavutil/x86/float_dsp.asm
new file mode 100644
index 0000000000..53be7ab99a
--- /dev/null
+++ b/libavutil/x86/float_dsp.asm
@@ -0,0 +1,55 @@
+;*****************************************************************************
+;* x86-optimized Float 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
+;******************************************************************************
+
+%include "x86inc.asm"
+
+SECTION .text
+
+;-----------------------------------------------------------------------------
+; void vector_fmul(float *dst, const float *src0, const float *src1, int len)
+;-----------------------------------------------------------------------------
+%macro VECTOR_FMUL 0
+cglobal vector_fmul, 4,4,2, dst, src0, src1, len
+ lea lenq, [lend*4 - 2*mmsize]
+ALIGN 16
+.loop
+ mova m0, [src0q + lenq]
+ mova m1, [src0q + lenq + mmsize]
+ mulps m0, m0, [src1q + lenq]
+ mulps m1, m1, [src1q + lenq + mmsize]
+ mova [dstq + lenq], m0
+ mova [dstq + lenq + mmsize], m1
+
+ sub lenq, 2*mmsize
+ jge .loop
+%if mmsize == 32
+ vzeroupper
+ RET
+%else
+ REP_RET
+%endif
+%endmacro
+
+INIT_XMM sse
+VECTOR_FMUL
+%if HAVE_AVX
+INIT_YMM avx
+VECTOR_FMUL
+%endif
diff --git a/libavutil/x86/float_dsp_init.c b/libavutil/x86/float_dsp_init.c
new file mode 100644
index 0000000000..8f6980cbc2
--- /dev/null
+++ b/libavutil/x86/float_dsp_init.c
@@ -0,0 +1,41 @@
+/*
+ * 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 "config.h"
+
+#include "libavutil/cpu.h"
+#include "libavutil/float_dsp.h"
+
+extern void ff_vector_fmul_sse(float *dst, const float *src0, const float *src1,
+ int len);
+extern void ff_vector_fmul_avx(float *dst, const float *src0, const float *src1,
+ int len);
+
+void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp)
+{
+#if HAVE_YASM
+ int mm_flags = av_get_cpu_flags();
+
+ if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) {
+ fdsp->vector_fmul = ff_vector_fmul_sse;
+ }
+ if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) {
+ fdsp->vector_fmul = ff_vector_fmul_avx;
+ }
+#endif
+}