Bug 1482193 [wpt PR 12382] - [PE] Allow blending for svg root etc., a=testonly
[gecko.git] / media / libspeex_resampler / hugemem.patch
blobe0ced5a053a3b7a12e7af69db646d114676d8338
1 diff --git a/media/libspeex_resampler/src/resample.c b/media/libspeex_resampler/src/resample.c
2 --- a/media/libspeex_resampler/src/resample.c
3 +++ b/media/libspeex_resampler/src/resample.c
4 @@ -56,16 +56,18 @@
5 (e.g. 2/3), and get rid of the rounding operations in the inner loop.
6 The latter both reduces CPU time and makes the algorithm more SIMD-friendly.
7 */
9 #ifdef HAVE_CONFIG_H
10 #include "config.h"
11 #endif
13 +#define RESAMPLE_HUGEMEM 1
15 #ifdef OUTSIDE_SPEEX
16 #include <stdlib.h>
17 static void *speex_alloc (int size) {return calloc(size,1);}
18 static void *speex_realloc (void *ptr, int size) {return realloc(ptr, size);}
19 static void speex_free (void *ptr) {free(ptr);}
20 #include "speex_resampler.h"
21 #include "arch.h"
22 #else /* OUTSIDE_SPEEX */
23 @@ -643,25 +645,26 @@ static int update_filter(SpeexResamplerS
24 st->oversample >>= 1;
25 if (st->oversample < 1)
26 st->oversample = 1;
27 } else {
28 /* up-sampling */
29 st->cutoff = quality_map[st->quality].upsample_bandwidth;
32 - /* Choose the resampling type that requires the least amount of memory */
33 -#ifdef RESAMPLE_FULL_SINC_TABLE
34 - use_direct = 1;
35 - if (INT_MAX/sizeof(spx_word16_t)/st->den_rate < st->filt_len)
36 - goto fail;
37 + use_direct =
38 +#ifdef RESAMPLE_HUGEMEM
39 + /* Choose the direct resampler, even with higher initialization costs,
40 + when resampling any multiple of 100 to 44100. */
41 + st->den_rate <= 441
42 #else
43 - use_direct = st->filt_len*st->den_rate <= st->filt_len*st->oversample+8
44 + /* Choose the resampling type that requires the least amount of memory */
45 + st->filt_len*st->den_rate <= st->filt_len*st->oversample+8
46 +#endif
47 && INT_MAX/sizeof(spx_word16_t)/st->den_rate >= st->filt_len;
48 -#endif
49 if (use_direct)
51 min_sinc_table_length = st->filt_len*st->den_rate;
52 } else {
53 if ((INT_MAX/sizeof(spx_word16_t)-8)/st->oversample < st->filt_len)
54 goto fail;
56 min_sinc_table_length = st->filt_len*st->oversample+8;