diff options
Diffstat (limited to 'lib/rbcodec/codecs/libspeex/speex')
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/ogg.h | 216 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex.h | 428 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex_bits.h | 184 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex_callbacks.h | 134 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex_config_types.h | 13 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex_echo.h | 123 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex_header.h | 91 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex_jitter.h | 197 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex_preprocess.h | 190 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex_resampler.h | 328 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex_stereo.h | 91 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libspeex/speex/speex_types.h | 126 |
12 files changed, 2121 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libspeex/speex/ogg.h b/lib/rbcodec/codecs/libspeex/speex/ogg.h new file mode 100644 index 0000000000..8898b99582 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/ogg.h | |||
@@ -0,0 +1,216 @@ | |||
1 | /******************************************************************** | ||
2 | * * | ||
3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | ||
4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | ||
5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | ||
6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | ||
7 | * * | ||
8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * | ||
9 | * by the Xiph.Org Foundation http://www.xiph.org/ * | ||
10 | * * | ||
11 | ******************************************************************** | ||
12 | |||
13 | function: toplevel libogg include | ||
14 | last mod: $Id$ | ||
15 | |||
16 | ********************************************************************/ | ||
17 | #ifndef _OGG_H | ||
18 | #define _OGG_H | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | #include "codeclib.h" | ||
25 | |||
26 | typedef short spx_ogg_int16_t; | ||
27 | typedef unsigned short spx_ogg_uint16_t; | ||
28 | typedef int spx_ogg_int32_t; | ||
29 | typedef unsigned int spx_ogg_uint32_t; | ||
30 | typedef long long spx_ogg_int64_t; | ||
31 | |||
32 | |||
33 | #define _spx_ogg_malloc codec_malloc | ||
34 | #define _spx_ogg_calloc codec_calloc | ||
35 | #define _spx_ogg_realloc codec_realloc | ||
36 | #define _spx_ogg_free codec_free | ||
37 | |||
38 | |||
39 | typedef struct { | ||
40 | long endbyte; | ||
41 | int endbit; | ||
42 | |||
43 | unsigned char *buffer; | ||
44 | unsigned char *ptr; | ||
45 | long storage; | ||
46 | } oggpack_buffer; | ||
47 | |||
48 | /* spx_ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ | ||
49 | |||
50 | typedef struct { | ||
51 | unsigned char *header; | ||
52 | long header_len; | ||
53 | unsigned char *body; | ||
54 | long body_len; | ||
55 | } spx_ogg_page; | ||
56 | |||
57 | /* spx_ogg_stream_state contains the current encode/decode state of a logical | ||
58 | Ogg bitstream **********************************************************/ | ||
59 | |||
60 | typedef struct { | ||
61 | unsigned char *body_data; /* bytes from packet bodies */ | ||
62 | long body_storage; /* storage elements allocated */ | ||
63 | long body_fill; /* elements stored; fill mark */ | ||
64 | long body_returned; /* elements of fill returned */ | ||
65 | |||
66 | |||
67 | int *lacing_vals; /* The values that will go to the segment table */ | ||
68 | spx_ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact | ||
69 | this way, but it is simple coupled to the | ||
70 | lacing fifo */ | ||
71 | long lacing_storage; | ||
72 | long lacing_fill; | ||
73 | long lacing_packet; | ||
74 | long lacing_returned; | ||
75 | |||
76 | unsigned char header[282]; /* working space for header encode */ | ||
77 | int header_fill; | ||
78 | |||
79 | int e_o_s; /* set when we have buffered the last packet in the | ||
80 | logical bitstream */ | ||
81 | int b_o_s; /* set after we've written the initial page | ||
82 | of a logical bitstream */ | ||
83 | long serialno; | ||
84 | long pageno; | ||
85 | spx_ogg_int64_t packetno; /* sequence number for decode; the framing | ||
86 | knows where there's a hole in the data, | ||
87 | but we need coupling so that the codec | ||
88 | (which is in a seperate abstraction | ||
89 | layer) also knows about the gap */ | ||
90 | spx_ogg_int64_t granulepos; | ||
91 | |||
92 | } spx_ogg_stream_state; | ||
93 | |||
94 | /* spx_ogg_packet is used to encapsulate the data and metadata belonging | ||
95 | to a single raw Ogg/Vorbis packet *************************************/ | ||
96 | |||
97 | typedef struct { | ||
98 | unsigned char *packet; | ||
99 | long bytes; | ||
100 | long b_o_s; | ||
101 | long e_o_s; | ||
102 | |||
103 | spx_ogg_int64_t granulepos; | ||
104 | |||
105 | spx_ogg_int64_t packetno; /* sequence number for decode; the framing | ||
106 | knows where there's a hole in the data, | ||
107 | but we need coupling so that the codec | ||
108 | (which is in a seperate abstraction | ||
109 | layer) also knows about the gap */ | ||
110 | } spx_ogg_packet; | ||
111 | |||
112 | typedef struct { | ||
113 | unsigned char *data; | ||
114 | int storage; | ||
115 | int fill; | ||
116 | int returned; | ||
117 | |||
118 | int unsynced; | ||
119 | int headerbytes; | ||
120 | int bodybytes; | ||
121 | } spx_ogg_sync_state; | ||
122 | |||
123 | /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ | ||
124 | |||
125 | extern void oggpack_writeinit(oggpack_buffer *b); | ||
126 | extern void oggpack_writetrunc(oggpack_buffer *b,long bits); | ||
127 | extern void oggpack_writealign(oggpack_buffer *b); | ||
128 | extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits); | ||
129 | extern void oggpack_reset(oggpack_buffer *b); | ||
130 | extern void oggpack_writeclear(oggpack_buffer *b); | ||
131 | extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); | ||
132 | extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits); | ||
133 | extern long oggpack_look(oggpack_buffer *b,int bits); | ||
134 | extern long oggpack_look1(oggpack_buffer *b); | ||
135 | extern void oggpack_adv(oggpack_buffer *b,int bits); | ||
136 | extern void oggpack_adv1(oggpack_buffer *b); | ||
137 | extern long oggpack_read(oggpack_buffer *b,int bits); | ||
138 | extern long oggpack_read1(oggpack_buffer *b); | ||
139 | extern long oggpack_bytes(oggpack_buffer *b); | ||
140 | extern long oggpack_bits(oggpack_buffer *b); | ||
141 | extern unsigned char *oggpack_get_buffer(oggpack_buffer *b); | ||
142 | |||
143 | extern void oggpackB_writeinit(oggpack_buffer *b); | ||
144 | extern void oggpackB_writetrunc(oggpack_buffer *b,long bits); | ||
145 | extern void oggpackB_writealign(oggpack_buffer *b); | ||
146 | extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits); | ||
147 | extern void oggpackB_reset(oggpack_buffer *b); | ||
148 | extern void oggpackB_writeclear(oggpack_buffer *b); | ||
149 | extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); | ||
150 | extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits); | ||
151 | extern long oggpackB_look(oggpack_buffer *b,int bits); | ||
152 | extern long oggpackB_look1(oggpack_buffer *b); | ||
153 | extern void oggpackB_adv(oggpack_buffer *b,int bits); | ||
154 | extern void oggpackB_adv1(oggpack_buffer *b); | ||
155 | extern long oggpackB_read(oggpack_buffer *b,int bits); | ||
156 | extern long oggpackB_read1(oggpack_buffer *b); | ||
157 | extern long oggpackB_bytes(oggpack_buffer *b); | ||
158 | extern long oggpackB_bits(oggpack_buffer *b); | ||
159 | extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b); | ||
160 | |||
161 | /* Ogg BITSTREAM PRIMITIVES: encoding **************************/ | ||
162 | |||
163 | extern int spx_ogg_stream_packetin(spx_ogg_stream_state *os, spx_ogg_packet *op); | ||
164 | extern int spx_ogg_stream_pageout(spx_ogg_stream_state *os, spx_ogg_page *og); | ||
165 | extern int spx_ogg_stream_flush(spx_ogg_stream_state *os, spx_ogg_page *og); | ||
166 | |||
167 | /* Ogg BITSTREAM PRIMITIVES: decoding **************************/ | ||
168 | |||
169 | extern int spx_ogg_sync_init(spx_ogg_sync_state *oy); | ||
170 | extern int spx_ogg_sync_clear(spx_ogg_sync_state *oy); | ||
171 | extern int spx_ogg_sync_reset(spx_ogg_sync_state *oy); | ||
172 | extern int spx_ogg_sync_destroy(spx_ogg_sync_state *oy); | ||
173 | |||
174 | extern void spx_ogg_alloc_buffer(spx_ogg_sync_state *oy, long size); | ||
175 | extern char *spx_ogg_sync_buffer(spx_ogg_sync_state *oy, long size); | ||
176 | extern int spx_ogg_sync_wrote(spx_ogg_sync_state *oy, long bytes); | ||
177 | extern long spx_ogg_sync_pageseek(spx_ogg_sync_state *oy,spx_ogg_page *og); | ||
178 | extern int spx_ogg_sync_pageout(spx_ogg_sync_state *oy, spx_ogg_page *og); | ||
179 | extern int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og); | ||
180 | extern int spx_ogg_stream_packetout(spx_ogg_stream_state *os,spx_ogg_packet *op); | ||
181 | extern int spx_ogg_stream_packetpeek(spx_ogg_stream_state *os,spx_ogg_packet *op); | ||
182 | |||
183 | /* Ogg BITSTREAM PRIMITIVES: general ***************************/ | ||
184 | |||
185 | extern int spx_ogg_stream_init(spx_ogg_stream_state *os,int serialno); | ||
186 | extern int spx_ogg_stream_clear(spx_ogg_stream_state *os); | ||
187 | extern int spx_ogg_stream_reset(spx_ogg_stream_state *os); | ||
188 | extern int spx_ogg_stream_reset_serialno(spx_ogg_stream_state *os,int serialno); | ||
189 | extern int spx_ogg_stream_destroy(spx_ogg_stream_state *os); | ||
190 | extern int spx_ogg_stream_eos(spx_ogg_stream_state *os); | ||
191 | |||
192 | extern void spx_ogg_page_checksum_set(spx_ogg_page *og); | ||
193 | |||
194 | extern int spx_ogg_page_version(spx_ogg_page *og); | ||
195 | extern int spx_ogg_page_continued(spx_ogg_page *og); | ||
196 | extern int spx_ogg_page_bos(spx_ogg_page *og); | ||
197 | extern int spx_ogg_page_eos(spx_ogg_page *og); | ||
198 | extern spx_ogg_int64_t spx_ogg_page_granulepos(spx_ogg_page *og); | ||
199 | extern int spx_ogg_page_serialno(spx_ogg_page *og); | ||
200 | extern long spx_ogg_page_pageno(spx_ogg_page *og); | ||
201 | extern int spx_ogg_page_packets(spx_ogg_page *og); | ||
202 | |||
203 | extern void spx_ogg_packet_clear(spx_ogg_packet *op); | ||
204 | |||
205 | |||
206 | #ifdef __cplusplus | ||
207 | } | ||
208 | #endif | ||
209 | |||
210 | #endif /* _OGG_H */ | ||
211 | |||
212 | |||
213 | |||
214 | |||
215 | |||
216 | |||
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex.h b/lib/rbcodec/codecs/libspeex/speex/speex.h new file mode 100644 index 0000000000..086d492670 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex.h | |||
@@ -0,0 +1,428 @@ | |||
1 | /* Copyright (C) 2002-2006 Jean-Marc Valin*/ | ||
2 | /** | ||
3 | @file speex.h | ||
4 | @brief Describes the different modes of the codec | ||
5 | */ | ||
6 | /* | ||
7 | Redistribution and use in source and binary forms, with or without | ||
8 | modification, are permitted provided that the following conditions | ||
9 | are met: | ||
10 | |||
11 | - Redistributions of source code must retain the above copyright | ||
12 | notice, this list of conditions and the following disclaimer. | ||
13 | |||
14 | - Redistributions in binary form must reproduce the above copyright | ||
15 | notice, this list of conditions and the following disclaimer in the | ||
16 | documentation and/or other materials provided with the distribution. | ||
17 | |||
18 | - Neither the name of the Xiph.org Foundation nor the names of its | ||
19 | contributors may be used to endorse or promote products derived from | ||
20 | this software without specific prior written permission. | ||
21 | |||
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | |||
34 | */ | ||
35 | |||
36 | #ifndef SPEEX_H | ||
37 | #define SPEEX_H | ||
38 | /** @defgroup Codec Speex encoder and decoder | ||
39 | * This is the Speex codec itself. | ||
40 | * @{ | ||
41 | */ | ||
42 | |||
43 | #include "speex_bits.h" | ||
44 | #include "speex_types.h" | ||
45 | |||
46 | #ifdef __cplusplus | ||
47 | extern "C" { | ||
48 | #endif | ||
49 | |||
50 | /* Values allowed for *ctl() requests */ | ||
51 | |||
52 | /** Set enhancement on/off (decoder only) */ | ||
53 | #define SPEEX_SET_ENH 0 | ||
54 | /** Get enhancement state (decoder only) */ | ||
55 | #define SPEEX_GET_ENH 1 | ||
56 | |||
57 | /*Would be SPEEX_SET_FRAME_SIZE, but it's (currently) invalid*/ | ||
58 | /** Obtain frame size used by encoder/decoder */ | ||
59 | #define SPEEX_GET_FRAME_SIZE 3 | ||
60 | |||
61 | /** Set quality value */ | ||
62 | #define SPEEX_SET_QUALITY 4 | ||
63 | /** Get current quality setting */ | ||
64 | /* #define SPEEX_GET_QUALITY 5 -- Doesn't make much sense, does it? */ | ||
65 | |||
66 | /** Set sub-mode to use */ | ||
67 | #define SPEEX_SET_MODE 6 | ||
68 | /** Get current sub-mode in use */ | ||
69 | #define SPEEX_GET_MODE 7 | ||
70 | |||
71 | /** Set low-band sub-mode to use (wideband only)*/ | ||
72 | #define SPEEX_SET_LOW_MODE 8 | ||
73 | /** Get current low-band mode in use (wideband only)*/ | ||
74 | #define SPEEX_GET_LOW_MODE 9 | ||
75 | |||
76 | /** Set high-band sub-mode to use (wideband only)*/ | ||
77 | #define SPEEX_SET_HIGH_MODE 10 | ||
78 | /** Get current high-band mode in use (wideband only)*/ | ||
79 | #define SPEEX_GET_HIGH_MODE 11 | ||
80 | |||
81 | /** Set VBR on (1) or off (0) */ | ||
82 | #define SPEEX_SET_VBR 12 | ||
83 | /** Get VBR status (1 for on, 0 for off) */ | ||
84 | #define SPEEX_GET_VBR 13 | ||
85 | |||
86 | /** Set quality value for VBR encoding (0-10) */ | ||
87 | #define SPEEX_SET_VBR_QUALITY 14 | ||
88 | /** Get current quality value for VBR encoding (0-10) */ | ||
89 | #define SPEEX_GET_VBR_QUALITY 15 | ||
90 | |||
91 | /** Set complexity of the encoder (0-10) */ | ||
92 | #define SPEEX_SET_COMPLEXITY 16 | ||
93 | /** Get current complexity of the encoder (0-10) */ | ||
94 | #define SPEEX_GET_COMPLEXITY 17 | ||
95 | |||
96 | /** Set bit-rate used by the encoder (or lower) */ | ||
97 | #define SPEEX_SET_BITRATE 18 | ||
98 | /** Get current bit-rate used by the encoder or decoder */ | ||
99 | #define SPEEX_GET_BITRATE 19 | ||
100 | |||
101 | /** Define a handler function for in-band Speex request*/ | ||
102 | #define SPEEX_SET_HANDLER 20 | ||
103 | |||
104 | /** Define a handler function for in-band user-defined request*/ | ||
105 | #define SPEEX_SET_USER_HANDLER 22 | ||
106 | |||
107 | /** Set sampling rate used in bit-rate computation */ | ||
108 | #define SPEEX_SET_SAMPLING_RATE 24 | ||
109 | /** Get sampling rate used in bit-rate computation */ | ||
110 | #define SPEEX_GET_SAMPLING_RATE 25 | ||
111 | |||
112 | /** Reset the encoder/decoder memories to zero*/ | ||
113 | #define SPEEX_RESET_STATE 26 | ||
114 | |||
115 | /** Get VBR info (mostly used internally) */ | ||
116 | #define SPEEX_GET_RELATIVE_QUALITY 29 | ||
117 | |||
118 | /** Set VAD status (1 for on, 0 for off) */ | ||
119 | #define SPEEX_SET_VAD 30 | ||
120 | |||
121 | /** Get VAD status (1 for on, 0 for off) */ | ||
122 | #define SPEEX_GET_VAD 31 | ||
123 | |||
124 | /** Set Average Bit-Rate (ABR) to n bits per seconds */ | ||
125 | #define SPEEX_SET_ABR 32 | ||
126 | /** Get Average Bit-Rate (ABR) setting (in bps) */ | ||
127 | #define SPEEX_GET_ABR 33 | ||
128 | |||
129 | /** Set DTX status (1 for on, 0 for off) */ | ||
130 | #define SPEEX_SET_DTX 34 | ||
131 | /** Get DTX status (1 for on, 0 for off) */ | ||
132 | #define SPEEX_GET_DTX 35 | ||
133 | |||
134 | /** Set submode encoding in each frame (1 for yes, 0 for no, setting to no breaks the standard) */ | ||
135 | #define SPEEX_SET_SUBMODE_ENCODING 36 | ||
136 | /** Get submode encoding in each frame */ | ||
137 | #define SPEEX_GET_SUBMODE_ENCODING 37 | ||
138 | |||
139 | /*#define SPEEX_SET_LOOKAHEAD 38*/ | ||
140 | /** Returns the lookahead used by Speex */ | ||
141 | #define SPEEX_GET_LOOKAHEAD 39 | ||
142 | |||
143 | /** Sets tuning for packet-loss concealment (expected loss rate) */ | ||
144 | #define SPEEX_SET_PLC_TUNING 40 | ||
145 | /** Gets tuning for PLC */ | ||
146 | #define SPEEX_GET_PLC_TUNING 41 | ||
147 | |||
148 | /** Sets the max bit-rate allowed in VBR mode */ | ||
149 | #define SPEEX_SET_VBR_MAX_BITRATE 42 | ||
150 | /** Gets the max bit-rate allowed in VBR mode */ | ||
151 | #define SPEEX_GET_VBR_MAX_BITRATE 43 | ||
152 | |||
153 | /** Turn on/off input/output high-pass filtering */ | ||
154 | #define SPEEX_SET_HIGHPASS 44 | ||
155 | /** Get status of input/output high-pass filtering */ | ||
156 | #define SPEEX_GET_HIGHPASS 45 | ||
157 | |||
158 | /** Get "activity level" of the last decoded frame, i.e. | ||
159 | how much damage we cause if we remove the frame */ | ||
160 | #define SPEEX_GET_ACTIVITY 47 | ||
161 | |||
162 | |||
163 | /* Preserving compatibility:*/ | ||
164 | /** Equivalent to SPEEX_SET_ENH */ | ||
165 | #define SPEEX_SET_PF 0 | ||
166 | /** Equivalent to SPEEX_GET_ENH */ | ||
167 | #define SPEEX_GET_PF 1 | ||
168 | |||
169 | |||
170 | |||
171 | |||
172 | /* Values allowed for mode queries */ | ||
173 | /** Query the frame size of a mode */ | ||
174 | #define SPEEX_MODE_FRAME_SIZE 0 | ||
175 | |||
176 | /** Query the size of an encoded frame for a particular sub-mode */ | ||
177 | #define SPEEX_SUBMODE_BITS_PER_FRAME 1 | ||
178 | |||
179 | |||
180 | |||
181 | /** Get major Speex version */ | ||
182 | #define SPEEX_LIB_GET_MAJOR_VERSION 1 | ||
183 | /** Get minor Speex version */ | ||
184 | #define SPEEX_LIB_GET_MINOR_VERSION 3 | ||
185 | /** Get micro Speex version */ | ||
186 | #define SPEEX_LIB_GET_MICRO_VERSION 5 | ||
187 | /** Get extra Speex version */ | ||
188 | #define SPEEX_LIB_GET_EXTRA_VERSION 7 | ||
189 | /** Get Speex version string */ | ||
190 | #define SPEEX_LIB_GET_VERSION_STRING 9 | ||
191 | |||
192 | /*#define SPEEX_LIB_SET_ALLOC_FUNC 10 | ||
193 | #define SPEEX_LIB_GET_ALLOC_FUNC 11 | ||
194 | #define SPEEX_LIB_SET_FREE_FUNC 12 | ||
195 | #define SPEEX_LIB_GET_FREE_FUNC 13 | ||
196 | |||
197 | #define SPEEX_LIB_SET_WARNING_FUNC 14 | ||
198 | #define SPEEX_LIB_GET_WARNING_FUNC 15 | ||
199 | #define SPEEX_LIB_SET_ERROR_FUNC 16 | ||
200 | #define SPEEX_LIB_GET_ERROR_FUNC 17 | ||
201 | */ | ||
202 | |||
203 | /** Number of defined modes in Speex */ | ||
204 | #define SPEEX_NB_MODES 3 | ||
205 | |||
206 | /** modeID for the defined narrowband mode */ | ||
207 | #define SPEEX_MODEID_NB 0 | ||
208 | |||
209 | /** modeID for the defined wideband mode */ | ||
210 | #define SPEEX_MODEID_WB 1 | ||
211 | |||
212 | /** modeID for the defined ultra-wideband mode */ | ||
213 | #define SPEEX_MODEID_UWB 2 | ||
214 | |||
215 | struct SpeexMode; | ||
216 | |||
217 | |||
218 | /* Prototypes for mode function pointers */ | ||
219 | |||
220 | /** Encoder state initialization function */ | ||
221 | typedef void *(*encoder_init_func)(const struct SpeexMode *mode); | ||
222 | |||
223 | /** Encoder state destruction function */ | ||
224 | typedef void (*encoder_destroy_func)(void *st); | ||
225 | |||
226 | /** Main encoding function */ | ||
227 | typedef int (*encode_func)(void *state, void *in, SpeexBits *bits); | ||
228 | |||
229 | /** Function for controlling the encoder options */ | ||
230 | typedef int (*encoder_ctl_func)(void *state, int request, void *ptr); | ||
231 | |||
232 | /** Decoder state initialization function */ | ||
233 | typedef void *(*decoder_init_func)(const struct SpeexMode *mode); | ||
234 | |||
235 | /** Decoder state destruction function */ | ||
236 | typedef void (*decoder_destroy_func)(void *st); | ||
237 | |||
238 | /** Main decoding function */ | ||
239 | typedef int (*decode_func)(void *state, SpeexBits *bits, void *out); | ||
240 | |||
241 | /** Function for controlling the decoder options */ | ||
242 | typedef int (*decoder_ctl_func)(void *state, int request, void *ptr); | ||
243 | |||
244 | |||
245 | /** Query function for a mode */ | ||
246 | typedef int (*mode_query_func)(const void *mode, int request, void *ptr); | ||
247 | |||
248 | /** Struct defining a Speex mode */ | ||
249 | typedef struct SpeexMode { | ||
250 | /** Pointer to the low-level mode data */ | ||
251 | const void *mode; | ||
252 | |||
253 | /** Pointer to the mode query function */ | ||
254 | mode_query_func query; | ||
255 | |||
256 | /** The name of the mode (you should not rely on this to identify the mode)*/ | ||
257 | const char *modeName; | ||
258 | |||
259 | /**ID of the mode*/ | ||
260 | int modeID; | ||
261 | |||
262 | /**Version number of the bitstream (incremented every time we break | ||
263 | bitstream compatibility*/ | ||
264 | int bitstream_version; | ||
265 | |||
266 | #ifndef SPEEX_DISABLE_ENCODER | ||
267 | /** Pointer to encoder initialization function */ | ||
268 | encoder_init_func enc_init; | ||
269 | |||
270 | /** Pointer to encoder destruction function */ | ||
271 | encoder_destroy_func enc_destroy; | ||
272 | |||
273 | /** Pointer to frame encoding function */ | ||
274 | encode_func enc; | ||
275 | #endif | ||
276 | |||
277 | /** Pointer to decoder initialization function */ | ||
278 | decoder_init_func dec_init; | ||
279 | |||
280 | /** Pointer to decoder destruction function */ | ||
281 | decoder_destroy_func dec_destroy; | ||
282 | |||
283 | /** Pointer to frame decoding function */ | ||
284 | decode_func dec; | ||
285 | |||
286 | #ifndef SPEEX_DISABLE_ENCODER | ||
287 | /** ioctl-like requests for encoder */ | ||
288 | encoder_ctl_func enc_ctl; | ||
289 | #endif | ||
290 | |||
291 | /** ioctl-like requests for decoder */ | ||
292 | decoder_ctl_func dec_ctl; | ||
293 | |||
294 | } SpeexMode; | ||
295 | |||
296 | /** | ||
297 | * Returns a handle to a newly created Speex encoder state structure. For now, | ||
298 | * the "mode" argument can be &nb_mode or &wb_mode . In the future, more modes | ||
299 | * may be added. Note that for now if you have more than one channels to | ||
300 | * encode, you need one state per channel. | ||
301 | * | ||
302 | * @param mode The mode to use (either speex_nb_mode or speex_wb.mode) | ||
303 | * @return A newly created encoder state or NULL if state allocation fails | ||
304 | */ | ||
305 | void *speex_encoder_init(const SpeexMode *mode); | ||
306 | |||
307 | /** Frees all resources associated to an existing Speex encoder state. | ||
308 | * @param state Encoder state to be destroyed */ | ||
309 | void speex_encoder_destroy(void *state); | ||
310 | |||
311 | /** Uses an existing encoder state to encode one frame of speech pointed to by | ||
312 | "in". The encoded bit-stream is saved in "bits". | ||
313 | @param state Encoder state | ||
314 | @param in Frame that will be encoded with a +-2^15 range. This data MAY be | ||
315 | overwritten by the encoder and should be considered uninitialised | ||
316 | after the call. | ||
317 | @param bits Bit-stream where the data will be written | ||
318 | @return 0 if frame needs not be transmitted (DTX only), 1 otherwise | ||
319 | */ | ||
320 | int speex_encode(void *state, float *in, SpeexBits *bits); | ||
321 | |||
322 | /** Uses an existing encoder state to encode one frame of speech pointed to by | ||
323 | "in". The encoded bit-stream is saved in "bits". | ||
324 | @param state Encoder state | ||
325 | @param in Frame that will be encoded with a +-2^15 range | ||
326 | @param bits Bit-stream where the data will be written | ||
327 | @return 0 if frame needs not be transmitted (DTX only), 1 otherwise | ||
328 | */ | ||
329 | int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits); | ||
330 | |||
331 | /** Used like the ioctl function to control the encoder parameters | ||
332 | * | ||
333 | * @param state Encoder state | ||
334 | * @param request ioctl-type request (one of the SPEEX_* macros) | ||
335 | * @param ptr Data exchanged to-from function | ||
336 | * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter | ||
337 | */ | ||
338 | int speex_encoder_ctl(void *state, int request, void *ptr); | ||
339 | |||
340 | |||
341 | /** Returns a handle to a newly created decoder state structure. For now, | ||
342 | * the mode argument can be &nb_mode or &wb_mode . In the future, more modes | ||
343 | * may be added. Note that for now if you have more than one channels to | ||
344 | * decode, you need one state per channel. | ||
345 | * | ||
346 | * @param mode Speex mode (one of speex_nb_mode or speex_wb_mode) | ||
347 | * @return A newly created decoder state or NULL if state allocation fails | ||
348 | */ | ||
349 | void *speex_decoder_init(const SpeexMode *mode); | ||
350 | |||
351 | /** Frees all resources associated to an existing decoder state. | ||
352 | * | ||
353 | * @param state State to be destroyed | ||
354 | */ | ||
355 | void speex_decoder_destroy(void *state); | ||
356 | |||
357 | /** Uses an existing decoder state to decode one frame of speech from | ||
358 | * bit-stream bits. The output speech is saved written to out. | ||
359 | * | ||
360 | * @param state Decoder state | ||
361 | * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost) | ||
362 | * @param out Where to write the decoded frame | ||
363 | * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream) | ||
364 | */ | ||
365 | int speex_decode(void *state, SpeexBits *bits, float *out); | ||
366 | |||
367 | /** Uses an existing decoder state to decode one frame of speech from | ||
368 | * bit-stream bits. The output speech is saved written to out. | ||
369 | * | ||
370 | * @param state Decoder state | ||
371 | * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost) | ||
372 | * @param out Where to write the decoded frame | ||
373 | * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream) | ||
374 | */ | ||
375 | int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out); | ||
376 | |||
377 | /** Used like the ioctl function to control the encoder parameters | ||
378 | * | ||
379 | * @param state Decoder state | ||
380 | * @param request ioctl-type request (one of the SPEEX_* macros) | ||
381 | * @param ptr Data exchanged to-from function | ||
382 | * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter | ||
383 | */ | ||
384 | int speex_decoder_ctl(void *state, int request, void *ptr); | ||
385 | |||
386 | |||
387 | /** Query function for mode information | ||
388 | * | ||
389 | * @param mode Speex mode | ||
390 | * @param request ioctl-type request (one of the SPEEX_* macros) | ||
391 | * @param ptr Data exchanged to-from function | ||
392 | * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter | ||
393 | */ | ||
394 | int speex_mode_query(const SpeexMode *mode, int request, void *ptr); | ||
395 | |||
396 | /** Functions for controlling the behavior of libspeex | ||
397 | * @param request ioctl-type request (one of the SPEEX_LIB_* macros) | ||
398 | * @param ptr Data exchanged to-from function | ||
399 | * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter | ||
400 | */ | ||
401 | int speex_lib_ctl(int request, void *ptr); | ||
402 | |||
403 | /** Default narrowband mode */ | ||
404 | extern const SpeexMode speex_nb_mode; | ||
405 | |||
406 | /** Default wideband mode */ | ||
407 | extern const SpeexMode speex_wb_mode; | ||
408 | |||
409 | /** Default "ultra-wideband" mode */ | ||
410 | extern const SpeexMode speex_uwb_mode; | ||
411 | |||
412 | /** List of all modes available */ | ||
413 | extern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES]; | ||
414 | |||
415 | /** Obtain one of the modes available */ | ||
416 | const SpeexMode * speex_lib_get_mode (int mode); | ||
417 | |||
418 | #ifndef WIN32 | ||
419 | /* We actually override the function in the narrowband case so that we can avoid linking in the wideband stuff */ | ||
420 | #define speex_lib_get_mode(mode) ((mode)==SPEEX_MODEID_NB ? &speex_nb_mode : speex_lib_get_mode (mode)) | ||
421 | #endif | ||
422 | |||
423 | #ifdef __cplusplus | ||
424 | } | ||
425 | #endif | ||
426 | |||
427 | /** @}*/ | ||
428 | #endif | ||
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_bits.h b/lib/rbcodec/codecs/libspeex/speex/speex_bits.h new file mode 100644 index 0000000000..fee2893380 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_bits.h | |||
@@ -0,0 +1,184 @@ | |||
1 | /* Copyright (C) 2002 Jean-Marc Valin */ | ||
2 | /** | ||
3 | @file speex_bits.h | ||
4 | @brief Handles bit packing/unpacking | ||
5 | */ | ||
6 | /* | ||
7 | Redistribution and use in source and binary forms, with or without | ||
8 | modification, are permitted provided that the following conditions | ||
9 | are met: | ||
10 | |||
11 | - Redistributions of source code must retain the above copyright | ||
12 | notice, this list of conditions and the following disclaimer. | ||
13 | |||
14 | - Redistributions in binary form must reproduce the above copyright | ||
15 | notice, this list of conditions and the following disclaimer in the | ||
16 | documentation and/or other materials provided with the distribution. | ||
17 | |||
18 | - Neither the name of the Xiph.org Foundation nor the names of its | ||
19 | contributors may be used to endorse or promote products derived from | ||
20 | this software without specific prior written permission. | ||
21 | |||
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | |||
34 | */ | ||
35 | |||
36 | #ifndef BITS_H | ||
37 | #define BITS_H | ||
38 | /** @defgroup SpeexBits SpeexBits: Bit-stream manipulations | ||
39 | * This is the structure that holds the bit-stream when encoding or decoding | ||
40 | * with Speex. It allows some manipulations as well. | ||
41 | * @{ | ||
42 | */ | ||
43 | |||
44 | #ifdef __cplusplus | ||
45 | extern "C" { | ||
46 | #endif | ||
47 | |||
48 | /** Bit-packing data structure representing (part of) a bit-stream. */ | ||
49 | typedef struct SpeexBits { | ||
50 | char *chars; /**< "raw" data */ | ||
51 | int nbBits; /**< Total number of bits stored in the stream*/ | ||
52 | int charPtr; /**< Position of the byte "cursor" */ | ||
53 | int bitPtr; /**< Position of the bit "cursor" within the current char */ | ||
54 | int owner; /**< Does the struct "own" the "raw" buffer (member "chars") */ | ||
55 | int overflow;/**< Set to one if we try to read past the valid data */ | ||
56 | int buf_size;/**< Allocated size for buffer */ | ||
57 | int reserved1; /**< Reserved for future use */ | ||
58 | void *reserved2; /**< Reserved for future use */ | ||
59 | } SpeexBits; | ||
60 | |||
61 | /** Initializes and allocates resources for a SpeexBits struct */ | ||
62 | void speex_bits_init(SpeexBits *bits); | ||
63 | |||
64 | /** Initializes SpeexBits struct using a pre-allocated buffer*/ | ||
65 | /* Rockbox: unused | ||
66 | void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size); | ||
67 | */ | ||
68 | |||
69 | /** Sets the bits in a SpeexBits struct to use data from an existing buffer (for decoding without copying data) */ | ||
70 | void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size); | ||
71 | |||
72 | /** Frees all resources associated to a SpeexBits struct. Right now this does nothing since no resources are allocated, but this could change in the future.*/ | ||
73 | void speex_bits_destroy(SpeexBits *bits); | ||
74 | |||
75 | /** Resets bits to initial value (just after initialization, erasing content)*/ | ||
76 | void speex_bits_reset(SpeexBits *bits); | ||
77 | |||
78 | /** Rewind the bit-stream to the beginning (ready for read) without erasing the content */ | ||
79 | /* Rockbox: unused | ||
80 | void speex_bits_rewind(SpeexBits *bits); | ||
81 | */ | ||
82 | |||
83 | /** Initializes the bit-stream from the data in an area of memory */ | ||
84 | void speex_bits_read_from(SpeexBits *bits, char *bytes, int len); | ||
85 | |||
86 | /** Append bytes to the bit-stream | ||
87 | * | ||
88 | * @param bits Bit-stream to operate on | ||
89 | * @param bytes pointer to the bytes what will be appended | ||
90 | * @param len Number of bytes of append | ||
91 | */ | ||
92 | void speex_bits_read_whole_bytes(SpeexBits *bits, char *bytes, int len); | ||
93 | |||
94 | /** Write the content of a bit-stream to an area of memory | ||
95 | * | ||
96 | * @param bits Bit-stream to operate on | ||
97 | * @param bytes Memory location where to write the bits | ||
98 | * @param max_len Maximum number of bytes to write (i.e. size of the "bytes" buffer) | ||
99 | * @return Number of bytes written to the "bytes" buffer | ||
100 | */ | ||
101 | int speex_bits_write(SpeexBits *bits, char *bytes, int max_len); | ||
102 | |||
103 | /** Like speex_bits_write, but writes only the complete bytes in the stream. Also removes the written bytes from the stream */ | ||
104 | int speex_bits_write_whole_bytes(SpeexBits *bits, char *bytes, int max_len); | ||
105 | |||
106 | /** Append bits to the bit-stream | ||
107 | * @param bits Bit-stream to operate on | ||
108 | * @param data Value to append as integer | ||
109 | * @param nbBits number of bits to consider in "data" | ||
110 | */ | ||
111 | void speex_bits_pack(SpeexBits *bits, int data, int nbBits); | ||
112 | |||
113 | /** Interpret the next bits in the bit-stream as a signed integer | ||
114 | * | ||
115 | * @param bits Bit-stream to operate on | ||
116 | * @param nbBits Number of bits to interpret | ||
117 | * @return A signed integer represented by the bits read | ||
118 | */ | ||
119 | /* Rockbox: unused | ||
120 | int speex_bits_unpack_signed(SpeexBits *bits, int nbBits); | ||
121 | */ | ||
122 | |||
123 | /** Interpret the next bits in the bit-stream as an unsigned integer | ||
124 | * | ||
125 | * @param bits Bit-stream to operate on | ||
126 | * @param nbBits Number of bits to interpret | ||
127 | * @return An unsigned integer represented by the bits read | ||
128 | */ | ||
129 | unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits); | ||
130 | |||
131 | /** Returns the number of bytes in the bit-stream, including the last one even if it is not "full" | ||
132 | * | ||
133 | * @param bits Bit-stream to operate on | ||
134 | * @return Number of bytes in the stream | ||
135 | */ | ||
136 | /* Rockbox: unused | ||
137 | int speex_bits_nbytes(SpeexBits *bits); | ||
138 | */ | ||
139 | |||
140 | /** Same as speex_bits_unpack_unsigned, but without modifying the cursor position | ||
141 | * | ||
142 | * @param bits Bit-stream to operate on | ||
143 | * @param nbBits Number of bits to look for | ||
144 | * @return Value of the bits peeked, interpreted as unsigned | ||
145 | */ | ||
146 | /* Rockbox: unused | ||
147 | unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits); | ||
148 | */ | ||
149 | |||
150 | /** Get the value of the next bit in the stream, without modifying the | ||
151 | * "cursor" position | ||
152 | * | ||
153 | * @param bits Bit-stream to operate on | ||
154 | * @return Value of the bit peeked (one bit only) | ||
155 | */ | ||
156 | int speex_bits_peek(SpeexBits *bits); | ||
157 | |||
158 | /** Advances the position of the "bit cursor" in the stream | ||
159 | * | ||
160 | * @param bits Bit-stream to operate on | ||
161 | * @param n Number of bits to advance | ||
162 | */ | ||
163 | void speex_bits_advance(SpeexBits *bits, int n); | ||
164 | |||
165 | /** Returns the number of bits remaining to be read in a stream | ||
166 | * | ||
167 | * @param bits Bit-stream to operate on | ||
168 | * @return Number of bits that can still be read from the stream | ||
169 | */ | ||
170 | int speex_bits_remaining(SpeexBits *bits); | ||
171 | |||
172 | /** Insert a terminator so that the data can be sent as a packet while auto-detecting | ||
173 | * the number of frames in each packet | ||
174 | * | ||
175 | * @param bits Bit-stream to operate on | ||
176 | */ | ||
177 | void speex_bits_insert_terminator(SpeexBits *bits); | ||
178 | |||
179 | #ifdef __cplusplus | ||
180 | } | ||
181 | #endif | ||
182 | |||
183 | /* @} */ | ||
184 | #endif | ||
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_callbacks.h b/lib/rbcodec/codecs/libspeex/speex/speex_callbacks.h new file mode 100644 index 0000000000..6f450b3a3a --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_callbacks.h | |||
@@ -0,0 +1,134 @@ | |||
1 | /* Copyright (C) 2002 Jean-Marc Valin*/ | ||
2 | /** | ||
3 | @file speex_callbacks.h | ||
4 | @brief Describes callback handling and in-band signalling | ||
5 | */ | ||
6 | /* | ||
7 | Redistribution and use in source and binary forms, with or without | ||
8 | modification, are permitted provided that the following conditions | ||
9 | are met: | ||
10 | |||
11 | - Redistributions of source code must retain the above copyright | ||
12 | notice, this list of conditions and the following disclaimer. | ||
13 | |||
14 | - Redistributions in binary form must reproduce the above copyright | ||
15 | notice, this list of conditions and the following disclaimer in the | ||
16 | documentation and/or other materials provided with the distribution. | ||
17 | |||
18 | - Neither the name of the Xiph.org Foundation nor the names of its | ||
19 | contributors may be used to endorse or promote products derived from | ||
20 | this software without specific prior written permission. | ||
21 | |||
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | |||
34 | */ | ||
35 | |||
36 | #ifndef SPEEX_CALLBACKS_H | ||
37 | #define SPEEX_CALLBACKS_H | ||
38 | /** @defgroup SpeexCallbacks Various definitions for Speex callbacks supported by the decoder. | ||
39 | * @{ | ||
40 | */ | ||
41 | |||
42 | #include "speex.h" | ||
43 | |||
44 | #ifdef __cplusplus | ||
45 | extern "C" { | ||
46 | #endif | ||
47 | |||
48 | /** Total number of callbacks */ | ||
49 | #define SPEEX_MAX_CALLBACKS 16 | ||
50 | |||
51 | /* Describes all the in-band requests */ | ||
52 | |||
53 | /*These are 1-bit requests*/ | ||
54 | /** Request for perceptual enhancement (1 for on, 0 for off) */ | ||
55 | #define SPEEX_INBAND_ENH_REQUEST 0 | ||
56 | /** Reserved */ | ||
57 | #define SPEEX_INBAND_RESERVED1 1 | ||
58 | |||
59 | /*These are 4-bit requests*/ | ||
60 | /** Request for a mode change */ | ||
61 | #define SPEEX_INBAND_MODE_REQUEST 2 | ||
62 | /** Request for a low mode change */ | ||
63 | #define SPEEX_INBAND_LOW_MODE_REQUEST 3 | ||
64 | /** Request for a high mode change */ | ||
65 | #define SPEEX_INBAND_HIGH_MODE_REQUEST 4 | ||
66 | /** Request for VBR (1 on, 0 off) */ | ||
67 | #define SPEEX_INBAND_VBR_QUALITY_REQUEST 5 | ||
68 | /** Request to be sent acknowledge */ | ||
69 | #define SPEEX_INBAND_ACKNOWLEDGE_REQUEST 6 | ||
70 | /** Request for VBR (1 for on, 0 for off) */ | ||
71 | #define SPEEX_INBAND_VBR_REQUEST 7 | ||
72 | |||
73 | /*These are 8-bit requests*/ | ||
74 | /** Send a character in-band */ | ||
75 | #define SPEEX_INBAND_CHAR 8 | ||
76 | /** Intensity stereo information */ | ||
77 | #define SPEEX_INBAND_STEREO 9 | ||
78 | |||
79 | /*These are 16-bit requests*/ | ||
80 | /** Transmit max bit-rate allowed */ | ||
81 | #define SPEEX_INBAND_MAX_BITRATE 10 | ||
82 | |||
83 | /*These are 32-bit requests*/ | ||
84 | /** Acknowledge packet reception */ | ||
85 | #define SPEEX_INBAND_ACKNOWLEDGE 12 | ||
86 | |||
87 | /** Callback function type */ | ||
88 | typedef int (*speex_callback_func)(SpeexBits *bits, void *state, void *data); | ||
89 | |||
90 | /** Callback information */ | ||
91 | typedef struct SpeexCallback { | ||
92 | int callback_id; /**< ID associated to the callback */ | ||
93 | speex_callback_func func; /**< Callback handler function */ | ||
94 | void *data; /**< Data that will be sent to the handler */ | ||
95 | void *reserved1; /**< Reserved for future use */ | ||
96 | int reserved2; /**< Reserved for future use */ | ||
97 | } SpeexCallback; | ||
98 | |||
99 | /** Handle in-band request */ | ||
100 | int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state); | ||
101 | |||
102 | /** Standard handler for mode request (change mode, no questions asked) */ | ||
103 | int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data); | ||
104 | |||
105 | /** Standard handler for high mode request (change high mode, no questions asked) */ | ||
106 | int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data); | ||
107 | |||
108 | /** Standard handler for in-band characters (write to stderr) */ | ||
109 | int speex_std_char_handler(SpeexBits *bits, void *state, void *data); | ||
110 | |||
111 | /** Default handler for user-defined requests: in this case, just ignore */ | ||
112 | int speex_default_user_handler(SpeexBits *bits, void *state, void *data); | ||
113 | |||
114 | |||
115 | |||
116 | /** Standard handler for low mode request (change low mode, no questions asked) */ | ||
117 | int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data); | ||
118 | |||
119 | /** Standard handler for VBR request (Set VBR, no questions asked) */ | ||
120 | int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data); | ||
121 | |||
122 | /** Standard handler for enhancer request (Turn enhancer on/off, no questions asked) */ | ||
123 | int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data); | ||
124 | |||
125 | /** Standard handler for VBR quality request (Set VBR quality, no questions asked) */ | ||
126 | int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data); | ||
127 | |||
128 | |||
129 | #ifdef __cplusplus | ||
130 | } | ||
131 | #endif | ||
132 | |||
133 | /** @} */ | ||
134 | #endif | ||
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_config_types.h b/lib/rbcodec/codecs/libspeex/speex/speex_config_types.h new file mode 100644 index 0000000000..ef328d48c1 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_config_types.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __SPEEX_TYPES_H__ | ||
2 | #define __SPEEX_TYPES_H__ | ||
3 | |||
4 | #include "inttypes.h" | ||
5 | #define spx_int16_t int16_t | ||
6 | #define spx_uint16_t uint16_t | ||
7 | #define spx_int32_t int32_t | ||
8 | #define spx_uint32_t uint32_t | ||
9 | #define spx_int64_t int64_t | ||
10 | #define spx_uint64_t uint64_t | ||
11 | |||
12 | #endif | ||
13 | |||
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_echo.h b/lib/rbcodec/codecs/libspeex/speex/speex_echo.h new file mode 100644 index 0000000000..6fcb0c00d7 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_echo.h | |||
@@ -0,0 +1,123 @@ | |||
1 | /* Copyright (C) Jean-Marc Valin */ | ||
2 | /** | ||
3 | @file speex_echo.h | ||
4 | @brief Echo cancellation | ||
5 | */ | ||
6 | /* | ||
7 | Redistribution and use in source and binary forms, with or without | ||
8 | modification, are permitted provided that the following conditions are | ||
9 | met: | ||
10 | |||
11 | 1. Redistributions of source code must retain the above copyright notice, | ||
12 | this list of conditions and the following disclaimer. | ||
13 | |||
14 | 2. Redistributions in binary form must reproduce the above copyright | ||
15 | notice, this list of conditions and the following disclaimer in the | ||
16 | documentation and/or other materials provided with the distribution. | ||
17 | |||
18 | 3. The name of the author may not be used to endorse or promote products | ||
19 | derived from this software without specific prior written permission. | ||
20 | |||
21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
30 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
31 | POSSIBILITY OF SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #ifndef SPEEX_ECHO_H | ||
35 | #define SPEEX_ECHO_H | ||
36 | /** @defgroup SpeexEchoState SpeexEchoState: Acoustic echo canceller | ||
37 | * This is the acoustic echo canceller module. | ||
38 | * @{ | ||
39 | */ | ||
40 | #include "speex_types.h" | ||
41 | |||
42 | #ifdef __cplusplus | ||
43 | extern "C" { | ||
44 | #endif | ||
45 | |||
46 | /** Obtain frame size used by the AEC */ | ||
47 | #define SPEEX_ECHO_GET_FRAME_SIZE 3 | ||
48 | |||
49 | /** Set sampling rate */ | ||
50 | #define SPEEX_ECHO_SET_SAMPLING_RATE 24 | ||
51 | /** Get sampling rate */ | ||
52 | #define SPEEX_ECHO_GET_SAMPLING_RATE 25 | ||
53 | |||
54 | /** Internal echo canceller state. Should never be accessed directly. */ | ||
55 | struct SpeexEchoState_; | ||
56 | |||
57 | /** @class SpeexEchoState | ||
58 | * This holds the state of the echo canceller. You need one per channel. | ||
59 | */ | ||
60 | |||
61 | /** Internal echo canceller state. Should never be accessed directly. */ | ||
62 | typedef struct SpeexEchoState_ SpeexEchoState; | ||
63 | |||
64 | /** Creates a new echo canceller state | ||
65 | * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms) | ||
66 | * @param filter_length Number of samples of echo to cancel (should generally correspond to 100-500 ms) | ||
67 | * @return Newly-created echo canceller state | ||
68 | */ | ||
69 | SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length); | ||
70 | |||
71 | /** Destroys an echo canceller state | ||
72 | * @param st Echo canceller state | ||
73 | */ | ||
74 | void speex_echo_state_destroy(SpeexEchoState *st); | ||
75 | |||
76 | /** Performs echo cancellation a frame, based on the audio sent to the speaker (no delay is added | ||
77 | * to playback in this form) | ||
78 | * | ||
79 | * @param st Echo canceller state | ||
80 | * @param rec Signal from the microphone (near end + far end echo) | ||
81 | * @param play Signal played to the speaker (received from far end) | ||
82 | * @param out Returns near-end signal with echo removed | ||
83 | */ | ||
84 | void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out); | ||
85 | |||
86 | /** Performs echo cancellation a frame (deprecated) */ | ||
87 | void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out, spx_int32_t *Yout); | ||
88 | |||
89 | /** Perform echo cancellation using internal playback buffer, which is delayed by two frames | ||
90 | * to account for the delay introduced by most soundcards (but it could be off!) | ||
91 | * @param st Echo canceller state | ||
92 | * @param rec Signal from the microphone (near end + far end echo) | ||
93 | * @param out Returns near-end signal with echo removed | ||
94 | */ | ||
95 | void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out); | ||
96 | |||
97 | /** Let the echo canceller know that a frame was just queued to the soundcard | ||
98 | * @param st Echo canceller state | ||
99 | * @param play Signal played to the speaker (received from far end) | ||
100 | */ | ||
101 | void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play); | ||
102 | |||
103 | /** Reset the echo canceller to its original state | ||
104 | * @param st Echo canceller state | ||
105 | */ | ||
106 | void speex_echo_state_reset(SpeexEchoState *st); | ||
107 | |||
108 | /** Used like the ioctl function to control the echo canceller parameters | ||
109 | * | ||
110 | * @param st Echo canceller state | ||
111 | * @param request ioctl-type request (one of the SPEEX_ECHO_* macros) | ||
112 | * @param ptr Data exchanged to-from function | ||
113 | * @return 0 if no error, -1 if request in unknown | ||
114 | */ | ||
115 | int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr); | ||
116 | |||
117 | #ifdef __cplusplus | ||
118 | } | ||
119 | #endif | ||
120 | |||
121 | |||
122 | /** @}*/ | ||
123 | #endif | ||
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_header.h b/lib/rbcodec/codecs/libspeex/speex/speex_header.h new file mode 100644 index 0000000000..2b60003fe9 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_header.h | |||
@@ -0,0 +1,91 @@ | |||
1 | /* Copyright (C) 2002 Jean-Marc Valin */ | ||
2 | /** | ||
3 | @file speex_header.h | ||
4 | @brief Describes the Speex header | ||
5 | */ | ||
6 | /* | ||
7 | Redistribution and use in source and binary forms, with or without | ||
8 | modification, are permitted provided that the following conditions | ||
9 | are met: | ||
10 | |||
11 | - Redistributions of source code must retain the above copyright | ||
12 | notice, this list of conditions and the following disclaimer. | ||
13 | |||
14 | - Redistributions in binary form must reproduce the above copyright | ||
15 | notice, this list of conditions and the following disclaimer in the | ||
16 | documentation and/or other materials provided with the distribution. | ||
17 | |||
18 | - Neither the name of the Xiph.org Foundation nor the names of its | ||
19 | contributors may be used to endorse or promote products derived from | ||
20 | this software without specific prior written permission. | ||
21 | |||
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | |||
34 | */ | ||
35 | |||
36 | |||
37 | #ifndef SPEEX_HEADER_H | ||
38 | #define SPEEX_HEADER_H | ||
39 | /** @defgroup SpeexHeader SpeexHeader: Makes it easy to write/parse an Ogg/Speex header | ||
40 | * This is the Speex header for the Ogg encapsulation. You don't need that if you just use RTP. | ||
41 | * @{ | ||
42 | */ | ||
43 | |||
44 | #include "speex_types.h" | ||
45 | |||
46 | #ifdef __cplusplus | ||
47 | extern "C" { | ||
48 | #endif | ||
49 | |||
50 | struct SpeexMode; | ||
51 | |||
52 | /** Length of the Speex header identifier */ | ||
53 | #define SPEEX_HEADER_STRING_LENGTH 8 | ||
54 | |||
55 | /** Maximum number of characters for encoding the Speex version number in the header */ | ||
56 | #define SPEEX_HEADER_VERSION_LENGTH 20 | ||
57 | |||
58 | /** Speex header info for file-based formats */ | ||
59 | typedef struct SpeexHeader { | ||
60 | char speex_string[SPEEX_HEADER_STRING_LENGTH]; /**< Identifies a Speex bit-stream, always set to "Speex " */ | ||
61 | char speex_version[SPEEX_HEADER_VERSION_LENGTH]; /**< Speex version */ | ||
62 | spx_int32_t speex_version_id; /**< Version for Speex (for checking compatibility) */ | ||
63 | spx_int32_t header_size; /**< Total size of the header ( sizeof(SpeexHeader) ) */ | ||
64 | spx_int32_t rate; /**< Sampling rate used */ | ||
65 | spx_int32_t mode; /**< Mode used (0 for narrowband, 1 for wideband) */ | ||
66 | spx_int32_t mode_bitstream_version; /**< Version ID of the bit-stream */ | ||
67 | spx_int32_t nb_channels; /**< Number of channels encoded */ | ||
68 | spx_int32_t bitrate; /**< Bit-rate used */ | ||
69 | spx_int32_t frame_size; /**< Size of frames */ | ||
70 | spx_int32_t vbr; /**< 1 for a VBR encoding, 0 otherwise */ | ||
71 | spx_int32_t frames_per_packet; /**< Number of frames stored per Ogg packet */ | ||
72 | spx_int32_t extra_headers; /**< Number of additional headers after the comments */ | ||
73 | spx_int32_t reserved1; /**< Reserved for future use, must be zero */ | ||
74 | spx_int32_t reserved2; /**< Reserved for future use, must be zero */ | ||
75 | } SpeexHeader; | ||
76 | |||
77 | /** Initializes a SpeexHeader using basic information */ | ||
78 | void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const struct SpeexMode *m); | ||
79 | |||
80 | /** Creates the header packet from the header itself (mostly involves endianness conversion) */ | ||
81 | char *speex_header_to_packet(SpeexHeader *header, int *size); | ||
82 | |||
83 | /** Creates a SpeexHeader from a packet */ | ||
84 | SpeexHeader *speex_packet_to_header(char *packet, int size); | ||
85 | |||
86 | #ifdef __cplusplus | ||
87 | } | ||
88 | #endif | ||
89 | |||
90 | /** @} */ | ||
91 | #endif | ||
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_jitter.h b/lib/rbcodec/codecs/libspeex/speex/speex_jitter.h new file mode 100644 index 0000000000..03bac15636 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_jitter.h | |||
@@ -0,0 +1,197 @@ | |||
1 | /* Copyright (C) 2002 Jean-Marc Valin */ | ||
2 | /** | ||
3 | @file speex_jitter.h | ||
4 | @brief Adaptive jitter buffer for Speex | ||
5 | */ | ||
6 | /* | ||
7 | Redistribution and use in source and binary forms, with or without | ||
8 | modification, are permitted provided that the following conditions | ||
9 | are met: | ||
10 | |||
11 | - Redistributions of source code must retain the above copyright | ||
12 | notice, this list of conditions and the following disclaimer. | ||
13 | |||
14 | - Redistributions in binary form must reproduce the above copyright | ||
15 | notice, this list of conditions and the following disclaimer in the | ||
16 | documentation and/or other materials provided with the distribution. | ||
17 | |||
18 | - Neither the name of the Xiph.org Foundation nor the names of its | ||
19 | contributors may be used to endorse or promote products derived from | ||
20 | this software without specific prior written permission. | ||
21 | |||
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | |||
34 | */ | ||
35 | |||
36 | #ifndef SPEEX_JITTER_H | ||
37 | #define SPEEX_JITTER_H | ||
38 | /** @defgroup JitterBuffer JitterBuffer: Adaptive jitter buffer | ||
39 | * This is the jitter buffer that reorders UDP/RTP packets and adjusts the buffer size | ||
40 | * to maintain good quality and low latency. | ||
41 | * @{ | ||
42 | */ | ||
43 | |||
44 | #include "speex_types.h" | ||
45 | |||
46 | #ifdef __cplusplus | ||
47 | extern "C" { | ||
48 | #endif | ||
49 | |||
50 | /** Generic adaptive jitter buffer state */ | ||
51 | struct JitterBuffer_; | ||
52 | |||
53 | /** Generic adaptive jitter buffer state */ | ||
54 | typedef struct JitterBuffer_ JitterBuffer; | ||
55 | |||
56 | /** Definition of an incoming packet */ | ||
57 | typedef struct _JitterBufferPacket JitterBufferPacket; | ||
58 | |||
59 | /** Definition of an incoming packet */ | ||
60 | struct _JitterBufferPacket { | ||
61 | char *data; /**< Data bytes contained in the packet */ | ||
62 | spx_uint32_t len; /**< Length of the packet in bytes */ | ||
63 | spx_uint32_t timestamp; /**< Timestamp for the packet */ | ||
64 | spx_uint32_t span; /**< Time covered by the packet (same units as timestamp) */ | ||
65 | spx_uint16_t sequence; /**< RTP Sequence number if available (0 otherwise) */ | ||
66 | spx_uint32_t user_data; /**< Put whatever data you like here (it's ignored by the jitter buffer) */ | ||
67 | }; | ||
68 | |||
69 | /** Packet has been retrieved */ | ||
70 | #define JITTER_BUFFER_OK 0 | ||
71 | /** Packet is lost or is late */ | ||
72 | #define JITTER_BUFFER_MISSING 1 | ||
73 | /** A "fake" packet is meant to be inserted here to increase buffering */ | ||
74 | #define JITTER_BUFFER_INSERTION 2 | ||
75 | /** There was an error in the jitter buffer */ | ||
76 | #define JITTER_BUFFER_INTERNAL_ERROR -1 | ||
77 | /** Invalid argument */ | ||
78 | #define JITTER_BUFFER_BAD_ARGUMENT -2 | ||
79 | |||
80 | |||
81 | /** Set minimum amount of extra buffering required (margin) */ | ||
82 | #define JITTER_BUFFER_SET_MARGIN 0 | ||
83 | /** Get minimum amount of extra buffering required (margin) */ | ||
84 | #define JITTER_BUFFER_GET_MARGIN 1 | ||
85 | /* JITTER_BUFFER_SET_AVAILABLE_COUNT wouldn't make sense */ | ||
86 | |||
87 | /** Get the amount of available packets currently buffered */ | ||
88 | #define JITTER_BUFFER_GET_AVAILABLE_COUNT 3 | ||
89 | /** Included because of an early misspelling (will remove in next release) */ | ||
90 | #define JITTER_BUFFER_GET_AVALIABLE_COUNT 3 | ||
91 | |||
92 | /** Assign a function to destroy unused packet. When setting that, the jitter | ||
93 | buffer no longer copies packet data. */ | ||
94 | #define JITTER_BUFFER_SET_DESTROY_CALLBACK 4 | ||
95 | /** */ | ||
96 | #define JITTER_BUFFER_GET_DESTROY_CALLBACK 5 | ||
97 | |||
98 | /** Tell the jitter buffer to only adjust the delay in multiples of the step parameter provided */ | ||
99 | #define JITTER_BUFFER_SET_DELAY_STEP 6 | ||
100 | /** */ | ||
101 | #define JITTER_BUFFER_GET_DELAY_STEP 7 | ||
102 | |||
103 | /** Tell the jitter buffer to only do concealment in multiples of the size parameter provided */ | ||
104 | #define JITTER_BUFFER_SET_CONCEALMENT_SIZE 8 | ||
105 | #define JITTER_BUFFER_GET_CONCEALMENT_SIZE 9 | ||
106 | |||
107 | /** Absolute max amount of loss that can be tolerated regardless of the delay. Typical loss | ||
108 | should be half of that or less. */ | ||
109 | #define JITTER_BUFFER_SET_MAX_LATE_RATE 10 | ||
110 | #define JITTER_BUFFER_GET_MAX_LATE_RATE 11 | ||
111 | |||
112 | /** Equivalent cost of one percent late packet in timestamp units */ | ||
113 | #define JITTER_BUFFER_SET_LATE_COST 12 | ||
114 | #define JITTER_BUFFER_GET_LATE_COST 13 | ||
115 | |||
116 | |||
117 | /** Initialises jitter buffer | ||
118 | * | ||
119 | * @param step_size Starting value for the size of concleanment packets and delay | ||
120 | adjustment steps. Can be changed at any time using JITTER_BUFFER_SET_DELAY_STEP | ||
121 | and JITTER_BUFFER_GET_CONCEALMENT_SIZE. | ||
122 | * @return Newly created jitter buffer state | ||
123 | */ | ||
124 | JitterBuffer *jitter_buffer_init(int step_size); | ||
125 | |||
126 | /** Restores jitter buffer to its original state | ||
127 | * | ||
128 | * @param jitter Jitter buffer state | ||
129 | */ | ||
130 | void jitter_buffer_reset(JitterBuffer *jitter); | ||
131 | |||
132 | /** Destroys jitter buffer | ||
133 | * | ||
134 | * @param jitter Jitter buffer state | ||
135 | */ | ||
136 | void jitter_buffer_destroy(JitterBuffer *jitter); | ||
137 | |||
138 | /** Put one packet into the jitter buffer | ||
139 | * | ||
140 | * @param jitter Jitter buffer state | ||
141 | * @param packet Incoming packet | ||
142 | */ | ||
143 | void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet); | ||
144 | |||
145 | /** Get one packet from the jitter buffer | ||
146 | * | ||
147 | * @param jitter Jitter buffer state | ||
148 | * @param packet Returned packet | ||
149 | * @param desired_span Number of samples (or units) we wish to get from the buffer (no guarantee) | ||
150 | * @param current_timestamp Timestamp for the returned packet | ||
151 | */ | ||
152 | int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t desired_span, spx_int32_t *start_offset); | ||
153 | |||
154 | /** Used right after jitter_buffer_get() to obtain another packet that would have the same timestamp. | ||
155 | * This is mainly useful for media where a single "frame" can be split into several packets. | ||
156 | * | ||
157 | * @param jitter Jitter buffer state | ||
158 | * @param packet Returned packet | ||
159 | */ | ||
160 | int jitter_buffer_get_another(JitterBuffer *jitter, JitterBufferPacket *packet); | ||
161 | |||
162 | /** Get pointer timestamp of jitter buffer | ||
163 | * | ||
164 | * @param jitter Jitter buffer state | ||
165 | */ | ||
166 | int jitter_buffer_get_pointer_timestamp(JitterBuffer *jitter); | ||
167 | |||
168 | /** Advance by one tick | ||
169 | * | ||
170 | * @param jitter Jitter buffer state | ||
171 | */ | ||
172 | void jitter_buffer_tick(JitterBuffer *jitter); | ||
173 | |||
174 | /** Telling the jitter buffer about the remaining data in the application buffer | ||
175 | * @param jitter Jitter buffer state | ||
176 | * @param rem Amount of data buffered by the application (timestamp units) | ||
177 | */ | ||
178 | void jitter_buffer_remaining_span(JitterBuffer *jitter, spx_uint32_t rem); | ||
179 | |||
180 | /** Used like the ioctl function to control the jitter buffer parameters | ||
181 | * | ||
182 | * @param jitter Jitter buffer state | ||
183 | * @param request ioctl-type request (one of the JITTER_BUFFER_* macros) | ||
184 | * @param ptr Data exchanged to-from function | ||
185 | * @return 0 if no error, -1 if request in unknown | ||
186 | */ | ||
187 | int jitter_buffer_ctl(JitterBuffer *jitter, int request, void *ptr); | ||
188 | |||
189 | int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset); | ||
190 | |||
191 | /* @} */ | ||
192 | |||
193 | #ifdef __cplusplus | ||
194 | } | ||
195 | #endif | ||
196 | |||
197 | #endif | ||
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_preprocess.h b/lib/rbcodec/codecs/libspeex/speex/speex_preprocess.h new file mode 100644 index 0000000000..273efaff79 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_preprocess.h | |||
@@ -0,0 +1,190 @@ | |||
1 | /* Copyright (C) 2003 Epic Games | ||
2 | Written by Jean-Marc Valin */ | ||
3 | /** | ||
4 | * @file speex_preprocess.h | ||
5 | * @brief Speex preprocessor. The preprocess can do noise suppression, | ||
6 | * residual echo suppression (after using the echo canceller), automatic | ||
7 | * gain control (AGC) and voice activity detection (VAD). | ||
8 | */ | ||
9 | /* | ||
10 | Redistribution and use in source and binary forms, with or without | ||
11 | modification, are permitted provided that the following conditions are | ||
12 | met: | ||
13 | |||
14 | 1. Redistributions of source code must retain the above copyright notice, | ||
15 | this list of conditions and the following disclaimer. | ||
16 | |||
17 | 2. Redistributions in binary form must reproduce the above copyright | ||
18 | notice, this list of conditions and the following disclaimer in the | ||
19 | documentation and/or other materials provided with the distribution. | ||
20 | |||
21 | 3. The name of the author may not be used to endorse or promote products | ||
22 | derived from this software without specific prior written permission. | ||
23 | |||
24 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
25 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
26 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
27 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
28 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
30 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
31 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
32 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
33 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
34 | POSSIBILITY OF SUCH DAMAGE. | ||
35 | */ | ||
36 | |||
37 | #ifndef SPEEX_PREPROCESS_H | ||
38 | #define SPEEX_PREPROCESS_H | ||
39 | /** @defgroup SpeexPreprocessState SpeexPreprocessState: The Speex preprocessor | ||
40 | * This is the Speex preprocessor. The preprocess can do noise suppression, | ||
41 | * residual echo suppression (after using the echo canceller), automatic | ||
42 | * gain control (AGC) and voice activity detection (VAD). | ||
43 | * @{ | ||
44 | */ | ||
45 | |||
46 | #include "speex_types.h" | ||
47 | |||
48 | #ifdef __cplusplus | ||
49 | extern "C" { | ||
50 | #endif | ||
51 | |||
52 | /** State of the preprocessor (one per channel). Should never be accessed directly. */ | ||
53 | struct SpeexPreprocessState_; | ||
54 | |||
55 | /** State of the preprocessor (one per channel). Should never be accessed directly. */ | ||
56 | typedef struct SpeexPreprocessState_ SpeexPreprocessState; | ||
57 | |||
58 | |||
59 | /** Creates a new preprocessing state. You MUST create one state per channel processed. | ||
60 | * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms). Must be | ||
61 | * the same value as that used for the echo canceller for residual echo cancellation to work. | ||
62 | * @param sampling_rate Sampling rate used for the input. | ||
63 | * @return Newly created preprocessor state | ||
64 | */ | ||
65 | SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate); | ||
66 | |||
67 | /** Destroys a preprocessor state | ||
68 | * @param st Preprocessor state to destroy | ||
69 | */ | ||
70 | void speex_preprocess_state_destroy(SpeexPreprocessState *st); | ||
71 | |||
72 | /** Preprocess a frame | ||
73 | * @param st Preprocessor state | ||
74 | * @param x Audio sample vector (in and out). Must be same size as specified in speex_preprocess_state_init(). | ||
75 | * @return Bool value for voice activity (1 for speech, 0 for noise/silence), ONLY if VAD turned on. | ||
76 | */ | ||
77 | int speex_preprocess_run(SpeexPreprocessState *st, spx_int16_t *x); | ||
78 | |||
79 | /** Preprocess a frame (deprecated, use speex_preprocess_run() instead)*/ | ||
80 | int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo); | ||
81 | |||
82 | /** Update preprocessor state, but do not compute the output | ||
83 | * @param st Preprocessor state | ||
84 | * @param x Audio sample vector (in only). Must be same size as specified in speex_preprocess_state_init(). | ||
85 | */ | ||
86 | void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x); | ||
87 | |||
88 | /** Used like the ioctl function to control the preprocessor parameters | ||
89 | * @param st Preprocessor state | ||
90 | * @param request ioctl-type request (one of the SPEEX_PREPROCESS_* macros) | ||
91 | * @param ptr Data exchanged to-from function | ||
92 | * @return 0 if no error, -1 if request in unknown | ||
93 | */ | ||
94 | int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr); | ||
95 | |||
96 | |||
97 | |||
98 | /** Set preprocessor denoiser state */ | ||
99 | #define SPEEX_PREPROCESS_SET_DENOISE 0 | ||
100 | /** Get preprocessor denoiser state */ | ||
101 | #define SPEEX_PREPROCESS_GET_DENOISE 1 | ||
102 | |||
103 | /** Set preprocessor Automatic Gain Control state */ | ||
104 | #define SPEEX_PREPROCESS_SET_AGC 2 | ||
105 | /** Get preprocessor Automatic Gain Control state */ | ||
106 | #define SPEEX_PREPROCESS_GET_AGC 3 | ||
107 | |||
108 | /** Set preprocessor Voice Activity Detection state */ | ||
109 | #define SPEEX_PREPROCESS_SET_VAD 4 | ||
110 | /** Get preprocessor Voice Activity Detection state */ | ||
111 | #define SPEEX_PREPROCESS_GET_VAD 5 | ||
112 | |||
113 | /** Set preprocessor Automatic Gain Control level */ | ||
114 | #define SPEEX_PREPROCESS_SET_AGC_LEVEL 6 | ||
115 | /** Get preprocessor Automatic Gain Control level */ | ||
116 | #define SPEEX_PREPROCESS_GET_AGC_LEVEL 7 | ||
117 | |||
118 | /** Set preprocessor dereverb state */ | ||
119 | #define SPEEX_PREPROCESS_SET_DEREVERB 8 | ||
120 | /** Get preprocessor dereverb state */ | ||
121 | #define SPEEX_PREPROCESS_GET_DEREVERB 9 | ||
122 | |||
123 | /** Set preprocessor dereverb level */ | ||
124 | #define SPEEX_PREPROCESS_SET_DEREVERB_LEVEL 10 | ||
125 | /** Get preprocessor dereverb level */ | ||
126 | #define SPEEX_PREPROCESS_GET_DEREVERB_LEVEL 11 | ||
127 | |||
128 | /** Set preprocessor dereverb decay */ | ||
129 | #define SPEEX_PREPROCESS_SET_DEREVERB_DECAY 12 | ||
130 | /** Get preprocessor dereverb decay */ | ||
131 | #define SPEEX_PREPROCESS_GET_DEREVERB_DECAY 13 | ||
132 | |||
133 | /** Set probability required for the VAD to go from silence to voice */ | ||
134 | #define SPEEX_PREPROCESS_SET_PROB_START 14 | ||
135 | /** Get probability required for the VAD to go from silence to voice */ | ||
136 | #define SPEEX_PREPROCESS_GET_PROB_START 15 | ||
137 | |||
138 | /** Set probability required for the VAD to stay in the voice state (integer percent) */ | ||
139 | #define SPEEX_PREPROCESS_SET_PROB_CONTINUE 16 | ||
140 | /** Get probability required for the VAD to stay in the voice state (integer percent) */ | ||
141 | #define SPEEX_PREPROCESS_GET_PROB_CONTINUE 17 | ||
142 | |||
143 | /** Set maximum attenuation of the noise in dB (negative number) */ | ||
144 | #define SPEEX_PREPROCESS_SET_NOISE_SUPPRESS 18 | ||
145 | /** Get maximum attenuation of the noise in dB (negative number) */ | ||
146 | #define SPEEX_PREPROCESS_GET_NOISE_SUPPRESS 19 | ||
147 | |||
148 | /** Set maximum attenuation of the residual echo in dB (negative number) */ | ||
149 | #define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS 20 | ||
150 | /** Get maximum attenuation of the residual echo in dB (negative number) */ | ||
151 | #define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS 21 | ||
152 | |||
153 | /** Set maximum attenuation of the residual echo in dB when near end is active (negative number) */ | ||
154 | #define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE 22 | ||
155 | /** Get maximum attenuation of the residual echo in dB when near end is active (negative number) */ | ||
156 | #define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE 23 | ||
157 | |||
158 | /** Set the corresponding echo canceller state so that residual echo suppression can be performed (NULL for no residual echo suppression) */ | ||
159 | #define SPEEX_PREPROCESS_SET_ECHO_STATE 24 | ||
160 | /** Get the corresponding echo canceller state */ | ||
161 | #define SPEEX_PREPROCESS_GET_ECHO_STATE 25 | ||
162 | |||
163 | /** Set maximal gain increase in dB/second (int32) */ | ||
164 | #define SPEEX_PREPROCESS_SET_AGC_INCREMENT 26 | ||
165 | |||
166 | /** Get maximal gain increase in dB/second (int32) */ | ||
167 | #define SPEEX_PREPROCESS_GET_AGC_INCREMENT 27 | ||
168 | |||
169 | /** Set maximal gain decrease in dB/second (int32) */ | ||
170 | #define SPEEX_PREPROCESS_SET_AGC_DECREMENT 28 | ||
171 | |||
172 | /** Get maximal gain decrease in dB/second (int32) */ | ||
173 | #define SPEEX_PREPROCESS_GET_AGC_DECREMENT 29 | ||
174 | |||
175 | /** Set maximal gain in dB (int32) */ | ||
176 | #define SPEEX_PREPROCESS_SET_AGC_MAX_GAIN 30 | ||
177 | |||
178 | /** Get maximal gain in dB (int32) */ | ||
179 | #define SPEEX_PREPROCESS_GET_AGC_MAX_GAIN 31 | ||
180 | |||
181 | /* Can't set loudness */ | ||
182 | /** Get loudness */ | ||
183 | #define SPEEX_PREPROCESS_GET_AGC_LOUDNESS 33 | ||
184 | |||
185 | #ifdef __cplusplus | ||
186 | } | ||
187 | #endif | ||
188 | |||
189 | /** @}*/ | ||
190 | #endif | ||
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_resampler.h b/lib/rbcodec/codecs/libspeex/speex/speex_resampler.h new file mode 100644 index 0000000000..c44fbcd0d1 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_resampler.h | |||
@@ -0,0 +1,328 @@ | |||
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 | |||
39 | #ifndef SPEEX_RESAMPLER_H | ||
40 | #define SPEEX_RESAMPLER_H | ||
41 | |||
42 | #ifdef OUTSIDE_SPEEX | ||
43 | |||
44 | /********* WARNING: MENTAL SANITY ENDS HERE *************/ | ||
45 | |||
46 | /* If the resampler is defined outside of Speex, we change the symbol names so that | ||
47 | there won't be any clash if linking with Speex later on. */ | ||
48 | |||
49 | /* #define RANDOM_PREFIX your software name here */ | ||
50 | #ifndef RANDOM_PREFIX | ||
51 | #error "Please define RANDOM_PREFIX (above) to something specific to your project to prevent symbol name clashes" | ||
52 | #endif | ||
53 | |||
54 | #define CAT_PREFIX2(a,b) a ## b | ||
55 | #define CAT_PREFIX(a,b) CAT_PREFIX2(a, b) | ||
56 | |||
57 | #define speex_resampler_init CAT_PREFIX(RANDOM_PREFIX,_resampler_init) | ||
58 | #define speex_resampler_init_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_init_frac) | ||
59 | #define speex_resampler_destroy CAT_PREFIX(RANDOM_PREFIX,_resampler_destroy) | ||
60 | #define speex_resampler_process_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_float) | ||
61 | #define speex_resampler_process_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_int) | ||
62 | #define speex_resampler_process_interleaved_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_float) | ||
63 | #define speex_resampler_process_interleaved_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_int) | ||
64 | #define speex_resampler_set_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate) | ||
65 | #define speex_resampler_get_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_get_rate) | ||
66 | #define speex_resampler_set_rate_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate_frac) | ||
67 | #define speex_resampler_get_ratio CAT_PREFIX(RANDOM_PREFIX,_resampler_get_ratio) | ||
68 | #define speex_resampler_set_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_set_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) | ||
71 | #define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride) | ||
72 | #define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_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) | ||
75 | #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem) | ||
76 | #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror) | ||
77 | |||
78 | #define spx_int16_t short | ||
79 | #define spx_int32_t int | ||
80 | #define spx_uint16_t unsigned short | ||
81 | #define spx_uint32_t unsigned int | ||
82 | |||
83 | #else /* OUTSIDE_SPEEX */ | ||
84 | |||
85 | #include "speex/speex_types.h" | ||
86 | |||
87 | #endif /* OUTSIDE_SPEEX */ | ||
88 | |||
89 | #ifdef __cplusplus | ||
90 | extern "C" { | ||
91 | #endif | ||
92 | |||
93 | #define SPEEX_RESAMPLER_QUALITY_MAX 10 | ||
94 | #define SPEEX_RESAMPLER_QUALITY_MIN 0 | ||
95 | #define SPEEX_RESAMPLER_QUALITY_DEFAULT 4 | ||
96 | #define SPEEX_RESAMPLER_QUALITY_VOIP 3 | ||
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, | ||
105 | |||
106 | RESAMPLER_ERR_MAX_ERROR | ||
107 | }; | ||
108 | |||
109 | struct SpeexResamplerState_; | ||
110 | typedef struct SpeexResamplerState_ SpeexResamplerState; | ||
111 | |||
112 | /** Create a new resampler with integer input and output rates. | ||
113 | * @param nb_channels Number of channels to be processed | ||
114 | * @param in_rate Input sampling rate (integer number of Hz). | ||
115 | * @param out_rate Output sampling rate (integer number of Hz). | ||
116 | * @param quality Resampling quality between 0 and 10, where 0 has poor quality | ||
117 | * and 10 has very high quality. | ||
118 | * @return Newly created resampler state | ||
119 | * @retval NULL Error: not enough memory | ||
120 | */ | ||
121 | SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels, | ||
122 | spx_uint32_t in_rate, | ||
123 | spx_uint32_t out_rate, | ||
124 | int quality, | ||
125 | int *err); | ||
126 | |||
127 | /** Create a new resampler with fractional input/output rates. The sampling | ||
128 | * rate ratio is an arbitrary rational number with both the numerator and | ||
129 | * denominator being 32-bit integers. | ||
130 | * @param nb_channels Number of channels to be processed | ||
131 | * @param ratio_num Numerator of the sampling rate ratio | ||
132 | * @param ratio_den Denominator of the sampling rate ratio | ||
133 | * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). | ||
134 | * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). | ||
135 | * @param quality Resampling quality between 0 and 10, where 0 has poor quality | ||
136 | * and 10 has very high quality. | ||
137 | * @return Newly created resampler state | ||
138 | * @retval NULL Error: not enough memory | ||
139 | */ | ||
140 | SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels, | ||
141 | spx_uint32_t ratio_num, | ||
142 | spx_uint32_t ratio_den, | ||
143 | spx_uint32_t in_rate, | ||
144 | spx_uint32_t out_rate, | ||
145 | int quality, | ||
146 | int *err); | ||
147 | |||
148 | /** Destroy a resampler state. | ||
149 | * @param st Resampler state | ||
150 | */ | ||
151 | void speex_resampler_destroy(SpeexResamplerState *st); | ||
152 | |||
153 | /** Resample a float array. The input and output buffers must *not* overlap. | ||
154 | * @param st Resampler state | ||
155 | * @param channel_index Index of the channel to process for the multi-channel | ||
156 | * base (0 otherwise) | ||
157 | * @param in Input buffer | ||
158 | * @param in_len Number of input samples in the input buffer. Returns the | ||
159 | * number of samples processed | ||
160 | * @param out Output buffer | ||
161 | * @param out_len Size of the output buffer. Returns the number of samples written | ||
162 | */ | ||
163 | int speex_resampler_process_float(SpeexResamplerState *st, | ||
164 | spx_uint32_t channel_index, | ||
165 | const float *in, | ||
166 | spx_uint32_t *in_len, | ||
167 | float *out, | ||
168 | spx_uint32_t *out_len); | ||
169 | |||
170 | /** Resample an int array. The input and output buffers must *not* overlap. | ||
171 | * @param st Resampler state | ||
172 | * @param channel_index Index of the channel to process for the multi-channel | ||
173 | * base (0 otherwise) | ||
174 | * @param in Input buffer | ||
175 | * @param in_len Number of input samples in the input buffer. Returns the number | ||
176 | * of samples processed | ||
177 | * @param out Output buffer | ||
178 | * @param out_len Size of the output buffer. Returns the number of samples written | ||
179 | */ | ||
180 | int speex_resampler_process_int(SpeexResamplerState *st, | ||
181 | spx_uint32_t channel_index, | ||
182 | const spx_int16_t *in, | ||
183 | spx_uint32_t *in_len, | ||
184 | spx_int16_t *out, | ||
185 | spx_uint32_t *out_len); | ||
186 | |||
187 | /** Resample an interleaved float array. The input and output buffers must *not* overlap. | ||
188 | * @param st Resampler state | ||
189 | * @param in Input buffer | ||
190 | * @param in_len Number of input samples in the input buffer. Returns the number | ||
191 | * of samples processed. This is all per-channel. | ||
192 | * @param out Output buffer | ||
193 | * @param out_len Size of the output buffer. Returns the number of samples written. | ||
194 | * This is all per-channel. | ||
195 | */ | ||
196 | int speex_resampler_process_interleaved_float(SpeexResamplerState *st, | ||
197 | const float *in, | ||
198 | spx_uint32_t *in_len, | ||
199 | float *out, | ||
200 | spx_uint32_t *out_len); | ||
201 | |||
202 | /** Resample an interleaved int array. The input and output buffers must *not* overlap. | ||
203 | * @param st Resampler state | ||
204 | * @param in Input buffer | ||
205 | * @param in_len Number of input samples in the input buffer. Returns the number | ||
206 | * of samples processed. This is all per-channel. | ||
207 | * @param out Output buffer | ||
208 | * @param out_len Size of the output buffer. Returns the number of samples written. | ||
209 | * This is all per-channel. | ||
210 | */ | ||
211 | int speex_resampler_process_interleaved_int(SpeexResamplerState *st, | ||
212 | const spx_int16_t *in, | ||
213 | spx_uint32_t *in_len, | ||
214 | spx_int16_t *out, | ||
215 | spx_uint32_t *out_len); | ||
216 | |||
217 | /** Set (change) the input/output sampling rates (integer value). | ||
218 | * @param st Resampler state | ||
219 | * @param in_rate Input sampling rate (integer number of Hz). | ||
220 | * @param out_rate Output sampling rate (integer number of Hz). | ||
221 | */ | ||
222 | int speex_resampler_set_rate(SpeexResamplerState *st, | ||
223 | spx_uint32_t in_rate, | ||
224 | spx_uint32_t out_rate); | ||
225 | |||
226 | /** Get the current input/output sampling rates (integer value). | ||
227 | * @param st Resampler state | ||
228 | * @param in_rate Input sampling rate (integer number of Hz) copied. | ||
229 | * @param out_rate Output sampling rate (integer number of Hz) copied. | ||
230 | */ | ||
231 | void speex_resampler_get_rate(SpeexResamplerState *st, | ||
232 | spx_uint32_t *in_rate, | ||
233 | spx_uint32_t *out_rate); | ||
234 | |||
235 | /** Set (change) the input/output sampling rates and resampling ratio | ||
236 | * (fractional values in Hz supported). | ||
237 | * @param st Resampler state | ||
238 | * @param ratio_num Numerator of the sampling rate ratio | ||
239 | * @param ratio_den Denominator of the sampling rate ratio | ||
240 | * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). | ||
241 | * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). | ||
242 | */ | ||
243 | int speex_resampler_set_rate_frac(SpeexResamplerState *st, | ||
244 | spx_uint32_t ratio_num, | ||
245 | spx_uint32_t ratio_den, | ||
246 | spx_uint32_t in_rate, | ||
247 | spx_uint32_t out_rate); | ||
248 | |||
249 | /** Get the current resampling ratio. This will be reduced to the least | ||
250 | * common denominator. | ||
251 | * @param st Resampler state | ||
252 | * @param ratio_num Numerator of the sampling rate ratio copied | ||
253 | * @param ratio_den Denominator of the sampling rate ratio copied | ||
254 | */ | ||
255 | void speex_resampler_get_ratio(SpeexResamplerState *st, | ||
256 | spx_uint32_t *ratio_num, | ||
257 | spx_uint32_t *ratio_den); | ||
258 | |||
259 | /** Set (change) the conversion quality. | ||
260 | * @param st Resampler state | ||
261 | * @param quality Resampling quality between 0 and 10, where 0 has poor | ||
262 | * quality and 10 has very high quality. | ||
263 | */ | ||
264 | int speex_resampler_set_quality(SpeexResamplerState *st, | ||
265 | int quality); | ||
266 | |||
267 | /** Get the conversion quality. | ||
268 | * @param st Resampler state | ||
269 | * @param quality Resampling quality between 0 and 10, where 0 has poor | ||
270 | * quality and 10 has very high quality. | ||
271 | */ | ||
272 | void speex_resampler_get_quality(SpeexResamplerState *st, | ||
273 | int *quality); | ||
274 | |||
275 | /** Set (change) the input stride. | ||
276 | * @param st Resampler state | ||
277 | * @param stride Input stride | ||
278 | */ | ||
279 | void speex_resampler_set_input_stride(SpeexResamplerState *st, | ||
280 | spx_uint32_t stride); | ||
281 | |||
282 | /** Get the input stride. | ||
283 | * @param st Resampler state | ||
284 | * @param stride Input stride copied | ||
285 | */ | ||
286 | void speex_resampler_get_input_stride(SpeexResamplerState *st, | ||
287 | spx_uint32_t *stride); | ||
288 | |||
289 | /** Set (change) the output stride. | ||
290 | * @param st Resampler state | ||
291 | * @param stride Output stride | ||
292 | */ | ||
293 | void speex_resampler_set_output_stride(SpeexResamplerState *st, | ||
294 | spx_uint32_t stride); | ||
295 | |||
296 | /** Get the output stride. | ||
297 | * @param st Resampler state copied | ||
298 | * @param stride Output stride | ||
299 | */ | ||
300 | void speex_resampler_get_output_stride(SpeexResamplerState *st, | ||
301 | spx_uint32_t *stride); | ||
302 | |||
303 | /** Make sure that the first samples to go out of the resamplers don't have | ||
304 | * leading zeros. This is only useful before starting to use a newly created | ||
305 | * resampler. It is recommended to use that when resampling an audio file, as | ||
306 | * it will generate a file with the same length. For real-time processing, | ||
307 | * it is probably easier not to use this call (so that the output duration | ||
308 | * is the same for the first frame). | ||
309 | * @param st Resampler state | ||
310 | */ | ||
311 | int speex_resampler_skip_zeros(SpeexResamplerState *st); | ||
312 | |||
313 | /** Reset a resampler so a new (unrelated) stream can be processed. | ||
314 | * @param st Resampler state | ||
315 | */ | ||
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); | ||
323 | |||
324 | #ifdef __cplusplus | ||
325 | } | ||
326 | #endif | ||
327 | |||
328 | #endif | ||
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_stereo.h b/lib/rbcodec/codecs/libspeex/speex/speex_stereo.h new file mode 100644 index 0000000000..67e2a8d4e0 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_stereo.h | |||
@@ -0,0 +1,91 @@ | |||
1 | /* Copyright (C) 2002 Jean-Marc Valin*/ | ||
2 | /** | ||
3 | @file speex_stereo.h | ||
4 | @brief Describes the handling for intensity stereo | ||
5 | */ | ||
6 | /* | ||
7 | Redistribution and use in source and binary forms, with or without | ||
8 | modification, are permitted provided that the following conditions | ||
9 | are met: | ||
10 | |||
11 | - Redistributions of source code must retain the above copyright | ||
12 | notice, this list of conditions and the following disclaimer. | ||
13 | |||
14 | - Redistributions in binary form must reproduce the above copyright | ||
15 | notice, this list of conditions and the following disclaimer in the | ||
16 | documentation and/or other materials provided with the distribution. | ||
17 | |||
18 | - Neither the name of the Xiph.org Foundation nor the names of its | ||
19 | contributors may be used to endorse or promote products derived from | ||
20 | this software without specific prior written permission. | ||
21 | |||
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | */ | ||
34 | |||
35 | #ifndef STEREO_H | ||
36 | #define STEREO_H | ||
37 | /** @defgroup SpeexStereoState SpeexStereoState: Handling Speex stereo files | ||
38 | * This describes the Speex intensity stereo encoding/decoding | ||
39 | * @{ | ||
40 | */ | ||
41 | |||
42 | #include "speex_types.h" | ||
43 | #include "speex_bits.h" | ||
44 | |||
45 | #ifdef __cplusplus | ||
46 | extern "C" { | ||
47 | #endif | ||
48 | |||
49 | /** If you access any of these fields directly, I'll personally come and bite you */ | ||
50 | typedef struct SpeexStereoState { | ||
51 | float balance; /**< Left/right balance info */ | ||
52 | float e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(right)] */ | ||
53 | float smooth_left; /**< Smoothed left channel gain */ | ||
54 | float smooth_right; /**< Smoothed right channel gain */ | ||
55 | float reserved1; /**< Reserved for future use */ | ||
56 | float reserved2; /**< Reserved for future use */ | ||
57 | } SpeexStereoState; | ||
58 | |||
59 | /** Deprecated. Use speex_stereo_state_init() instead. */ | ||
60 | #define SPEEX_STEREO_STATE_INIT {1,.5,1,1,0,0} | ||
61 | |||
62 | /** Initialise/create a stereo stereo state */ | ||
63 | SpeexStereoState *speex_stereo_state_init(void); | ||
64 | |||
65 | /** Reset/re-initialise an already allocated stereo state */ | ||
66 | void speex_stereo_state_reset(SpeexStereoState *stereo); | ||
67 | |||
68 | /** Destroy a stereo stereo state */ | ||
69 | void speex_stereo_state_destroy(SpeexStereoState *stereo); | ||
70 | |||
71 | /** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */ | ||
72 | void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits); | ||
73 | |||
74 | /** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */ | ||
75 | void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits); | ||
76 | |||
77 | /** Transforms a mono frame into a stereo frame using intensity stereo info */ | ||
78 | void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo); | ||
79 | |||
80 | /** Transforms a mono frame into a stereo frame using intensity stereo info */ | ||
81 | void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *stereo); | ||
82 | |||
83 | /** Callback handler for intensity stereo info */ | ||
84 | int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data); | ||
85 | |||
86 | #ifdef __cplusplus | ||
87 | } | ||
88 | #endif | ||
89 | |||
90 | /** @} */ | ||
91 | #endif | ||
diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_types.h b/lib/rbcodec/codecs/libspeex/speex/speex_types.h new file mode 100644 index 0000000000..a2ff1d6b53 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_types.h | |||
@@ -0,0 +1,126 @@ | |||
1 | /* speex_types.h taken from libogg */ | ||
2 | /******************************************************************** | ||
3 | * * | ||
4 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | ||
5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | ||
6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | ||
7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | ||
8 | * * | ||
9 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * | ||
10 | * by the Xiph.Org Foundation http://www.xiph.org/ * | ||
11 | * * | ||
12 | ******************************************************************** | ||
13 | |||
14 | function: #ifdef jail to whip a few platforms into the UNIX ideal. | ||
15 | last mod: $Id$ | ||
16 | |||
17 | ********************************************************************/ | ||
18 | /** | ||
19 | @file speex_types.h | ||
20 | @brief Speex types | ||
21 | */ | ||
22 | #ifndef _SPEEX_TYPES_H | ||
23 | #define _SPEEX_TYPES_H | ||
24 | |||
25 | #if defined(_WIN32) | ||
26 | |||
27 | # if defined(__CYGWIN__) | ||
28 | # include <_G_config.h> | ||
29 | typedef _G_int32_t spx_int32_t; | ||
30 | typedef _G_uint32_t spx_uint32_t; | ||
31 | typedef _G_int16_t spx_int16_t; | ||
32 | typedef _G_uint16_t spx_uint16_t; | ||
33 | # elif defined(__MINGW32__) | ||
34 | typedef short spx_int16_t; | ||
35 | typedef unsigned short spx_uint16_t; | ||
36 | typedef int spx_int32_t; | ||
37 | typedef unsigned int spx_uint32_t; | ||
38 | # elif defined(__MWERKS__) | ||
39 | typedef int spx_int32_t; | ||
40 | typedef unsigned int spx_uint32_t; | ||
41 | typedef short spx_int16_t; | ||
42 | typedef unsigned short spx_uint16_t; | ||
43 | # else | ||
44 | /* MSVC/Borland */ | ||
45 | typedef __int32 spx_int32_t; | ||
46 | typedef unsigned __int32 spx_uint32_t; | ||
47 | typedef __int16 spx_int16_t; | ||
48 | typedef unsigned __int16 spx_uint16_t; | ||
49 | # endif | ||
50 | |||
51 | #elif defined(__MACOS__) | ||
52 | |||
53 | # include <sys/types.h> | ||
54 | typedef SInt16 spx_int16_t; | ||
55 | typedef UInt16 spx_uint16_t; | ||
56 | typedef SInt32 spx_int32_t; | ||
57 | typedef UInt32 spx_uint32_t; | ||
58 | |||
59 | #elif defined(__MACOSX__) /* MacOS X Framework build */ | ||
60 | |||
61 | # include <sys/types.h> | ||
62 | typedef int16_t spx_int16_t; | ||
63 | typedef u_int16_t spx_uint16_t; | ||
64 | typedef int32_t spx_int32_t; | ||
65 | typedef u_int32_t spx_uint32_t; | ||
66 | |||
67 | #elif defined(__BEOS__) | ||
68 | |||
69 | /* Be */ | ||
70 | # include <inttypes.h> | ||
71 | typedef int16_t spx_int16_t; | ||
72 | typedef u_int16_t spx_uint16_t; | ||
73 | typedef int32_t spx_int32_t; | ||
74 | typedef u_int32_t spx_uint32_t; | ||
75 | |||
76 | #elif defined (__EMX__) | ||
77 | |||
78 | /* OS/2 GCC */ | ||
79 | typedef short spx_int16_t; | ||
80 | typedef unsigned short spx_uint16_t; | ||
81 | typedef int spx_int32_t; | ||
82 | typedef unsigned int spx_uint32_t; | ||
83 | |||
84 | #elif defined (DJGPP) | ||
85 | |||
86 | /* DJGPP */ | ||
87 | typedef short spx_int16_t; | ||
88 | typedef int spx_int32_t; | ||
89 | typedef unsigned int spx_uint32_t; | ||
90 | |||
91 | #elif defined(R5900) | ||
92 | |||
93 | /* PS2 EE */ | ||
94 | typedef int spx_int32_t; | ||
95 | typedef unsigned spx_uint32_t; | ||
96 | typedef short spx_int16_t; | ||
97 | |||
98 | #elif defined(__SYMBIAN32__) | ||
99 | |||
100 | /* Symbian GCC */ | ||
101 | typedef signed short spx_int16_t; | ||
102 | typedef unsigned short spx_uint16_t; | ||
103 | typedef signed int spx_int32_t; | ||
104 | typedef unsigned int spx_uint32_t; | ||
105 | |||
106 | #elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) | ||
107 | |||
108 | typedef short spx_int16_t; | ||
109 | typedef unsigned short spx_uint16_t; | ||
110 | typedef long spx_int32_t; | ||
111 | typedef unsigned long spx_uint32_t; | ||
112 | |||
113 | #elif defined(CONFIG_TI_C6X) | ||
114 | |||
115 | typedef short spx_int16_t; | ||
116 | typedef unsigned short spx_uint16_t; | ||
117 | typedef int spx_int32_t; | ||
118 | typedef unsigned int spx_uint32_t; | ||
119 | |||
120 | #else | ||
121 | |||
122 | # include "speex_config_types.h" | ||
123 | |||
124 | #endif | ||
125 | |||
126 | #endif /* _SPEEX_TYPES_H */ | ||