00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef SPEEX_RESAMPLER_H
00040 #define SPEEX_RESAMPLER_H
00041
00042 #ifdef OUTSIDE_SPEEX
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef RANDOM_PREFIX
00051 #error "Please define RANDOM_PREFIX (above) to something specific to your project to prevent symbol name clashes"
00052 #endif
00053
00054 #define CAT_PREFIX2(a,b) a ## b
00055 #define CAT_PREFIX(a,b) CAT_PREFIX2(a, b)
00056
00057 #define speex_resampler_init CAT_PREFIX(RANDOM_PREFIX,_resampler_init)
00058 #define speex_resampler_init_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_init_frac)
00059 #define speex_resampler_destroy CAT_PREFIX(RANDOM_PREFIX,_resampler_destroy)
00060 #define speex_resampler_process_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_float)
00061 #define speex_resampler_process_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_int)
00062 #define speex_resampler_process_interleaved_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_float)
00063 #define speex_resampler_process_interleaved_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_int)
00064 #define speex_resampler_set_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate)
00065 #define speex_resampler_get_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_get_rate)
00066 #define speex_resampler_set_rate_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate_frac)
00067 #define speex_resampler_get_ratio CAT_PREFIX(RANDOM_PREFIX,_resampler_get_ratio)
00068 #define speex_resampler_set_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_set_quality)
00069 #define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality)
00070 #define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride)
00071 #define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride)
00072 #define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride)
00073 #define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride)
00074 #define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros)
00075 #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
00076 #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
00077
00078 #define spx_int16_t short
00079 #define spx_int32_t int
00080 #define spx_uint16_t unsigned short
00081 #define spx_uint32_t unsigned int
00082
00083 #else
00084
00085 #include "speex/speex_types.h"
00086
00087 #endif
00088
00089 #ifdef __cplusplus
00090 extern "C" {
00091 #endif
00092
00093 #define SPEEX_RESAMPLER_QUALITY_MAX 10
00094 #define SPEEX_RESAMPLER_QUALITY_MIN 0
00095 #define SPEEX_RESAMPLER_QUALITY_DEFAULT 4
00096 #define SPEEX_RESAMPLER_QUALITY_VOIP 3
00097 #define SPEEX_RESAMPLER_QUALITY_DESKTOP 5
00098
00099 enum {
00100 RESAMPLER_ERR_SUCCESS = 0,
00101 RESAMPLER_ERR_ALLOC_FAILED = 1,
00102 RESAMPLER_ERR_BAD_STATE = 2,
00103 RESAMPLER_ERR_INVALID_ARG = 3,
00104 RESAMPLER_ERR_PTR_OVERLAP = 4,
00105
00106 RESAMPLER_ERR_MAX_ERROR
00107 };
00108
00109 struct SpeexResamplerState_;
00110 typedef struct SpeexResamplerState_ SpeexResamplerState;
00111
00121 SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels,
00122 spx_uint32_t in_rate,
00123 spx_uint32_t out_rate,
00124 int quality,
00125 int *err);
00126
00140 SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels,
00141 spx_uint32_t ratio_num,
00142 spx_uint32_t ratio_den,
00143 spx_uint32_t in_rate,
00144 spx_uint32_t out_rate,
00145 int quality,
00146 int *err);
00147
00151 void speex_resampler_destroy(SpeexResamplerState *st);
00152
00163 int speex_resampler_process_float(SpeexResamplerState *st,
00164 spx_uint32_t channel_index,
00165 const float *in,
00166 spx_uint32_t *in_len,
00167 float *out,
00168 spx_uint32_t *out_len);
00169
00180 int speex_resampler_process_int(SpeexResamplerState *st,
00181 spx_uint32_t channel_index,
00182 const spx_int16_t *in,
00183 spx_uint32_t *in_len,
00184 spx_int16_t *out,
00185 spx_uint32_t *out_len);
00186
00196 int speex_resampler_process_interleaved_float(SpeexResamplerState *st,
00197 const float *in,
00198 spx_uint32_t *in_len,
00199 float *out,
00200 spx_uint32_t *out_len);
00201
00211 int speex_resampler_process_interleaved_int(SpeexResamplerState *st,
00212 const spx_int16_t *in,
00213 spx_uint32_t *in_len,
00214 spx_int16_t *out,
00215 spx_uint32_t *out_len);
00216
00222 int speex_resampler_set_rate(SpeexResamplerState *st,
00223 spx_uint32_t in_rate,
00224 spx_uint32_t out_rate);
00225
00231 void speex_resampler_get_rate(SpeexResamplerState *st,
00232 spx_uint32_t *in_rate,
00233 spx_uint32_t *out_rate);
00234
00243 int speex_resampler_set_rate_frac(SpeexResamplerState *st,
00244 spx_uint32_t ratio_num,
00245 spx_uint32_t ratio_den,
00246 spx_uint32_t in_rate,
00247 spx_uint32_t out_rate);
00248
00255 void speex_resampler_get_ratio(SpeexResamplerState *st,
00256 spx_uint32_t *ratio_num,
00257 spx_uint32_t *ratio_den);
00258
00264 int speex_resampler_set_quality(SpeexResamplerState *st,
00265 int quality);
00266
00272 void speex_resampler_get_quality(SpeexResamplerState *st,
00273 int *quality);
00274
00279 void speex_resampler_set_input_stride(SpeexResamplerState *st,
00280 spx_uint32_t stride);
00281
00286 void speex_resampler_get_input_stride(SpeexResamplerState *st,
00287 spx_uint32_t *stride);
00288
00293 void speex_resampler_set_output_stride(SpeexResamplerState *st,
00294 spx_uint32_t stride);
00295
00300 void speex_resampler_get_output_stride(SpeexResamplerState *st,
00301 spx_uint32_t *stride);
00302
00311 int speex_resampler_skip_zeros(SpeexResamplerState *st);
00312
00316 int speex_resampler_reset_mem(SpeexResamplerState *st);
00317
00322 const char *speex_resampler_strerror(int err);
00323
00324 #ifdef __cplusplus
00325 }
00326 #endif
00327
00328 #endif