📄 g729ev_main_filt.c
字号:
b2 = L_mult0(G729EV_MAIN_qmf_J64D[13], *x1b--); /* Use Coeffs 15..End to Accumulate in Sums a2 & b2 */ FOR(c = &G729EV_MAIN_qmf_J64D[14]; c < &G729EV_MAIN_qmf_J64D[G729EV_MAIN_S_QMF]; c += 2) { a2 = L_mac0(a2, c[0], *x1a--); a2 = L_mac0(a2, c[1], *++x2a); b2 = L_mac0(b2, c[1], *x1b--); b2 = L_mac0(b2, c[0], *++x2b); } /* Rescale */ a1 = L_mls(a1, 31838); a2 = L_mls(a2, 1378); b1 = L_mls(b1, 31838); b2 = L_mls(b2, 1378); /* Add to Get Filter Sum */ a1 = L_shl(L_add(a1, a2), 1); b1 = L_shl(L_add(b1, b2), 1); *output++ = round(a1); *output++ = round(b1); } return;}/*--------------------------------------------------------------------------* * Function G729EV_MAIN_QMF_mirror() * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Spectral folding, i.e. multiply by (-1)^n * *--------------------------------------------------------------------------*/void G729EV_MAIN_QMF_mirror(Word16 * s, /* (i/o) signal */ Word16 l /* (i) number of samples */ ){ Word16 i; FOR(i = 0; i < l; i += 2) { s[i] = negate(s[i]); }}/*--------------------------------------------------------------------------* * Function G729EV_MAIN_init_iir2() * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * memory initialization * *--------------------------------------------------------------------------*/void G729EV_MAIN_init_iir2(G729EV_MAIN_IIR2STAT * stat /* (i/o) filter states */ ){#if(WMOPS) move16(); move16(); move16(); move16(); move16(); move16();#endif stat->x0 = (Word16) 0; stat->x1 = (Word16) 0; stat->y1_hi = (Word16) 0; stat->y1_lo = (Word16) 0; stat->y2_hi = (Word16) 0; stat->y2_lo = (Word16) 0;}/*--------------------------------------------------------------------------* * Function G729EV_MAIN_iir2() * * ~~~~~~~~~~~~~~~~~~~~~~~~~~ * * 50 Hz HP preprocessing * *--------------------------------------------------------------------------*/void G729EV_MAIN_iir2(G729EV_MAIN_IIR2STAT * exStat, /* (i/o) filter states */ Word16 signal[], /* (i/o) signal */ Word16 lg, /* (i) lenght of signal */ const Word16 * b, /* (i) Filter coefficients Q13 */ const Word16 * a, /* (i) Filter coefficients Q13 */ Word16 ScalingMode) /* (i) ScalingMode = 1 : Upscale by 2 */ /* (i) ScalingMode = -1 : Downscale by 2 */{ Word32 ACC0, tmp1; Word16 i, x0, x1, x2, y1_hi, y1_lo, y2_hi, y2_lo; x0 = exStat->x0; x1 = exStat->x1; y1_hi = exStat->y1_hi; y1_lo = exStat->y1_lo; y2_hi = exStat->y2_hi; y2_lo = exStat->y2_lo;#if(WMOPS) move16(); move16(); move16(); move16(); move16(); move16();#endif FOR(i = 0; i < lg; i++) { x2 = x1; x1 = x0; x0 = signal[i];#if(WMOPS) move16(); move16(); move16();#endif /* y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2] */ /* + a[1]*y[i-1] + a[2] * y[i-2]; */ ACC0 = L_mult0(x0, b[0]); ACC0 = L_mac0(ACC0, x1, b[1]); ACC0 = L_mac0(ACC0, x2, b[2]); ACC0 = L_mac0(ACC0, y1_hi, a[1]); tmp1 = L_mult0(y1_lo, a[1]); ACC0 = L_mac0(ACC0, y2_hi, a[2]); tmp1 = L_mac0(tmp1, y2_lo, a[2]); ACC0 = L_shl(ACC0, 2); /* Q29 --> Q31 */ ACC0 = L_add(ACC0, L_shr(tmp1, 13)); /* If ScalingMode == 1, Multiplication by two of output speech with saturation. */ /* If ScalingMode == -1, Division by two of output speech */ signal[i] = round(L_shl(ACC0, ScalingMode)); y2_hi = y1_hi; y2_lo = y1_lo;#if(WMOPS) move16(); move16();#endif L_Extract(ACC0, &y1_hi, &y1_lo); } exStat->x0 = x0; exStat->x1 = x1; exStat->y1_hi = y1_hi; exStat->y1_lo = y1_lo; exStat->y2_hi = y2_hi; exStat->y2_lo = y2_lo;#if(WMOPS) move16(); move16(); move16(); move16(); move16(); move16();#endif return;}/*--------------------------------------------------------------------------* * Function G729EV_MAIN_init_lp3k() * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * 50 Hz HP preprocessing * *--------------------------------------------------------------------------*/void G729EV_MAIN_init_lp3k(G729EV_MAIN_IIRN_STAT * stat /* (i/o) filter states */ ){ Word16 i; /* memory initialization */ FOR(i = 0; i < G729EV_MAIN_LP_ORD; i++) {#if(WMOPS) move16(); move16(); move16();#endif stat->x[i] = (Word16) 0; stat->y_hi[i] = (Word16) 0; stat->y_lo[i] = (Word16) 0; } return;}/*--------------------------------------------------------------------------* * Function G729EV_MAIN_lp3k() * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * 3kHz LP filtering * *--------------------------------------------------------------------------*/void G729EV_MAIN_lp3k(G729EV_MAIN_IIRN_STAT * stat, /* (i/o) filter states */ Word16 signal[], /* (i/o) signal */ Word16 lg /* (i) number of samples */ ){ Word32 ACC0; Word32 tmp32; Word16 x[G729EV_MAIN_LP_ORD + 1]; Word16 y_hi[G729EV_MAIN_LP_ORD + 1]; Word16 y_lo[G729EV_MAIN_LP_ORD + 1]; Word16 i, j; FOR(j = 0; j < G729EV_MAIN_LP_ORD; j++) {#if(WMOPS) move16();#endif x[j] = stat->x[j]; } FOR(j = 0; j < G729EV_MAIN_LP_ORD; j++) {#if(WMOPS) move16(); move16();#endif y_hi[j + 1] = stat->y_hi[j]; y_lo[j + 1] = stat->y_lo[j]; } FOR(i = 0; i < lg; i++) { FOR(j = G729EV_MAIN_LP_ORD; j >= 1; j--) {#if(WMOPS) move16();#endif x[j] = x[j - 1]; } x[0] = signal[i]; ACC0 = (Word32) 0;#if(WMOPS) move16(); move32();#endif FOR(j = 1; j <= G729EV_MAIN_LP_ORD; j++) { tmp32 = Mpy_32(y_hi[j], y_lo[j], G729EV_MAIN_lp3k_a_hi[j], G729EV_MAIN_lp3k_a_lo[j]); ACC0 = L_add(ACC0, tmp32); } ACC0 = L_shl(ACC0, 1); FOR(j = 0; j <= G729EV_MAIN_LP_ORD; j++) { tmp32 = Mpy_32_16(G729EV_MAIN_lp3k_b_hi[j], G729EV_MAIN_lp3k_b_lo[j], x[j]); ACC0 = L_add(ACC0, tmp32); } /* Q27 --> Q30 */ ACC0 = L_shl(ACC0, 3); L_Extract(ACC0, &y_hi[0], &y_lo[0]); /* Q30 --> Q31 */ ACC0 = L_shl(ACC0, 1); signal[i] = round(ACC0); FOR(j = G729EV_MAIN_LP_ORD; j >= 1; j--) {#if(WMOPS) move16(); move16();#endif y_hi[j] = y_hi[j - 1]; y_lo[j] = y_lo[j - 1]; } } FOR(j = 0; j < G729EV_MAIN_LP_ORD; j++) {#if(WMOPS) move16();#endif stat->x[j] = x[j]; } FOR(j = 0; j < G729EV_MAIN_LP_ORD; j++) {#if(WMOPS) move16(); move16();#endif stat->y_hi[j] = y_hi[j + 1]; stat->y_lo[j] = y_lo[j + 1]; }}/*--------------------------------------------------------------------------* * Function G729EV_MAIN_CONVOLVE_2Tap() * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * convolution with 2-tap pattern * *--------------------------------------------------------------------------*/void G729EV_MAIN_CONVOLVE_2Tap(Word16 Input[], Word16 Output[], Word16 Coef, Word16 Length){ Word32 Acc0; Word16 x0, x1; Word16 i; x0 = (Word16) 0;#if(WMOPS) move16();#endif FOR(i = 0; i < Length - 1; i++) { x1 = Input[i]; Acc0 = L_deposit_h(x1); Acc0 = L_mac(Acc0, Coef, x0); Output[i] = round(Acc0); x0 = x1;#if(WMOPS) move16(); move16();#endif } Acc0 = L_deposit_h(Input[Length - 1]); Acc0 = L_mac(Acc0, Coef, x0); Output[Length - 1] = round(Acc0);}/*--------------------------------------------------------------------------* * Function G729EV_MAIN_CONVOLVE_2Tap() * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * convolution with 3-tap pattern * *--------------------------------------------------------------------------*/void G729EV_MAIN_CONVOLVE_3Tap(Word16 Input[], Word16 Output[], Word16 Coef, Word16 Length){ Word32 Acc0; Word16 x0, x1; Word16 i; x0 = (Word16) 0;#if(WMOPS) move16();#endif FOR(i = 0; i < Length - 1; i++) { x1 = Input[i]; Acc0 = L_deposit_h(x1); Acc0 = L_mac(Acc0, Coef, x0); Acc0 = L_mac(Acc0, Coef, Input[i + 1]); Output[i] = round(Acc0); x0 = x1;#if(WMOPS) move16(); move16();#endif } Acc0 = L_deposit_h(Input[Length - 1]); Acc0 = L_mac(Acc0, Coef, x0); Output[Length - 1] = round(Acc0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -