speex.h

Go to the documentation of this file.
00001 /* Copyright (C) 2002-2006 Jean-Marc Valin*/
00006 /*
00007    Redistribution and use in source and binary forms, with or without
00008    modification, are permitted provided that the following conditions
00009    are met:
00010    
00011    - Redistributions of source code must retain the above copyright
00012    notice, this list of conditions and the following disclaimer.
00013    
00014    - Redistributions in binary form must reproduce the above copyright
00015    notice, this list of conditions and the following disclaimer in the
00016    documentation and/or other materials provided with the distribution.
00017    
00018    - Neither the name of the Xiph.org Foundation nor the names of its
00019    contributors may be used to endorse or promote products derived from
00020    this software without specific prior written permission.
00021    
00022    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00025    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00026    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00028    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00029    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00030    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00031    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 
00036 #ifndef SPEEX_H
00037 #define SPEEX_H
00038 
00043 #include "speex/speex_bits.h"
00044 #include "speex/speex_types.h"
00045 
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049 
00050 /* Values allowed for *ctl() requests */
00051 
00053 #define SPEEX_SET_ENH 0
00054 
00055 #define SPEEX_GET_ENH 1
00056 
00057 /*Would be SPEEX_SET_FRAME_SIZE, but it's (currently) invalid*/
00059 #define SPEEX_GET_FRAME_SIZE 3
00060 
00062 #define SPEEX_SET_QUALITY 4
00063 
00064 /* #define SPEEX_GET_QUALITY 5 -- Doesn't make much sense, does it? */
00065 
00067 #define SPEEX_SET_MODE 6
00068 
00069 #define SPEEX_GET_MODE 7
00070 
00072 #define SPEEX_SET_LOW_MODE 8
00073 
00074 #define SPEEX_GET_LOW_MODE 9
00075 
00077 #define SPEEX_SET_HIGH_MODE 10
00078 
00079 #define SPEEX_GET_HIGH_MODE 11
00080 
00082 #define SPEEX_SET_VBR 12
00083 
00084 #define SPEEX_GET_VBR 13
00085 
00087 #define SPEEX_SET_VBR_QUALITY 14
00088 
00089 #define SPEEX_GET_VBR_QUALITY 15
00090 
00092 #define SPEEX_SET_COMPLEXITY 16
00093 
00094 #define SPEEX_GET_COMPLEXITY 17
00095 
00097 #define SPEEX_SET_BITRATE 18
00098 
00099 #define SPEEX_GET_BITRATE 19
00100 
00102 #define SPEEX_SET_HANDLER 20
00103 
00105 #define SPEEX_SET_USER_HANDLER 22
00106 
00108 #define SPEEX_SET_SAMPLING_RATE 24
00109 
00110 #define SPEEX_GET_SAMPLING_RATE 25
00111 
00113 #define SPEEX_RESET_STATE 26
00114 
00116 #define SPEEX_GET_RELATIVE_QUALITY 29
00117 
00119 #define SPEEX_SET_VAD 30
00120 
00122 #define SPEEX_GET_VAD 31
00123 
00125 #define SPEEX_SET_ABR 32
00126 
00127 #define SPEEX_GET_ABR 33
00128 
00130 #define SPEEX_SET_DTX 34
00131 
00132 #define SPEEX_GET_DTX 35
00133 
00135 #define SPEEX_SET_SUBMODE_ENCODING 36
00136 
00137 #define SPEEX_GET_SUBMODE_ENCODING 37
00138 
00139 /*#define SPEEX_SET_LOOKAHEAD 38*/
00141 #define SPEEX_GET_LOOKAHEAD 39
00142 
00144 #define SPEEX_SET_PLC_TUNING 40
00145 
00146 #define SPEEX_GET_PLC_TUNING 41
00147 
00149 #define SPEEX_SET_VBR_MAX_BITRATE 42
00150 
00151 #define SPEEX_GET_VBR_MAX_BITRATE 43
00152 
00154 #define SPEEX_SET_HIGHPASS 44
00155 
00156 #define SPEEX_GET_HIGHPASS 45
00157 
00160 #define SPEEX_GET_ACTIVITY 47
00161 
00162 
00163 /* Preserving compatibility:*/
00165 #define SPEEX_SET_PF 0
00166 
00167 #define SPEEX_GET_PF 1
00168 
00169 
00170 
00171 
00172 /* Values allowed for mode queries */
00174 #define SPEEX_MODE_FRAME_SIZE 0
00175 
00177 #define SPEEX_SUBMODE_BITS_PER_FRAME 1
00178 
00179 
00180 
00182 #define SPEEX_LIB_GET_MAJOR_VERSION 1
00183 
00184 #define SPEEX_LIB_GET_MINOR_VERSION 3
00185 
00186 #define SPEEX_LIB_GET_MICRO_VERSION 5
00187 
00188 #define SPEEX_LIB_GET_EXTRA_VERSION 7
00189 
00190 #define SPEEX_LIB_GET_VERSION_STRING 9
00191 
00192 /*#define SPEEX_LIB_SET_ALLOC_FUNC 10
00193 #define SPEEX_LIB_GET_ALLOC_FUNC 11
00194 #define SPEEX_LIB_SET_FREE_FUNC 12
00195 #define SPEEX_LIB_GET_FREE_FUNC 13
00196 
00197 #define SPEEX_LIB_SET_WARNING_FUNC 14
00198 #define SPEEX_LIB_GET_WARNING_FUNC 15
00199 #define SPEEX_LIB_SET_ERROR_FUNC 16
00200 #define SPEEX_LIB_GET_ERROR_FUNC 17
00201 */
00202 
00204 #define SPEEX_NB_MODES 3
00205 
00207 #define SPEEX_MODEID_NB 0
00208 
00210 #define SPEEX_MODEID_WB 1
00211 
00213 #define SPEEX_MODEID_UWB 2
00214 
00215 struct SpeexMode;
00216 
00217 
00218 /* Prototypes for mode function pointers */
00219 
00221 typedef void *(*encoder_init_func)(const struct SpeexMode *mode);
00222 
00224 typedef void (*encoder_destroy_func)(void *st);
00225 
00227 typedef int (*encode_func)(void *state, void *in, SpeexBits *bits);
00228 
00230 typedef int (*encoder_ctl_func)(void *state, int request, void *ptr);
00231 
00233 typedef void *(*decoder_init_func)(const struct SpeexMode *mode);
00234 
00236 typedef void (*decoder_destroy_func)(void *st);
00237 
00239 typedef int  (*decode_func)(void *state, SpeexBits *bits, void *out);
00240 
00242 typedef int (*decoder_ctl_func)(void *state, int request, void *ptr);
00243 
00244 
00246 typedef int (*mode_query_func)(const void *mode, int request, void *ptr);
00247 
00249 typedef struct SpeexMode {
00251    const void *mode;
00252 
00254    mode_query_func query;
00255    
00257    const char *modeName;
00258 
00260    int modeID;
00261 
00264    int bitstream_version;
00265 
00267    encoder_init_func enc_init;
00268 
00270    encoder_destroy_func enc_destroy;
00271 
00273    encode_func enc;
00274 
00276    decoder_init_func dec_init;
00277 
00279    decoder_destroy_func dec_destroy;
00280 
00282    decode_func dec;
00283 
00285    encoder_ctl_func enc_ctl;
00286 
00288    decoder_ctl_func dec_ctl;
00289 
00290 } SpeexMode;
00291 
00301 void *speex_encoder_init(const SpeexMode *mode);
00302 
00305 void speex_encoder_destroy(void *state);
00306 
00316 int speex_encode(void *state, float *in, SpeexBits *bits);
00317 
00325 int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits);
00326 
00334 int speex_encoder_ctl(void *state, int request, void *ptr);
00335 
00336 
00345 void *speex_decoder_init(const SpeexMode *mode);
00346 
00351 void speex_decoder_destroy(void *state);
00352 
00361 int speex_decode(void *state, SpeexBits *bits, float *out);
00362 
00371 int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out);
00372 
00380 int speex_decoder_ctl(void *state, int request, void *ptr);
00381 
00382 
00390 int speex_mode_query(const SpeexMode *mode, int request, void *ptr);
00391 
00397 int speex_lib_ctl(int request, void *ptr);
00398 
00400 extern const SpeexMode speex_nb_mode;
00401 
00403 extern const SpeexMode speex_wb_mode;
00404 
00406 extern const SpeexMode speex_uwb_mode;
00407 
00409 extern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES];
00410 
00412 const SpeexMode * speex_lib_get_mode (int mode);
00413 
00414 #ifndef WIN32
00415 /* We actually override the function in the narrowband case so that we can avoid linking in the wideband stuff */
00416 #define speex_lib_get_mode(mode) ((mode)==SPEEX_MODEID_NB ? &speex_nb_mode : speex_lib_get_mode (mode))
00417 #endif
00418 
00419 #ifdef __cplusplus
00420 }
00421 #endif
00422 
00424 #endif

Generated on Sat Dec 6 22:03:22 2008 for Speex by  doxygen 1.5.1