aboutsummaryrefslogtreecommitdiffstats
path: root/libswresample/x86
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-06-19 03:08:19 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-06-28 00:36:27 +0200
commit4ccf6e397139ad83bc7413f8cf7ec667be6ace3a (patch)
treea6284fe635b4e5e5349ee0bb3b985c619e22608b /libswresample/x86
parent7803a040419f7abb82310fb02a109f6a411650d6 (diff)
downloadffmpeg-4ccf6e397139ad83bc7413f8cf7ec667be6ace3a.tar.gz
swr: MMX2 & SSSE3 int16 resample core
about 4 times faster Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample/x86')
-rw-r--r--libswresample/x86/resample_mmx.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/libswresample/x86/resample_mmx.h b/libswresample/x86/resample_mmx.h
new file mode 100644
index 0000000000..bbf23adf6f
--- /dev/null
+++ b/libswresample/x86/resample_mmx.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2012 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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 "libavutil/cpu.h"
+
+int swri_resample_int16_mmx2 (struct ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx);
+int swri_resample_int16_ssse3(struct ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx);
+
+DECLARE_ALIGNED(16, const uint64_t, ff_resample_int16_rounder)[2] = { 0x0000000000004000ULL, 0x0000000000000000ULL};
+
+#define COMMON_CORE_INT16_MMX2 \
+ x86_reg len= -2*c->filter_length;\
+__asm volatile(\
+ "movq "MANGLE(ff_resample_int16_rounder)", %%mm0 \n\t"\
+ "1: \n\t"\
+ "movq (%1, %0), %%mm1 \n\t"\
+ "pmaddwd (%2, %0), %%mm1 \n\t"\
+ "paddd %%mm1, %%mm0 \n\t"\
+ "add $8, %0 \n\t"\
+ " js 1b \n\t"\
+ "pshufw $0x0E, %%mm0, %%mm1 \n\t"\
+ "paddd %%mm1, %%mm0 \n\t"\
+ "psrad $15, %%mm0 \n\t"\
+ "packssdw %%mm0, %%mm0 \n\t"\
+ "movd %%mm0, (%3) \n\t"\
+ : "+r" (len)\
+ : "r" (((uint8_t*)(src+sample_index))-len),\
+ "r" (((uint8_t*)filter)-len),\
+ "r" (dst+dst_index)\
+);
+
+#define COMMON_CORE_INT16_SSSE3 \
+ x86_reg len= -2*c->filter_length;\
+__asm volatile(\
+ "movdqa "MANGLE(ff_resample_int16_rounder)", %%xmm0 \n\t"\
+ "1: \n\t"\
+ "movdqu (%1, %0), %%xmm1 \n\t"\
+ "pmaddwd (%2, %0), %%xmm1 \n\t"\
+ "paddd %%xmm1, %%xmm0 \n\t"\
+ "add $16, %0 \n\t"\
+ " js 1b \n\t"\
+ "phaddd %%xmm0, %%xmm0 \n\t"\
+ "phaddd %%xmm0, %%xmm0 \n\t"\
+ "psrad $15, %%xmm0 \n\t"\
+ "packssdw %%xmm0, %%xmm0 \n\t"\
+ "movd %%xmm0, (%3) \n\t"\
+ : "+r" (len)\
+ : "r" (((uint8_t*)(src+sample_index))-len),\
+ "r" (((uint8_t*)filter)-len),\
+ "r" (dst+dst_index)\
+);