nb_celp.h

Go to the documentation of this file.
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/speex_bits.h>
00041 #include <speex/speex_callbacks.h>
00042 #include "vbr.h"
00043 #include "filters.h"
00044 
00045 #ifdef VORBIS_PSYCHO
00046 #include "vorbis_psy.h"
00047 #endif
00048 
00050 typedef struct EncState {
00051    const SpeexMode *mode;       
00052    int    first;          
00053    int    frameSize;      
00054    int    subframeSize;   
00055    int    nbSubframes;    
00056    int    windowSize;     
00057    int    lpcSize;        
00058    int    min_pitch;      
00059    int    max_pitch;      
00061    int    safe_pitch;     
00062    int    bounded_pitch;  
00063    int    ol_pitch;       
00064    int    ol_voiced;      
00065    int   *pitch;
00066 
00067 #ifdef EPIC_48K
00068    int    lbr_48k;
00069 #endif
00070 
00071 #ifdef VORBIS_PSYCHO
00072    VorbisPsy *psy;
00073    float *curve;
00074    float *old_curve;
00075 #endif
00076 
00077    spx_word16_t  gamma1;         
00078    spx_word16_t  gamma2;         
00079    float  lag_factor;     
00080    spx_word16_t  lpc_floor;      
00081    char  *stack;          
00082    spx_sig_t *inBuf;          
00083    spx_sig_t *frame;          
00084    spx_sig_t *excBuf;         
00085    spx_sig_t *exc;            
00086    spx_sig_t *swBuf;          
00087    spx_sig_t *sw;             
00088    spx_sig_t *innov;          
00089    spx_word16_t *window;         
00090    spx_word16_t *autocorr;       
00091    spx_word16_t *lagWindow;      
00092    spx_coef_t *lpc;            
00093    spx_lsp_t *lsp;            
00094    spx_lsp_t *qlsp;           
00095    spx_lsp_t *old_lsp;        
00096    spx_lsp_t *old_qlsp;       
00097    spx_lsp_t *interp_lsp;     
00098    spx_lsp_t *interp_qlsp;    
00099    spx_coef_t *interp_lpc;     
00100    spx_coef_t *interp_qlpc;    
00101    spx_coef_t *bw_lpc1;        
00102    spx_coef_t *bw_lpc2;        
00103    spx_mem_t *mem_sp;         
00104    spx_mem_t *mem_sw;         
00105    spx_mem_t *mem_sw_whole;   
00106    spx_mem_t *mem_exc;        
00107    spx_word32_t *pi_gain;        
00109    VBRState *vbr;         
00110    float  vbr_quality;    
00111    float  relative_quality; 
00112    int    vbr_enabled;    
00113    int    vad_enabled;    
00114    int    dtx_enabled;    
00115    int    dtx_count;      
00116    int    abr_enabled;    
00117    float  abr_drift;
00118    float  abr_drift2;
00119    float  abr_count;
00120    int    complexity;     
00121    int    sampling_rate;
00122    int    plc_tuning;
00123    int    encode_submode;
00124    const SpeexSubmode * const *submodes; 
00125    int    submodeID;      
00126    int    submodeSelect;  
00127 } EncState;
00128 
00130 typedef struct DecState {
00131    const SpeexMode *mode;       
00132    int    first;          
00133    int    count_lost;     
00134    int    frameSize;      
00135    int    subframeSize;   
00136    int    nbSubframes;    
00137    int    lpcSize;        
00138    int    min_pitch;      
00139    int    max_pitch;      
00140    int    sampling_rate;
00141 
00142 #ifdef EPIC_48K
00143    int    lbr_48k;
00144 #endif
00145 
00146    spx_word16_t  last_ol_gain;   
00148    char  *stack;          
00149    spx_sig_t *inBuf;          
00150    spx_sig_t *frame;          
00151    spx_sig_t *excBuf;         
00152    spx_sig_t *exc;            
00153    spx_sig_t *innov;          
00154    spx_lsp_t *qlsp;           
00155    spx_lsp_t *old_qlsp;       
00156    spx_lsp_t *interp_qlsp;    
00157    spx_coef_t *interp_qlpc;    
00158    spx_mem_t *mem_sp;         
00159    spx_word32_t *pi_gain;        
00160    int    last_pitch;     
00161    spx_word16_t  last_pitch_gain; 
00162    spx_word16_t  pitch_gain_buf[3];  
00163    int    pitch_gain_buf_idx; 
00164    spx_int32_t seed;          
00166    int    encode_submode;
00167    const SpeexSubmode * const *submodes; 
00168    int    submodeID;      
00169    int    lpc_enh_enabled; 
00170    CombFilterMem *comb_mem;
00171    SpeexCallback speex_callbacks[SPEEX_MAX_CALLBACKS];
00172 
00173    SpeexCallback user_callback;
00174 
00175    /*Vocoder data*/
00176    float  voc_m1;
00177    float  voc_m2;
00178    float  voc_mean;
00179    int    voc_offset;
00180 
00181    int    dtx_enabled;
00182 } DecState;
00183 
00185 void *nb_encoder_init(const SpeexMode *m);
00186 
00188 void nb_encoder_destroy(void *state);
00189 
00191 int nb_encode(void *state, void *in, SpeexBits *bits);
00192 
00193 
00195 void *nb_decoder_init(const SpeexMode *m);
00196 
00198 void nb_decoder_destroy(void *state);
00199 
00201 int nb_decode(void *state, SpeexBits *bits, void *out);
00202 
00204 int nb_encoder_ctl(void *state, int request, void *ptr);
00205 
00207 int nb_decoder_ctl(void *state, int request, void *ptr);
00208 
00209 
00210 #endif

Generated on Fri Jan 2 13:28:35 2009 for speex by  doxygen 1.4.6