[MPlayer-cvslog] r25103 - trunk/libaf/af_scaletempo.c

reimar subversion at mplayerhq.hu
Sun Nov 18 19:52:51 CET 2007


Author: reimar
Date: Sun Nov 18 19:52:51 2007
New Revision: 25103

Log:
Change to a 64 bit accumulation variable instead of shifting.
Changing the way the loop is done is necessary to reduce register pressure.
About 20% speedup even on 32 bit x86.


Modified:
   trunk/libaf/af_scaletempo.c

Modified: trunk/libaf/af_scaletempo.c
==============================================================================
--- trunk/libaf/af_scaletempo.c	(original)
+++ trunk/libaf/af_scaletempo.c	Sun Nov 18 19:52:51 2007
@@ -69,7 +69,6 @@ typedef struct af_scaletempo_s
   void*   buf_pre_corr;
   void*   table_window;
   int     (*best_overlap_offset)(struct af_scaletempo_s* s);
-  short   shift_corr;
   // command line
   float   scale_nominal;
   float   ms_stride;
@@ -153,7 +152,7 @@ static int best_overlap_offset_s16(af_sc
 {
   int32_t *pw, *ppc;
   int16_t *po, *search_start;
-  int32_t best_corr = INT_MIN;
+  int64_t best_corr = INT64_MIN;
   int best_off = 0;
   int off;
   long i;
@@ -168,12 +167,14 @@ static int best_overlap_offset_s16(af_sc
 
   search_start = (int16_t*)s->buf_queue + s->num_channels;
   for (off=0; off<s->frames_search; off++) {
-    int32_t corr = 0;
+    int64_t corr = 0;
     int16_t* ps = search_start;
     ppc = s->buf_pre_corr;
+    ppc += s->samples_overlap - s->num_channels;
+    ps  += s->samples_overlap - s->num_channels;
     i  = -(s->samples_overlap - s->num_channels);
     do {
-      corr += ( *ppc++ * *ps++ ) >> s->shift_corr;
+      corr += ppc[i] * ps[i];
     } while (++i < 0);
     if (corr > best_corr) {
       best_corr = corr;
@@ -380,7 +381,6 @@ static int control(struct af_instance_s*
             *pw++ = v;
           }
         }
-        s->shift_corr = av_log2( 2*(s->samples_overlap - nch) - 1 );
         s->best_overlap_offset = best_overlap_offset_s16;
       } else {
         float* pw;



More information about the MPlayer-cvslog mailing list