hugemem.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. */
  8. #ifdef HAVE_CONFIG_H
  9. #include "config.h"
  10. #endif
  11. +#define RESAMPLE_HUGEMEM 1
  12. +
  13. #ifdef OUTSIDE_SPEEX
  14. #include <stdlib.h>
  15. static void *speex_alloc (int size) {return calloc(size,1);}
  16. static void *speex_realloc (void *ptr, int size) {return realloc(ptr, size);}
  17. static void speex_free (void *ptr) {free(ptr);}
  18. #include "speex_resampler.h"
  19. #include "arch.h"
  20. #else /* OUTSIDE_SPEEX */
  21. @@ -632,25 +634,26 @@ static int update_filter(SpeexResamplerS
  22. st->oversample >>= 1;
  23. if (st->oversample < 1)
  24. st->oversample = 1;
  25. } else {
  26. /* up-sampling */
  27. st->cutoff = quality_map[st->quality].upsample_bandwidth;
  28. }
  29. - /* Choose the resampling type that requires the least amount of memory */
  30. -#ifdef RESAMPLE_FULL_SINC_TABLE
  31. - use_direct = 1;
  32. - if (INT_MAX/sizeof(spx_word16_t)/st->den_rate < st->filt_len)
  33. - goto fail;
  34. + use_direct =
  35. +#ifdef RESAMPLE_HUGEMEM
  36. + /* Choose the direct resampler, even with higher initialization costs,
  37. + when resampling any multiple of 100 to 44100. */
  38. + st->den_rate <= 441
  39. #else
  40. - use_direct = st->filt_len*st->den_rate <= st->filt_len*st->oversample+8
  41. + /* Choose the resampling type that requires the least amount of memory */
  42. + st->filt_len*st->den_rate <= st->filt_len*st->oversample+8
  43. +#endif
  44. && INT_MAX/sizeof(spx_word16_t)/st->den_rate >= st->filt_len;
  45. -#endif
  46. if (use_direct)
  47. {
  48. min_sinc_table_length = st->filt_len*st->den_rate;
  49. } else {
  50. if ((INT_MAX/sizeof(spx_word16_t)-8)/st->oversample < st->filt_len)
  51. goto fail;
  52. min_sinc_table_length = st->filt_len*st->oversample+8;