📄 decld8cp.c
字号:
pA_t = A_t_fwd; m_aq = M; /* update the previous filter for the next frame */ copy(&A_t_fwd[MP1], state->prev_filter, MP1); /*for(i=MP1; i<M_BWDP1; i++) state->prev_filter[i] = (F)0.;*/ set_zero(state->prev_filter + MP1, M_BWDP1 - MP1); } else { int_bwd(A_t_bwd, state->prev_filter, &state->c_int); pA_t = A_t_bwd; m_aq = M_BWD; /* update the previous filter for the next frame */ copy(&A_t_bwd[M_BWDP1], state->prev_filter, M_BWDP1); } /*------------------------------------------------------------------------* * 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 * *------------------------------------------------------------------------*/ for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) { index = *parm++; /* pitch index */ if (i_subfr == 0) { if (rate == G729D) i = 0; /* no pitch parity at 6.4 kb/s */ else i = *parm++; /* get parity check result */ bad_pitch = bfi + i; if( bad_pitch == 0) { dec_lag3cp(index, PIT_MIN, PIT_MAX, i_subfr, &t0, &t0_frac, rate); state->prev_t0 = t0; state->prev_t0_frac = t0_frac; } else { /* Bad frame, or parity error */ if (bfi == 0) printf(" ! Wrong Pitch 1st subfr. ! "); t0 = state->prev_t0; if (rate == G729E) { t0_frac = state->prev_t0_frac; } else { t0_frac = 0; state->prev_t0++; if(state->prev_t0 > PIT_MAX) { state->prev_t0 = PIT_MAX; } } } *t0_first = t0; /* If first frame */ } else { /* second subframe */ if( bfi == 0) { dec_lag3cp(index, PIT_MIN, PIT_MAX, i_subfr, &t0, &t0_frac, rate); state->prev_t0 = t0; state->prev_t0_frac = t0_frac; } else { t0 = state->prev_t0; if (rate == G729E) { t0_frac = state->prev_t0_frac; } else { t0_frac = 0; state->prev_t0++; if (state->prev_t0 > PIT_MAX) state->prev_t0 = PIT_MAX; } } } /*-------------------------------------------------* * - Find the adaptive codebook vector. * *-------------------------------------------------*/ pred_lt_3(&state->exc[i_subfr], t0, t0_frac, L_SUBFR); /* --------------------------------- */ /* pitch tracking for frame erasures */ /* --------------------------------- */ if( rate == G729E) { track_pit(&state->prev_t0, &state->prev_t0_frac, &state->prev_pitch, &state->stat_pitch, &state->pitch_sta, &state->frac_sta); } else { i = state->prev_t0; j = state->prev_t0_frac; track_pit(&i, &j, &state->prev_pitch, &state->stat_pitch, &state->pitch_sta, &state->frac_sta); } /*-------------------------------------------------------* * - Decode innovative codebook. * *-------------------------------------------------------*/ if (bfi != 0) { /* Bad frame */ parm[0] = (int)random_g729c(&state->seed_fer); parm[1] = (int)random_g729c(&state->seed_fer); if (rate == G729E) { parm[2] = (int)random_g729c(&state->seed_fer); parm[3] = (int)random_g729c(&state->seed_fer); parm[4] = (int)random_g729c(&state->seed_fer); } } stationnary = 0; /* to avoid visual warning */ if (rate == G729) { /* case 8 kbps */ decod_ACELP(parm[1], parm[0], code); parm += 2; /* for gain decoding in case of frame erasure */ state->stat_bwd = 0; stationnary = 0; } else if (rate == G729D) { /* case 8 kbps */ decod_ACELP64(parm[1], parm[0], code); parm += 2; /* for gain decoding in case of frame erasure */ state->stat_bwd = 0; stationnary = 0; } else if (rate == G729E) { /* case 11.8 kbps */ if (lp_mode == 0) { dec_ACELP_10i40_35bits(parm, code); /* for gain decoding in case of frame erasure */ state->stat_bwd = 0; stationnary = 0; } else { dec_ACELP_12i40_44bits(parm, code); /* for gain decoding in case of frame erasure */ state->stat_bwd++; if (state->stat_bwd >= 30) { stationnary = 1; state->stat_bwd = 30; } else stationnary = 0; } parm += 5; } /*-------------------------------------------------------* * - Add the fixed-gain pitch contribution to code[]. * *-------------------------------------------------------*/ for (i = t0; i < L_SUBFR; i++) code[i] += state->sharp * code[i-t0]; /*-------------------------------------------------* * - Decode pitch and codebook gains. * *-------------------------------------------------*/ index = *parm++; /* index of energy VQ */ if (rate == G729D) dec_gain_6k(&state->gain_s, index, code, L_SUBFR, bfi, &state->gain_pitch, &state->gain_code); else dec_gaine(&state->gain_s, index, code, L_SUBFR, bfi, &state->gain_pitch, &state->gain_code, rate, state->gain_pit_mem, state->gain_cod_mem, &state->c_muting, state->count_bfi, stationnary); /*-------------------------------------------------------------* * - Update previous gains *-------------------------------------------------------------*/ state->gain_pit_mem = state->gain_pitch; state->gain_cod_mem = state->gain_code; /*-------------------------------------------------------------* * - Update pitch sharpening "sharp" with quantized gain_pitch * *-------------------------------------------------------------*/ state->sharp = state->gain_pitch; if (state->sharp > SHARPMAX) state->sharp = SHARPMAX; if (state->sharp < SHARPMIN) state->sharp = SHARPMIN; /*-------------------------------------------------------* * - Find the total excitation. * * - Find synthesis speech corresponding to exc[]. * *-------------------------------------------------------*/ if (bfi != 0) { /* Bad frame */ state->count_bfi++; if (voicing == 0 ) { g_p = (F)0.; g_c = state->gain_code; } else { g_p = state->gain_pitch; g_c = (F)0.; } } else { g_p = state->gain_pitch; g_c = state->gain_code; } for (i = 0; i < L_SUBFR; i++) { state->exc[i+i_subfr] = g_p * state->exc[i+i_subfr] + g_c * code[i]; } if (rate == G729D) { PhDisp(&state->cng_s.phdisp_s, &state->exc[i_subfr], exc_phdisp, state->gain_code, state->gain_pitch, code); syn_filte(m_aq, pA_t, exc_phdisp, &synth[i_subfr], L_SUBFR, &state->mem_syn[M_BWD-m_aq], 0); } else { syn_filte(m_aq, pA_t, &state->exc[i_subfr], &synth[i_subfr], L_SUBFR, &state->mem_syn[M_BWD-m_aq], 0); /* Updates state machine for phase dispersion in 6.4 kbps mode, if running at other rate */ Update_PhDisp(&state->cng_s.phdisp_s, state->gain_pitch, state->gain_code); } copy(&synth[i_subfr+L_SUBFR-M_BWD], state->mem_syn, M_BWD); pA_t += m_aq+1; /* interpolated LPC parameters for next subframe */ } } /*------------* * For G729b *-----------*/ if (bfi == 0) { state->sid_sav = (FLOAT)0.0; for(i=0; i<L_FRAME; i++) { state->sid_sav += state->exc[i] * state->exc[i]; } } state->past_ftyp = ftyp; /*------------* * For G729E *-----------*/ energy = ener_dB(synth, L_FRAME); if (energy >= (F)40.) tst_bwd_dominant(&state->bwd_s, bwd_dominant, lp_mode); /*--------------------------------------------------* * Update signal for next frame. * * -> shift to the left by L_FRAME exc[] * *--------------------------------------------------*/ copy(&state->old_exc[L_FRAME], &state->old_exc[0], PIT_MAX+L_INTERPOL); if (lp_mode == 0) { copy(A_t_fwd, Az_dec, 2*MP1); *m_pst = M; } else { copy(A_t_bwd, Az_dec, 2*M_BWDP1); *m_pst = M_BWD; } state->prev_bfi = bfi; state->prev_lp_mode = lp_mode; state->prev_voicing = voicing; if (bfi != 0) state->c_fe = (F)1.; else { if (lp_mode == 0) state->c_fe = 0; else { if (*bwd_dominant == 1) state->c_fe -= (F)0.1; else state->c_fe -= (F)0.5; if (state->c_fe < 0) state->c_fe = 0; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -