44#ifndef SPEEX_RESAMPLER_H
45#define SPEEX_RESAMPLER_H
48#define RANDOM_PREFIX speex_
59#error "Please define RANDOM_PREFIX (above) to something specific to your project to prevent symbol name clashes"
62#define CAT_PREFIX2(a,b) a ## b
63#define CAT_PREFIX(a,b) CAT_PREFIX2(a, b)
65#define speex_resampler_init CAT_PREFIX(RANDOM_PREFIX,_resampler_init)
66#define speex_resampler_init_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_init_frac)
67#define speex_resampler_destroy CAT_PREFIX(RANDOM_PREFIX,_resampler_destroy)
68#define speex_resampler_process_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_float)
69#define speex_resampler_process_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_int)
70#define speex_resampler_process_interleaved_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_float)
71#define speex_resampler_process_interleaved_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_int)
72#define speex_resampler_set_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate)
73#define speex_resampler_get_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_get_rate)
74#define speex_resampler_set_rate_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate_frac)
75#define speex_resampler_get_ratio CAT_PREFIX(RANDOM_PREFIX,_resampler_get_ratio)
76#define speex_resampler_set_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_set_quality)
77#define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality)
78#define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride)
79#define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride)
80#define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride)
81#define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride)
82#define speex_resampler_get_input_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_latency)
83#define speex_resampler_get_output_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_latency)
84#define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros)
85#define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
86#define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
88#define spx_int16_t short
89#define spx_int32_t int
90#define spx_uint16_t unsigned short
91#define spx_uint32_t unsigned int
93#define speex_assert(cond)
105#define SPEEX_RESAMPLER_QUALITY_MAX 10
106#define SPEEX_RESAMPLER_QUALITY_MIN 0
107#define SPEEX_RESAMPLER_QUALITY_DEFAULT 4
108#define SPEEX_RESAMPLER_QUALITY_VOIP 3
109#define SPEEX_RESAMPLER_QUALITY_DESKTOP 5
112 RESAMPLER_ERR_SUCCESS = 0,
113 RESAMPLER_ERR_ALLOC_FAILED = 1,
114 RESAMPLER_ERR_BAD_STATE = 2,
115 RESAMPLER_ERR_INVALID_ARG = 3,
116 RESAMPLER_ERR_PTR_OVERLAP = 4,
117 RESAMPLER_ERR_OVERFLOW = 5,
119 RESAMPLER_ERR_MAX_ERROR
134SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels,
135 spx_uint32_t in_rate,
136 spx_uint32_t out_rate,
153SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels,
154 spx_uint32_t ratio_num,
155 spx_uint32_t ratio_den,
156 spx_uint32_t in_rate,
157 spx_uint32_t out_rate,
164void speex_resampler_destroy(SpeexResamplerState *st);
176int speex_resampler_process_float(SpeexResamplerState *st,
177 spx_uint32_t channel_index,
179 spx_uint32_t *in_len,
181 spx_uint32_t *out_len);
193int speex_resampler_process_int(SpeexResamplerState *st,
194 spx_uint32_t channel_index,
195 const spx_int16_t *in,
196 spx_uint32_t *in_len,
198 spx_uint32_t *out_len);
209int speex_resampler_process_interleaved_float(SpeexResamplerState *st,
211 spx_uint32_t *in_len,
213 spx_uint32_t *out_len);
224int speex_resampler_process_interleaved_int(SpeexResamplerState *st,
225 const spx_int16_t *in,
226 spx_uint32_t *in_len,
228 spx_uint32_t *out_len);
235int speex_resampler_set_rate(SpeexResamplerState *st,
236 spx_uint32_t in_rate,
237 spx_uint32_t out_rate);
244void speex_resampler_get_rate(SpeexResamplerState *st,
245 spx_uint32_t *in_rate,
246 spx_uint32_t *out_rate);
256int speex_resampler_set_rate_frac(SpeexResamplerState *st,
257 spx_uint32_t ratio_num,
258 spx_uint32_t ratio_den,
259 spx_uint32_t in_rate,
260 spx_uint32_t out_rate);
268void speex_resampler_get_ratio(SpeexResamplerState *st,
269 spx_uint32_t *ratio_num,
270 spx_uint32_t *ratio_den);
277int speex_resampler_set_quality(SpeexResamplerState *st,
285void speex_resampler_get_quality(SpeexResamplerState *st,
292void speex_resampler_set_input_stride(SpeexResamplerState *st,
293 spx_uint32_t stride);
299void speex_resampler_get_input_stride(SpeexResamplerState *st,
300 spx_uint32_t *stride);
306void speex_resampler_set_output_stride(SpeexResamplerState *st,
307 spx_uint32_t stride);
313void speex_resampler_get_output_stride(SpeexResamplerState *st,
314 spx_uint32_t *stride);
319int speex_resampler_get_input_latency(SpeexResamplerState *st);
324int speex_resampler_get_output_latency(SpeexResamplerState *st);
334int speex_resampler_skip_zeros(SpeexResamplerState *st);
339int speex_resampler_reset_mem(SpeexResamplerState *st);
345const char *speex_resampler_strerror(
int err);