Wireshark 2.9.0-477-g68ec514b The Wireshark network protocol analyzer

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

speex_resampler.h
1 /* Copyright (C) 2007 Jean-Marc Valin
2
3 File: speex_resampler.h
4 Resampling code
5
6 The design goals of this code are:
7 - Very fast algorithm
8 - Low memory requirement
9 - Good *perceptual* quality (and not best SNR)
10
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions are
13 met:
14
15 1. Redistributions of source code must retain the above copyright notice,
16 this list of conditions and the following disclaimer.
17
18 2. Redistributions in binary form must reproduce the above copyright
19 notice, this list of conditions and the following disclaimer in the
20 documentation and/or other materials provided with the distribution.
21
22 3. The name of the author may not be used to endorse or promote products
23 derived from this software without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
29 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 POSSIBILITY OF SUCH DAMAGE.
36 */
37
38 #ifndef SPEEX_RESAMPLER_H
39 #define SPEEX_RESAMPLER_H
40
41 #define OUTSIDE_SPEEX 1
42 #define RANDOM_PREFIX ws_codec
43 #include "ws_symbol_export.h"
44 #define EXPORT
45
46 #ifdef OUTSIDE_SPEEX
47
48 /********* WARNING: MENTAL SANITY ENDS HERE *************/
49
50 /* If the resampler is defined outside of Speex, we change the symbol names so that
51 there won't be any clash if linking with Speex later on. */
52
53 /* #define RANDOM_PREFIX your software name here */
54 #ifndef RANDOM_PREFIX
55 #error "Please define RANDOM_PREFIX (above) to something specific to your project to prevent symbol name clashes"
56 #endif
57
58 #define CAT_PREFIX2(a,b) a ## b
59 #define CAT_PREFIX(a,b) CAT_PREFIX2(a, b)
60
61 #define speex_resampler_init CAT_PREFIX(RANDOM_PREFIX,_resampler_init)
62 #define speex_resampler_init_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_init_frac)
63 #define speex_resampler_destroy CAT_PREFIX(RANDOM_PREFIX,_resampler_destroy)
64 #define speex_resampler_process_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_float)
65 #define speex_resampler_process_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_int)
66 #define speex_resampler_process_interleaved_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_float)
67 #define speex_resampler_process_interleaved_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_int)
68 #define speex_resampler_set_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate)
69 #define speex_resampler_get_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_get_rate)
70 #define speex_resampler_set_rate_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate_frac)
71 #define speex_resampler_get_ratio CAT_PREFIX(RANDOM_PREFIX,_resampler_get_ratio)
72 #define speex_resampler_set_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_set_quality)
73 #define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality)
74 #define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride)
75 #define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride)
76 #define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride)
77 #define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride)
78 #define speex_resampler_get_input_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_latency)
79 #define speex_resampler_get_output_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_latency)
80 #define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros)
81 #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
82 #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
83
84 #define spx_int16_t short
85 #define spx_int32_t int
86 #define spx_uint16_t unsigned short
87 #define spx_uint32_t unsigned int
88
89 #else /* OUTSIDE_SPEEX */
90
91 #include "speexdsp_types.h"
92
93 #endif /* OUTSIDE_SPEEX */
94
95 #ifdef __cplusplus
96 extern "C" {
97 #endif
98
99 #define SPEEX_RESAMPLER_QUALITY_MAX 10
100 #define SPEEX_RESAMPLER_QUALITY_MIN 0
101 #define SPEEX_RESAMPLER_QUALITY_DEFAULT 4
102 #define SPEEX_RESAMPLER_QUALITY_VOIP 3
103 #define SPEEX_RESAMPLER_QUALITY_DESKTOP 5
104
105 enum {
106 RESAMPLER_ERR_SUCCESS = 0,
107 RESAMPLER_ERR_ALLOC_FAILED = 1,
108 RESAMPLER_ERR_BAD_STATE = 2,
109 RESAMPLER_ERR_INVALID_ARG = 3,
110 RESAMPLER_ERR_PTR_OVERLAP = 4,
111
112 RESAMPLER_ERR_MAX_ERROR
113 };
114
115 struct SpeexResamplerState_;
116 typedef struct SpeexResamplerState_ SpeexResamplerState;
117
127 WS_DLL_PUBLIC SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels,
128 spx_uint32_t in_rate,
129 spx_uint32_t out_rate,
130 int quality,
131 int *err);
132
146 WS_DLL_PUBLIC SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels,
147 spx_uint32_t ratio_num,
148 spx_uint32_t ratio_den,
149 spx_uint32_t in_rate,
150 spx_uint32_t out_rate,
151 int quality,
152 int *err);
153
157 WS_DLL_PUBLIC void speex_resampler_destroy(SpeexResamplerState *st);
158
169 WS_DLL_PUBLIC int speex_resampler_process_float(SpeexResamplerState *st,
170 spx_uint32_t channel_index,
171 const float *in,
172 spx_uint32_t *in_len,
173 float *out,
174 spx_uint32_t *out_len);
175
186 WS_DLL_PUBLIC int speex_resampler_process_int(SpeexResamplerState *st,
187 spx_uint32_t channel_index,
188 const spx_int16_t *in,
189 spx_uint32_t *in_len,
190 spx_int16_t *out,
191 spx_uint32_t *out_len);
192
202 WS_DLL_PUBLIC int speex_resampler_process_interleaved_float(SpeexResamplerState *st,
203 const float *in,
204 spx_uint32_t *in_len,
205 float *out,
206 spx_uint32_t *out_len);
207
217 WS_DLL_PUBLIC int speex_resampler_process_interleaved_int(SpeexResamplerState *st,
218 const spx_int16_t *in,
219 spx_uint32_t *in_len,
220 spx_int16_t *out,
221 spx_uint32_t *out_len);
222
228 WS_DLL_PUBLIC int speex_resampler_set_rate(SpeexResamplerState *st,
229 spx_uint32_t in_rate,
230 spx_uint32_t out_rate);
231
237 WS_DLL_PUBLIC void speex_resampler_get_rate(SpeexResamplerState *st,
238 spx_uint32_t *in_rate,
239 spx_uint32_t *out_rate);
240
249 WS_DLL_PUBLIC int speex_resampler_set_rate_frac(SpeexResamplerState *st,
250 spx_uint32_t ratio_num,
251 spx_uint32_t ratio_den,
252 spx_uint32_t in_rate,
253 spx_uint32_t out_rate);
254
261 WS_DLL_PUBLIC void speex_resampler_get_ratio(SpeexResamplerState *st,
262 spx_uint32_t *ratio_num,
263 spx_uint32_t *ratio_den);
264
270 WS_DLL_PUBLIC int speex_resampler_set_quality(SpeexResamplerState *st,
271 int quality);
272
278 WS_DLL_PUBLIC void speex_resampler_get_quality(SpeexResamplerState *st,
279 int *quality);
280
285 WS_DLL_PUBLIC void speex_resampler_set_input_stride(SpeexResamplerState *st,
286 spx_uint32_t stride);
287
292 WS_DLL_PUBLIC void speex_resampler_get_input_stride(SpeexResamplerState *st,
293 spx_uint32_t *stride);
294
299 WS_DLL_PUBLIC void speex_resampler_set_output_stride(SpeexResamplerState *st,
300 spx_uint32_t stride);
301
306 WS_DLL_PUBLIC void speex_resampler_get_output_stride(SpeexResamplerState *st,
307 spx_uint32_t *stride);
308
312 WS_DLL_PUBLIC int speex_resampler_get_input_latency(SpeexResamplerState *st);
313
317 WS_DLL_PUBLIC int speex_resampler_get_output_latency(SpeexResamplerState *st);
318
327 WS_DLL_PUBLIC int speex_resampler_skip_zeros(SpeexResamplerState *st);
328
332 WS_DLL_PUBLIC int speex_resampler_reset_mem(SpeexResamplerState *st);
333
338 WS_DLL_PUBLIC const char *speex_resampler_strerror(int err);
339
340 #ifdef __cplusplus
341 }
342 #endif
343
344 #endif
SpeexResamplerState_
Definition: resample.c:113