Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | # HG changeset patch |
michael@0 | 2 | # Parent 091c02c13c8ba50903248432d0c7561104dace21 |
michael@0 | 3 | # User Karl Tomlinson <karlt+@karlt.net> |
michael@0 | 4 | b=913854 add speex_resampler_set_skip_frac_num r=jmspeex |
michael@0 | 5 | |
michael@0 | 6 | This allows a client to align output samples consistently for independent |
michael@0 | 7 | resampling of contiguous input buffers. |
michael@0 | 8 | |
michael@0 | 9 | diff --git a/layout/media/symbols.def.in b/layout/media/symbols.def.in |
michael@0 | 10 | --- a/layout/media/symbols.def.in |
michael@0 | 11 | +++ b/layout/media/symbols.def.in |
michael@0 | 12 | @@ -122,16 +122,17 @@ speex_resampler_set_quality |
michael@0 | 13 | speex_resampler_get_quality |
michael@0 | 14 | speex_resampler_set_input_stride |
michael@0 | 15 | speex_resampler_get_input_stride |
michael@0 | 16 | speex_resampler_set_output_stride |
michael@0 | 17 | speex_resampler_get_output_stride |
michael@0 | 18 | speex_resampler_get_input_latency |
michael@0 | 19 | speex_resampler_get_output_latency |
michael@0 | 20 | speex_resampler_skip_zeros |
michael@0 | 21 | +speex_resampler_set_skip_frac_num |
michael@0 | 22 | speex_resampler_reset_mem |
michael@0 | 23 | speex_resampler_strerror |
michael@0 | 24 | cubeb_destroy |
michael@0 | 25 | cubeb_init |
michael@0 | 26 | cubeb_get_max_channel_count |
michael@0 | 27 | cubeb_get_min_latency |
michael@0 | 28 | cubeb_get_preferred_sample_rate |
michael@0 | 29 | cubeb_stream_destroy |
michael@0 | 30 | diff --git a/media/libspeex_resampler/src/resample.c b/media/libspeex_resampler/src/resample.c |
michael@0 | 31 | --- a/media/libspeex_resampler/src/resample.c |
michael@0 | 32 | +++ b/media/libspeex_resampler/src/resample.c |
michael@0 | 33 | @@ -1138,16 +1138,28 @@ SPX_RESAMPLE_EXPORT int speex_resampler_ |
michael@0 | 34 | SPX_RESAMPLE_EXPORT int speex_resampler_skip_zeros(SpeexResamplerState *st) |
michael@0 | 35 | { |
michael@0 | 36 | spx_uint32_t i; |
michael@0 | 37 | for (i=0;i<st->nb_channels;i++) |
michael@0 | 38 | st->last_sample[i] = st->filt_len/2; |
michael@0 | 39 | return RESAMPLER_ERR_SUCCESS; |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | +SPX_RESAMPLE_EXPORT int speex_resampler_set_skip_frac_num(SpeexResamplerState *st, spx_uint32_t skip_frac_num) |
michael@0 | 43 | +{ |
michael@0 | 44 | + spx_uint32_t i; |
michael@0 | 45 | + spx_uint32_t last_sample = skip_frac_num / st->den_rate; |
michael@0 | 46 | + spx_uint32_t samp_frac_num = skip_frac_num % st->den_rate; |
michael@0 | 47 | + for (i=0;i<st->nb_channels;i++) { |
michael@0 | 48 | + st->last_sample[i] = last_sample; |
michael@0 | 49 | + st->samp_frac_num[i] = samp_frac_num; |
michael@0 | 50 | + } |
michael@0 | 51 | + return RESAMPLER_ERR_SUCCESS; |
michael@0 | 52 | +} |
michael@0 | 53 | + |
michael@0 | 54 | SPX_RESAMPLE_EXPORT int speex_resampler_reset_mem(SpeexResamplerState *st) |
michael@0 | 55 | { |
michael@0 | 56 | spx_uint32_t i; |
michael@0 | 57 | for (i=0;i<st->nb_channels;i++) |
michael@0 | 58 | { |
michael@0 | 59 | st->last_sample[i] = 0; |
michael@0 | 60 | st->magic_samples[i] = 0; |
michael@0 | 61 | st->samp_frac_num[i] = 0; |
michael@0 | 62 | diff --git a/media/libspeex_resampler/src/speex_resampler.h b/media/libspeex_resampler/src/speex_resampler.h |
michael@0 | 63 | --- a/media/libspeex_resampler/src/speex_resampler.h |
michael@0 | 64 | +++ b/media/libspeex_resampler/src/speex_resampler.h |
michael@0 | 65 | @@ -69,16 +69,17 @@ |
michael@0 | 66 | #define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality) |
michael@0 | 67 | #define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride) |
michael@0 | 68 | #define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride) |
michael@0 | 69 | #define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride) |
michael@0 | 70 | #define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride) |
michael@0 | 71 | #define speex_resampler_get_input_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_latency) |
michael@0 | 72 | #define speex_resampler_get_output_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_latency) |
michael@0 | 73 | #define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros) |
michael@0 | 74 | +#define speex_resampler_set_skip_frac_num CAT_PREFIX(RANDOM_PREFIX,_resampler_set_skip_frac_num) |
michael@0 | 75 | #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem) |
michael@0 | 76 | #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror) |
michael@0 | 77 | |
michael@0 | 78 | #define spx_int16_t short |
michael@0 | 79 | #define spx_int32_t int |
michael@0 | 80 | #define spx_uint16_t unsigned short |
michael@0 | 81 | #define spx_uint32_t unsigned int |
michael@0 | 82 | |
michael@0 | 83 | @@ -321,16 +322,32 @@ int speex_resampler_get_output_latency(S |
michael@0 | 84 | * resampler. It is recommended to use that when resampling an audio file, as |
michael@0 | 85 | * it will generate a file with the same length. For real-time processing, |
michael@0 | 86 | * it is probably easier not to use this call (so that the output duration |
michael@0 | 87 | * is the same for the first frame). |
michael@0 | 88 | * @param st Resampler state |
michael@0 | 89 | */ |
michael@0 | 90 | int speex_resampler_skip_zeros(SpeexResamplerState *st); |
michael@0 | 91 | |
michael@0 | 92 | +/** Set the numerator in a fraction determining the advance through input |
michael@0 | 93 | + * samples before writing any output samples. The denominator of the fraction |
michael@0 | 94 | + * is the value returned from speex_resampler_get_ratio() in ratio_den. This |
michael@0 | 95 | + * is only useful before starting to use a newly created or reset resampler. |
michael@0 | 96 | + * If the first input sample is interpreted as the signal at time |
michael@0 | 97 | + * input_latency*in_rate, then the first output sample represents the signal |
michael@0 | 98 | + * at the time frac_num/ratio_num*out_rate. |
michael@0 | 99 | + * This is intended for careful alignment of output sample points wrt input |
michael@0 | 100 | + * sample points. Large values are not an efficient offset into the in buffer. |
michael@0 | 101 | + * @param st Resampler state |
michael@0 | 102 | + * @param skip_frac_num Numerator of the offset fraction, |
michael@0 | 103 | + * between 0 and ratio_den-1. |
michael@0 | 104 | + */ |
michael@0 | 105 | +int speex_resampler_set_skip_frac_num(SpeexResamplerState *st, |
michael@0 | 106 | + spx_uint32_t skip_frac_num); |
michael@0 | 107 | + |
michael@0 | 108 | /** Reset a resampler so a new (unrelated) stream can be processed. |
michael@0 | 109 | * @param st Resampler state |
michael@0 | 110 | */ |
michael@0 | 111 | int speex_resampler_reset_mem(SpeexResamplerState *st); |
michael@0 | 112 | |
michael@0 | 113 | /** Returns the English meaning for an error code |
michael@0 | 114 | * @param err Error code |
michael@0 | 115 | * @return English string |