b=1042504 use direct resampler for 48->44.1k r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Mon, 21 Jul 2014 16:34:26 +1200
changeset 195800 ebb543336e85e32bc56a895d5518ebaa15d9d1c3
parent 195799 0ca7ce33b2b2e7de72da140bbd748ee157574cb2
child 195801 1b7d7dcf71e23f6ed68f10a72416f7dc5e58a6c2
push id27197
push usercbook@mozilla.com
push dateThu, 24 Jul 2014 13:25:44 +0000
treeherderautoland@340ff53a5467 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1042504
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=1042504 use direct resampler for 48->44.1k r=padenot Transplanted from patch by Gregory Maxwell <greg@xiph.org> http://git.xiph.org/?p=opus-tools.git;a=commitdiff;h=f426ab52
media/libspeex_resampler/hugemem.patch
media/libspeex_resampler/src/resample.c
media/libspeex_resampler/update.sh
new file mode 100644
--- /dev/null
+++ b/media/libspeex_resampler/hugemem.patch
@@ -0,0 +1,43 @@
+diff --git a/media/libspeex_resampler/src/resample.c b/media/libspeex_resampler/src/resample.c
+--- a/media/libspeex_resampler/src/resample.c
++++ b/media/libspeex_resampler/src/resample.c
+@@ -56,16 +56,18 @@
+    (e.g. 2/3), and get rid of the rounding operations in the inner loop. 
+    The latter both reduces CPU time and makes the algorithm more SIMD-friendly.
+ */
+ 
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+ #endif
+ 
++#define RESAMPLE_HUGEMEM 1
++
+ #ifdef OUTSIDE_SPEEX
+ #include <stdlib.h>
+ static void *speex_alloc (int size) {return calloc(size,1);}
+ static void *speex_realloc (void *ptr, int size) {return realloc(ptr, size);}
+ static void speex_free (void *ptr) {free(ptr);}
+ #include "speex_resampler.h"
+ #include "arch.h"
+ #else /* OUTSIDE_SPEEX */
+@@ -613,18 +615,18 @@ static void update_filter(SpeexResampler
+       if (st->oversample < 1)
+          st->oversample = 1;
+    } else {
+       /* up-sampling */
+       st->cutoff = quality_map[st->quality].upsample_bandwidth;
+    }
+    
+    /* Choose the resampling type that requires the least amount of memory */
+-#ifdef RESAMPLE_FULL_SINC_TABLE
+-   if (1)
++#ifdef RESAMPLE_HUGEMEM
++   if (st->den_rate <= 16*(st->oversample+8))
+ #else
+    if (st->filt_len*st->den_rate <= st->filt_len*st->oversample+8)
+ #endif
+    {
+       spx_uint32_t i;
+       if (st->sinc_table_length < st->filt_len*st->den_rate)
+       {
+          st->sinc_table = (spx_word16_t *)speex_realloc(st->sinc_table,st->filt_len*st->den_rate*sizeof(spx_word16_t));
--- a/media/libspeex_resampler/src/resample.c
+++ b/media/libspeex_resampler/src/resample.c
@@ -56,16 +56,18 @@
    (e.g. 2/3), and get rid of the rounding operations in the inner loop. 
    The latter both reduces CPU time and makes the algorithm more SIMD-friendly.
 */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#define RESAMPLE_HUGEMEM 1
+
 #ifdef OUTSIDE_SPEEX
 #include <stdlib.h>
 static void *speex_alloc (int size) {return calloc(size,1);}
 static void *speex_realloc (void *ptr, int size) {return realloc(ptr, size);}
 static void speex_free (void *ptr) {free(ptr);}
 #include "speex_resampler.h"
 #include "arch.h"
 #else /* OUTSIDE_SPEEX */
@@ -613,18 +615,18 @@ static void update_filter(SpeexResampler
       if (st->oversample < 1)
          st->oversample = 1;
    } else {
       /* up-sampling */
       st->cutoff = quality_map[st->quality].upsample_bandwidth;
    }
    
    /* Choose the resampling type that requires the least amount of memory */
-#ifdef RESAMPLE_FULL_SINC_TABLE
-   if (1)
+#ifdef RESAMPLE_HUGEMEM
+   if (st->den_rate <= 16*(st->oversample+8))
 #else
    if (st->filt_len*st->den_rate <= st->filt_len*st->oversample+8)
 #endif
    {
       spx_uint32_t i;
       if (st->sinc_table_length < st->filt_len*st->den_rate)
       {
          st->sinc_table = (spx_word16_t *)speex_realloc(st->sinc_table,st->filt_len*st->den_rate*sizeof(spx_word16_t));
--- a/media/libspeex_resampler/update.sh
+++ b/media/libspeex_resampler/update.sh
@@ -17,8 +17,9 @@ cp $1/libspeexdsp/fixed_generic.h src
 cp $1/include/speex/speex_resampler.h src
 cp $1/AUTHORS .
 cp $1/COPYING .
 
 # apply outstanding local patches
 patch -p3 < outside-speex.patch
 patch -p3 < sse-detect-runtime.patch
 patch -p3 < set-skip-frac.patch
+patch -p3 < hugemem.patch