📄 codld8cp.c
字号:
state->old_A_bwd, state->old_rc_bwd ); /* Tests saturation of A_t_bwd */ sat_filter = 0; for (i=M_BWDP1; i<2*M_BWDP1; i++) if (A_t_bwd[i] >= (F)8.) sat_filter = 1; if (sat_filter == 1) copy(state->A_t_bwd_mem, &A_t_bwd[M_BWDP1], M_BWDP1); else copy(&A_t_bwd[M_BWDP1], state->A_t_bwd_mem, M_BWDP1); /* Additional bandwidth expansion on backward filter */ weight_az(&A_t_bwd[M_BWDP1], GAMMA_BWD, M_BWD, &A_t_bwd[M_BWDP1]); } /*--------------------------------------------------* * Update synthesis signal for next frame. * *--------------------------------------------------*/ copy(&state->synth[L_FRAME], &state->synth[0], MEM_SYN_BWD); /*--------------------------------------------------------------------* * Find interpolated LPC parameters in all subframes unquantized. * * The interpolated parameters are in array A_t[] of size (M+1)*4 * *---------------------------------------------------------------------*/ if(state->prev_lp_mode == 0) { int_lpc(state->lsp_old, lsp_new, lsf_int, lsf_new, A_t_fwd); } else { /* no interpolation */ /* unquantized */ lsp_az(lsp_new, A_t_fwd); /* Subframe 1 */ lsp_lsf(lsp_new, lsf_new, M); /* transformation from LSP to LSF (freq.domain) */ copy(lsf_new, lsf_int, M); /* Subframe 1 */ } if (Vad) { /* ---------------- */ /* LSP quantization */ /* ---------------- */ qua_lspe(lsp_new, lsp_new_q, code_lsp, state->lsp_s.freq_prev, freq_cur); /*-------------------------------------------------------------------* * Find interpolated LPC parameters in all subframes quantized. * * and the quantized interpolated parameters are in array Aq_t[] * *--------------------------------------------------------------------*/ if(state->prev_lp_mode == 0) { int_qlpc(state->lsp_old_q, lsp_new_q, A_t_fwd_q); } else { /* no interpolation */ lsp_az(lsp_new_q, &A_t_fwd_q[MP1]); /* Subframe 2 */ copy(&A_t_fwd_q[MP1], A_t_fwd_q, MP1); /* Subframe 1 */ } /*---------------------------------------------------------------------* * - Decision for the switch Forward / Backward * *---------------------------------------------------------------------*/ if(rate == G729E) { set_lpc_mode(&state->bwd_s, state->speech, A_t_fwd_q, A_t_bwd, &lp_mode, lsp_new, state->lsp_old, &state->bwd_dominant, state->prev_lp_mode, state->prev_filter, &state->C_int, &state->glob_stat, &state->stat_bwd, &state->val_stat_bwd); } else update_bwd(&lp_mode, &state->bwd_dominant, &state->C_int, &state->glob_stat); } else update_bwd(&lp_mode, &state->bwd_dominant, &state->C_int, &state->glob_stat); /* ---------------------------------- */ /* update the LSPs for the next frame */ /* ---------------------------------- */ copy(lsp_new, state->lsp_old, M); /*----------------------------------------------------------------------* * - Find the weighted input speech w_sp[] for the whole speech frame * *----------------------------------------------------------------------*/ if(lp_mode == 0) { m_ap = M; if (state->bwd_dominant == 0) Ap = A_t_fwd; else Ap = A_t_fwd_q; perc_var(&state->pwf_s, state->gamma1, state->gamma2, lsf_int, lsf_new, rc_fwd); } else { if (state->bwd_dominant == 0) { m_ap = M; Ap = A_t_fwd; } else { m_ap = M_BWD; Ap = A_t_bwd; } perc_vare(state->gamma1, state->gamma2, state->bwd_dominant); } pAp = Ap; for (i=0; i<2; i++) { weight_az(pAp, state->gamma1[i], m_ap, Ap1); weight_az(pAp, state->gamma2[i], m_ap, Ap2); residue(m_ap, Ap1, &state->speech[i*L_SUBFR], &state->wsp[i*L_SUBFR], L_SUBFR); syn_filte(m_ap, Ap2, &state->wsp[i*L_SUBFR], &state->wsp[i*L_SUBFR], L_SUBFR, &state->mem_w[M_BWD-m_ap], 0); /*for (j=0; j<M_BWD; j++) state->mem_w[j] = state->wsp[i*L_SUBFR+L_SUBFR-M_BWD+j];*/ copy(state->wsp+i*L_SUBFR+L_SUBFR-M_BWD, state->mem_w, M_BWD); pAp += m_ap+1; } /* ---------------------- */ /* Case of Inactive frame */ /* ---------------------- */ if (!Vad) { /*for (i=0; i<MA_NP; i++) copy(&state->lsp_s.freq_prev[i][0], &lsfq_mem[i][0], M);*/ get_freq_prev((const FLOAT (*)[M]) state->lsp_s.freq_prev, lsfq_mem); cod_cng(&state->cng_s, state->exc, state->pastVad, state->lsp_old_q, state->old_A_fwd, state->old_rc_fwd, A_t_fwd_q, ana, lsfq_mem, &state->seed); /*for (i=0; i<MA_NP; i++) copy(&lsfq_mem[i][0], &state->lsp_s.freq_prev[i][0], M);*/ update_freq_prev(state->lsp_s.freq_prev, (const FLOAT (*)[M]) lsfq_mem); state->ppastVad = state->pastVad; state->pastVad = Vad; /* UPDATE wsp, mem_w, mem_syn, mem_err, and mem_w0 */ pAp = A_t_fwd; /* pointer to interpolated LPC parameters */ pAq = A_t_fwd_q; /* pointer to interpolated quantized LPC parameters */ i_gamma = 0; for (i_subfr=0; i_subfr < L_FRAME; i_subfr += L_SUBFR) { weight_az(pAp, state->gamma1[i_gamma], M, Ap1); weight_az(pAp, state->gamma2[i_gamma], M, Ap2); i_gamma++; /* update mem_syn */ syn_filte(M, pAq, &state->exc[i_subfr], &state->synth_ptr[i_subfr], L_SUBFR, &state->mem_syn[M_BWD-M], 0); /*for(j=0; j<M_BWD; j++) state->mem_syn[j] = state->synth_ptr[i_subfr+L_SUBFR-M_BWD+j];*/ copy(state->synth_ptr+i_subfr+L_SUBFR-M_BWD, state->mem_syn, M_BWD); /* update mem_w0 */ for (i=0; i<L_SUBFR; i++) state->error[i] = state->speech[i_subfr+i] - state->synth_ptr[i_subfr+i]; residue(M, Ap1, state->error, xn, L_SUBFR); syn_filte(M, Ap2, xn, xn, L_SUBFR, &state->mem_w0[M_BWD-M], 0); /*for(j=0; j<M_BWD; j++) state->mem_w0[j] = xn[L_SUBFR-M_BWD+j];*/ copy(xn+L_SUBFR-M_BWD, state->mem_w0, M_BWD); /* update mem_err */ /*for (i = L_SUBFR-M_BWD, j = 0; i < L_SUBFR; i++, j++) state->mem_err[j] = state->error[i];*/ copy(state->error+L_SUBFR-M_BWD, state->mem_err, M_BWD); for (i = 0; i < 4; i++) state->pgain_buf[i] = state->pgain_buf[i+1]; state->pgain_buf[4] = (F)0.5; pAp += MP1; pAq += MP1; } /* update previous filter for next frame */ copy(&A_t_fwd_q[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); state->prev_lp_mode = lp_mode; state->pit_sharp = SHARPMIN; /* Update memories for next frames */ copy(&state->old_speech[L_FRAME], &state->old_speech[0], L_TOTAL-L_FRAME); copy(&state->old_wsp[L_FRAME], &state->old_wsp[0], PIT_MAX); copy(&state->old_exc[L_FRAME], &state->old_exc[0], PIT_MAX+L_INTERPOL); return; } /* End of inactive frame case */ /* -------------------- */ /* Case of Active frame */ /* -------------------- */ *ana++ = rate+2; /* bit rate mode */ if (lp_mode == 0) { m_aq = M; Aq = A_t_fwd_q; /* update previous filter for next frame */ copy(&Aq[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); /*for(j=MP1; j<M_BWDP1; j++) state->ai_zero[j] = (F)0.;*/ set_zero(state->ai_zero + MP1, M_BWDP1 - MP1); } else { m_aq = M_BWD; Aq = A_t_bwd; if (state->bwd_dominant == 0) /*for(j=MP1; j<M_BWDP1; j++) state->ai_zero[j] = (F)0.;*/ set_zero(state->ai_zero + MP1, M_BWDP1 - MP1); /* update previous filter for next frame */ copy(&Aq[M_BWDP1], state->prev_filter, M_BWDP1); } if(dtx_enable) { state->seed = INIT_SEED; state->ppastVad = state->pastVad; state->pastVad = Vad; } if (rate == G729E) *ana++ = lp_mode; if( lp_mode == 0) { copy(lsp_new_q, state->lsp_old_q, M); lsp_prev_update(freq_cur, state->lsp_s.freq_prev); *ana++ = code_lsp[0]; *ana++ = code_lsp[1]; } /*--------------------------------------------------------------------* * - Find the open-loop pitch delay for the whole speech frame * * - Set the range for searching closed-loop pitch in 1st subframe * *--------------------------------------------------------------------*/ T_op = pitch_ol(state->wsp, PIT_MIN, PIT_MAX, L_FRAME); for (i= 0; i < 4; i++) state->lag_buf[i] = state->lag_buf[i+1]; avg_lag = AVG(state->lag_buf[0], state->lag_buf[1], state->lag_buf[2], state->lag_buf[3]); if( abs( (int) (T_op/2.0) - avg_lag)<=2) state->lag_buf[4] = (int) (T_op/2.0); else if( abs((int) (T_op/3.0) - avg_lag)<=2) state->lag_buf[4] = (int) (T_op/3.0); else state->lag_buf[4] = T_op; /* Range for closed loop pitch search in 1st subframe */ t0_min = T_op - 3; if (t0_min < PIT_MIN) t0_min = PIT_MIN; t0_max = t0_min + 6; if (t0_max > PIT_MAX) { t0_max = PIT_MAX; t0_min = t0_max - 6;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -