📄 dtx.h
字号:
/* ITU-T G.729 Annex C+ - Reference C code for floating point implementation of G.729 Annex C+ (integration of Annexes B, D and E) Version 2.1 of October 1999*//* File : DTX.H*//*--------------------------------------------------------------------------* * Constants for DTX/CNG * *--------------------------------------------------------------------------*//* DTX constants */#define FLAG_COD 1#define FLAG_DEC 0#define INIT_SEED (INT16)11111#define FR_SID_MIN 3#define NB_SUMACF 3#define NB_CURACF 2#define NB_GAIN 2#define THRESH1 (FLOAT)1.1481628#define THRESH2 (FLOAT)1.0966466#define A_GAIN0 (FLOAT)0.875#define SIZ_SUMACF (NB_SUMACF * MP1)#define SIZ_ACF (NB_CURACF * MP1)#define A_GAIN1 ((FLOAT)1. - A_GAIN0)#define MIN_ENER (FLOAT)0.1588489319 /* <=> - 8 dB */#define RATE_8000 80 /* Full rate (8000 bit/s) */#define RATE_SID 15 /* SID */#define RATE_0 0 /* 0 bit/s rate *//* CNG excitation generation constant */ /* alpha = 0.5 */#define NORM_GAUSS (FLOAT)3.16227766 /* sqrt(40)xalpha */#define K0 (FLOAT)3. /* 4 x (1 - alpha ** 2) */#define G_MAX (FLOAT)5000./*--------------------------------------------------------------------------* * Prototypes for DTX/CNG * *--------------------------------------------------------------------------*/struct cod_cng_state_t{ /* Static Variables */ FLOAT lspSid_q[M] ; FLOAT pastCoeff[MP1]; FLOAT RCoeff[MP1]; FLOAT Acf[SIZ_ACF]; FLOAT sumAcf[SIZ_SUMACF]; FLOAT ener[NB_GAIN]; int fr_cur; FLOAT cur_gain; int nb_ener; FLOAT sid_gain; int flag_chang; FLOAT prev_energy; int count_fr0; FLOAT exc_err[4]; /* taming state */ struct lsfq_state_t lsfq_s; //struct taming_state_t taming_s;};/* Encoder DTX/CNG functions */void init_cod_cng(struct cod_cng_state_t *);void cod_cng(struct cod_cng_state_t *, FLOAT *exc, /* (i/o) : excitation array */ int pastVad, /* (i) : previous VAD decision */ FLOAT *lsp_old_q, /* (i/o) : previous quantized lsp */// FLOAT *old_A, /* (i/o) : last stable filter LPC coefficients */// FLOAT *old_rc, /* (i/o) : last stable filter Reflection coefficients.*/ FLOAT *Aq, /* (o) : set of interpolated LPC coefficients */ int *ana, /* (o) : coded SID parameters */ FLOAT freq_prev[MA_NP][M], /* (i/o) : previous LPS for quantization */ INT16 *seed /* (i/o) : random generator seed */);void update_cng(struct cod_cng_state_t *, FLOAT *r, /* (i) : frame autocorrelation */ int Vad /* (i) : current Vad decision */);/* SID gain Quantization */void qua_Sidgain( FLOAT *ener, /* (i) array of energies */ int nb_ener, /* (i) number of energies or */ FLOAT *enerq, /* (o) decoded energies in dB */ int *idx /* (o) SID gain quantization index */);/* CNG excitation generation */void calc_exc_rand(FLOAT exc_err[4], FLOAT cur_gain, /* (i) : target sample gain */ FLOAT *exc, /* (i/o) : excitation array */ INT16 *seed, /* (i) : current Vad decision */ int flag_cod /* (i) : encoder/decoder flag */);struct dec_cng_state_t{ FLOAT cur_gain; FLOAT lspSid[M]; FLOAT sid_gain; FLOAT exc_err[4]; /* taming state */ struct lsfq_state_t lsfq_s; //struct taming_state_t taming_s;};/* Decoder CNG generation */void init_dec_cng(struct dec_cng_state_t *);void dec_cng(struct dec_cng_state_t *, int past_ftyp, /* (i) : past frame type */ FLOAT sid_sav, /* (i) : energy to recover SID gain */ int *parm, /* (i) : coded SID parameters */ FLOAT *exc, /* (i/o) : excitation array */ FLOAT *lsp_old, /* (i/o) : previous lsp */ FLOAT *A_t, /* (o) : set of interpolated LPC coefficients */ INT16 *seed, /* (i/o) : random generator seed */ FLOAT freq_prev[MA_NP][M] /* (i/o) : previous LPS for quantization */);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -