Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / media / libspeex_resampler / 03_set-skip-frac.patch
blob3885c97680f5eb866f48cc44e233263a24cdf086
1 # HG changeset patch
2 # User Karl Tomlinson <karlt+@karlt.net>
3 b=913854 add speex_resampler_set_skip_frac_num r=jmspeex
5 This allows a client to align output samples consistently for independent
6 resampling of contiguous input buffers.
8 diff --git a/src/resample.c b/src/resample.c
9 --- a/src/resample.c
10 +++ b/src/resample.c
11 @@ -1128,16 +1128,28 @@ EXPORT int speex_resampler_get_output_la
12 EXPORT int speex_resampler_skip_zeros(SpeexResamplerState *st)
14 spx_uint32_t i;
15 for (i=0;i<st->nb_channels;i++)
16 st->last_sample[i] = st->filt_len/2;
17 return RESAMPLER_ERR_SUCCESS;
20 +EXPORT int speex_resampler_set_skip_frac_num(SpeexResamplerState *st, spx_uint32_t skip_frac_num)
22 + spx_uint32_t i;
23 + spx_uint32_t last_sample = skip_frac_num / st->den_rate;
24 + spx_uint32_t samp_frac_num = skip_frac_num % st->den_rate;
25 + for (i=0;i<st->nb_channels;i++) {
26 + st->last_sample[i] = last_sample;
27 + st->samp_frac_num[i] = samp_frac_num;
28 + }
29 + return RESAMPLER_ERR_SUCCESS;
32 EXPORT int speex_resampler_reset_mem(SpeexResamplerState *st)
34 spx_uint32_t i;
35 for (i=0;i<st->nb_channels;i++)
37 st->last_sample[i] = 0;
38 st->magic_samples[i] = 0;
39 st->samp_frac_num[i] = 0;
40 diff --git a/src/speex_resampler.h b/src/speex_resampler.h
41 --- a/src/speex_resampler.h
42 +++ b/src/speex_resampler.h
43 @@ -69,16 +69,17 @@
44 #define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality)
45 #define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride)
46 #define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride)
47 #define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride)
48 #define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride)
49 #define speex_resampler_get_input_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_latency)
50 #define speex_resampler_get_output_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_latency)
51 #define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros)
52 +#define speex_resampler_set_skip_frac_num CAT_PREFIX(RANDOM_PREFIX,_resampler_set_skip_frac_num)
53 #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
54 #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
56 #define spx_int16_t short
57 #define spx_int32_t int
58 #define spx_uint16_t unsigned short
59 #define spx_uint32_t unsigned int
61 @@ -317,16 +318,32 @@ int speex_resampler_get_output_latency(S
62 * resampler. It is recommended to use that when resampling an audio file, as
63 * it will generate a file with the same length. For real-time processing,
64 * it is probably easier not to use this call (so that the output duration
65 * is the same for the first frame).
66 * @param st Resampler state
68 int speex_resampler_skip_zeros(SpeexResamplerState *st);
70 +/** Set the numerator in a fraction determining the advance through input
71 + * samples before writing any output samples. The denominator of the fraction
72 + * is the value returned from speex_resampler_get_ratio() in ratio_den. This
73 + * is only useful before starting to use a newly created or reset resampler.
74 + * If the first input sample is interpreted as the signal at time
75 + * input_latency*in_rate, then the first output sample represents the signal
76 + * at the time frac_num/ratio_num*out_rate.
77 + * This is intended for careful alignment of output sample points wrt input
78 + * sample points. Large values are not an efficient offset into the in buffer.
79 + * @param st Resampler state
80 + * @param skip_frac_num Numerator of the offset fraction,
81 + * between 0 and ratio_den-1.
82 + */
83 +int speex_resampler_set_skip_frac_num(SpeexResamplerState *st,
84 + spx_uint32_t skip_frac_num);
86 /** Reset a resampler so a new (unrelated) stream can be processed.
87 * @param st Resampler state
89 int speex_resampler_reset_mem(SpeexResamplerState *st);
91 /** Returns the English meaning for an error code
92 * @param err Error code
93 * @return English string