diff mpegaudiodec.c @ 11939:ef338bd70180 libavcodec

SSE-optimized MP3 floating point windowing functions
author vitor
date Thu, 24 Jun 2010 07:44:50 +0000
parents 5e8770f9d8f1
children 11a8d4c1ee81
line wrap: on
line diff
--- a/mpegaudiodec.c	Wed Jun 23 23:44:48 2010 +0000
+++ b/mpegaudiodec.c	Thu Jun 24 07:44:50 2010 +0000
@@ -112,7 +112,7 @@
     SCALE_GEN(4.0 / 9.0), /* 9 steps */
 };
 
-DECLARE_ALIGNED(16, MPA_INT, RENAME(ff_mpa_synth_window))[512];
+DECLARE_ALIGNED(16, MPA_INT, RENAME(ff_mpa_synth_window))[512+256];
 
 /**
  * Convert region offsets to region sizes and truncate
@@ -308,7 +308,9 @@
 
     s->avctx = avctx;
     s->apply_window_mp3 = apply_window_mp3_c;
-
+#if HAVE_MMX
+    ff_mpegaudiodec_init_mmx(s);
+#endif
     avctx->sample_fmt= OUT_FMT;
     s->error_recognition= avctx->error_recognition;
 
@@ -820,7 +822,7 @@
 
 void av_cold RENAME(ff_mpa_synth_init)(MPA_INT *window)
 {
-    int i;
+    int i, j;
 
     /* max = 18760, max sum over all 16 coefs : 44736 */
     for(i=0;i<257;i++) {
@@ -837,6 +839,15 @@
         if (i != 0)
             window[512 - i] = v;
     }
+
+    // Needed for avoiding shuffles in ASM implementations
+    for(i=0; i < 8; i++)
+        for(j=0; j < 16; j++)
+            window[512+16*i+j] = window[64*i+32-j];
+
+    for(i=0; i < 8; i++)
+        for(j=0; j < 16; j++)
+            window[512+128+16*i+j] = window[64*i+48-j];
 }
 
 static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window,