ex
Fork of mbed-os-example-mbed5-blinky by
DuerOS-Light-SDK-v1.1.0/duer-os-light/external/speex/include/speex/speex.h@47:9e361da97763, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:54:45 2017 +0800
- Revision:
- 47:9e361da97763
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 47:9e361da97763 | 1 | /* Copyright (C) 2002-2006 Jean-Marc Valin*/ |
| TMBOY | 47:9e361da97763 | 2 | /** |
| TMBOY | 47:9e361da97763 | 3 | @file speex.h |
| TMBOY | 47:9e361da97763 | 4 | @brief Describes the different modes of the codec |
| TMBOY | 47:9e361da97763 | 5 | */ |
| TMBOY | 47:9e361da97763 | 6 | /* |
| TMBOY | 47:9e361da97763 | 7 | Redistribution and use in source and binary forms, with or without |
| TMBOY | 47:9e361da97763 | 8 | modification, are permitted provided that the following conditions |
| TMBOY | 47:9e361da97763 | 9 | are met: |
| TMBOY | 47:9e361da97763 | 10 | |
| TMBOY | 47:9e361da97763 | 11 | - Redistributions of source code must retain the above copyright |
| TMBOY | 47:9e361da97763 | 12 | notice, this list of conditions and the following disclaimer. |
| TMBOY | 47:9e361da97763 | 13 | |
| TMBOY | 47:9e361da97763 | 14 | - Redistributions in binary form must reproduce the above copyright |
| TMBOY | 47:9e361da97763 | 15 | notice, this list of conditions and the following disclaimer in the |
| TMBOY | 47:9e361da97763 | 16 | documentation and/or other materials provided with the distribution. |
| TMBOY | 47:9e361da97763 | 17 | |
| TMBOY | 47:9e361da97763 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its |
| TMBOY | 47:9e361da97763 | 19 | contributors may be used to endorse or promote products derived from |
| TMBOY | 47:9e361da97763 | 20 | this software without specific prior written permission. |
| TMBOY | 47:9e361da97763 | 21 | |
| TMBOY | 47:9e361da97763 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| TMBOY | 47:9e361da97763 | 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| TMBOY | 47:9e361da97763 | 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| TMBOY | 47:9e361da97763 | 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
| TMBOY | 47:9e361da97763 | 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| TMBOY | 47:9e361da97763 | 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| TMBOY | 47:9e361da97763 | 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| TMBOY | 47:9e361da97763 | 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| TMBOY | 47:9e361da97763 | 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| TMBOY | 47:9e361da97763 | 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| TMBOY | 47:9e361da97763 | 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| TMBOY | 47:9e361da97763 | 33 | |
| TMBOY | 47:9e361da97763 | 34 | */ |
| TMBOY | 47:9e361da97763 | 35 | |
| TMBOY | 47:9e361da97763 | 36 | #ifndef SPEEX_H |
| TMBOY | 47:9e361da97763 | 37 | #define SPEEX_H |
| TMBOY | 47:9e361da97763 | 38 | /** @defgroup Codec Speex encoder and decoder |
| TMBOY | 47:9e361da97763 | 39 | * This is the Speex codec itself. |
| TMBOY | 47:9e361da97763 | 40 | * @{ |
| TMBOY | 47:9e361da97763 | 41 | */ |
| TMBOY | 47:9e361da97763 | 42 | |
| TMBOY | 47:9e361da97763 | 43 | #include "speex/speex_bits.h" |
| TMBOY | 47:9e361da97763 | 44 | #include "speex/speex_types.h" |
| TMBOY | 47:9e361da97763 | 45 | |
| TMBOY | 47:9e361da97763 | 46 | #ifdef __cplusplus |
| TMBOY | 47:9e361da97763 | 47 | extern "C" { |
| TMBOY | 47:9e361da97763 | 48 | #endif |
| TMBOY | 47:9e361da97763 | 49 | |
| TMBOY | 47:9e361da97763 | 50 | /* Values allowed for *ctl() requests */ |
| TMBOY | 47:9e361da97763 | 51 | |
| TMBOY | 47:9e361da97763 | 52 | /** Set enhancement on/off (decoder only) */ |
| TMBOY | 47:9e361da97763 | 53 | #define SPEEX_SET_ENH 0 |
| TMBOY | 47:9e361da97763 | 54 | /** Get enhancement state (decoder only) */ |
| TMBOY | 47:9e361da97763 | 55 | #define SPEEX_GET_ENH 1 |
| TMBOY | 47:9e361da97763 | 56 | |
| TMBOY | 47:9e361da97763 | 57 | /*Would be SPEEX_SET_FRAME_SIZE, but it's (currently) invalid*/ |
| TMBOY | 47:9e361da97763 | 58 | /** Obtain frame size used by encoder/decoder */ |
| TMBOY | 47:9e361da97763 | 59 | #define SPEEX_GET_FRAME_SIZE 3 |
| TMBOY | 47:9e361da97763 | 60 | |
| TMBOY | 47:9e361da97763 | 61 | /** Set quality value */ |
| TMBOY | 47:9e361da97763 | 62 | #define SPEEX_SET_QUALITY 4 |
| TMBOY | 47:9e361da97763 | 63 | /** Get current quality setting */ |
| TMBOY | 47:9e361da97763 | 64 | /* #define SPEEX_GET_QUALITY 5 -- Doesn't make much sense, does it? */ |
| TMBOY | 47:9e361da97763 | 65 | |
| TMBOY | 47:9e361da97763 | 66 | /** Set sub-mode to use */ |
| TMBOY | 47:9e361da97763 | 67 | #define SPEEX_SET_MODE 6 |
| TMBOY | 47:9e361da97763 | 68 | /** Get current sub-mode in use */ |
| TMBOY | 47:9e361da97763 | 69 | #define SPEEX_GET_MODE 7 |
| TMBOY | 47:9e361da97763 | 70 | |
| TMBOY | 47:9e361da97763 | 71 | /** Set low-band sub-mode to use (wideband only)*/ |
| TMBOY | 47:9e361da97763 | 72 | #define SPEEX_SET_LOW_MODE 8 |
| TMBOY | 47:9e361da97763 | 73 | /** Get current low-band mode in use (wideband only)*/ |
| TMBOY | 47:9e361da97763 | 74 | #define SPEEX_GET_LOW_MODE 9 |
| TMBOY | 47:9e361da97763 | 75 | |
| TMBOY | 47:9e361da97763 | 76 | /** Set high-band sub-mode to use (wideband only)*/ |
| TMBOY | 47:9e361da97763 | 77 | #define SPEEX_SET_HIGH_MODE 10 |
| TMBOY | 47:9e361da97763 | 78 | /** Get current high-band mode in use (wideband only)*/ |
| TMBOY | 47:9e361da97763 | 79 | #define SPEEX_GET_HIGH_MODE 11 |
| TMBOY | 47:9e361da97763 | 80 | |
| TMBOY | 47:9e361da97763 | 81 | /** Set VBR on (1) or off (0) */ |
| TMBOY | 47:9e361da97763 | 82 | #define SPEEX_SET_VBR 12 |
| TMBOY | 47:9e361da97763 | 83 | /** Get VBR status (1 for on, 0 for off) */ |
| TMBOY | 47:9e361da97763 | 84 | #define SPEEX_GET_VBR 13 |
| TMBOY | 47:9e361da97763 | 85 | |
| TMBOY | 47:9e361da97763 | 86 | /** Set quality value for VBR encoding (0-10) */ |
| TMBOY | 47:9e361da97763 | 87 | #define SPEEX_SET_VBR_QUALITY 14 |
| TMBOY | 47:9e361da97763 | 88 | /** Get current quality value for VBR encoding (0-10) */ |
| TMBOY | 47:9e361da97763 | 89 | #define SPEEX_GET_VBR_QUALITY 15 |
| TMBOY | 47:9e361da97763 | 90 | |
| TMBOY | 47:9e361da97763 | 91 | /** Set complexity of the encoder (0-10) */ |
| TMBOY | 47:9e361da97763 | 92 | #define SPEEX_SET_COMPLEXITY 16 |
| TMBOY | 47:9e361da97763 | 93 | /** Get current complexity of the encoder (0-10) */ |
| TMBOY | 47:9e361da97763 | 94 | #define SPEEX_GET_COMPLEXITY 17 |
| TMBOY | 47:9e361da97763 | 95 | |
| TMBOY | 47:9e361da97763 | 96 | /** Set bit-rate used by the encoder (or lower) */ |
| TMBOY | 47:9e361da97763 | 97 | #define SPEEX_SET_BITRATE 18 |
| TMBOY | 47:9e361da97763 | 98 | /** Get current bit-rate used by the encoder or decoder */ |
| TMBOY | 47:9e361da97763 | 99 | #define SPEEX_GET_BITRATE 19 |
| TMBOY | 47:9e361da97763 | 100 | |
| TMBOY | 47:9e361da97763 | 101 | /** Define a handler function for in-band Speex request*/ |
| TMBOY | 47:9e361da97763 | 102 | #define SPEEX_SET_HANDLER 20 |
| TMBOY | 47:9e361da97763 | 103 | |
| TMBOY | 47:9e361da97763 | 104 | /** Define a handler function for in-band user-defined request*/ |
| TMBOY | 47:9e361da97763 | 105 | #define SPEEX_SET_USER_HANDLER 22 |
| TMBOY | 47:9e361da97763 | 106 | |
| TMBOY | 47:9e361da97763 | 107 | /** Set sampling rate used in bit-rate computation */ |
| TMBOY | 47:9e361da97763 | 108 | #define SPEEX_SET_SAMPLING_RATE 24 |
| TMBOY | 47:9e361da97763 | 109 | /** Get sampling rate used in bit-rate computation */ |
| TMBOY | 47:9e361da97763 | 110 | #define SPEEX_GET_SAMPLING_RATE 25 |
| TMBOY | 47:9e361da97763 | 111 | |
| TMBOY | 47:9e361da97763 | 112 | /** Reset the encoder/decoder memories to zero*/ |
| TMBOY | 47:9e361da97763 | 113 | #define SPEEX_RESET_STATE 26 |
| TMBOY | 47:9e361da97763 | 114 | |
| TMBOY | 47:9e361da97763 | 115 | /** Get VBR info (mostly used internally) */ |
| TMBOY | 47:9e361da97763 | 116 | #define SPEEX_GET_RELATIVE_QUALITY 29 |
| TMBOY | 47:9e361da97763 | 117 | |
| TMBOY | 47:9e361da97763 | 118 | /** Set VAD status (1 for on, 0 for off) */ |
| TMBOY | 47:9e361da97763 | 119 | #define SPEEX_SET_VAD 30 |
| TMBOY | 47:9e361da97763 | 120 | |
| TMBOY | 47:9e361da97763 | 121 | /** Get VAD status (1 for on, 0 for off) */ |
| TMBOY | 47:9e361da97763 | 122 | #define SPEEX_GET_VAD 31 |
| TMBOY | 47:9e361da97763 | 123 | |
| TMBOY | 47:9e361da97763 | 124 | /** Set Average Bit-Rate (ABR) to n bits per seconds */ |
| TMBOY | 47:9e361da97763 | 125 | #define SPEEX_SET_ABR 32 |
| TMBOY | 47:9e361da97763 | 126 | /** Get Average Bit-Rate (ABR) setting (in bps) */ |
| TMBOY | 47:9e361da97763 | 127 | #define SPEEX_GET_ABR 33 |
| TMBOY | 47:9e361da97763 | 128 | |
| TMBOY | 47:9e361da97763 | 129 | /** Set DTX status (1 for on, 0 for off) */ |
| TMBOY | 47:9e361da97763 | 130 | #define SPEEX_SET_DTX 34 |
| TMBOY | 47:9e361da97763 | 131 | /** Get DTX status (1 for on, 0 for off) */ |
| TMBOY | 47:9e361da97763 | 132 | #define SPEEX_GET_DTX 35 |
| TMBOY | 47:9e361da97763 | 133 | |
| TMBOY | 47:9e361da97763 | 134 | /** Set submode encoding in each frame (1 for yes, 0 for no, setting to no breaks the standard) */ |
| TMBOY | 47:9e361da97763 | 135 | #define SPEEX_SET_SUBMODE_ENCODING 36 |
| TMBOY | 47:9e361da97763 | 136 | /** Get submode encoding in each frame */ |
| TMBOY | 47:9e361da97763 | 137 | #define SPEEX_GET_SUBMODE_ENCODING 37 |
| TMBOY | 47:9e361da97763 | 138 | |
| TMBOY | 47:9e361da97763 | 139 | /*#define SPEEX_SET_LOOKAHEAD 38*/ |
| TMBOY | 47:9e361da97763 | 140 | /** Returns the lookahead used by Speex */ |
| TMBOY | 47:9e361da97763 | 141 | #define SPEEX_GET_LOOKAHEAD 39 |
| TMBOY | 47:9e361da97763 | 142 | |
| TMBOY | 47:9e361da97763 | 143 | /** Sets tuning for packet-loss concealment (expected loss rate) */ |
| TMBOY | 47:9e361da97763 | 144 | #define SPEEX_SET_PLC_TUNING 40 |
| TMBOY | 47:9e361da97763 | 145 | /** Gets tuning for PLC */ |
| TMBOY | 47:9e361da97763 | 146 | #define SPEEX_GET_PLC_TUNING 41 |
| TMBOY | 47:9e361da97763 | 147 | |
| TMBOY | 47:9e361da97763 | 148 | /** Sets the max bit-rate allowed in VBR mode */ |
| TMBOY | 47:9e361da97763 | 149 | #define SPEEX_SET_VBR_MAX_BITRATE 42 |
| TMBOY | 47:9e361da97763 | 150 | /** Gets the max bit-rate allowed in VBR mode */ |
| TMBOY | 47:9e361da97763 | 151 | #define SPEEX_GET_VBR_MAX_BITRATE 43 |
| TMBOY | 47:9e361da97763 | 152 | |
| TMBOY | 47:9e361da97763 | 153 | /** Turn on/off input/output high-pass filtering */ |
| TMBOY | 47:9e361da97763 | 154 | #define SPEEX_SET_HIGHPASS 44 |
| TMBOY | 47:9e361da97763 | 155 | /** Get status of input/output high-pass filtering */ |
| TMBOY | 47:9e361da97763 | 156 | #define SPEEX_GET_HIGHPASS 45 |
| TMBOY | 47:9e361da97763 | 157 | |
| TMBOY | 47:9e361da97763 | 158 | /** Get "activity level" of the last decoded frame, i.e. |
| TMBOY | 47:9e361da97763 | 159 | now much damage we cause if we remove the frame */ |
| TMBOY | 47:9e361da97763 | 160 | #define SPEEX_GET_ACTIVITY 47 |
| TMBOY | 47:9e361da97763 | 161 | |
| TMBOY | 47:9e361da97763 | 162 | |
| TMBOY | 47:9e361da97763 | 163 | /* Preserving compatibility:*/ |
| TMBOY | 47:9e361da97763 | 164 | /** Equivalent to SPEEX_SET_ENH */ |
| TMBOY | 47:9e361da97763 | 165 | #define SPEEX_SET_PF 0 |
| TMBOY | 47:9e361da97763 | 166 | /** Equivalent to SPEEX_GET_ENH */ |
| TMBOY | 47:9e361da97763 | 167 | #define SPEEX_GET_PF 1 |
| TMBOY | 47:9e361da97763 | 168 | |
| TMBOY | 47:9e361da97763 | 169 | |
| TMBOY | 47:9e361da97763 | 170 | |
| TMBOY | 47:9e361da97763 | 171 | |
| TMBOY | 47:9e361da97763 | 172 | /* Values allowed for mode queries */ |
| TMBOY | 47:9e361da97763 | 173 | /** Query the frame size of a mode */ |
| TMBOY | 47:9e361da97763 | 174 | #define SPEEX_MODE_FRAME_SIZE 0 |
| TMBOY | 47:9e361da97763 | 175 | |
| TMBOY | 47:9e361da97763 | 176 | /** Query the size of an encoded frame for a particular sub-mode */ |
| TMBOY | 47:9e361da97763 | 177 | #define SPEEX_SUBMODE_BITS_PER_FRAME 1 |
| TMBOY | 47:9e361da97763 | 178 | |
| TMBOY | 47:9e361da97763 | 179 | |
| TMBOY | 47:9e361da97763 | 180 | |
| TMBOY | 47:9e361da97763 | 181 | /** Get major Speex version */ |
| TMBOY | 47:9e361da97763 | 182 | #define SPEEX_LIB_GET_MAJOR_VERSION 1 |
| TMBOY | 47:9e361da97763 | 183 | /** Get minor Speex version */ |
| TMBOY | 47:9e361da97763 | 184 | #define SPEEX_LIB_GET_MINOR_VERSION 3 |
| TMBOY | 47:9e361da97763 | 185 | /** Get micro Speex version */ |
| TMBOY | 47:9e361da97763 | 186 | #define SPEEX_LIB_GET_MICRO_VERSION 5 |
| TMBOY | 47:9e361da97763 | 187 | /** Get extra Speex version */ |
| TMBOY | 47:9e361da97763 | 188 | #define SPEEX_LIB_GET_EXTRA_VERSION 7 |
| TMBOY | 47:9e361da97763 | 189 | /** Get Speex version string */ |
| TMBOY | 47:9e361da97763 | 190 | #define SPEEX_LIB_GET_VERSION_STRING 9 |
| TMBOY | 47:9e361da97763 | 191 | |
| TMBOY | 47:9e361da97763 | 192 | /*#define SPEEX_LIB_SET_ALLOC_FUNC 10 |
| TMBOY | 47:9e361da97763 | 193 | #define SPEEX_LIB_GET_ALLOC_FUNC 11 |
| TMBOY | 47:9e361da97763 | 194 | #define SPEEX_LIB_SET_FREE_FUNC 12 |
| TMBOY | 47:9e361da97763 | 195 | #define SPEEX_LIB_GET_FREE_FUNC 13 |
| TMBOY | 47:9e361da97763 | 196 | |
| TMBOY | 47:9e361da97763 | 197 | #define SPEEX_LIB_SET_WARNING_FUNC 14 |
| TMBOY | 47:9e361da97763 | 198 | #define SPEEX_LIB_GET_WARNING_FUNC 15 |
| TMBOY | 47:9e361da97763 | 199 | #define SPEEX_LIB_SET_ERROR_FUNC 16 |
| TMBOY | 47:9e361da97763 | 200 | #define SPEEX_LIB_GET_ERROR_FUNC 17 |
| TMBOY | 47:9e361da97763 | 201 | */ |
| TMBOY | 47:9e361da97763 | 202 | |
| TMBOY | 47:9e361da97763 | 203 | /** Number of defined modes in Speex */ |
| TMBOY | 47:9e361da97763 | 204 | #define SPEEX_NB_MODES 3 |
| TMBOY | 47:9e361da97763 | 205 | |
| TMBOY | 47:9e361da97763 | 206 | /** modeID for the defined narrowband mode */ |
| TMBOY | 47:9e361da97763 | 207 | #define SPEEX_MODEID_NB 0 |
| TMBOY | 47:9e361da97763 | 208 | |
| TMBOY | 47:9e361da97763 | 209 | /** modeID for the defined wideband mode */ |
| TMBOY | 47:9e361da97763 | 210 | #define SPEEX_MODEID_WB 1 |
| TMBOY | 47:9e361da97763 | 211 | |
| TMBOY | 47:9e361da97763 | 212 | /** modeID for the defined ultra-wideband mode */ |
| TMBOY | 47:9e361da97763 | 213 | #define SPEEX_MODEID_UWB 2 |
| TMBOY | 47:9e361da97763 | 214 | |
| TMBOY | 47:9e361da97763 | 215 | #ifdef EPIC_48K |
| TMBOY | 47:9e361da97763 | 216 | /** modeID for the Epic 48K mode */ |
| TMBOY | 47:9e361da97763 | 217 | #define SPEEX_MODEID_NB_48K 1000 |
| TMBOY | 47:9e361da97763 | 218 | #endif |
| TMBOY | 47:9e361da97763 | 219 | |
| TMBOY | 47:9e361da97763 | 220 | struct SpeexMode; |
| TMBOY | 47:9e361da97763 | 221 | |
| TMBOY | 47:9e361da97763 | 222 | |
| TMBOY | 47:9e361da97763 | 223 | /* Prototypes for mode function pointers */ |
| TMBOY | 47:9e361da97763 | 224 | |
| TMBOY | 47:9e361da97763 | 225 | /** Encoder state initialization function */ |
| TMBOY | 47:9e361da97763 | 226 | typedef void *(*encoder_init_func)(const struct SpeexMode *mode); |
| TMBOY | 47:9e361da97763 | 227 | |
| TMBOY | 47:9e361da97763 | 228 | /** Encoder state destruction function */ |
| TMBOY | 47:9e361da97763 | 229 | typedef void (*encoder_destroy_func)(void *st); |
| TMBOY | 47:9e361da97763 | 230 | |
| TMBOY | 47:9e361da97763 | 231 | /** Main encoding function */ |
| TMBOY | 47:9e361da97763 | 232 | typedef int (*encode_func)(void *state, void *in, SpeexBits *bits); |
| TMBOY | 47:9e361da97763 | 233 | |
| TMBOY | 47:9e361da97763 | 234 | /** Function for controlling the encoder options */ |
| TMBOY | 47:9e361da97763 | 235 | typedef int (*encoder_ctl_func)(void *state, int request, void *ptr); |
| TMBOY | 47:9e361da97763 | 236 | |
| TMBOY | 47:9e361da97763 | 237 | /** Decoder state initialization function */ |
| TMBOY | 47:9e361da97763 | 238 | typedef void *(*decoder_init_func)(const struct SpeexMode *mode); |
| TMBOY | 47:9e361da97763 | 239 | |
| TMBOY | 47:9e361da97763 | 240 | /** Decoder state destruction function */ |
| TMBOY | 47:9e361da97763 | 241 | typedef void (*decoder_destroy_func)(void *st); |
| TMBOY | 47:9e361da97763 | 242 | |
| TMBOY | 47:9e361da97763 | 243 | /** Main decoding function */ |
| TMBOY | 47:9e361da97763 | 244 | typedef int (*decode_func)(void *state, SpeexBits *bits, void *out); |
| TMBOY | 47:9e361da97763 | 245 | |
| TMBOY | 47:9e361da97763 | 246 | /** Function for controlling the decoder options */ |
| TMBOY | 47:9e361da97763 | 247 | typedef int (*decoder_ctl_func)(void *state, int request, void *ptr); |
| TMBOY | 47:9e361da97763 | 248 | |
| TMBOY | 47:9e361da97763 | 249 | |
| TMBOY | 47:9e361da97763 | 250 | /** Query function for a mode */ |
| TMBOY | 47:9e361da97763 | 251 | typedef int (*mode_query_func)(const void *mode, int request, void *ptr); |
| TMBOY | 47:9e361da97763 | 252 | |
| TMBOY | 47:9e361da97763 | 253 | /** Struct defining a Speex mode */ |
| TMBOY | 47:9e361da97763 | 254 | typedef struct SpeexMode { |
| TMBOY | 47:9e361da97763 | 255 | /** Pointer to the low-level mode data */ |
| TMBOY | 47:9e361da97763 | 256 | const void *mode; |
| TMBOY | 47:9e361da97763 | 257 | |
| TMBOY | 47:9e361da97763 | 258 | /** Pointer to the mode query function */ |
| TMBOY | 47:9e361da97763 | 259 | mode_query_func query; |
| TMBOY | 47:9e361da97763 | 260 | |
| TMBOY | 47:9e361da97763 | 261 | /** The name of the mode (you should not rely on this to identify the mode)*/ |
| TMBOY | 47:9e361da97763 | 262 | const char *modeName; |
| TMBOY | 47:9e361da97763 | 263 | |
| TMBOY | 47:9e361da97763 | 264 | /**ID of the mode*/ |
| TMBOY | 47:9e361da97763 | 265 | int modeID; |
| TMBOY | 47:9e361da97763 | 266 | |
| TMBOY | 47:9e361da97763 | 267 | /**Version number of the bitstream (incremented every time we break |
| TMBOY | 47:9e361da97763 | 268 | bitstream compatibility*/ |
| TMBOY | 47:9e361da97763 | 269 | int bitstream_version; |
| TMBOY | 47:9e361da97763 | 270 | |
| TMBOY | 47:9e361da97763 | 271 | /** Pointer to encoder initialization function */ |
| TMBOY | 47:9e361da97763 | 272 | encoder_init_func enc_init; |
| TMBOY | 47:9e361da97763 | 273 | |
| TMBOY | 47:9e361da97763 | 274 | /** Pointer to encoder destruction function */ |
| TMBOY | 47:9e361da97763 | 275 | encoder_destroy_func enc_destroy; |
| TMBOY | 47:9e361da97763 | 276 | |
| TMBOY | 47:9e361da97763 | 277 | /** Pointer to frame encoding function */ |
| TMBOY | 47:9e361da97763 | 278 | encode_func enc; |
| TMBOY | 47:9e361da97763 | 279 | |
| TMBOY | 47:9e361da97763 | 280 | /** Pointer to decoder initialization function */ |
| TMBOY | 47:9e361da97763 | 281 | decoder_init_func dec_init; |
| TMBOY | 47:9e361da97763 | 282 | |
| TMBOY | 47:9e361da97763 | 283 | /** Pointer to decoder destruction function */ |
| TMBOY | 47:9e361da97763 | 284 | decoder_destroy_func dec_destroy; |
| TMBOY | 47:9e361da97763 | 285 | |
| TMBOY | 47:9e361da97763 | 286 | /** Pointer to frame decoding function */ |
| TMBOY | 47:9e361da97763 | 287 | decode_func dec; |
| TMBOY | 47:9e361da97763 | 288 | |
| TMBOY | 47:9e361da97763 | 289 | /** ioctl-like requests for encoder */ |
| TMBOY | 47:9e361da97763 | 290 | encoder_ctl_func enc_ctl; |
| TMBOY | 47:9e361da97763 | 291 | |
| TMBOY | 47:9e361da97763 | 292 | /** ioctl-like requests for decoder */ |
| TMBOY | 47:9e361da97763 | 293 | decoder_ctl_func dec_ctl; |
| TMBOY | 47:9e361da97763 | 294 | |
| TMBOY | 47:9e361da97763 | 295 | } SpeexMode; |
| TMBOY | 47:9e361da97763 | 296 | |
| TMBOY | 47:9e361da97763 | 297 | /** |
| TMBOY | 47:9e361da97763 | 298 | * Returns a handle to a newly created Speex encoder state structure. For now, |
| TMBOY | 47:9e361da97763 | 299 | * the "mode" argument can be &nb_mode or &wb_mode . In the future, more modes |
| TMBOY | 47:9e361da97763 | 300 | * may be added. Note that for now if you have more than one channels to |
| TMBOY | 47:9e361da97763 | 301 | * encode, you need one state per channel. |
| TMBOY | 47:9e361da97763 | 302 | * |
| TMBOY | 47:9e361da97763 | 303 | * @param mode The mode to use (either speex_nb_mode or speex_wb.mode) |
| TMBOY | 47:9e361da97763 | 304 | * @return A newly created encoder state or NULL if state allocation fails |
| TMBOY | 47:9e361da97763 | 305 | */ |
| TMBOY | 47:9e361da97763 | 306 | void *speex_encoder_init(const SpeexMode *mode); |
| TMBOY | 47:9e361da97763 | 307 | |
| TMBOY | 47:9e361da97763 | 308 | /** Frees all resources associated to an existing Speex encoder state. |
| TMBOY | 47:9e361da97763 | 309 | * @param state Encoder state to be destroyed */ |
| TMBOY | 47:9e361da97763 | 310 | void speex_encoder_destroy(void *state); |
| TMBOY | 47:9e361da97763 | 311 | |
| TMBOY | 47:9e361da97763 | 312 | /** Uses an existing encoder state to encode one frame of speech pointed to by |
| TMBOY | 47:9e361da97763 | 313 | "in". The encoded bit-stream is saved in "bits". |
| TMBOY | 47:9e361da97763 | 314 | @param state Encoder state |
| TMBOY | 47:9e361da97763 | 315 | @param in Frame that will be encoded with a +-2^15 range. This data MAY be |
| TMBOY | 47:9e361da97763 | 316 | overwritten by the encoder and should be considered uninitialised |
| TMBOY | 47:9e361da97763 | 317 | after the call. |
| TMBOY | 47:9e361da97763 | 318 | @param bits Bit-stream where the data will be written |
| TMBOY | 47:9e361da97763 | 319 | @return 0 if frame needs not be transmitted (DTX only), 1 otherwise |
| TMBOY | 47:9e361da97763 | 320 | */ |
| TMBOY | 47:9e361da97763 | 321 | int speex_encode(void *state, float *in, SpeexBits *bits); |
| TMBOY | 47:9e361da97763 | 322 | |
| TMBOY | 47:9e361da97763 | 323 | /** Uses an existing encoder state to encode one frame of speech pointed to by |
| TMBOY | 47:9e361da97763 | 324 | "in". The encoded bit-stream is saved in "bits". |
| TMBOY | 47:9e361da97763 | 325 | @param state Encoder state |
| TMBOY | 47:9e361da97763 | 326 | @param in Frame that will be encoded with a +-2^15 range |
| TMBOY | 47:9e361da97763 | 327 | @param bits Bit-stream where the data will be written |
| TMBOY | 47:9e361da97763 | 328 | @return 0 if frame needs not be transmitted (DTX only), 1 otherwise |
| TMBOY | 47:9e361da97763 | 329 | */ |
| TMBOY | 47:9e361da97763 | 330 | int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits); |
| TMBOY | 47:9e361da97763 | 331 | |
| TMBOY | 47:9e361da97763 | 332 | /** Used like the ioctl function to control the encoder parameters |
| TMBOY | 47:9e361da97763 | 333 | * |
| TMBOY | 47:9e361da97763 | 334 | * @param state Encoder state |
| TMBOY | 47:9e361da97763 | 335 | * @param request ioctl-type request (one of the SPEEX_* macros) |
| TMBOY | 47:9e361da97763 | 336 | * @param ptr Data exchanged to-from function |
| TMBOY | 47:9e361da97763 | 337 | * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter |
| TMBOY | 47:9e361da97763 | 338 | */ |
| TMBOY | 47:9e361da97763 | 339 | int speex_encoder_ctl(void *state, int request, void *ptr); |
| TMBOY | 47:9e361da97763 | 340 | |
| TMBOY | 47:9e361da97763 | 341 | |
| TMBOY | 47:9e361da97763 | 342 | /** Returns a handle to a newly created decoder state structure. For now, |
| TMBOY | 47:9e361da97763 | 343 | * the mode argument can be &nb_mode or &wb_mode . In the future, more modes |
| TMBOY | 47:9e361da97763 | 344 | * may be added. Note that for now if you have more than one channels to |
| TMBOY | 47:9e361da97763 | 345 | * decode, you need one state per channel. |
| TMBOY | 47:9e361da97763 | 346 | * |
| TMBOY | 47:9e361da97763 | 347 | * @param mode Speex mode (one of speex_nb_mode or speex_wb_mode) |
| TMBOY | 47:9e361da97763 | 348 | * @return A newly created decoder state or NULL if state allocation fails |
| TMBOY | 47:9e361da97763 | 349 | */ |
| TMBOY | 47:9e361da97763 | 350 | void *speex_decoder_init(const SpeexMode *mode); |
| TMBOY | 47:9e361da97763 | 351 | |
| TMBOY | 47:9e361da97763 | 352 | /** Frees all resources associated to an existing decoder state. |
| TMBOY | 47:9e361da97763 | 353 | * |
| TMBOY | 47:9e361da97763 | 354 | * @param state State to be destroyed |
| TMBOY | 47:9e361da97763 | 355 | */ |
| TMBOY | 47:9e361da97763 | 356 | void speex_decoder_destroy(void *state); |
| TMBOY | 47:9e361da97763 | 357 | |
| TMBOY | 47:9e361da97763 | 358 | /** Uses an existing decoder state to decode one frame of speech from |
| TMBOY | 47:9e361da97763 | 359 | * bit-stream bits. The output speech is saved written to out. |
| TMBOY | 47:9e361da97763 | 360 | * |
| TMBOY | 47:9e361da97763 | 361 | * @param state Decoder state |
| TMBOY | 47:9e361da97763 | 362 | * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost) |
| TMBOY | 47:9e361da97763 | 363 | * @param out Where to write the decoded frame |
| TMBOY | 47:9e361da97763 | 364 | * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream) |
| TMBOY | 47:9e361da97763 | 365 | */ |
| TMBOY | 47:9e361da97763 | 366 | int speex_decode(void *state, SpeexBits *bits, float *out); |
| TMBOY | 47:9e361da97763 | 367 | |
| TMBOY | 47:9e361da97763 | 368 | /** Uses an existing decoder state to decode one frame of speech from |
| TMBOY | 47:9e361da97763 | 369 | * bit-stream bits. The output speech is saved written to out. |
| TMBOY | 47:9e361da97763 | 370 | * |
| TMBOY | 47:9e361da97763 | 371 | * @param state Decoder state |
| TMBOY | 47:9e361da97763 | 372 | * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost) |
| TMBOY | 47:9e361da97763 | 373 | * @param out Where to write the decoded frame |
| TMBOY | 47:9e361da97763 | 374 | * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream) |
| TMBOY | 47:9e361da97763 | 375 | */ |
| TMBOY | 47:9e361da97763 | 376 | int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out); |
| TMBOY | 47:9e361da97763 | 377 | |
| TMBOY | 47:9e361da97763 | 378 | /** Used like the ioctl function to control the encoder parameters |
| TMBOY | 47:9e361da97763 | 379 | * |
| TMBOY | 47:9e361da97763 | 380 | * @param state Decoder state |
| TMBOY | 47:9e361da97763 | 381 | * @param request ioctl-type request (one of the SPEEX_* macros) |
| TMBOY | 47:9e361da97763 | 382 | * @param ptr Data exchanged to-from function |
| TMBOY | 47:9e361da97763 | 383 | * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter |
| TMBOY | 47:9e361da97763 | 384 | */ |
| TMBOY | 47:9e361da97763 | 385 | int speex_decoder_ctl(void *state, int request, void *ptr); |
| TMBOY | 47:9e361da97763 | 386 | |
| TMBOY | 47:9e361da97763 | 387 | |
| TMBOY | 47:9e361da97763 | 388 | /** Query function for mode information |
| TMBOY | 47:9e361da97763 | 389 | * |
| TMBOY | 47:9e361da97763 | 390 | * @param mode Speex mode |
| TMBOY | 47:9e361da97763 | 391 | * @param request ioctl-type request (one of the SPEEX_* macros) |
| TMBOY | 47:9e361da97763 | 392 | * @param ptr Data exchanged to-from function |
| TMBOY | 47:9e361da97763 | 393 | * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter |
| TMBOY | 47:9e361da97763 | 394 | */ |
| TMBOY | 47:9e361da97763 | 395 | int speex_mode_query(const SpeexMode *mode, int request, void *ptr); |
| TMBOY | 47:9e361da97763 | 396 | |
| TMBOY | 47:9e361da97763 | 397 | /** Functions for controlling the behavior of libspeex |
| TMBOY | 47:9e361da97763 | 398 | * @param request ioctl-type request (one of the SPEEX_LIB_* macros) |
| TMBOY | 47:9e361da97763 | 399 | * @param ptr Data exchanged to-from function |
| TMBOY | 47:9e361da97763 | 400 | * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter |
| TMBOY | 47:9e361da97763 | 401 | */ |
| TMBOY | 47:9e361da97763 | 402 | int speex_lib_ctl(int request, void *ptr); |
| TMBOY | 47:9e361da97763 | 403 | |
| TMBOY | 47:9e361da97763 | 404 | /** Default narrowband mode */ |
| TMBOY | 47:9e361da97763 | 405 | extern const SpeexMode speex_nb_mode; |
| TMBOY | 47:9e361da97763 | 406 | |
| TMBOY | 47:9e361da97763 | 407 | /** Default wideband mode */ |
| TMBOY | 47:9e361da97763 | 408 | extern const SpeexMode speex_wb_mode; |
| TMBOY | 47:9e361da97763 | 409 | |
| TMBOY | 47:9e361da97763 | 410 | /** Default "ultra-wideband" mode */ |
| TMBOY | 47:9e361da97763 | 411 | extern const SpeexMode speex_uwb_mode; |
| TMBOY | 47:9e361da97763 | 412 | |
| TMBOY | 47:9e361da97763 | 413 | #ifdef EPIC_48K |
| TMBOY | 47:9e361da97763 | 414 | /** 4.8 kbps narrowband mode */ |
| TMBOY | 47:9e361da97763 | 415 | extern const SpeexMode speex_nb_48k_mode; |
| TMBOY | 47:9e361da97763 | 416 | #endif |
| TMBOY | 47:9e361da97763 | 417 | |
| TMBOY | 47:9e361da97763 | 418 | /** List of all modes available */ |
| TMBOY | 47:9e361da97763 | 419 | extern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES]; |
| TMBOY | 47:9e361da97763 | 420 | |
| TMBOY | 47:9e361da97763 | 421 | /** Obtain one of the modes available */ |
| TMBOY | 47:9e361da97763 | 422 | const SpeexMode * speex_lib_get_mode (int mode); |
| TMBOY | 47:9e361da97763 | 423 | |
| TMBOY | 47:9e361da97763 | 424 | #ifdef __cplusplus |
| TMBOY | 47:9e361da97763 | 425 | } |
| TMBOY | 47:9e361da97763 | 426 | #endif |
| TMBOY | 47:9e361da97763 | 427 | |
| TMBOY | 47:9e361da97763 | 428 | /** @}*/ |
| TMBOY | 47:9e361da97763 | 429 | #endif |
