From 61c3a3af34e6c58e6af70394e4190015901e9d84 Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 17 Dec 2001 21:19:57 +0000 Subject: MMX opt git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3570 b3059339-0415-0410-9bf9-f77b7e298cf2 --- liba52/resample.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++ liba52/resample_c.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++ liba52/resample_mmx.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 285 insertions(+) (limited to 'liba52') diff --git a/liba52/resample.c b/liba52/resample.c index 7d774bc26e..99645fce73 100644 --- a/liba52/resample.c +++ b/liba52/resample.c @@ -7,6 +7,14 @@ // a52_resample() should do the conversion. +// MMX optimizations from Michael Niedermayer (michaelni@gmx.at) (under GPL) + +/* optimization TODO / NOTES + movntq is slightly faster (0.5% with the current test.c benchmark) + (but thats just test.c so that needs to be testd in reallity) + and it would mean (C / MMX2 / MMX / 3DNOW) versions +*/ + #include #include "a52.h" #include "../config.h" @@ -108,12 +116,61 @@ int a52_resample(float * _f, int16_t * s16) } break; case A52_2F2R: +#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 2048(%1, %%esi), %%mm3 \n\t" + "movq 2056(%1, %%esi), %%mm4 \n\t" + "movq 3072(%1, %%esi), %%mm5 \n\t" + "movq 3080(%1, %%esi), %%mm6 \n\t" + "psubd %%mm7, %%mm3 \n\t" + "psubd %%mm7, %%mm4 \n\t" + "psubd %%mm7, %%mm5 \n\t" + "psubd %%mm7, %%mm6 \n\t" + "packssdw %%mm4, %%mm3 \n\t" + "packssdw %%mm6, %%mm5 \n\t" + "movq %%mm0, %%mm1 \n\t" + "movq %%mm3, %%mm4 \n\t" + "punpcklwd %%mm2, %%mm0 \n\t" + "punpckhwd %%mm2, %%mm1 \n\t" + "punpcklwd %%mm5, %%mm3 \n\t" + "punpckhwd %%mm5, %%mm4 \n\t" + "movq %%mm0, %%mm2 \n\t" + "movq %%mm1, %%mm5 \n\t" + "punpckldq %%mm3, %%mm0 \n\t" + "punpckhdq %%mm3, %%mm2 \n\t" + "punpckldq %%mm4, %%mm1 \n\t" + "punpckhdq %%mm4, %%mm5 \n\t" + "movq %%mm0, (%0, %%esi,2) \n\t" + "movq %%mm2, 8(%0, %%esi,2) \n\t" + "movq %%mm1, 16(%0, %%esi,2) \n\t" + "movq %%mm5, 24(%0, %%esi,2) \n\t" + "addl $16, %%esi \n\t" + " jnz 1b \n\t" + "emms \n\t" + :: "r" (s16+1024), "r" (f+256) + :"%esi", "memory" + ); +#else for (i = 0; i < 256; i++) { s16[4*i] = convert (f[i]); s16[4*i+1] = convert (f[i+256]); s16[4*i+2] = convert (f[i+512]); s16[4*i+3] = convert (f[i+768]); } +#endif break; case A52_3F2R: for (i = 0; i < 256; i++) { @@ -125,11 +182,49 @@ int a52_resample(float * _f, int16_t * s16) } break; case A52_MONO | A52_LFE: +#ifdef HAVE_MMX + asm volatile( + "movl $-1024, %%esi \n\t" + "movq magicF2W, %%mm7 \n\t" + "pxor %%mm6, %%mm6 \n\t" + "1: \n\t" + "movq 1024(%1, %%esi), %%mm0 \n\t" + "movq 1032(%1, %%esi), %%mm1 \n\t" + "movq (%1, %%esi), %%mm2 \n\t" + "movq 8(%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" + "leal (%%esi, %%esi, 2), %%edi \n\t" + "movq %%mm6, (%0, %%edi) \n\t" + "movd %%mm0, 8(%0, %%edi) \n\t" + "punpckhdq %%mm0, %%mm0 \n\t" + "movq %%mm6, 12(%0, %%edi) \n\t" + "movd %%mm0, 20(%0, %%edi) \n\t" + "movq %%mm6, 24(%0, %%edi) \n\t" + "movd %%mm1, 32(%0, %%edi) \n\t" + "punpckhdq %%mm1, %%mm1 \n\t" + "movq %%mm6, 36(%0, %%edi) \n\t" + "movd %%mm1, 44(%0, %%edi) \n\t" + "addl $16, %%esi \n\t" + " jnz 1b \n\t" + "emms \n\t" + :: "r" (s16+1536), "r" (f+256) + :"%esi", "%edi", "memory" + ); +#else for (i = 0; i < 256; i++) { s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0; s16[6*i+4] = convert (f[i+256]); s16[6*i+5] = convert (f[i]); } +#endif break; case A52_CHANNEL | A52_LFE: case A52_STEREO | A52_LFE: diff --git a/liba52/resample_c.c b/liba52/resample_c.c index 7d774bc26e..99645fce73 100644 --- a/liba52/resample_c.c +++ b/liba52/resample_c.c @@ -7,6 +7,14 @@ // a52_resample() should do the conversion. +// MMX optimizations from Michael Niedermayer (michaelni@gmx.at) (under GPL) + +/* optimization TODO / NOTES + movntq is slightly faster (0.5% with the current test.c benchmark) + (but thats just test.c so that needs to be testd in reallity) + and it would mean (C / MMX2 / MMX / 3DNOW) versions +*/ + #include #include "a52.h" #include "../config.h" @@ -108,12 +116,61 @@ int a52_resample(float * _f, int16_t * s16) } break; case A52_2F2R: +#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 2048(%1, %%esi), %%mm3 \n\t" + "movq 2056(%1, %%esi), %%mm4 \n\t" + "movq 3072(%1, %%esi), %%mm5 \n\t" + "movq 3080(%1, %%esi), %%mm6 \n\t" + "psubd %%mm7, %%mm3 \n\t" + "psubd %%mm7, %%mm4 \n\t" + "psubd %%mm7, %%mm5 \n\t" + "psubd %%mm7, %%mm6 \n\t" + "packssdw %%mm4, %%mm3 \n\t" + "packssdw %%mm6, %%mm5 \n\t" + "movq %%mm0, %%mm1 \n\t" + "movq %%mm3, %%mm4 \n\t" + "punpcklwd %%mm2, %%mm0 \n\t" + "punpckhwd %%mm2, %%mm1 \n\t" + "punpcklwd %%mm5, %%mm3 \n\t" + "punpckhwd %%mm5, %%mm4 \n\t" + "movq %%mm0, %%mm2 \n\t" + "movq %%mm1, %%mm5 \n\t" + "punpckldq %%mm3, %%mm0 \n\t" + "punpckhdq %%mm3, %%mm2 \n\t" + "punpckldq %%mm4, %%mm1 \n\t" + "punpckhdq %%mm4, %%mm5 \n\t" + "movq %%mm0, (%0, %%esi,2) \n\t" + "movq %%mm2, 8(%0, %%esi,2) \n\t" + "movq %%mm1, 16(%0, %%esi,2) \n\t" + "movq %%mm5, 24(%0, %%esi,2) \n\t" + "addl $16, %%esi \n\t" + " jnz 1b \n\t" + "emms \n\t" + :: "r" (s16+1024), "r" (f+256) + :"%esi", "memory" + ); +#else for (i = 0; i < 256; i++) { s16[4*i] = convert (f[i]); s16[4*i+1] = convert (f[i+256]); s16[4*i+2] = convert (f[i+512]); s16[4*i+3] = convert (f[i+768]); } +#endif break; case A52_3F2R: for (i = 0; i < 256; i++) { @@ -125,11 +182,49 @@ int a52_resample(float * _f, int16_t * s16) } break; case A52_MONO | A52_LFE: +#ifdef HAVE_MMX + asm volatile( + "movl $-1024, %%esi \n\t" + "movq magicF2W, %%mm7 \n\t" + "pxor %%mm6, %%mm6 \n\t" + "1: \n\t" + "movq 1024(%1, %%esi), %%mm0 \n\t" + "movq 1032(%1, %%esi), %%mm1 \n\t" + "movq (%1, %%esi), %%mm2 \n\t" + "movq 8(%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" + "leal (%%esi, %%esi, 2), %%edi \n\t" + "movq %%mm6, (%0, %%edi) \n\t" + "movd %%mm0, 8(%0, %%edi) \n\t" + "punpckhdq %%mm0, %%mm0 \n\t" + "movq %%mm6, 12(%0, %%edi) \n\t" + "movd %%mm0, 20(%0, %%edi) \n\t" + "movq %%mm6, 24(%0, %%edi) \n\t" + "movd %%mm1, 32(%0, %%edi) \n\t" + "punpckhdq %%mm1, %%mm1 \n\t" + "movq %%mm6, 36(%0, %%edi) \n\t" + "movd %%mm1, 44(%0, %%edi) \n\t" + "addl $16, %%esi \n\t" + " jnz 1b \n\t" + "emms \n\t" + :: "r" (s16+1536), "r" (f+256) + :"%esi", "%edi", "memory" + ); +#else for (i = 0; i < 256; i++) { s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0; s16[6*i+4] = convert (f[i+256]); s16[6*i+5] = convert (f[i]); } +#endif break; case A52_CHANNEL | A52_LFE: case A52_STEREO | A52_LFE: diff --git a/liba52/resample_mmx.c b/liba52/resample_mmx.c index 7d774bc26e..99645fce73 100644 --- a/liba52/resample_mmx.c +++ b/liba52/resample_mmx.c @@ -7,6 +7,14 @@ // a52_resample() should do the conversion. +// MMX optimizations from Michael Niedermayer (michaelni@gmx.at) (under GPL) + +/* optimization TODO / NOTES + movntq is slightly faster (0.5% with the current test.c benchmark) + (but thats just test.c so that needs to be testd in reallity) + and it would mean (C / MMX2 / MMX / 3DNOW) versions +*/ + #include #include "a52.h" #include "../config.h" @@ -108,12 +116,61 @@ int a52_resample(float * _f, int16_t * s16) } break; case A52_2F2R: +#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 2048(%1, %%esi), %%mm3 \n\t" + "movq 2056(%1, %%esi), %%mm4 \n\t" + "movq 3072(%1, %%esi), %%mm5 \n\t" + "movq 3080(%1, %%esi), %%mm6 \n\t" + "psubd %%mm7, %%mm3 \n\t" + "psubd %%mm7, %%mm4 \n\t" + "psubd %%mm7, %%mm5 \n\t" + "psubd %%mm7, %%mm6 \n\t" + "packssdw %%mm4, %%mm3 \n\t" + "packssdw %%mm6, %%mm5 \n\t" + "movq %%mm0, %%mm1 \n\t" + "movq %%mm3, %%mm4 \n\t" + "punpcklwd %%mm2, %%mm0 \n\t" + "punpckhwd %%mm2, %%mm1 \n\t" + "punpcklwd %%mm5, %%mm3 \n\t" + "punpckhwd %%mm5, %%mm4 \n\t" + "movq %%mm0, %%mm2 \n\t" + "movq %%mm1, %%mm5 \n\t" + "punpckldq %%mm3, %%mm0 \n\t" + "punpckhdq %%mm3, %%mm2 \n\t" + "punpckldq %%mm4, %%mm1 \n\t" + "punpckhdq %%mm4, %%mm5 \n\t" + "movq %%mm0, (%0, %%esi,2) \n\t" + "movq %%mm2, 8(%0, %%esi,2) \n\t" + "movq %%mm1, 16(%0, %%esi,2) \n\t" + "movq %%mm5, 24(%0, %%esi,2) \n\t" + "addl $16, %%esi \n\t" + " jnz 1b \n\t" + "emms \n\t" + :: "r" (s16+1024), "r" (f+256) + :"%esi", "memory" + ); +#else for (i = 0; i < 256; i++) { s16[4*i] = convert (f[i]); s16[4*i+1] = convert (f[i+256]); s16[4*i+2] = convert (f[i+512]); s16[4*i+3] = convert (f[i+768]); } +#endif break; case A52_3F2R: for (i = 0; i < 256; i++) { @@ -125,11 +182,49 @@ int a52_resample(float * _f, int16_t * s16) } break; case A52_MONO | A52_LFE: +#ifdef HAVE_MMX + asm volatile( + "movl $-1024, %%esi \n\t" + "movq magicF2W, %%mm7 \n\t" + "pxor %%mm6, %%mm6 \n\t" + "1: \n\t" + "movq 1024(%1, %%esi), %%mm0 \n\t" + "movq 1032(%1, %%esi), %%mm1 \n\t" + "movq (%1, %%esi), %%mm2 \n\t" + "movq 8(%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" + "leal (%%esi, %%esi, 2), %%edi \n\t" + "movq %%mm6, (%0, %%edi) \n\t" + "movd %%mm0, 8(%0, %%edi) \n\t" + "punpckhdq %%mm0, %%mm0 \n\t" + "movq %%mm6, 12(%0, %%edi) \n\t" + "movd %%mm0, 20(%0, %%edi) \n\t" + "movq %%mm6, 24(%0, %%edi) \n\t" + "movd %%mm1, 32(%0, %%edi) \n\t" + "punpckhdq %%mm1, %%mm1 \n\t" + "movq %%mm6, 36(%0, %%edi) \n\t" + "movd %%mm1, 44(%0, %%edi) \n\t" + "addl $16, %%esi \n\t" + " jnz 1b \n\t" + "emms \n\t" + :: "r" (s16+1536), "r" (f+256) + :"%esi", "%edi", "memory" + ); +#else for (i = 0; i < 256; i++) { s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0; s16[6*i+4] = convert (f[i+256]); s16[6*i+5] = convert (f[i]); } +#endif break; case A52_CHANNEL | A52_LFE: case A52_STEREO | A52_LFE: -- cgit v1.2.3