tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

04_hugemem.patch (1969B)


      1 diff --git a/src/resample.c b/src/resample.c
      2 --- a/src/resample.c
      3 +++ b/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 */
      8 
      9 #ifdef HAVE_CONFIG_H
     10 #include "config.h"
     11 #endif
     12 
     13 +#define RESAMPLE_HUGEMEM 1
     14 +
     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 #ifndef EXPORT
     21 #define EXPORT
     22 #endif
     23 @@ -633,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;
     30    }
     31 
     32 -#ifdef RESAMPLE_FULL_SINC_TABLE
     33 -   use_direct = 1;
     34 -   if (INT_MAX/sizeof(spx_word16_t)/st->den_rate < st->filt_len)
     35 -      goto fail;
     36 -#else
     37 -   /* Choose the resampling type that requires the least amount of memory */
     38 -   use_direct = st->filt_len*st->den_rate <= st->filt_len*st->oversample+8
     39 -                && INT_MAX/sizeof(spx_word16_t)/st->den_rate >= st->filt_len;
     40 +   use_direct =
     41 +#ifdef RESAMPLE_HUGEMEM
     42 +      /* Choose the direct resampler, even with higher initialization costs,
     43 +         when resampling any multiple of 100 to 44100. */
     44 +      st->den_rate <= 441
     45 +#else
     46 +      /* Choose the resampling type that requires the least amount of memory */
     47 +      st->filt_len*st->den_rate <= st->filt_len*st->oversample+8
     48 #endif
     49 +                && INT_MAX/sizeof(spx_word16_t)/st->den_rate >= st->filt_len;
     50    if (use_direct)
     51    {
     52       min_sinc_table_length = st->filt_len*st->den_rate;
     53    } else {
     54       if ((INT_MAX/sizeof(spx_word16_t)-8)/st->oversample < st->filt_len)
     55          goto fail;
     56 
     57       min_sinc_table_length = st->filt_len*st->oversample+8;