2 * Copyright (C) 2007-2008 Sebastian Dröge <sebastian.droege@collabora.co.uk>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __SPEEX_RESAMPLER_WRAPPER_H__
21 #define __SPEEX_RESAMPLER_WRAPPER_H__
23 #define SPEEX_RESAMPLER_QUALITY_MAX 10
24 #define SPEEX_RESAMPLER_QUALITY_MIN 0
25 #define SPEEX_RESAMPLER_QUALITY_DEFAULT 4
26 #define SPEEX_RESAMPLER_QUALITY_VOIP 3
27 #define SPEEX_RESAMPLER_QUALITY_DESKTOP 5
31 RESAMPLER_ERR_SUCCESS = 0,
32 RESAMPLER_ERR_ALLOC_FAILED = 1,
33 RESAMPLER_ERR_BAD_STATE = 2,
34 RESAMPLER_ERR_INVALID_ARG = 3,
35 RESAMPLER_ERR_PTR_OVERLAP = 4,
37 RESAMPLER_ERR_MAX_ERROR
40 typedef struct SpeexResamplerState_ SpeexResamplerState;
43 SpeexResamplerState *(*init) (guint32 nb_channels,
44 guint32 in_rate, guint32 out_rate, gint quality, gint * err);
45 void (*destroy) (SpeexResamplerState * st);
46 int (*process) (SpeexResamplerState *
47 st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len);
48 int (*set_rate) (SpeexResamplerState * st,
49 guint32 in_rate, guint32 out_rate);
50 void (*get_rate) (SpeexResamplerState * st,
51 guint32 * in_rate, guint32 * out_rate);
52 void (*get_ratio) (SpeexResamplerState * st,
53 guint32 * ratio_num, guint32 * ratio_den);
54 int (*get_input_latency) (SpeexResamplerState * st);
55 int (*get_filt_len) (SpeexResamplerState * st);
56 int (*set_quality) (SpeexResamplerState * st, gint quality);
57 int (*reset_mem) (SpeexResamplerState * st);
58 int (*skip_zeros) (SpeexResamplerState * st);
59 const char * (*strerror) (gint err);
63 SpeexResamplerState *resample_float_resampler_init (guint32 nb_channels,
64 guint32 in_rate, guint32 out_rate, gint quality, gint * err);
65 void resample_float_resampler_destroy (SpeexResamplerState * st);
66 int resample_float_resampler_process_interleaved_float (SpeexResamplerState *
67 st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len);
68 int resample_float_resampler_set_rate (SpeexResamplerState * st,
69 guint32 in_rate, guint32 out_rate);
70 void resample_float_resampler_get_rate (SpeexResamplerState * st,
71 guint32 * in_rate, guint32 * out_rate);
72 void resample_float_resampler_get_ratio (SpeexResamplerState * st,
73 guint32 * ratio_num, guint32 * ratio_den);
74 int resample_float_resampler_get_input_latency (SpeexResamplerState * st);
75 int resample_float_resampler_get_filt_len (SpeexResamplerState * st);
76 int resample_float_resampler_set_quality (SpeexResamplerState * st, gint quality);
77 int resample_float_resampler_reset_mem (SpeexResamplerState * st);
78 int resample_float_resampler_skip_zeros (SpeexResamplerState * st);
79 const char * resample_float_resampler_strerror (gint err);
81 static const SpeexResampleFuncs float_funcs =
83 resample_float_resampler_init,
84 resample_float_resampler_destroy,
85 resample_float_resampler_process_interleaved_float,
86 resample_float_resampler_set_rate,
87 resample_float_resampler_get_rate,
88 resample_float_resampler_get_ratio,
89 resample_float_resampler_get_input_latency,
90 resample_float_resampler_get_filt_len,
91 resample_float_resampler_set_quality,
92 resample_float_resampler_reset_mem,
93 resample_float_resampler_skip_zeros,
94 resample_float_resampler_strerror,
98 SpeexResamplerState *resample_double_resampler_init (guint32 nb_channels,
99 guint32 in_rate, guint32 out_rate, gint quality, gint * err);
100 void resample_double_resampler_destroy (SpeexResamplerState * st);
101 int resample_double_resampler_process_interleaved_float (SpeexResamplerState *
102 st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len);
103 int resample_double_resampler_set_rate (SpeexResamplerState * st,
104 guint32 in_rate, guint32 out_rate);
105 void resample_double_resampler_get_rate (SpeexResamplerState * st,
106 guint32 * in_rate, guint32 * out_rate);
107 void resample_double_resampler_get_ratio (SpeexResamplerState * st,
108 guint32 * ratio_num, guint32 * ratio_den);
109 int resample_double_resampler_get_input_latency (SpeexResamplerState * st);
110 int resample_double_resampler_get_filt_len (SpeexResamplerState * st);
111 int resample_double_resampler_set_quality (SpeexResamplerState * st, gint quality);
112 int resample_double_resampler_reset_mem (SpeexResamplerState * st);
113 int resample_double_resampler_skip_zeros (SpeexResamplerState * st);
114 const char * resample_double_resampler_strerror (gint err);
116 static const SpeexResampleFuncs double_funcs =
118 resample_double_resampler_init,
119 resample_double_resampler_destroy,
120 resample_double_resampler_process_interleaved_float,
121 resample_double_resampler_set_rate,
122 resample_double_resampler_get_rate,
123 resample_double_resampler_get_ratio,
124 resample_double_resampler_get_input_latency,
125 resample_double_resampler_get_filt_len,
126 resample_double_resampler_set_quality,
127 resample_double_resampler_reset_mem,
128 resample_double_resampler_skip_zeros,
129 resample_double_resampler_strerror,
133 SpeexResamplerState *resample_int_resampler_init (guint32 nb_channels,
134 guint32 in_rate, guint32 out_rate, gint quality, gint * err);
135 void resample_int_resampler_destroy (SpeexResamplerState * st);
136 int resample_int_resampler_process_interleaved_int (SpeexResamplerState *
137 st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len);
138 int resample_int_resampler_set_rate (SpeexResamplerState * st,
139 guint32 in_rate, guint32 out_rate);
140 void resample_int_resampler_get_rate (SpeexResamplerState * st,
141 guint32 * in_rate, guint32 * out_rate);
142 void resample_int_resampler_get_ratio (SpeexResamplerState * st,
143 guint32 * ratio_num, guint32 * ratio_den);
144 int resample_int_resampler_get_input_latency (SpeexResamplerState * st);
145 int resample_int_resampler_get_filt_len (SpeexResamplerState * st);
146 int resample_int_resampler_set_quality (SpeexResamplerState * st, gint quality);
147 int resample_int_resampler_reset_mem (SpeexResamplerState * st);
148 int resample_int_resampler_skip_zeros (SpeexResamplerState * st);
149 const char * resample_int_resampler_strerror (gint err);
151 static const SpeexResampleFuncs int_funcs =
153 resample_int_resampler_init,
154 resample_int_resampler_destroy,
155 resample_int_resampler_process_interleaved_int,
156 resample_int_resampler_set_rate,
157 resample_int_resampler_get_rate,
158 resample_int_resampler_get_ratio,
159 resample_int_resampler_get_input_latency,
160 resample_int_resampler_get_filt_len,
161 resample_int_resampler_set_quality,
162 resample_int_resampler_reset_mem,
163 resample_int_resampler_skip_zeros,
164 resample_int_resampler_strerror,
168 #endif /* __SPEEX_RESAMPLER_WRAPPER_H__ */