Rename files and types from speexresample to audioresample
[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., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, 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 enum
30 {
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,
36
37   RESAMPLER_ERR_MAX_ERROR
38 };
39
40 typedef struct SpeexResamplerState_ SpeexResamplerState;
41
42 typedef struct {
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 (*set_quality) (SpeexResamplerState * st, gint quality);
56   int (*reset_mem) (SpeexResamplerState * st);
57   int (*skip_zeros) (SpeexResamplerState * st);
58   const char * (*strerror) (gint err);
59   unsigned int width;
60 } SpeexResampleFuncs;
61
62 SpeexResamplerState *resample_float_resampler_init (guint32 nb_channels,
63     guint32 in_rate, guint32 out_rate, gint quality, gint * err);
64 void resample_float_resampler_destroy (SpeexResamplerState * st);
65 int resample_float_resampler_process_interleaved_float (SpeexResamplerState *
66     st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len);
67 int resample_float_resampler_set_rate (SpeexResamplerState * st,
68     guint32 in_rate, guint32 out_rate);
69 void resample_float_resampler_get_rate (SpeexResamplerState * st,
70     guint32 * in_rate, guint32 * out_rate);
71 void resample_float_resampler_get_ratio (SpeexResamplerState * st,
72     guint32 * ratio_num, guint32 * ratio_den);
73 int resample_float_resampler_get_input_latency (SpeexResamplerState * st);
74 int resample_float_resampler_set_quality (SpeexResamplerState * st, gint quality);
75 int resample_float_resampler_reset_mem (SpeexResamplerState * st);
76 int resample_float_resampler_skip_zeros (SpeexResamplerState * st);
77 const char * resample_float_resampler_strerror (gint err);
78
79 static const SpeexResampleFuncs float_funcs =
80 {
81   resample_float_resampler_init,
82   resample_float_resampler_destroy,
83   resample_float_resampler_process_interleaved_float,
84   resample_float_resampler_set_rate,
85   resample_float_resampler_get_rate,
86   resample_float_resampler_get_ratio,
87   resample_float_resampler_get_input_latency,
88   resample_float_resampler_set_quality,
89   resample_float_resampler_reset_mem,
90   resample_float_resampler_skip_zeros,
91   resample_float_resampler_strerror,
92   32
93 };
94
95 SpeexResamplerState *resample_double_resampler_init (guint32 nb_channels,
96     guint32 in_rate, guint32 out_rate, gint quality, gint * err);
97 void resample_double_resampler_destroy (SpeexResamplerState * st);
98 int resample_double_resampler_process_interleaved_float (SpeexResamplerState *
99     st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len);
100 int resample_double_resampler_set_rate (SpeexResamplerState * st,
101     guint32 in_rate, guint32 out_rate);
102 void resample_double_resampler_get_rate (SpeexResamplerState * st,
103     guint32 * in_rate, guint32 * out_rate);
104 void resample_double_resampler_get_ratio (SpeexResamplerState * st,
105     guint32 * ratio_num, guint32 * ratio_den);
106 int resample_double_resampler_get_input_latency (SpeexResamplerState * st);
107 int resample_double_resampler_set_quality (SpeexResamplerState * st, gint quality);
108 int resample_double_resampler_reset_mem (SpeexResamplerState * st);
109 int resample_double_resampler_skip_zeros (SpeexResamplerState * st);
110 const char * resample_double_resampler_strerror (gint err);
111
112 static const SpeexResampleFuncs double_funcs =
113 {
114   resample_double_resampler_init,
115   resample_double_resampler_destroy,
116   resample_double_resampler_process_interleaved_float,
117   resample_double_resampler_set_rate,
118   resample_double_resampler_get_rate,
119   resample_double_resampler_get_ratio,
120   resample_double_resampler_get_input_latency,
121   resample_double_resampler_set_quality,
122   resample_double_resampler_reset_mem,
123   resample_double_resampler_skip_zeros,
124   resample_double_resampler_strerror,
125   64
126 };
127
128 SpeexResamplerState *resample_int_resampler_init (guint32 nb_channels,
129     guint32 in_rate, guint32 out_rate, gint quality, gint * err);
130 void resample_int_resampler_destroy (SpeexResamplerState * st);
131 int resample_int_resampler_process_interleaved_int (SpeexResamplerState *
132     st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len);
133 int resample_int_resampler_set_rate (SpeexResamplerState * st,
134     guint32 in_rate, guint32 out_rate);
135 void resample_int_resampler_get_rate (SpeexResamplerState * st,
136     guint32 * in_rate, guint32 * out_rate);
137 void resample_int_resampler_get_ratio (SpeexResamplerState * st,
138     guint32 * ratio_num, guint32 * ratio_den);
139 int resample_int_resampler_get_input_latency (SpeexResamplerState * st);
140 int resample_int_resampler_set_quality (SpeexResamplerState * st, gint quality);
141 int resample_int_resampler_reset_mem (SpeexResamplerState * st);
142 int resample_int_resampler_skip_zeros (SpeexResamplerState * st);
143 const char * resample_int_resampler_strerror (gint err);
144
145 static const SpeexResampleFuncs int_funcs =
146 {
147   resample_int_resampler_init,
148   resample_int_resampler_destroy,
149   resample_int_resampler_process_interleaved_int,
150   resample_int_resampler_set_rate,
151   resample_int_resampler_get_rate,
152   resample_int_resampler_get_ratio,
153   resample_int_resampler_get_input_latency,
154   resample_int_resampler_set_quality,
155   resample_int_resampler_reset_mem,
156   resample_int_resampler_skip_zeros,
157   resample_int_resampler_strerror,
158   16
159 };
160
161 #endif /* __SPEEX_RESAMPLER_WRAPPER_H__ */