diff options
Diffstat (limited to 'libspeex/nb_celp.h')
-rw-r--r-- | libspeex/nb_celp.h | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/libspeex/nb_celp.h b/libspeex/nb_celp.h index 3fecab6..37cd283 100644 --- a/libspeex/nb_celp.h +++ b/libspeex/nb_celp.h @@ -46,6 +46,16 @@ #include "vorbis_psy.h" #endif +#define NB_ORDER 10 +#define NB_FRAME_SIZE 160 +#define NB_SUBFRAME_SIZE 40 +#define NB_NB_SUBFRAMES 4 +#define NB_PITCH_START 17 +#define NB_PITCH_END 144 + +#define NB_WINDOW_SIZE (NB_FRAME_SIZE+NB_SUBFRAME_SIZE) +#define NB_EXCBUF (NB_FRAME_SIZE+NB_PITCH_END+2) +#define NB_DEC_BUFFER (NB_FRAME_SIZE+2*NB_PITCH_END+NB_SUBFRAME_SIZE+12) /**Structure representing the full state of the narrowband encoder*/ typedef struct EncState { const SpeexMode *mode; /**< Mode corresponding to the state */ @@ -62,7 +72,7 @@ typedef struct EncState { int bounded_pitch; /**< Next frame should not rely on previous frames for pitch */ int ol_pitch; /**< Open-loop pitch */ int ol_voiced; /**< Open-loop voiced/non-voiced decision */ - int *pitch; + int pitch[NB_NB_SUBFRAMES]; #ifdef VORBIS_PSYCHO VorbisPsy *psy; @@ -75,26 +85,26 @@ typedef struct EncState { spx_word16_t gamma2; /**< Perceptual filter: A(z/gamma2) */ spx_word16_t lpc_floor; /**< Noise floor multiplier for A[0] in LPC analysis*/ char *stack; /**< Pseudo-stack allocation for temporary memory */ - spx_word16_t *winBuf; /**< Input buffer (original signal) */ - spx_word16_t *excBuf; /**< Excitation buffer */ + spx_word16_t winBuf[NB_WINDOW_SIZE-NB_FRAME_SIZE]; /**< Input buffer (original signal) */ + spx_word16_t excBuf[NB_EXCBUF]; /**< Excitation buffer */ spx_word16_t *exc; /**< Start of excitation frame */ - spx_word16_t *swBuf; /**< Weighted signal buffer */ + spx_word16_t swBuf[NB_EXCBUF]; /**< Weighted signal buffer */ spx_word16_t *sw; /**< Start of weighted signal frame */ const spx_word16_t *window; /**< Temporary (Hanning) window */ const spx_word16_t *lagWindow; /**< Window applied to auto-correlation */ - spx_lsp_t *old_lsp; /**< LSPs for previous frame */ - spx_lsp_t *old_qlsp; /**< Quantized LSPs for previous frame */ - spx_mem_t *mem_sp; /**< Filter memory for signal synthesis */ - spx_mem_t *mem_sw; /**< Filter memory for perceptually-weighted signal */ - spx_mem_t *mem_sw_whole; /**< Filter memory for perceptually-weighted signal (whole frame)*/ - spx_mem_t *mem_exc; /**< Filter memory for excitation (whole frame) */ - spx_mem_t *mem_exc2; /**< Filter memory for excitation (whole frame) */ + spx_lsp_t old_lsp[NB_ORDER]; /**< LSPs for previous frame */ + spx_lsp_t old_qlsp[NB_ORDER]; /**< Quantized LSPs for previous frame */ + spx_mem_t mem_sp[NB_ORDER]; /**< Filter memory for signal synthesis */ + spx_mem_t mem_sw[NB_ORDER]; /**< Filter memory for perceptually-weighted signal */ + spx_mem_t mem_sw_whole[NB_ORDER]; /**< Filter memory for perceptually-weighted signal (whole frame)*/ + spx_mem_t mem_exc[NB_ORDER]; /**< Filter memory for excitation (whole frame) */ + spx_mem_t mem_exc2[NB_ORDER]; /**< Filter memory for excitation (whole frame) */ spx_mem_t mem_hp[2]; /**< High-pass filter memory */ - spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */ + spx_word32_t pi_gain[NB_NB_SUBFRAMES]; /**< Gain of LPC filter at theta=pi (fe/2) */ spx_word16_t *innov_rms_save; /**< If non-NULL, innovation RMS is copied here */ #ifndef DISABLE_VBR - VBRState *vbr; /**< State of the VBR data */ + VBRState vbr; /**< State of the VBR data */ float vbr_quality; /**< Quality setting for VBR encoding */ float relative_quality; /**< Relative quality that will be needed by VBR */ spx_int32_t vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */ @@ -135,13 +145,13 @@ typedef struct DecState { spx_word16_t last_ol_gain; /**< Open-loop gain for previous frame */ char *stack; /**< Pseudo-stack allocation for temporary memory */ - spx_word16_t *excBuf; /**< Excitation buffer */ + spx_word16_t excBuf[NB_DEC_BUFFER]; /**< Excitation buffer */ spx_word16_t *exc; /**< Start of excitation frame */ - spx_lsp_t *old_qlsp; /**< Quantized LSPs for previous frame */ - spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs */ - spx_mem_t *mem_sp; /**< Filter memory for synthesis signal */ + spx_lsp_t old_qlsp[NB_ORDER]; /**< Quantized LSPs for previous frame */ + spx_coef_t interp_qlpc[NB_ORDER]; /**< Interpolated quantized LPCs */ + spx_mem_t mem_sp[NB_ORDER]; /**< Filter memory for synthesis signal */ spx_mem_t mem_hp[2]; /**< High-pass filter memory */ - spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */ + spx_word32_t pi_gain[NB_NB_SUBFRAMES]; /**< Gain of LPC filter at theta=pi (fe/2) */ spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */ spx_word16_t level; |