shithub: opus-tools

Download patch

ref: f426ab5260fe9f1618a187fc2a8264dbba4aef08
parent: 00caf732431a47e023bd2eb834b43a9e9cdab320
author: Gregory Maxwell <greg@xiph.org>
date: Tue Jul 24 19:56:14 EDT 2012

Switch 48->44.1k to the direct resampler. 2x speedup for opusdec.

Also fixes a bug where the filter could be size which was
not a multiple of 8 (as required by the SSE code).

--- a/src/resample.c
+++ b/src/resample.c
@@ -61,6 +61,8 @@
 # include "config.h"
 #endif
 
+#define RESAMPLE_HUGEMEM 1
+
 #ifdef OUTSIDE_SPEEX
 #include <stdlib.h>
 static void *speex_alloc (int size) {return calloc(size,1);}
@@ -567,8 +569,8 @@
       st->cutoff = quality_map[st->quality].downsample_bandwidth * st->den_rate / st->num_rate;
       /* FIXME: divide the numerator and denominator by a certain amount if they're too large */
       st->filt_len = st->filt_len*st->num_rate / st->den_rate;
-      /* Round down to make sure we have a multiple of 4 */
-      st->filt_len &= (~0x3);
+      /* Round up to make sure we have a multiple of 8 */
+      st->filt_len = ((st->filt_len-1)&(~0x7))+8;
       if (2*st->den_rate < st->num_rate)
          st->oversample >>= 1;
       if (4*st->den_rate < st->num_rate)
@@ -583,9 +585,13 @@
       /* up-sampling */
       st->cutoff = quality_map[st->quality].upsample_bandwidth;
    }
-   
+
+#ifdef RESAMPLE_HUGEMEM
+   if (st->den_rate <= 16*(st->oversample+8))
+#else
    /* Choose the resampling type that requires the least amount of memory */
-   if (st->den_rate <= st->oversample)
+   if (st->den_rate <= (st->oversample+8))
+#endif
    {
       spx_uint32_t i;
       if (!st->sinc_table)