diff options
author | Dan Everton <dan@iocaine.org> | 2007-05-22 09:50:31 +0000 |
---|---|---|
committer | Dan Everton <dan@iocaine.org> | 2007-05-22 09:50:31 +0000 |
commit | df6f2f9a3c88a7a4a8ad0382ee4ee7c9a3ee3256 (patch) | |
tree | d9862e5d04f4014def5911bb4ff8206c85636fb7 /apps/codecs/libspeex/speex/speex_resampler.h | |
parent | 8970055ec107a2387eedbb373889d0f540745121 (diff) | |
download | rockbox-df6f2f9a3c88a7a4a8ad0382ee4ee7c9a3ee3256.tar.gz rockbox-df6f2f9a3c88a7a4a8ad0382ee4ee7c9a3ee3256.zip |
Upgrade to libspeex 1.2beta2. Very minor performance increase (0.6% on coldfire).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13461 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libspeex/speex/speex_resampler.h')
-rw-r--r-- | apps/codecs/libspeex/speex/speex_resampler.h | 133 |
1 files changed, 71 insertions, 62 deletions
diff --git a/apps/codecs/libspeex/speex/speex_resampler.h b/apps/codecs/libspeex/speex/speex_resampler.h index 93642ced2f..c44fbcd0d1 100644 --- a/apps/codecs/libspeex/speex/speex_resampler.h +++ b/apps/codecs/libspeex/speex/speex_resampler.h | |||
@@ -69,29 +69,20 @@ | |||
69 | #define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality) | 69 | #define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality) |
70 | #define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride) | 70 | #define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride) |
71 | #define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride) | 71 | #define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride) |
72 | #define speex_resample_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resample_set_output_stride) | 72 | #define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride) |
73 | #define speex_resample_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resample_get_output_stride) | 73 | #define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride) |
74 | #define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros) | 74 | #define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros) |
75 | #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem) | 75 | #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem) |
76 | #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror) | ||
76 | 77 | ||
77 | #define spx_int16_t short | 78 | #define spx_int16_t short |
78 | 79 | #define spx_int32_t int | |
79 | #ifdef FIXED_POINT | 80 | #define spx_uint16_t unsigned short |
80 | #define spx_word16_t short | 81 | #define spx_uint32_t unsigned int |
81 | #define spx_word32_t int | 82 | |
82 | |||
83 | #else /* FIXED_POINT */ | ||
84 | |||
85 | #define spx_word16_t float | ||
86 | #define spx_word32_t float | ||
87 | #define MULT16_16(a,b) ((a)*(b)) | ||
88 | #define MULT16_32_Q15(a,b) ((a)*(b)) | ||
89 | #define PSHR32(a,b) (a) | ||
90 | #endif /* FIXED_POINT */ | ||
91 | |||
92 | #else /* OUTSIDE_SPEEX */ | 83 | #else /* OUTSIDE_SPEEX */ |
93 | 84 | ||
94 | #include "speex_types.h" | 85 | #include "speex/speex_types.h" |
95 | 86 | ||
96 | #endif /* OUTSIDE_SPEEX */ | 87 | #endif /* OUTSIDE_SPEEX */ |
97 | 88 | ||
@@ -104,7 +95,17 @@ extern "C" { | |||
104 | #define SPEEX_RESAMPLER_QUALITY_DEFAULT 4 | 95 | #define SPEEX_RESAMPLER_QUALITY_DEFAULT 4 |
105 | #define SPEEX_RESAMPLER_QUALITY_VOIP 3 | 96 | #define SPEEX_RESAMPLER_QUALITY_VOIP 3 |
106 | #define SPEEX_RESAMPLER_QUALITY_DESKTOP 5 | 97 | #define SPEEX_RESAMPLER_QUALITY_DESKTOP 5 |
98 | |||
99 | enum { | ||
100 | RESAMPLER_ERR_SUCCESS = 0, | ||
101 | RESAMPLER_ERR_ALLOC_FAILED = 1, | ||
102 | RESAMPLER_ERR_BAD_STATE = 2, | ||
103 | RESAMPLER_ERR_INVALID_ARG = 3, | ||
104 | RESAMPLER_ERR_PTR_OVERLAP = 4, | ||
107 | 105 | ||
106 | RESAMPLER_ERR_MAX_ERROR | ||
107 | }; | ||
108 | |||
108 | struct SpeexResamplerState_; | 109 | struct SpeexResamplerState_; |
109 | typedef struct SpeexResamplerState_ SpeexResamplerState; | 110 | typedef struct SpeexResamplerState_ SpeexResamplerState; |
110 | 111 | ||
@@ -117,10 +118,11 @@ typedef struct SpeexResamplerState_ SpeexResamplerState; | |||
117 | * @return Newly created resampler state | 118 | * @return Newly created resampler state |
118 | * @retval NULL Error: not enough memory | 119 | * @retval NULL Error: not enough memory |
119 | */ | 120 | */ |
120 | SpeexResamplerState *speex_resampler_init(int nb_channels, | 121 | SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels, |
121 | int in_rate, | 122 | spx_uint32_t in_rate, |
122 | int out_rate, | 123 | spx_uint32_t out_rate, |
123 | int quality); | 124 | int quality, |
125 | int *err); | ||
124 | 126 | ||
125 | /** Create a new resampler with fractional input/output rates. The sampling | 127 | /** Create a new resampler with fractional input/output rates. The sampling |
126 | * rate ratio is an arbitrary rational number with both the numerator and | 128 | * rate ratio is an arbitrary rational number with both the numerator and |
@@ -135,12 +137,13 @@ SpeexResamplerState *speex_resampler_init(int nb_channels, | |||
135 | * @return Newly created resampler state | 137 | * @return Newly created resampler state |
136 | * @retval NULL Error: not enough memory | 138 | * @retval NULL Error: not enough memory |
137 | */ | 139 | */ |
138 | SpeexResamplerState *speex_resampler_init_frac(int nb_channels, | 140 | SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels, |
139 | int ratio_num, | 141 | spx_uint32_t ratio_num, |
140 | int ratio_den, | 142 | spx_uint32_t ratio_den, |
141 | int in_rate, | 143 | spx_uint32_t in_rate, |
142 | int out_rate, | 144 | spx_uint32_t out_rate, |
143 | int quality); | 145 | int quality, |
146 | int *err); | ||
144 | 147 | ||
145 | /** Destroy a resampler state. | 148 | /** Destroy a resampler state. |
146 | * @param st Resampler state | 149 | * @param st Resampler state |
@@ -157,12 +160,12 @@ void speex_resampler_destroy(SpeexResamplerState *st); | |||
157 | * @param out Output buffer | 160 | * @param out Output buffer |
158 | * @param out_len Size of the output buffer. Returns the number of samples written | 161 | * @param out_len Size of the output buffer. Returns the number of samples written |
159 | */ | 162 | */ |
160 | void speex_resampler_process_float(SpeexResamplerState *st, | 163 | int speex_resampler_process_float(SpeexResamplerState *st, |
161 | int channel_index, | 164 | spx_uint32_t channel_index, |
162 | const float *in, | 165 | const float *in, |
163 | int *in_len, | 166 | spx_uint32_t *in_len, |
164 | float *out, | 167 | float *out, |
165 | int *out_len); | 168 | spx_uint32_t *out_len); |
166 | 169 | ||
167 | /** Resample an int array. The input and output buffers must *not* overlap. | 170 | /** Resample an int array. The input and output buffers must *not* overlap. |
168 | * @param st Resampler state | 171 | * @param st Resampler state |
@@ -174,12 +177,12 @@ void speex_resampler_process_float(SpeexResamplerState *st, | |||
174 | * @param out Output buffer | 177 | * @param out Output buffer |
175 | * @param out_len Size of the output buffer. Returns the number of samples written | 178 | * @param out_len Size of the output buffer. Returns the number of samples written |
176 | */ | 179 | */ |
177 | void speex_resampler_process_int(SpeexResamplerState *st, | 180 | int speex_resampler_process_int(SpeexResamplerState *st, |
178 | int channel_index, | 181 | spx_uint32_t channel_index, |
179 | const spx_int16_t *in, | 182 | const spx_int16_t *in, |
180 | int *in_len, | 183 | spx_uint32_t *in_len, |
181 | spx_int16_t *out, | 184 | spx_int16_t *out, |
182 | int *out_len); | 185 | spx_uint32_t *out_len); |
183 | 186 | ||
184 | /** Resample an interleaved float array. The input and output buffers must *not* overlap. | 187 | /** Resample an interleaved float array. The input and output buffers must *not* overlap. |
185 | * @param st Resampler state | 188 | * @param st Resampler state |
@@ -190,11 +193,11 @@ void speex_resampler_process_int(SpeexResamplerState *st, | |||
190 | * @param out_len Size of the output buffer. Returns the number of samples written. | 193 | * @param out_len Size of the output buffer. Returns the number of samples written. |
191 | * This is all per-channel. | 194 | * This is all per-channel. |
192 | */ | 195 | */ |
193 | void speex_resampler_process_interleaved_float(SpeexResamplerState *st, | 196 | int speex_resampler_process_interleaved_float(SpeexResamplerState *st, |
194 | const float *in, | 197 | const float *in, |
195 | int *in_len, | 198 | spx_uint32_t *in_len, |
196 | float *out, | 199 | float *out, |
197 | int *out_len); | 200 | spx_uint32_t *out_len); |
198 | 201 | ||
199 | /** Resample an interleaved int array. The input and output buffers must *not* overlap. | 202 | /** Resample an interleaved int array. The input and output buffers must *not* overlap. |
200 | * @param st Resampler state | 203 | * @param st Resampler state |
@@ -205,20 +208,20 @@ void speex_resampler_process_interleaved_float(SpeexResamplerState *st, | |||
205 | * @param out_len Size of the output buffer. Returns the number of samples written. | 208 | * @param out_len Size of the output buffer. Returns the number of samples written. |
206 | * This is all per-channel. | 209 | * This is all per-channel. |
207 | */ | 210 | */ |
208 | void speex_resampler_process_interleaved_int(SpeexResamplerState *st, | 211 | int speex_resampler_process_interleaved_int(SpeexResamplerState *st, |
209 | const spx_int16_t *in, | 212 | const spx_int16_t *in, |
210 | int *in_len, | 213 | spx_uint32_t *in_len, |
211 | spx_int16_t *out, | 214 | spx_int16_t *out, |
212 | int *out_len); | 215 | spx_uint32_t *out_len); |
213 | 216 | ||
214 | /** Set (change) the input/output sampling rates (integer value). | 217 | /** Set (change) the input/output sampling rates (integer value). |
215 | * @param st Resampler state | 218 | * @param st Resampler state |
216 | * @param in_rate Input sampling rate (integer number of Hz). | 219 | * @param in_rate Input sampling rate (integer number of Hz). |
217 | * @param out_rate Output sampling rate (integer number of Hz). | 220 | * @param out_rate Output sampling rate (integer number of Hz). |
218 | */ | 221 | */ |
219 | void speex_resampler_set_rate(SpeexResamplerState *st, | 222 | int speex_resampler_set_rate(SpeexResamplerState *st, |
220 | int in_rate, | 223 | spx_uint32_t in_rate, |
221 | int out_rate); | 224 | spx_uint32_t out_rate); |
222 | 225 | ||
223 | /** Get the current input/output sampling rates (integer value). | 226 | /** Get the current input/output sampling rates (integer value). |
224 | * @param st Resampler state | 227 | * @param st Resampler state |
@@ -226,8 +229,8 @@ void speex_resampler_set_rate(SpeexResamplerState *st, | |||
226 | * @param out_rate Output sampling rate (integer number of Hz) copied. | 229 | * @param out_rate Output sampling rate (integer number of Hz) copied. |
227 | */ | 230 | */ |
228 | void speex_resampler_get_rate(SpeexResamplerState *st, | 231 | void speex_resampler_get_rate(SpeexResamplerState *st, |
229 | int *in_rate, | 232 | spx_uint32_t *in_rate, |
230 | int *out_rate); | 233 | spx_uint32_t *out_rate); |
231 | 234 | ||
232 | /** Set (change) the input/output sampling rates and resampling ratio | 235 | /** Set (change) the input/output sampling rates and resampling ratio |
233 | * (fractional values in Hz supported). | 236 | * (fractional values in Hz supported). |
@@ -237,11 +240,11 @@ void speex_resampler_get_rate(SpeexResamplerState *st, | |||
237 | * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). | 240 | * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). |
238 | * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). | 241 | * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). |
239 | */ | 242 | */ |
240 | void speex_resampler_set_rate_frac(SpeexResamplerState *st, | 243 | int speex_resampler_set_rate_frac(SpeexResamplerState *st, |
241 | int ratio_num, | 244 | spx_uint32_t ratio_num, |
242 | int ratio_den, | 245 | spx_uint32_t ratio_den, |
243 | int in_rate, | 246 | spx_uint32_t in_rate, |
244 | int out_rate); | 247 | spx_uint32_t out_rate); |
245 | 248 | ||
246 | /** Get the current resampling ratio. This will be reduced to the least | 249 | /** Get the current resampling ratio. This will be reduced to the least |
247 | * common denominator. | 250 | * common denominator. |
@@ -250,15 +253,15 @@ void speex_resampler_set_rate_frac(SpeexResamplerState *st, | |||
250 | * @param ratio_den Denominator of the sampling rate ratio copied | 253 | * @param ratio_den Denominator of the sampling rate ratio copied |
251 | */ | 254 | */ |
252 | void speex_resampler_get_ratio(SpeexResamplerState *st, | 255 | void speex_resampler_get_ratio(SpeexResamplerState *st, |
253 | int *ratio_num, | 256 | spx_uint32_t *ratio_num, |
254 | int *ratio_den); | 257 | spx_uint32_t *ratio_den); |
255 | 258 | ||
256 | /** Set (change) the conversion quality. | 259 | /** Set (change) the conversion quality. |
257 | * @param st Resampler state | 260 | * @param st Resampler state |
258 | * @param quality Resampling quality between 0 and 10, where 0 has poor | 261 | * @param quality Resampling quality between 0 and 10, where 0 has poor |
259 | * quality and 10 has very high quality. | 262 | * quality and 10 has very high quality. |
260 | */ | 263 | */ |
261 | void speex_resampler_set_quality(SpeexResamplerState *st, | 264 | int speex_resampler_set_quality(SpeexResamplerState *st, |
262 | int quality); | 265 | int quality); |
263 | 266 | ||
264 | /** Get the conversion quality. | 267 | /** Get the conversion quality. |
@@ -274,28 +277,28 @@ void speex_resampler_get_quality(SpeexResamplerState *st, | |||
274 | * @param stride Input stride | 277 | * @param stride Input stride |
275 | */ | 278 | */ |
276 | void speex_resampler_set_input_stride(SpeexResamplerState *st, | 279 | void speex_resampler_set_input_stride(SpeexResamplerState *st, |
277 | int stride); | 280 | spx_uint32_t stride); |
278 | 281 | ||
279 | /** Get the input stride. | 282 | /** Get the input stride. |
280 | * @param st Resampler state | 283 | * @param st Resampler state |
281 | * @param stride Input stride copied | 284 | * @param stride Input stride copied |
282 | */ | 285 | */ |
283 | void speex_resampler_get_input_stride(SpeexResamplerState *st, | 286 | void speex_resampler_get_input_stride(SpeexResamplerState *st, |
284 | int *stride); | 287 | spx_uint32_t *stride); |
285 | 288 | ||
286 | /** Set (change) the output stride. | 289 | /** Set (change) the output stride. |
287 | * @param st Resampler state | 290 | * @param st Resampler state |
288 | * @param stride Output stride | 291 | * @param stride Output stride |
289 | */ | 292 | */ |
290 | void speex_resample_set_output_stride(SpeexResamplerState *st, | 293 | void speex_resampler_set_output_stride(SpeexResamplerState *st, |
291 | int stride); | 294 | spx_uint32_t stride); |
292 | 295 | ||
293 | /** Get the output stride. | 296 | /** Get the output stride. |
294 | * @param st Resampler state copied | 297 | * @param st Resampler state copied |
295 | * @param stride Output stride | 298 | * @param stride Output stride |
296 | */ | 299 | */ |
297 | void speex_resample_get_output_stride(SpeexResamplerState *st, | 300 | void speex_resampler_get_output_stride(SpeexResamplerState *st, |
298 | int *stride); | 301 | spx_uint32_t *stride); |
299 | 302 | ||
300 | /** Make sure that the first samples to go out of the resamplers don't have | 303 | /** Make sure that the first samples to go out of the resamplers don't have |
301 | * leading zeros. This is only useful before starting to use a newly created | 304 | * leading zeros. This is only useful before starting to use a newly created |
@@ -305,12 +308,18 @@ void speex_resample_get_output_stride(SpeexResamplerState *st, | |||
305 | * is the same for the first frame). | 308 | * is the same for the first frame). |
306 | * @param st Resampler state | 309 | * @param st Resampler state |
307 | */ | 310 | */ |
308 | void speex_resampler_skip_zeros(SpeexResamplerState *st); | 311 | int speex_resampler_skip_zeros(SpeexResamplerState *st); |
309 | 312 | ||
310 | /** Reset a resampler so a new (unrelated) stream can be processed. | 313 | /** Reset a resampler so a new (unrelated) stream can be processed. |
311 | * @param st Resampler state | 314 | * @param st Resampler state |
312 | */ | 315 | */ |
313 | void speex_resampler_reset_mem(SpeexResamplerState *st); | 316 | int speex_resampler_reset_mem(SpeexResamplerState *st); |
317 | |||
318 | /** Returns the English meaning for an error code | ||
319 | * @param err Error code | ||
320 | * @return English string | ||
321 | */ | ||
322 | const char *speex_resampler_strerror(int err); | ||
314 | 323 | ||
315 | #ifdef __cplusplus | 324 | #ifdef __cplusplus |
316 | } | 325 | } |