00001 /* Copyright (C) 2002 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 NB_CELP_H 00037 #define NB_CELP_H 00038 00039 #include "modes.h" 00040 #include "speex_bits.h" 00041 #include "speex_callbacks.h" 00042 #include "vbr.h" 00043 #include "filters.h" 00044 00046 typedef struct EncState { 00047 SpeexMode *mode; 00048 int first; 00049 int frameSize; 00050 int subframeSize; 00051 int nbSubframes; 00052 int windowSize; 00053 int lpcSize; 00054 int bufSize; 00055 int min_pitch; 00056 int max_pitch; 00058 int safe_pitch; 00059 int bounded_pitch; 00060 int ol_pitch; 00061 int ol_voiced; 00062 int *pitch; 00063 00064 #ifdef EPIC_48K 00065 int lbr_48k; 00066 #endif 00067 00068 float gamma1; 00069 float gamma2; 00070 float lag_factor; 00071 float lpc_floor; 00072 float preemph; 00073 float pre_mem; 00074 float pre_mem2; 00075 char *stack; 00076 float *inBuf; 00077 float *frame; 00078 float *excBuf; 00079 float *exc; 00080 float *exc2Buf; 00081 float *exc2; 00082 float *swBuf; 00083 float *sw; 00084 float *innov; 00085 float *window; 00086 float *buf2; 00087 float *autocorr; 00088 float *lagWindow; 00089 float *lpc; 00090 float *lsp; 00091 float *qlsp; 00092 float *old_lsp; 00093 float *old_qlsp; 00094 float *interp_lsp; 00095 float *interp_qlsp; 00096 float *interp_lpc; 00097 float *interp_qlpc; 00098 float *bw_lpc1; 00099 float *bw_lpc2; 00100 float *mem_sp; 00101 float *mem_sw; 00102 float *mem_sw_whole; 00103 float *mem_exc; 00104 float *pi_gain; 00106 VBRState *vbr; 00107 float vbr_quality; 00108 float relative_quality; 00109 int vbr_enabled; 00110 int vad_enabled; 00111 int dtx_enabled; 00112 int dtx_count; 00113 int abr_enabled; 00114 float abr_drift; 00115 float abr_drift2; 00116 float abr_count; 00117 int complexity; 00118 int sampling_rate; 00119 00120 int encode_submode; 00121 SpeexSubmode **submodes; 00122 int submodeID; 00123 int submodeSelect; 00124 } EncState; 00125 00127 typedef struct DecState { 00128 SpeexMode *mode; 00129 int first; 00130 int count_lost; 00131 int frameSize; 00132 int subframeSize; 00133 int nbSubframes; 00134 int windowSize; 00135 int lpcSize; 00136 int bufSize; 00137 int min_pitch; 00138 int max_pitch; 00139 int sampling_rate; 00140 00141 #ifdef EPIC_48K 00142 int lbr_48k; 00143 #endif 00144 00145 float last_ol_gain; 00147 float gamma1; 00148 float gamma2; 00149 float preemph; 00150 float pre_mem; 00151 char *stack; 00152 float *inBuf; 00153 float *frame; 00154 float *excBuf; 00155 float *exc; 00156 float *innov; 00157 float *qlsp; 00158 float *old_qlsp; 00159 float *interp_qlsp; 00160 float *interp_qlpc; 00161 float *mem_sp; 00162 float *pi_gain; 00163 int last_pitch; 00164 float last_pitch_gain; 00165 float pitch_gain_buf[3]; 00166 int pitch_gain_buf_idx; 00168 int encode_submode; 00169 SpeexSubmode **submodes; 00170 int submodeID; 00171 int lpc_enh_enabled; 00172 CombFilterMem *comb_mem; 00173 SpeexCallback speex_callbacks[SPEEX_MAX_CALLBACKS]; 00174 00175 SpeexCallback user_callback; 00176 00177 /*Vocoder data*/ 00178 float voc_m1; 00179 float voc_m2; 00180 float voc_mean; 00181 int voc_offset; 00182 00183 int dtx_enabled; 00184 } DecState; 00185 00187 void *nb_encoder_init(SpeexMode *m); 00188 00190 void nb_encoder_destroy(void *state); 00191 00193 int nb_encode(void *state, float *in, SpeexBits *bits); 00194 00195 00197 void *nb_decoder_init(SpeexMode *m); 00198 00200 void nb_decoder_destroy(void *state); 00201 00203 int nb_decode(void *state, SpeexBits *bits, float *out); 00204 00206 int nb_encoder_ctl(void *state, int request, void *ptr); 00207 00209 int nb_decoder_ctl(void *state, int request, void *ptr); 00210 00211 00212 #endif