media/libspeex_resampler/set-skip-frac.patch

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libspeex_resampler/set-skip-frac.patch	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,115 @@
     1.4 +# HG changeset patch
     1.5 +# Parent 091c02c13c8ba50903248432d0c7561104dace21
     1.6 +# User Karl Tomlinson <karlt+@karlt.net>
     1.7 +b=913854 add speex_resampler_set_skip_frac_num r=jmspeex
     1.8 +
     1.9 +This allows a client to align output samples consistently for independent
    1.10 +resampling of contiguous input buffers.
    1.11 +
    1.12 +diff --git a/layout/media/symbols.def.in b/layout/media/symbols.def.in
    1.13 +--- a/layout/media/symbols.def.in
    1.14 ++++ b/layout/media/symbols.def.in
    1.15 +@@ -122,16 +122,17 @@ speex_resampler_set_quality
    1.16 + speex_resampler_get_quality
    1.17 + speex_resampler_set_input_stride
    1.18 + speex_resampler_get_input_stride
    1.19 + speex_resampler_set_output_stride
    1.20 + speex_resampler_get_output_stride
    1.21 + speex_resampler_get_input_latency
    1.22 + speex_resampler_get_output_latency
    1.23 + speex_resampler_skip_zeros
    1.24 ++speex_resampler_set_skip_frac_num
    1.25 + speex_resampler_reset_mem
    1.26 + speex_resampler_strerror
    1.27 + cubeb_destroy
    1.28 + cubeb_init
    1.29 + cubeb_get_max_channel_count
    1.30 + cubeb_get_min_latency
    1.31 + cubeb_get_preferred_sample_rate
    1.32 + cubeb_stream_destroy
    1.33 +diff --git a/media/libspeex_resampler/src/resample.c b/media/libspeex_resampler/src/resample.c
    1.34 +--- a/media/libspeex_resampler/src/resample.c
    1.35 ++++ b/media/libspeex_resampler/src/resample.c
    1.36 +@@ -1138,16 +1138,28 @@ SPX_RESAMPLE_EXPORT int speex_resampler_
    1.37 + SPX_RESAMPLE_EXPORT int speex_resampler_skip_zeros(SpeexResamplerState *st)
    1.38 + {
    1.39 +    spx_uint32_t i;
    1.40 +    for (i=0;i<st->nb_channels;i++)
    1.41 +       st->last_sample[i] = st->filt_len/2;
    1.42 +    return RESAMPLER_ERR_SUCCESS;
    1.43 + }
    1.44 + 
    1.45 ++SPX_RESAMPLE_EXPORT int speex_resampler_set_skip_frac_num(SpeexResamplerState *st, spx_uint32_t skip_frac_num)
    1.46 ++{
    1.47 ++   spx_uint32_t i;
    1.48 ++   spx_uint32_t last_sample = skip_frac_num / st->den_rate;
    1.49 ++   spx_uint32_t samp_frac_num = skip_frac_num % st->den_rate;
    1.50 ++   for (i=0;i<st->nb_channels;i++) {
    1.51 ++      st->last_sample[i] = last_sample;
    1.52 ++      st->samp_frac_num[i] = samp_frac_num;
    1.53 ++   }
    1.54 ++   return RESAMPLER_ERR_SUCCESS;
    1.55 ++}
    1.56 ++
    1.57 + SPX_RESAMPLE_EXPORT int speex_resampler_reset_mem(SpeexResamplerState *st)
    1.58 + {
    1.59 +    spx_uint32_t i;
    1.60 +    for (i=0;i<st->nb_channels;i++)
    1.61 +    {
    1.62 +       st->last_sample[i] = 0;
    1.63 +       st->magic_samples[i] = 0;
    1.64 +       st->samp_frac_num[i] = 0;
    1.65 +diff --git a/media/libspeex_resampler/src/speex_resampler.h b/media/libspeex_resampler/src/speex_resampler.h
    1.66 +--- a/media/libspeex_resampler/src/speex_resampler.h
    1.67 ++++ b/media/libspeex_resampler/src/speex_resampler.h
    1.68 +@@ -69,16 +69,17 @@
    1.69 + #define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality)
    1.70 + #define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride)
    1.71 + #define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride)
    1.72 + #define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride)
    1.73 + #define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride)
    1.74 + #define speex_resampler_get_input_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_latency)
    1.75 + #define speex_resampler_get_output_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_latency)
    1.76 + #define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros)
    1.77 ++#define speex_resampler_set_skip_frac_num CAT_PREFIX(RANDOM_PREFIX,_resampler_set_skip_frac_num)
    1.78 + #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
    1.79 + #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
    1.80 + 
    1.81 + #define spx_int16_t short
    1.82 + #define spx_int32_t int
    1.83 + #define spx_uint16_t unsigned short
    1.84 + #define spx_uint32_t unsigned int
    1.85 +       
    1.86 +@@ -321,16 +322,32 @@ int speex_resampler_get_output_latency(S
    1.87 +  * resampler. It is recommended to use that when resampling an audio file, as
    1.88 +  * it will generate a file with the same length. For real-time processing,
    1.89 +  * it is probably easier not to use this call (so that the output duration
    1.90 +  * is the same for the first frame).
    1.91 +  * @param st Resampler state
    1.92 +  */
    1.93 + int speex_resampler_skip_zeros(SpeexResamplerState *st);
    1.94 + 
    1.95 ++/** Set the numerator in a fraction determining the advance through input
    1.96 ++ * samples before writing any output samples. The denominator of the fraction
    1.97 ++ * is the value returned from speex_resampler_get_ratio() in ratio_den. This
    1.98 ++ * is only useful before starting to use a newly created or reset resampler.
    1.99 ++ * If the first input sample is interpreted as the signal at time
   1.100 ++ * input_latency*in_rate, then the first output sample represents the signal
   1.101 ++ * at the time frac_num/ratio_num*out_rate.
   1.102 ++ * This is intended for careful alignment of output sample points wrt input
   1.103 ++ * sample points. Large values are not an efficient offset into the in buffer.
   1.104 ++ * @param st Resampler state
   1.105 ++ * @param skip_frac_num Numerator of the offset fraction,
   1.106 ++ *                      between 0 and ratio_den-1.
   1.107 ++ */
   1.108 ++int speex_resampler_set_skip_frac_num(SpeexResamplerState *st,
   1.109 ++                                      spx_uint32_t skip_frac_num);
   1.110 ++
   1.111 + /** Reset a resampler so a new (unrelated) stream can be processed.
   1.112 +  * @param st Resampler state
   1.113 +  */
   1.114 + int speex_resampler_reset_mem(SpeexResamplerState *st);
   1.115 + 
   1.116 + /** Returns the English meaning for an error code
   1.117 +  * @param err Error code
   1.118 +  * @return English string

mercurial