📄 dec_amr.c
字号:
/* If there was no DTX muting, the first speech frame is not */ /* muted. The BFH state machine starts from state 5, however, to */ /* keep the audible noise resulting from a SID frame which is */ /* erroneously interpreted as a good speech frame as small as */ /* possible (the decoder output in this case is quickly muted) */ test(); if (sub(st->dtxDecoderState->dtxGlobalState, DTX) == 0) { st->state = 5; move16 (); st->prev_bf = 0; move16 (); } else if (test (), sub(st->dtxDecoderState->dtxGlobalState, DTX_MUTE) == 0) { st->state = 5; move16 (); st->prev_bf = 1; move16 (); } /* save old LSFs for CB gain smoothing */ Copy (st->lsfState->past_lsf_q, prev_lsf, M); /* decode LSF parameters and generate interpolated lpc coefficients for the 4 subframes */ test (); if (sub (mode, MR122) != 0) { D_plsf_3(st->lsfState, mode, bfi, parm, lsp_new); fwc (); /* function worst case */ /* Advance synthesis parameters pointer */ parm += 3; move16 (); Int_lpc_1to3(st->lsp_old, lsp_new, A_t); } else { D_plsf_5 (st->lsfState, bfi, parm, lsp_mid, lsp_new); fwc (); /* function worst case */ /* Advance synthesis parameters pointer */ parm += 5; move16 (); Int_lpc_1and3 (st->lsp_old, lsp_mid, lsp_new, A_t); } /* update the LSPs for the next frame */ for (i = 0; i < M; i++) { st->lsp_old[i] = lsp_new[i]; move16 (); } fwc (); /* function worst case */ /*------------------------------------------------------------------------* * Loop for every subframe in the analysis frame * *------------------------------------------------------------------------* * The subframe size is L_SUBFR and the loop is repeated L_FRAME/L_SUBFR * * times * * - decode the pitch delay * * - decode algebraic code * * - decode pitch and codebook gains * * - find the excitation and compute synthesis speech * *------------------------------------------------------------------------*/ /* pointer to interpolated LPC parameters */ Az = A_t; move16 (); evenSubfr = 0; move16(); subfrNr = -1; move16(); for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) { subfrNr = add(subfrNr, 1); evenSubfr = sub(1, evenSubfr); /* flag for first and 3th subframe */ pit_flag = i_subfr; move16 (); test(); if (sub (i_subfr, L_FRAME_BY2) == 0) { test(); test(); if (sub(mode, MR475) != 0 && sub(mode, MR515) != 0) { pit_flag = 0; move16 (); } } /* pitch index */ index = *parm++; move16 (); /*-------------------------------------------------------* * - decode pitch lag and find adaptive codebook vector. * *-------------------------------------------------------*/ test (); if (sub(mode, MR122) != 0) { /* flag4 indicates encoding with 4 bit resolution; */ /* this is needed for mode MR475, MR515, MR59 and MR67 */ flag4 = 0; move16 (); test (); test (); test (); test (); if ((sub (mode, MR475) == 0) || (sub (mode, MR515) == 0) || (sub (mode, MR59) == 0) || (sub (mode, MR67) == 0) ) { flag4 = 1; move16 (); } /*-------------------------------------------------------* * - get ranges for the t0_min and t0_max * * - only needed in delta decoding * *-------------------------------------------------------*/ delta_frc_low = 5; move16(); delta_frc_range = 9; move16(); test (); if ( sub(mode, MR795) == 0 ) { delta_frc_low = 10; move16(); delta_frc_range = 19; move16(); } t0_min = sub(st->old_T0, delta_frc_low); test (); if (sub(t0_min, PIT_MIN) < 0) { t0_min = PIT_MIN; move16(); } t0_max = add(t0_min, delta_frc_range); test (); if (sub(t0_max, PIT_MAX) > 0) { t0_max = PIT_MAX; move16(); t0_min = sub(t0_max, delta_frc_range); } Dec_lag3 (index, t0_min, t0_max, pit_flag, st->old_T0, &T0, &T0_frac, flag4); st->T0_lagBuff = T0; move16 (); test (); if (bfi != 0) { test (); if (sub (st->old_T0, PIT_MAX) < 0) { /* Graceful pitch */ st->old_T0 = add(st->old_T0, 1); /* degradation */ } T0 = st->old_T0; move16 (); T0_frac = 0; move16 (); test (); test (); test (); test (); test (); if ( st->inBackgroundNoise != 0 && sub(st->voicedHangover, 4) > 0 && ((sub(mode, MR475) == 0 ) || (sub(mode, MR515) == 0 ) || (sub(mode, MR59) == 0) ) ) { T0 = st->T0_lagBuff; move16 (); } } fwc (); /* function worst case */ Pred_lt_3or6 (st->exc, T0, T0_frac, L_SUBFR, 1); } else { Dec_lag6 (index, PIT_MIN_MR122, PIT_MAX, pit_flag, &T0, &T0_frac); test (); test (); test (); if ( bfi == 0 && (pit_flag == 0 || sub (index, 61) < 0)) { } else { st->T0_lagBuff = T0; move16 (); T0 = st->old_T0; move16 (); T0_frac = 0; move16 (); } fwc (); /* function worst case */ Pred_lt_3or6 (st->exc, T0, T0_frac, L_SUBFR, 0); } fwc (); /* function worst case */ /*-------------------------------------------------------* * - (MR122 only: Decode pitch gain.) * * - Decode innovative codebook. * * - set pitch sharpening factor * *-------------------------------------------------------*/ test (); test (); if (sub (mode, MR475) == 0 || sub (mode, MR515) == 0) { /* MR475, MR515 */ index = *parm++; /* index of position */ move16 (); i = *parm++; /* signs */ move16 (); fwc (); /* function worst case */ decode_2i40_9bits (subfrNr, i, index, code); fwc (); /* function worst case */ pit_sharp = shl (st->sharp, 1); } else if (sub (mode, MR59) == 0) { /* MR59 */ test (); index = *parm++; /* index of position */ move16 (); i = *parm++; /* signs */ move16 (); fwc (); /* function worst case */ decode_2i40_11bits (i, index, code); fwc (); /* function worst case */ pit_sharp = shl (st->sharp, 1); } else if (sub (mode, MR67) == 0) { /* MR67 */ test (); test (); index = *parm++; /* index of position */ move16 (); i = *parm++; /* signs */ move16 (); fwc (); /* function worst case */ decode_3i40_14bits (i, index, code); fwc (); /* function worst case */ pit_sharp = shl (st->sharp, 1); } else if (sub (mode, MR795) <= 0) { /* MR74, MR795 */ test (); test (); test (); index = *parm++; /* index of position */ move16 (); i = *parm++; /* signs */ move16 (); fwc (); /* function worst case */ decode_4i40_17bits (i, index, code); fwc (); /* function worst case */ pit_sharp = shl (st->sharp, 1); } else if (sub (mode, MR102) == 0) { /* MR102 */ test (); test (); test (); fwc (); /* function worst case */ dec_8i40_31bits (parm, code); parm += 7; move16 (); fwc (); /* function worst case */ pit_sharp = shl (st->sharp, 1); } else { /* MR122 */ test (); test (); test (); index = *parm++; move16 (); test(); if (bfi != 0) { ec_gain_pitch (st->ec_gain_p_st, st->state, &gain_pit); } else { gain_pit = d_gain_pitch (mode, index); move16 (); } ec_gain_pitch_update (st->ec_gain_p_st, bfi, st->prev_bf, &gain_pit); fwc (); /* function worst case */ dec_10i40_35bits (parm, code); parm += 10; move16 (); fwc (); /* function worst case */ /* pit_sharp = gain_pit; */ /* if (pit_sharp > 1.0) pit_sharp = 1.0; */ pit_sharp = shl (gain_pit, 1); } /*-------------------------------------------------------* * - Add the pitch contribution to code[]. * *-------------------------------------------------------*/ for (i = T0; i < L_SUBFR; i++) { temp = mult (code[i - T0], pit_sharp); code[i] = add (code[i], temp); move16 (); } fwc (); /* function worst case */ /*------------------------------------------------------------* * - Decode codebook gain (MR122) or both pitch * * gain and codebook gain (all others) * * - Update pitch sharpening "sharp" with quantized gain_pit * *------------------------------------------------------------*/ if (test(), sub (mode, MR475) == 0) { /* read and decode pitch and code gain */ test(); if (evenSubfr != 0) { index_mr475 = *parm++; move16 (); /* index of gain(s) */ } test(); if (bfi == 0) { Dec_gain(st->pred_state, mode, index_mr475, code, evenSubfr, &gain_pit, &gain_code); } else { ec_gain_pitch (st->ec_gain_p_st, st->state, &gain_pit); ec_gain_code (st->ec_gain_c_st, st->pred_state, st->state, &gain_code); } ec_gain_pitch_update (st->ec_gain_p_st, bfi, st->prev_bf, &gain_pit); ec_gain_code_update (st->ec_gain_c_st, bfi, st->prev_bf, &gain_code); fwc (); /* function worst case */ pit_sharp = gain_pit; move16 (); test (); if (sub (pit_sharp, SHARPMAX) > 0) { pit_sharp = SHARPMAX; move16 (); } } else if (test(), test(), (sub (mode, MR74) <= 0) || (sub (mode, MR102) == 0)) { /* read and decode pitch and code gain */ index = *parm++; move16 (); /* index of gain(s) */ test(); if (bfi == 0) { Dec_gain(st->pred_state, mode, index, code, evenSubfr, &gain_pit, &gain_code); } else { ec_gain_pitch (st->ec_gain_p_st, st->state, &gain_pit); ec_gain_code (st->ec_gain_c_st, st->pred_state, st->state, &gain_code); } ec_gain_pitch_update (st->ec_gain_p_st, bfi, st->prev_bf, &gain_pit); ec_gain_code_update (st->ec_gain_c_st, bfi, st->prev_bf, &gain_code); fwc (); /* function worst case */ pit_sharp = gain_pit; move16 ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -