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

--HG--
extra : rebase_source : 457a874135b4fea8649d72299be96a79e7dcda64
This commit is contained in:
Karl Tomlinson 2014-07-21 16:34:26 +12:00
parent 6d4723f7d2
commit 82e2b3354d
3 changed files with 48 additions and 2 deletions

View File

@ -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));

View File

@ -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);}
@ -618,8 +620,8 @@ static void update_filter(SpeexResamplerState *st)
}
/* 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

View File

@ -22,3 +22,4 @@ cp $1/COPYING .
patch -p3 < outside-speex.patch
patch -p3 < sse-detect-runtime.patch
patch -p3 < set-skip-frac.patch
patch -p3 < hugemem.patch