ssaparse: ignore invalid UTF-8 in init section
[platform/upstream/gstreamer.git] / gst / audioresample / speex_resampler_wrapper.h
1 /* GStreamer
2  * Copyright (C) 2007-2008 Sebastian Dröge <sebastian.droege@collabora.co.uk>
3  *
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.
8  *
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.
13  *
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., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef __SPEEX_RESAMPLER_WRAPPER_H__
21 #define __SPEEX_RESAMPLER_WRAPPER_H__
22
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
28
29 #define SPEEX_RESAMPLER_SINC_FILTER_DEFAULT SPEEX_RESAMPLER_SINC_FILTER_AUTO
30 #define SPEEX_RESAMPLER_SINC_FILTER_AUTO_THRESHOLD_DEFAULT (1 * 1048576)
31
32 enum
33 {
34   RESAMPLER_ERR_SUCCESS = 0,
35   RESAMPLER_ERR_ALLOC_FAILED = 1,
36   RESAMPLER_ERR_BAD_STATE = 2,
37   RESAMPLER_ERR_INVALID_ARG = 3,
38   RESAMPLER_ERR_PTR_OVERLAP = 4,
39
40   RESAMPLER_ERR_MAX_ERROR
41 };
42
43 typedef enum {
44   SPEEX_RESAMPLER_SINC_FILTER_INTERPOLATED   = 0,
45   SPEEX_RESAMPLER_SINC_FILTER_FULL           = 1,
46   SPEEX_RESAMPLER_SINC_FILTER_AUTO           = 2
47 } SpeexResamplerSincFilterMode;
48
49 typedef struct SpeexResamplerState_ SpeexResamplerState;
50
51 typedef struct {
52   SpeexResamplerState *(*init) (guint32 nb_channels,
53     guint32 in_rate, guint32 out_rate, gint quality,
54     SpeexResamplerSincFilterMode sinc_filter_mode,
55     guint32 sinc_filter_auto_threshold, gint * err);
56   void (*destroy) (SpeexResamplerState * st);
57   int (*process) (SpeexResamplerState *
58     st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len);
59   int (*set_rate) (SpeexResamplerState * st,
60     guint32 in_rate, guint32 out_rate);
61   void (*get_rate) (SpeexResamplerState * st,
62     guint32 * in_rate, guint32 * out_rate);
63   void (*get_ratio) (SpeexResamplerState * st,
64     guint32 * ratio_num, guint32 * ratio_den);
65   int (*get_input_latency) (SpeexResamplerState * st);
66   int (*get_filt_len) (SpeexResamplerState * st);
67   int (*get_sinc_filter_mode) (SpeexResamplerState * st);
68   int (*set_quality) (SpeexResamplerState * st, gint quality);
69   int (*reset_mem) (SpeexResamplerState * st);
70   int (*skip_zeros) (SpeexResamplerState * st);
71   const char * (*strerror) (gint err);
72   unsigned int width;
73 } SpeexResampleFuncs;
74
75 SpeexResamplerState *resample_float_resampler_init (guint32 nb_channels,
76     guint32 in_rate, guint32 out_rate, gint quality,
77     SpeexResamplerSincFilterMode sinc_filter_mode,
78     guint32 sinc_filter_auto_threshold, gint * err);
79 void resample_float_resampler_destroy (SpeexResamplerState * st);
80 int resample_float_resampler_process_interleaved_float (SpeexResamplerState *
81     st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len);
82 int resample_float_resampler_set_rate (SpeexResamplerState * st,
83     guint32 in_rate, guint32 out_rate);
84 void resample_float_resampler_get_rate (SpeexResamplerState * st,
85     guint32 * in_rate, guint32 * out_rate);
86 void resample_float_resampler_get_ratio (SpeexResamplerState * st,
87     guint32 * ratio_num, guint32 * ratio_den);
88 int resample_float_resampler_get_input_latency (SpeexResamplerState * st);
89 int resample_float_resampler_get_filt_len (SpeexResamplerState * st);
90 int resample_float_resampler_get_sinc_filter_mode (SpeexResamplerState * st);
91 int resample_float_resampler_set_quality (SpeexResamplerState * st, gint quality);
92 int resample_float_resampler_reset_mem (SpeexResamplerState * st);
93 int resample_float_resampler_skip_zeros (SpeexResamplerState * st);
94 const char * resample_float_resampler_strerror (gint err);
95
96 static const SpeexResampleFuncs float_funcs =
97 {
98   resample_float_resampler_init,
99   resample_float_resampler_destroy,
100   resample_float_resampler_process_interleaved_float,
101   resample_float_resampler_set_rate,
102   resample_float_resampler_get_rate,
103   resample_float_resampler_get_ratio,
104   resample_float_resampler_get_input_latency,
105   resample_float_resampler_get_filt_len,
106   resample_float_resampler_get_sinc_filter_mode,
107   resample_float_resampler_set_quality,
108   resample_float_resampler_reset_mem,
109   resample_float_resampler_skip_zeros,
110   resample_float_resampler_strerror,
111   32
112 };
113
114 SpeexResamplerState *resample_double_resampler_init (guint32 nb_channels,
115     guint32 in_rate, guint32 out_rate, gint quality,
116     SpeexResamplerSincFilterMode sinc_filter_mode,
117     guint32 sinc_filter_auto_threshold, gint * err);
118 void resample_double_resampler_destroy (SpeexResamplerState * st);
119 int resample_double_resampler_process_interleaved_float (SpeexResamplerState *
120     st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len);
121 int resample_double_resampler_set_rate (SpeexResamplerState * st,
122     guint32 in_rate, guint32 out_rate);
123 void resample_double_resampler_get_rate (SpeexResamplerState * st,
124     guint32 * in_rate, guint32 * out_rate);
125 void resample_double_resampler_get_ratio (SpeexResamplerState * st,
126     guint32 * ratio_num, guint32 * ratio_den);
127 int resample_double_resampler_get_input_latency (SpeexResamplerState * st);
128 int resample_double_resampler_get_filt_len (SpeexResamplerState * st);
129 int resample_double_resampler_get_sinc_filter_mode (SpeexResamplerState * st);
130 int resample_double_resampler_set_quality (SpeexResamplerState * st, gint quality);
131 int resample_double_resampler_reset_mem (SpeexResamplerState * st);
132 int resample_double_resampler_skip_zeros (SpeexResamplerState * st);
133 const char * resample_double_resampler_strerror (gint err);
134
135 static const SpeexResampleFuncs double_funcs =
136 {
137   resample_double_resampler_init,
138   resample_double_resampler_destroy,
139   resample_double_resampler_process_interleaved_float,
140   resample_double_resampler_set_rate,
141   resample_double_resampler_get_rate,
142   resample_double_resampler_get_ratio,
143   resample_double_resampler_get_input_latency,
144   resample_double_resampler_get_filt_len,
145   resample_double_resampler_get_sinc_filter_mode,
146   resample_double_resampler_set_quality,
147   resample_double_resampler_reset_mem,
148   resample_double_resampler_skip_zeros,
149   resample_double_resampler_strerror,
150   64
151 };
152
153 SpeexResamplerState *resample_int_resampler_init (guint32 nb_channels,
154     guint32 in_rate, guint32 out_rate, gint quality,
155     SpeexResamplerSincFilterMode sinc_filter_mode,
156     guint32 sinc_filter_auto_threshold, gint * err);
157 void resample_int_resampler_destroy (SpeexResamplerState * st);
158 int resample_int_resampler_process_interleaved_int (SpeexResamplerState *
159     st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len);
160 int resample_int_resampler_set_rate (SpeexResamplerState * st,
161     guint32 in_rate, guint32 out_rate);
162 void resample_int_resampler_get_rate (SpeexResamplerState * st,
163     guint32 * in_rate, guint32 * out_rate);
164 void resample_int_resampler_get_ratio (SpeexResamplerState * st,
165     guint32 * ratio_num, guint32 * ratio_den);
166 int resample_int_resampler_get_input_latency (SpeexResamplerState * st);
167 int resample_int_resampler_get_filt_len (SpeexResamplerState * st);
168 int resample_int_resampler_get_sinc_filter_mode (SpeexResamplerState * st);
169 int resample_int_resampler_set_quality (SpeexResamplerState * st, gint quality);
170 int resample_int_resampler_reset_mem (SpeexResamplerState * st);
171 int resample_int_resampler_skip_zeros (SpeexResamplerState * st);
172 const char * resample_int_resampler_strerror (gint err);
173
174 static const SpeexResampleFuncs int_funcs =
175 {
176   resample_int_resampler_init,
177   resample_int_resampler_destroy,
178   resample_int_resampler_process_interleaved_int,
179   resample_int_resampler_set_rate,
180   resample_int_resampler_get_rate,
181   resample_int_resampler_get_ratio,
182   resample_int_resampler_get_input_latency,
183   resample_int_resampler_get_filt_len,
184   resample_int_resampler_get_sinc_filter_mode,
185   resample_int_resampler_set_quality,
186   resample_int_resampler_reset_mem,
187   resample_int_resampler_skip_zeros,
188   resample_int_resampler_strerror,
189   16
190 };
191
192 #endif /* __SPEEX_RESAMPLER_WRAPPER_H__ */