summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-12-17 19:33:19 +0000
committermichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-12-17 19:33:19 +0000
commitf846d875d50d07895a4453d8c240b475e489bf2c (patch)
tree6791dbf7bf41a71d962afc7606371d001f9d180b
parent8d1f9c14447580f031efe36414a64ac01c48e2c4 (diff)
downloadmpv-f846d875d50d07895a4453d8c240b475e489bf2c.tar.bz2
mpv-f846d875d50d07895a4453d8c240b475e489bf2c.tar.xz
mmx opt
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3568 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--liba52/resample.c51
-rw-r--r--liba52/resample_c.c51
-rw-r--r--liba52/resample_mmx.c51
3 files changed, 153 insertions, 0 deletions
diff --git a/liba52/resample.c b/liba52/resample.c
index 61d12aa0cf..7d774bc26e 100644
--- a/liba52/resample.c
+++ b/liba52/resample.c
@@ -9,6 +9,11 @@
#include <inttypes.h>
#include "a52.h"
+#include "../config.h"
+
+#ifdef HAVE_MMX
+static uint64_t __attribute__((aligned(16))) magicF2W= 0x43c0000043c00000LL;
+#endif
static inline int16_t convert (int32_t i)
{
@@ -43,10 +48,56 @@ int a52_resample(float * _f, int16_t * s16)
case A52_CHANNEL:
case A52_STEREO:
case A52_DOLBY:
+/* benchmark scores are 0.3% better with SSE but we would need to set bias=0 and premultiply it
+#ifdef HAVE_SSE
+ asm volatile(
+ "movl $-1024, %%esi \n\t"
+ "1: \n\t"
+ "cvtps2pi (%1, %%esi), %%mm0 \n\t"
+ "cvtps2pi 1024(%1, %%esi), %%mm2\n\t"
+ "movq %%mm0, %%mm1 \n\t"
+ "punpcklwd %%mm2, %%mm0 \n\t"
+ "punpckhwd %%mm2, %%mm1 \n\t"
+ "movq %%mm0, (%0, %%esi) \n\t"
+ "movq %%mm1, 8(%0, %%esi) \n\t"
+ "addl $16, %%esi \n\t"
+ " jnz 1b \n\t"
+ "emms \n\t"
+ :: "r" (s16+512), "r" (f+256)
+ :"%esi", "memory"
+ );*/
+#ifdef HAVE_MMX
+ asm volatile(
+ "movl $-1024, %%esi \n\t"
+ "movq magicF2W, %%mm7 \n\t"
+ "1: \n\t"
+ "movq (%1, %%esi), %%mm0 \n\t"
+ "movq 8(%1, %%esi), %%mm1 \n\t"
+ "movq 1024(%1, %%esi), %%mm2 \n\t"
+ "movq 1032(%1, %%esi), %%mm3 \n\t"
+ "psubd %%mm7, %%mm0 \n\t"
+ "psubd %%mm7, %%mm1 \n\t"
+ "psubd %%mm7, %%mm2 \n\t"
+ "psubd %%mm7, %%mm3 \n\t"
+ "packssdw %%mm1, %%mm0 \n\t"
+ "packssdw %%mm3, %%mm2 \n\t"
+ "movq %%mm0, %%mm1 \n\t"
+ "punpcklwd %%mm2, %%mm0 \n\t"
+ "punpckhwd %%mm2, %%mm1 \n\t"
+ "movq %%mm0, (%0, %%esi) \n\t"
+ "movq %%mm1, 8(%0, %%esi) \n\t"
+ "addl $16, %%esi \n\t"
+ " jnz 1b \n\t"
+ "emms \n\t"
+ :: "r" (s16+512), "r" (f+256)
+ :"%esi", "memory"
+ );
+#else
for (i = 0; i < 256; i++) {
s16[2*i] = convert (f[i]);
s16[2*i+1] = convert (f[i+256]);
}
+#endif
break;
case A52_3F:
for (i = 0; i < 256; i++) {
diff --git a/liba52/resample_c.c b/liba52/resample_c.c
index 61d12aa0cf..7d774bc26e 100644
--- a/liba52/resample_c.c
+++ b/liba52/resample_c.c
@@ -9,6 +9,11 @@
#include <inttypes.h>
#include "a52.h"
+#include "../config.h"
+
+#ifdef HAVE_MMX
+static uint64_t __attribute__((aligned(16))) magicF2W= 0x43c0000043c00000LL;
+#endif
static inline int16_t convert (int32_t i)
{
@@ -43,10 +48,56 @@ int a52_resample(float * _f, int16_t * s16)
case A52_CHANNEL:
case A52_STEREO:
case A52_DOLBY:
+/* benchmark scores are 0.3% better with SSE but we would need to set bias=0 and premultiply it
+#ifdef HAVE_SSE
+ asm volatile(
+ "movl $-1024, %%esi \n\t"
+ "1: \n\t"
+ "cvtps2pi (%1, %%esi), %%mm0 \n\t"
+ "cvtps2pi 1024(%1, %%esi), %%mm2\n\t"
+ "movq %%mm0, %%mm1 \n\t"
+ "punpcklwd %%mm2, %%mm0 \n\t"
+ "punpckhwd %%mm2, %%mm1 \n\t"
+ "movq %%mm0, (%0, %%esi) \n\t"
+ "movq %%mm1, 8(%0, %%esi) \n\t"
+ "addl $16, %%esi \n\t"
+ " jnz 1b \n\t"
+ "emms \n\t"
+ :: "r" (s16+512), "r" (f+256)
+ :"%esi", "memory"
+ );*/
+#ifdef HAVE_MMX
+ asm volatile(
+ "movl $-1024, %%esi \n\t"
+ "movq magicF2W, %%mm7 \n\t"
+ "1: \n\t"
+ "movq (%1, %%esi), %%mm0 \n\t"
+ "movq 8(%1, %%esi), %%mm1 \n\t"
+ "movq 1024(%1, %%esi), %%mm2 \n\t"
+ "movq 1032(%1, %%esi), %%mm3 \n\t"
+ "psubd %%mm7, %%mm0 \n\t"
+ "psubd %%mm7, %%mm1 \n\t"
+ "psubd %%mm7, %%mm2 \n\t"
+ "psubd %%mm7, %%mm3 \n\t"
+ "packssdw %%mm1, %%mm0 \n\t"
+ "packssdw %%mm3, %%mm2 \n\t"
+ "movq %%mm0, %%mm1 \n\t"
+ "punpcklwd %%mm2, %%mm0 \n\t"
+ "punpckhwd %%mm2, %%mm1 \n\t"
+ "movq %%mm0, (%0, %%esi) \n\t"
+ "movq %%mm1, 8(%0, %%esi) \n\t"
+ "addl $16, %%esi \n\t"
+ " jnz 1b \n\t"
+ "emms \n\t"
+ :: "r" (s16+512), "r" (f+256)
+ :"%esi", "memory"
+ );
+#else
for (i = 0; i < 256; i++) {
s16[2*i] = convert (f[i]);
s16[2*i+1] = convert (f[i+256]);
}
+#endif
break;
case A52_3F:
for (i = 0; i < 256; i++) {
diff --git a/liba52/resample_mmx.c b/liba52/resample_mmx.c
index 61d12aa0cf..7d774bc26e 100644
--- a/liba52/resample_mmx.c
+++ b/liba52/resample_mmx.c
@@ -9,6 +9,11 @@
#include <inttypes.h>
#include "a52.h"
+#include "../config.h"
+
+#ifdef HAVE_MMX
+static uint64_t __attribute__((aligned(16))) magicF2W= 0x43c0000043c00000LL;
+#endif
static inline int16_t convert (int32_t i)
{
@@ -43,10 +48,56 @@ int a52_resample(float * _f, int16_t * s16)
case A52_CHANNEL:
case A52_STEREO:
case A52_DOLBY:
+/* benchmark scores are 0.3% better with SSE but we would need to set bias=0 and premultiply it
+#ifdef HAVE_SSE
+ asm volatile(
+ "movl $-1024, %%esi \n\t"
+ "1: \n\t"
+ "cvtps2pi (%1, %%esi), %%mm0 \n\t"
+ "cvtps2pi 1024(%1, %%esi), %%mm2\n\t"
+ "movq %%mm0, %%mm1 \n\t"
+ "punpcklwd %%mm2, %%mm0 \n\t"
+ "punpckhwd %%mm2, %%mm1 \n\t"
+ "movq %%mm0, (%0, %%esi) \n\t"
+ "movq %%mm1, 8(%0, %%esi) \n\t"
+ "addl $16, %%esi \n\t"
+ " jnz 1b \n\t"
+ "emms \n\t"
+ :: "r" (s16+512), "r" (f+256)
+ :"%esi", "memory"
+ );*/
+#ifdef HAVE_MMX
+ asm volatile(
+ "movl $-1024, %%esi \n\t"
+ "movq magicF2W, %%mm7 \n\t"
+ "1: \n\t"
+ "movq (%1, %%esi), %%mm0 \n\t"
+ "movq 8(%1, %%esi), %%mm1 \n\t"
+ "movq 1024(%1, %%esi), %%mm2 \n\t"
+ "movq 1032(%1, %%esi), %%mm3 \n\t"
+ "psubd %%mm7, %%mm0 \n\t"
+ "psubd %%mm7, %%mm1 \n\t"
+ "psubd %%mm7, %%mm2 \n\t"
+ "psubd %%mm7, %%mm3 \n\t"
+ "packssdw %%mm1, %%mm0 \n\t"
+ "packssdw %%mm3, %%mm2 \n\t"
+ "movq %%mm0, %%mm1 \n\t"
+ "punpcklwd %%mm2, %%mm0 \n\t"
+ "punpckhwd %%mm2, %%mm1 \n\t"
+ "movq %%mm0, (%0, %%esi) \n\t"
+ "movq %%mm1, 8(%0, %%esi) \n\t"
+ "addl $16, %%esi \n\t"
+ " jnz 1b \n\t"
+ "emms \n\t"
+ :: "r" (s16+512), "r" (f+256)
+ :"%esi", "memory"
+ );
+#else
for (i = 0; i < 256; i++) {
s16[2*i] = convert (f[i]);
s16[2*i+1] = convert (f[i+256]);
}
+#endif
break;
case A52_3F:
for (i = 0; i < 256; i++) {