📄 ld8k.h
字号:
Word16 T0, /* (i) :Pitch lag */
Word16 pitch_sharp, /* (i) Q14 :Last quantized pitch gain */
Word16 i_subfr, /* (i) :Indicator of 1st subframe, */
Word16 code[], /* (o) Q13 :Innovative codebook */
Word16 y[], /* (o) Q12 :Filtered innovative codebook */
Word16 *sign /* (o) :Signs of 4 pulses */
);
void Decod_ACELP(
Word16 sign, /* (i) : signs of 4 pulses. */
Word16 index, /* (i) : Positions of the 4 pulses. */
Word16 cod[] /* (o) Q13 : algebraic (fixed) codebook excitation */
);
/*--------------------------------------------------------------------------*
* LSP constant parameters *
*--------------------------------------------------------------------------*/
#define N_PR 10
#define NC 5 /* NC = M/2 */
#define MA_NP 4 /* MA prediction order for LSP */
#define MODE 2 /* number of modes for MA prediction */
#define NC0_B 7 /* number of first stage bits */
#define NC1_B 5 /* number of second stage bits */
#define NC0 (1<<NC0_B)
#define NC1 (1<<NC1_B)
#define L_LIMIT 40 /* Q13:0.005 */
#define M_LIMIT 25681 /* Q13:3.135 */
#define GAP1 10 /* Q13 */
#define GAP2 5 /* Q13 */
#define GAP3 321 /* Q13 */
#define GRID_POINTS 60
#define PI04 ((Word16)1029) /* Q13 pi*0.04 */
#define PI92 ((Word16)23677) /* Q13 pi*0.92 */
#define CONST10 ((Word16)10*(1<<11)) /* Q11 10.0 */
#define CONST12 ((Word16)19661) /* Q14 1.2 */
/*-------------------------------*
* LSP VQ functions. *
*-------------------------------*/
void Lsf_lsp2(
Word16 lsf[], /* (i) Q13 : lsf[m] (range: 0.0<=val<PI) */
Word16 lsp[], /* (o) Q15 : lsp[m] (range: -1<=val<1) */
Word16 m /* (i) : LPC order */
);
void Lsp_lsf2(
Word16 lsp[], /* (i) Q15 : lsp[m] (range: -1<=val<1) */
Word16 lsf[], /* (o) Q13 : lsf[m] (range: 0.0<=val<PI) */
Word16 m /* (i) : LPC order */
);
void Qua_lsp(
Word16 lsp[], /* (i) Q15 : Unquantized LSP */
Word16 lsp_q[], /* (o) Q15 : Quantized LSP */
Word16 ana[] /* (o) : indexes */
);
void Get_wegt(
Word16 flsp[], /* Q13 */
Word16 wegt[] /* Q11 -> normalized */
);
void Lsp_encw_reset(
void
);
void Lsp_qua_cs(
Word16 flsp_in[N_PR], /* Q13 */
Word16 lspq_out[N_PR], /* Q13 */
Word16 *code
);
void Lsp_expand_1(
Word16 buf[], /* Q13 */
Word16 gap /* Q13 */
);
void Lsp_expand_2(
Word16 buf[], /* Q13 */
Word16 gap /* Q13 */
);
void Lsp_expand_1_2(
Word16 buf[], /* Q13 */
Word16 gap /* Q13 */
);
void Lsp_get_quant(
Word16 lspcb1[][N_PR], /* Q13 */
Word16 lspcb2[][N_PR], /* Q13 */
Word16 code0,
Word16 code1,
Word16 code2,
Word16 fg[][N_PR], /* Q15 */
Word16 freq_prev[][N_PR], /* Q13 */
Word16 lspq[], /* Q13 */
Word16 fg_sum[] /* Q15 */
);
void Lsp_get_tdist(
Word16 wegt[], /* normalized */
Word16 buf[], /* Q13 */
Word32 *L_tdist, /* Q27 */
Word16 rbuf[], /* Q13 */
Word16 fg_sum[] /* Q15 */
);
void Lsp_last_select(
Word32 L_tdist[], /* Q27 */
Word16 *mode_index
);
void Lsp_pre_select(
Word16 rbuf[], /* Q13 */
Word16 lspcb1[][N_PR], /* Q13 */
Word16 *cand
);
void Lsp_select_1(
Word16 rbuf[], /* Q13 */
Word16 lspcb1[], /* Q13 */
Word16 wegt[], /* normalized */
Word16 lspcb2[][N_PR], /* Q13 */
Word16 *index
);
void Lsp_select_2(
Word16 rbuf[], /* Q13 */
Word16 lspcb1[], /* Q13 */
Word16 wegt[], /* normalized */
Word16 lspcb2[][N_PR], /* Q13 */
Word16 bufsave, /* Q13 */
Word16 *index
);
void Lsp_stability(
Word16 buf[] /* Q13 */
);
void Relspwed(
Word16 lsp[], /* Q13 */
Word16 wegt[], /* normalized */
Word16 lspq[], /* Q13 */
Word16 lspcb1[][N_PR], /* Q13 */
Word16 lspcb2[][N_PR], /* Q13 */
Word16 fg[MODE][MA_NP][N_PR], /* Q15 */
Word16 freq_prev[MA_NP][N_PR], /* Q13 */
Word16 fg_sum[MODE][N_PR], /* Q15 */
Word16 fg_sum_inv[MODE][N_PR], /* Q12 */
Word16 code_ana[]
);
void D_lsp(
Word16 prm[], /* (i) : indexes of the selected LSP */
Word16 lsp_q[], /* (o) Q15 : Quantized LSP parameters */
Word16 erase /* (i) : frame erase information */
);
void Lsp_decw_reset(
void
);
void Lsp_iqua_cs(
Word16 prm[], /* input : codes of the selected LSP*/
Word16 lsp_q[], /* output: Quantized LSP parameters*/
Word16 erase /* input : frame erase information */
);
void Lsp_prev_compose(
Word16 lsp_ele[], /* Q13 */
Word16 lsp[], /* Q13 */
Word16 fg[][N_PR], /* Q15 */
Word16 freq_prev[][N_PR], /* Q13 */
Word16 fg_sum[] /* Q15 */
);
void Lsp_prev_extract(
Word16 lsp[N_PR], /* Q13 */
Word16 lsp_ele[N_PR], /* Q13 */
Word16 fg[MA_NP][N_PR], /* Q15 */
Word16 freq_prev[MA_NP][N_PR], /* Q13 */
Word16 fg_sum_inv[N_PR] /* Q12 */
);
void Lsp_prev_update(
Word16 lsp_ele[N_PR], /* Q13 */
Word16 freq_prev[MA_NP][N_PR] /* Q13 */
);
/*-------------------------------*
* gain VQ constants. *
*-------------------------------*/
#define NCODE1_B 3 /* number of Codebook-bit */
#define NCODE2_B 4 /* number of Codebook-bit */
#define NCODE1 (1<<NCODE1_B) /* Codebook 1 size */
#define NCODE2 (1<<NCODE2_B) /* Codebook 2 size */
#define NCAN1 4 /* Pre-selecting order for #1 */
#define NCAN2 8 /* Pre-selecting order for #2 */
#define INV_COEF -17103 /* Q19 */
/*-------------------------------*
* gain VQ functions. *
*-------------------------------*/
Word16 Qua_gain(
Word16 code[], /* (i) Q13 :Innovative vector. */
Word16 g_coeff[], /* (i) :Correlations <xn y1> -2<y1 y1> */
/* <y2,y2>, -2<xn,y2>, 2<y1,y2> */
Word16 exp_coeff[], /* (i) :Q-Format g_coeff[] */
Word16 L_subfr, /* (i) :Subframe length. */
Word16 *gain_pit, /* (o) Q14 :Pitch gain. */
Word16 *gain_cod /* (o) Q1 :Code gain. */
);
void Dec_gain(
Word16 index, /* (i) :Index of quantization. */
Word16 code[], /* (i) Q13 :Innovative vector. */
Word16 L_subfr, /* (i) :Subframe length. */
Word16 bfi, /* (i) :Bad frame indicator */
Word16 *gain_pit, /* (o) Q14 :Pitch gain. */
Word16 *gain_cod /* (o) Q1 :Code gain. */
);
void Gain_predict(
Word16 code[], /* (i) Q13 :Innovative vector. */
Word16 L_subfr, /* (i) :Subframe length. */
Word16 *gcode0, /* (o) Qxx :Predicted codebook gain */
Word16 *exp_gcode0 /* (o) :Q-Format(gcode0) */
);
void Gain_update(
Word32 L_gbk12 /* (i) Q13 : gbk1[indice1][1]+gbk2[indice2][1] */
);
void Gain_update_erasure(
void
);
void Corr_xy2(
Word16 xn[], /* (i) Q0 :Target vector. */
Word16 y1[], /* (i) Q0 :Adaptive codebook. */
Word16 y2[], /* (i) Q12 :Filtered innovative vector. */
Word16 g_coeff[], /* (o) Q[exp]:Correlations between xn,y1,y2 */
Word16 exp_g_coeff[] /* (o) :Q-format of g_coeff[] */
);
/*-----------------------*
* Postfilter constants *
*-----------------------*/
/* short term pst parameters : */
#define GAMMA1_PST 22938 /* denominator weighting factor (Q15) */
#define GAMMA2_PST 18022 /* numerator weighting factor (Q15) */
#define LONG_H_ST 20 /* impulse response length */
#define GAMMA3_PLUS 6554 /* tilt weighting factor when k1>0 (Q15) */
#define GAMMA3_MINUS 29491 /* tilt weighting factor when k1<0 (Q15) */
/* long term pst parameters : */
#define F_UP_PST 8 /* resolution for fractionnal delay */
#define LH2_S 4 /* length of short interp. subfilters */
#define L2_LH2_L 4 /* log2(LH2_L) */
#define LH2_L (1 << L2_LH2_L)
#define MIN_GPLT 21845 /* LT gain minimum (Q15) */
#define LH_UP_S (LH2_S/2)
#define LH_UP_SM1 (LH_UP_S-1)
#define LH_UP_L (LH2_L/2)
#define LH2_L_P1 (LH2_L + 1)
/* gain adjustment parameters */
#define AGC_FAC 27853 /* gain adjustment factor (Q15) */
#define AGC_FAC1 (Word16)(32768L - AGC_FAC)
/* Array sizes */
#define MEM_RES2 (PIT_MAX + 1 + LH_UP_L)
#define SIZ_RES2 (MEM_RES2 + L_SUBFR)
#define SIZ_Y_UP ((F_UP_PST-1) * L_SUBFRP1)
#define SIZ_TAB_HUP_L ((F_UP_PST-1) * LH2_L)
#define SIZ_TAB_HUP_S ((F_UP_PST-1) * LH2_S)
/*-----------------------*
* Postfilter functions *
*-----------------------*/
void Init_Post_Filter(
void
);
void Post(
Word16 t0, /* input : 1st subframe delay given by coder */
Word16 *signal_ptr, /* input : input signal (pointer to current subframe */
Word16 *coeff, /* input : LPC coefficients for current subframe */
Word16 *sig_out, /* output: postfiltered output */
Word16 *vo /* output: voicing decision 0 = uv, > 0 delay */
);
/*-----------------------*
* Bitstream function *
*-----------------------*/
void prm2bits_ld8k(Word16 prm[], Word16 bits[]);
void bits2prm_ld8k(Word16 bits[], Word16 prm[]);
#define BIT_0 (short)0x007f /* definition of zero-bit in bit-stream */
#define BIT_1 (short)0x0081 /* definition of one-bit in bit-stream */
#define SYNC_WORD (short)0x6b21 /* definition of frame erasure flag */
#define SIZE_WORD (short)80 /* number of speech bits */
/*--------------------------------------------------------------------------*
* Prototypes for auxiliary functions. *
*--------------------------------------------------------------------------*/
void Copy(
Word16 x[], /* (i) : input vector */
Word16 y[], /* (o) : output vector */
Word16 L /* (i) : vector length */
);
void Set_zero(
Word16 x[], /* (o) : vector to clear */
Word16 L /* (i) : length of vector */
);
Word16 Random(void);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -