📄 dec_amr.c
字号:
test (); if (sub (pit_sharp, SHARPMAX) > 0) { pit_sharp = SHARPMAX; move16 (); } if (sub (mode, MR102) == 0) { if (sub (st->old_T0, add(L_SUBFR, 5)) > 0) { pit_sharp = shr(pit_sharp, 2); } } } else { /* read and decode pitch gain */ index = *parm++; move16 (); /* index of gain(s) */ test (); if (sub (mode, MR795) == 0) { /* decode pitch gain */ 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); /* read and decode code gain */ index = *parm++; move16 (); test(); if (bfi == 0) { d_gain_code (st->pred_state, mode, index, code, &gain_code); } else { ec_gain_code (st->ec_gain_c_st, st->pred_state, st->state, &gain_code); } 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 { /* MR122 */ test(); if (bfi == 0) { d_gain_code (st->pred_state, mode, index, code, &gain_code); } else { ec_gain_code (st->ec_gain_c_st, st->pred_state, st->state, &gain_code); } ec_gain_code_update (st->ec_gain_c_st, bfi, st->prev_bf, &gain_code); fwc (); /* function worst case */ pit_sharp = gain_pit; move16 (); } } /* store pitch sharpening for next subframe */ /* (for modes which use the previous pitch gain for pitch sharpening in the search phase) */ /* do not update sharpening in even subframes for MR475 */ test(); test(); if (sub(mode, MR475) != 0 || evenSubfr == 0) { st->sharp = gain_pit; move16 (); test (); if (sub (st->sharp, SHARPMAX) > 0) { st->sharp = SHARPMAX; move16 (); } } pit_sharp = shl (pit_sharp, 1); test (); if (sub (pit_sharp, 16384) > 0) { for (i = 0; i < L_SUBFR; i++) { temp = mult (st->exc[i], pit_sharp); L_temp = L_mult (temp, gain_pit); test (); if (sub(mode, MR122)==0) { L_temp = L_shr (L_temp, 1); } excp[i] = round (L_temp); move16 (); } } /*-------------------------------------------------------* * - Store list of LTP gains needed in the source * * characteristic detector (SCD) * *-------------------------------------------------------*/ test (); if ( bfi == 0 ) { for (i = 0; i < 8; i++) { st->ltpGainHistory[i] = st->ltpGainHistory[i+1]; move16 (); } st->ltpGainHistory[8] = gain_pit; move16 (); } /*-------------------------------------------------------* * - Limit gain_pit if in background noise and BFI * * for MR475, MR515, MR59 * *-------------------------------------------------------*/ test (); test (); test (); test (); test (); test (); if ( (st->prev_bf != 0 || bfi != 0) && st->inBackgroundNoise != 0 && ((sub(mode, MR475) == 0) || (sub(mode, MR515) == 0) || (sub(mode, MR59) == 0)) ) { test (); if ( sub (gain_pit, 12288) > 0) /* if (gain_pit > 0.75) in Q14*/ gain_pit = add( shr( sub(gain_pit, 12288), 1 ), 12288 ); /* gain_pit = (gain_pit-0.75)/2.0 + 0.75; */ test (); if ( sub (gain_pit, 14745) > 0) /* if (gain_pit > 0.90) in Q14*/ { gain_pit = 14745; move16 (); } } /*-------------------------------------------------------* * Calculate CB mixed gain * *-------------------------------------------------------*/ Int_lsf(prev_lsf, st->lsfState->past_lsf_q, i_subfr, lsf_i); gain_code_mix = Cb_gain_average( st->Cb_gain_averState, mode, gain_code, lsf_i, st->lsp_avg_st->lsp_meanSave, bfi, st->prev_bf, pdfi, st->prev_pdf, st->inBackgroundNoise, st->voicedHangover); move16 (); /* make sure that MR74, MR795, MR122 have original code_gain*/ test(); if ((sub(mode, MR67) > 0) && (sub(mode, MR102) != 0) ) /* MR74, MR795, MR122 */ { gain_code_mix = gain_code; move16 (); } /*-------------------------------------------------------* * - Find the total excitation. * * - Find synthesis speech corresponding to st->exc[]. * *-------------------------------------------------------*/ test (); if (sub(mode, MR102) <= 0) /* MR475, MR515, MR59, MR67, MR74, MR795, MR102*/ { pitch_fac = gain_pit; move16 (); tmp_shift = 1; move16 (); } else /* MR122 */ { pitch_fac = shr (gain_pit, 1); move16 (); tmp_shift = 2; move16 (); } /* copy unscaled LTP excitation to exc_enhanced (used in phase * dispersion below) and compute total excitation for LTP feedback */ for (i = 0; i < L_SUBFR; i++) { exc_enhanced[i] = st->exc[i]; move16 (); /* st->exc[i] = gain_pit*st->exc[i] + gain_code*code[i]; */ L_temp = L_mult (st->exc[i], pitch_fac); /* 12.2: Q0 * Q13 */ /* 7.4: Q0 * Q14 */ L_temp = L_mac (L_temp, code[i], gain_code); /* 12.2: Q12 * Q1 */ /* 7.4: Q13 * Q1 */ L_temp = L_shl (L_temp, tmp_shift); /* Q16 */ st->exc[i] = round (L_temp); move16 (); } /*-------------------------------------------------------* * - Adaptive phase dispersion * *-------------------------------------------------------*/ ph_disp_release(st->ph_disp_st); /* free phase dispersion adaption */ test (); test (); test (); test (); test (); test (); if ( ((sub(mode, MR475) == 0) || (sub(mode, MR515) == 0) || (sub(mode, MR59) == 0)) && sub(st->voicedHangover, 3) > 0 && st->inBackgroundNoise != 0 && bfi != 0 ) { ph_disp_lock(st->ph_disp_st); /* Always Use full Phase Disp. */ } /* if error in bg noise */ /* apply phase dispersion to innovation (if enabled) and compute total excitation for synthesis part */ ph_disp(st->ph_disp_st, mode, exc_enhanced, gain_code_mix, gain_pit, code, pitch_fac, tmp_shift); /*-------------------------------------------------------* * - The Excitation control module are active during BFI.* * - Conceal drops in signal energy if in bg noise. * *-------------------------------------------------------*/ L_temp = 0; move32 (); for (i = 0; i < L_SUBFR; i++) { L_temp = L_mac (L_temp, exc_enhanced[i], exc_enhanced[i] ); } L_temp = L_shr (L_temp, 1); /* excEnergy = sqrt(L_temp) in Q0 */ L_temp = sqrt_l_exp(L_temp, &temp); move32 (); /* function result */ L_temp = L_shr(L_temp, add( shr(temp, 1), 15)); L_temp = L_shr(L_temp, 2); /* To cope with 16-bit and */ excEnergy = extract_l(L_temp); /* scaling in ex_ctrl() */ test (); test (); test (); test (); test (); test (); test (); test (); test (); test (); if ( ((sub (mode, MR475) == 0) || (sub (mode, MR515) == 0) || (sub (mode, MR59) == 0)) && sub(st->voicedHangover, 5) > 0 && st->inBackgroundNoise != 0 && sub(st->state, 4) < 0 && ( (pdfi != 0 && st->prev_pdf != 0) || bfi != 0 || st->prev_bf != 0) ) { carefulFlag = 0; move32 (); test (); test (); if ( pdfi != 0 && bfi == 0 ) { carefulFlag = 1; move16 (); } Ex_ctrl(exc_enhanced, excEnergy, st->excEnergyHist, st->voicedHangover, st->prev_bf, carefulFlag); } test (); test (); test (); test (); if ( st->inBackgroundNoise != 0 && ( bfi != 0 || st->prev_bf != 0 ) && sub(st->state, 4) < 0 ) { ; /* do nothing! */ } else { /* Update energy history for all modes */ for (i = 0; i < 8; i++) { st->excEnergyHist[i] = st->excEnergyHist[i+1]; move16 (); } st->excEnergyHist[8] = excEnergy; move16 (); } /*-------------------------------------------------------* * Excitation control module end. * *-------------------------------------------------------*/ fwc (); /* function worst case */ test (); if (sub (pit_sharp, 16384) > 0) { for (i = 0; i < L_SUBFR; i++) { excp[i] = add (excp[i], exc_enhanced[i]); move16 (); } agc2 (exc_enhanced, excp, L_SUBFR); Overflow = 0; move16 (); Syn_filt (Az, excp, &synth[i_subfr], L_SUBFR, st->mem_syn, 0); } else { Overflow = 0; move16 (); Syn_filt (Az, exc_enhanced, &synth[i_subfr], L_SUBFR, st->mem_syn, 0); } test (); if (Overflow != 0) /* Test for overflow */ { for (i = 0; i < PIT_MAX + L_INTERPOL + L_SUBFR; i++) { st->old_exc[i] = shr(st->old_exc[i], 2); move16 (); } for (i = 0; i < L_SUBFR; i++) { exc_enhanced[i] = shr(exc_enhanced[i], 2); move16 (); } Syn_filt(Az, exc_enhanced, &synth[i_subfr], L_SUBFR, st->mem_syn, 1); } else { Copy(&synth[i_subfr+L_SUBFR-M], st->mem_syn, M); } /*--------------------------------------------------* * Update signal for next frame. * * -> shift to the left by L_SUBFR st->exc[] * *--------------------------------------------------*/ Copy (&st->old_exc[L_SUBFR], &st->old_exc[0], PIT_MAX + L_INTERPOL); fwc (); /* function worst case */ /* interpolated LPC parameters for next subframe */ Az += MP1; move16 (); /* store T0 for next subframe */ st->old_T0 = T0; move16 (); } /*-------------------------------------------------------* * Call the Source Characteristic Detector which updates * * st->inBackgroundNoise and st->voicedHangover. * *-------------------------------------------------------*/ move16 (); /* function result */ st->inBackgroundNoise = Bgn_scd(st->background_state, &(st->ltpGainHistory[0]), &(synth[0]), &(st->voicedHangover) ); dtx_dec_activity_update(st->dtxDecoderState, st->lsfState->past_lsf_q, synth); fwc (); /* function worst case */ /* store bfi for next subframe */ st->prev_bf = bfi; move16 (); st->prev_pdf = pdfi; move16 (); /*--------------------------------------------------* * Calculate the LSF averages on the eight * * previous frames * *--------------------------------------------------*/ lsp_avg(st->lsp_avg_st, st->lsfState->past_lsf_q); fwc (); /* function worst case */the_end: st->dtxDecoderState->dtxGlobalState = newDTXState; move16(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -