📄 funcg722.c
字号:
___________________________________________________________________________*/Word16 scalel (nbpl)Word16 nbpl;{ Word16 wd1, wd2; wd1 = (nbpl >> 6) & 511; wd2 = wd1 + 64; return ((ila[wd2] + 1) << 2);}/* ..................... End of scalel() ..................... *//*___________________________________________________________________________ Function Name : scaleh Purpose : . Inputs : Outputs : none Return Value : ___________________________________________________________________________*/Word16 scaleh (nbph)Word16 nbph;{ Word16 wd; wd = (nbph >> 6) & 511; return ((ila[wd] + 1) << 2);}/* ..................... End of scaleh() ..................... *//*___________________________________________________________________________ Function Name : uppol1 Purpose : . Inputs : Outputs : none Return Value : None. ___________________________________________________________________________*/void uppol1 (al, plt)Word16 al [];Word16 plt [];{ Word16 sg0, sg1, wd1, wd2, wd3, apl1; sg0 = shr (plt[0], 15); sg1 = shr (plt[1], 15); wd1 = (sg0 == sg1) ? 192 : -192; wd2 = mult (al[1], 32640); apl1 = add (wd1, wd2); wd3 = sub (15360, al[2]); apl1 = (apl1 > wd3) ? wd3 : ((apl1 < -wd3) ? negate (wd3) : apl1); /* Shift of the plt signals */ plt[2] = plt[1]; plt[1] = plt[0]; al[1] = apl1;}/* ..................... End of uppol1() ..................... *//*___________________________________________________________________________ Function Name : uppol2 Purpose : . Inputs : Outputs : none Return Value : None. ___________________________________________________________________________*/void uppol2 (al, plt)Word16 al [];Word16 plt [];{ Word16 sg0, sg1, sg2, wd1, wd2, wd3, wd4, wd5, apl2; sg0 = shr (plt[0], 15); sg1 = shr (plt[1], 15); sg2 = shr (plt[2], 15); wd1 = add (al[1], al[1]); wd1 = add (wd1, wd1); wd2 = (sg0 == sg1) ? sub (0, wd1) : add (0, wd1); wd2 = shr (wd2, 7); wd3 = (sg0 == sg2) ? 128 : -128; wd4 = add (wd2, wd3); wd5 = mult (al[2], 32512); apl2 = add (wd4, wd5); apl2 = (apl2 > 0) ? ((apl2 > 12288) ? 12288 : apl2) : ((apl2 < -12288) ? -12288 : apl2); al[2] = apl2;}/* ..................... End of uppol2() ..................... *//*___________________________________________________________________________ Function Name : upzero Purpose : . Inputs : Outputs : none Return Value : None. ___________________________________________________________________________*/void upzero (dlt, bl)Word16 dlt [];Word16 bl [];{ Word16 sg0, sgi, wd1, wd2, wd3; Word16 i; /* shift of the dlt line signal and update of bl */ wd1 = (dlt[0] == 0) ? 0 : 128; sg0 = shr (dlt[0], 15); for (i = 6; i > 0; i--) { sgi = shr (dlt[i], 15); wd2 = (sg0 == sgi) ? add (0, wd1) : sub (0, wd1); wd3 = mult (bl[i], 32640); bl[i] = add (wd2, wd3); dlt[i] = dlt[i - 1]; }}/* ..................... End of upzero() ..................... *//* **** Coefficients for both transmission and reception QMF **** */static Word16 coef_qmf[24] = { 3 * 2, -11 * 2, -11 * 2, 53 * 2, 12 * 2, -156 * 2, 32 * 2, 362 * 2, -210 * 2, -805 * 2, 951 * 2, 3876 * 2, 3876 * 2, 951 * 2, -805 * 2, -210 * 2, 362 * 2, 32 * 2, -156 * 2, 12 * 2, 53 * 2, -11 * 2, -11 * 2, 3 * 2};/* ..................... End of table coef_qmf[] ..................... *//*___________________________________________________________________________ Function Name : qmf_tx Purpose : G722 QMF analysis (encoder) filter. Uses coefficients in array coef_qmf[] defined above. Inputs : xin0 - first sample for the QMF filter (read-only) xin1 - secon sample for the QMF filter (read-only) xl - lower band portion of samples xin0 and xin1 (write-only) xh - higher band portion of samples xin0 and xin1 (write-only) s - pointer to state variable structure (read/write) Return Value : None. ___________________________________________________________________________*/#define delayx s->qmf_tx_delayxvoid qmf_tx (xin0, xin1, xl, xh, s)Word16 xin0;Word16 xin1;Word16 *xl;Word16 *xh;g722_state *s;{ /* Local variables */ int i, j; Word32 accuma, accumb; Word32 comp_low, comp_high; /* Variable initialization */ if (s->init_qmf_tx == 0) { s->init_qmf_tx = 1; for (j = 0; j < 24; j++) { delayx[j] = 0; } } /* Saving past samples in delay line */ delayx[1] = xin1; delayx[0] = xin0; /* QMF filtering */ accuma = 0L; accumb = 0L; for (i = 0, j = 0; i < 12; i++) { accuma = accuma + (Word32) coef_qmf[j] * delayx[j]; j++; accumb = accumb + (Word32) coef_qmf[j] * delayx[j]; j++; } /* Descaling and shift of the delay line */ for (j = 0; j < 22; j++) { delayx[23 - j] = delayx[21 - j]; } comp_low = L_add (accuma, accumb); comp_low = L_add (comp_low, comp_low); comp_high = L_add (accuma, (-accumb)); comp_high = L_add (comp_high, comp_high); *xl = limit ((Word16) L_shr (comp_low, (Word16) 16)); *xh = limit ((Word16) L_shr (comp_high, (Word16) 16));}#undef delayx/* ..................... End of qmf_tx() ..................... *//*___________________________________________________________________________ Function Name : qmf_rx G722 QMF synthesis (decoder) filter. Uses coefficients in array coef_qmf[] defined above. Inputs : xout0 - first sample out of the QMF filter (write-only) xout1 - secon sample out of the QMF filter (write-only) rl - lower band portion of a sample (read-only) rh - higher band portion of a sample (read-only) s - pointer to state variable structure (read/write) Return Value : None. ___________________________________________________________________________*/#define delayx s->qmf_rx_delayxvoid qmf_rx (rl, rh, xout1, xout2, s)Word16 rl;Word16 rh;Word16 *xout1;Word16 *xout2;g722_state *s;{ /* definition of the local variables */ int i, j; Word32 accuma, accumb; Word32 comp_low, comp_high; Word16 xd, xs; /* initialisation des variables */ if (s->init_qmf_rx == 0) { s->init_qmf_rx = 1; for (j = 0; j < 24; j++) { delayx[j] = 0; } } /* calcul de xs et xd
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -