From 55146b977a608485aab3f10e8d52f055c231f347 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 10 Feb 2025 15:02:12 +0100 Subject: [PATCH 01/28] REMOVE_EVS_DUPLICATES in acelp_core_dec_fx() --- lib_com/gs_inact_switching_fx.c | 65 +++++++++++++++++++++++++------- lib_com/gs_noisefill_fx.c | 55 ++++++++++++++++++--------- lib_com/options.h | 2 + lib_com/prot_fx.h | 3 ++ lib_dec/FEC_scale_syn_fx.c | 10 +++++ lib_dec/acelp_core_dec_fx.c | 57 +++++++++++++++++++++++++++- lib_dec/acelp_core_dec_ivas_fx.c | 15 +++++++- lib_dec/dec_gen_voic_fx.c | 14 ++++++- lib_dec/gs_dec_fx.c | 12 +++++- 9 files changed, 196 insertions(+), 37 deletions(-) diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index 5dfe6b1d6..52635d502 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -253,31 +253,68 @@ void Inac_switch_ematch_ivas_fx( exp = sub( exp, 14 ); IF( LT_16( i, 2 ) ) { - FOR( j = 0; j < 8; j++ ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( element_mode, EVS_MONO ) ) { - L_tmp = L_mult0( *pt_exc, ftmp ); - L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ - *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ - move16(); - pt_exc++; + FOR( j = 0; j < 8; j++ ) + { + L_tmp = L_mult( *pt_exc, ftmp ); + L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ + move16(); + pt_exc++; + } + } + ELSE +#endif + { + FOR( j = 0; j < 8; j++ ) + { + L_tmp = L_mult0( *pt_exc, ftmp ); + L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ + move16(); + pt_exc++; + } } } ELSE { - FOR( j = 0; j < 16; j++ ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( element_mode, EVS_MONO ) ) { - L_tmp = L_mult0( *pt_exc, ftmp ); - L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ - *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ - move16(); - pt_exc++; + FOR( j = 0; j < 16; j++ ) + { + L_tmp = L_mult( *pt_exc, ftmp ); + L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ + move16(); + pt_exc++; + } + } + ELSE +#endif + { + FOR( j = 0; j < 16; j++ ) + { + L_tmp = L_mult0( *pt_exc, ftmp ); + L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ + move16(); + pt_exc++; + } } } } /* Going back to time */ - Scale_sig( dct_exc_tmp, 240, 1 ); // Q_exc - Scale_sig( exc2, 240, 1 ); // Q_exc +#ifdef REMOVE_EVS_DUPLICATES + IF( GT_16( element_mode, EVS_MONO ) ) +#endif + { + Scale_sig( dct_exc_tmp, 240, 1 ); // Q_exc + Scale_sig( exc2, 240, 1 ); // Q_exc + } edct_16fx( dct_exc_tmp, exc2, L_frame, 5, element_mode ); } diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index d2a576dbe..5cf285bf2 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1412,32 +1412,51 @@ void highband_exc_dct_in_ivas_fx( } } #endif - Word16 Q_tmp = *Q_exc; - move16(); - Word16 Q_old = *Q_exc; - move16(); - Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); - IF( exc_wo_nf != NULL ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( element_mode, EVS_MONO ) ) { - Comp_and_apply_gain_ivas_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, &Q_tmp ); - IF( GT_16( Q_tmp, *Q_exc ) ) - { - Scale_sig( exc_wo_nf, L_frame, sub( *Q_exc, Q_tmp ) ); - } - ELSE IF( LT_16( Q_tmp, *Q_exc ) ) + Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); + + IF( exc_wo_nf != NULL ) { - Scale_sig( exc_diffQ, L_frame, sub( Q_tmp, *Q_exc ) ); - *Q_exc = Q_tmp; - move16(); + Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); + Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } - Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); - Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } ELSE { - Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); +#endif + Word16 Q_tmp = *Q_exc; + move16(); + Word16 Q_old = *Q_exc; + move16(); + Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); + + IF( exc_wo_nf != NULL ) + { + Comp_and_apply_gain_ivas_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, &Q_tmp ); + IF( GT_16( Q_tmp, *Q_exc ) ) + { + Scale_sig( exc_wo_nf, L_frame, sub( *Q_exc, Q_tmp ) ); + } + ELSE IF( LT_16( Q_tmp, *Q_exc ) ) + { + Scale_sig( exc_diffQ, L_frame, sub( Q_tmp, *Q_exc ) ); + *Q_exc = Q_tmp; + move16(); + } + Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); + Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); + } + ELSE + { + Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); + } +#ifdef REMOVE_EVS_DUPLICATES } +#endif + /*--------------------------------------------------------------------------------------* * add the correction layer to the LF bins, * and add the quantized pulses or the noise for the higher part of the spectrum diff --git a/lib_com/options.h b/lib_com/options.h index 1b2c15f87..c34882a0e 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -154,4 +154,6 @@ #define FIX_ISSUE_1245 /* Ittiam: Fix for issue 1245: Basop Encoder: Audible noise for silent Stereo input DTX on @24.4 kbps, @32 kbps*/ #define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */ #define SVD_WMOPS_OPT /* Ittiam : SVD related optimizations */ + +#define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions */ #endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index fbd3b27f3..bef07e952 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8242,6 +8242,9 @@ void FEC_scale_syn_ivas_fx( Word16 *mem_syn, /* o: initial synthesis filter states */ Word16 Q_exc, Word16 Q_syn, +#ifdef REMOVE_EVS_DUPLICATES + const Word16 element_mode, /* i : element mode */ +#endif const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ const Word16 force_scaling /* i: force scaling */ ); diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c index d664aa9fb..f6439b166 100644 --- a/lib_dec/FEC_scale_syn_fx.c +++ b/lib_dec/FEC_scale_syn_fx.c @@ -641,6 +641,9 @@ void FEC_scale_syn_ivas_fx( Word16 *mem_syn, /* o: initial synthesis filter states Q_syn*/ Word16 Q_exc, Word16 Q_syn, +#ifdef REMOVE_EVS_DUPLICATES + const Word16 element_mode, /* i : element mode */ +#endif const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ const Word16 force_scaling /* i: force scaling */ ) @@ -735,8 +738,15 @@ void FEC_scale_syn_ivas_fx( /*-----------------------------------------------------------------* * Find the energy/gain at the end of the frame *-----------------------------------------------------------------*/ + tmp = sub( 3, getScaleFactor16( synth, L_frame ) ); + +#ifdef REMOVE_EVS_DUPLICATES + test(); + IF( tmp > 0 && GT_16( element_mode, EVS_MONO ) ) +#else IF( tmp > 0 ) +#endif { Word16 synth_tmp[L_FRAME16k]; Copy_Scale_sig( synth, synth_tmp, L_frame, -tmp ); // Q_synth - tmp diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index a41a0c813..e3770b997 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -777,14 +777,21 @@ ivas_error acelp_core_dec_fx( move16(); } +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); - +#endif test(); test(); IF( EQ_16( st_fx->coder_type, TRANSITION ) && LT_16( tc_subfr_fx, L_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) { +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#endif } } @@ -827,8 +834,12 @@ ivas_error acelp_core_dec_fx( if ( !tdm_lp_reuse_flag ) #endif { +#ifdef REMOVE_EVS_DUPLICATES + lsf_dec_ivas_fx( st_fx, tc_subfr_fx, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, tdm_lsfQ_PCh ); +#else lsf_dec_fx( st_fx, tc_subfr_fx, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, tdm_lsfQ_PCh ); +#endif } #ifdef ADD_LRTD else @@ -953,7 +964,11 @@ ivas_error acelp_core_dec_fx( IF( st_fx->stab_fac_fx == 0 && st_fx->old_bfi_cnt > 0 && NE_16( st_fx->clas_dec, VOICED_CLAS ) && NE_16( st_fx->clas_dec, ONSET ) && st_fx->relax_prev_lsf_interp == 0 && !( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) ) { +#ifdef REMOVE_EVS_DUPLICATES + int_lsp4_ivas_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); +#else int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); +#endif } /*---------------------------------------------------------------* @@ -1005,7 +1020,11 @@ ivas_error acelp_core_dec_fx( ELSE IF( EQ_16( st_fx->coder_type, UNVOICED ) ) { /* UNVOICED frames */ +#ifdef REMOVE_EVS_DUPLICATES + decod_unvoiced_ivas_fx( st_fx, Aq_fx, Es_pred_fx, uc_two_stage_flag, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); +#else decod_unvoiced_fx( st_fx, Aq_fx, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); +#endif } ELSE IF( EQ_16( st_fx->ppp_mode_dec, 1 ) ) { @@ -1026,17 +1045,26 @@ ivas_error acelp_core_dec_fx( } ELSE IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) ) ) { +#ifdef REMOVE_EVS_DUPLICATES + decod_audio_ivas_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf, + 0, 0, 0, NULL ); +#else decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf #ifdef ADD_LRTD , tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf #endif ); +#endif tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ } ELSE { +#ifdef REMOVE_EVS_DUPLICATES + IF( NE_32( ( error = decod_gen_voic_ivas_fx( st_fx, st_fx->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf, 0, NULL ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = decod_gen_voic_fx( st_fx, st_fx->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf /*, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf*/ ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -1049,6 +1077,7 @@ ivas_error acelp_core_dec_fx( /* synthesis for ACELP core switching and SWB BWE */ syn_12k8_fx( st_fx->L_frame, Aq_fx, exc_fx, temp_buf_fx, st_fx->mem_syn1_fx, 1, st_fx->Q_exc, -1 ); + /* save and delay synthesis to be used by SWB BWE */ IF( hBWE_FD != NULL ) { @@ -1059,7 +1088,11 @@ ivas_error acelp_core_dec_fx( * Apply energy matching when switching to inactive frames *-----------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES + Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode, 0, EVS_MONO ); +#else Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode ); +#endif /*------------------------------------------------------------* * Decode information and modify the excitation signal of stationary unvoiced frames *------------------------------------------------------------*/ @@ -1187,9 +1220,16 @@ ivas_error acelp_core_dec_fx( k = add( k, 1 ); } +#ifdef REMOVE_EVS_DUPLICATES + FEC_scale_syn_ivas_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, + &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, + exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 ); + +#else FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); +#endif test(); test(); @@ -1268,8 +1308,13 @@ ivas_error acelp_core_dec_fx( { save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx ); } + /* Apply energy matching when switching to inactive frames */ +#ifdef REMOVE_EVS_DUPLICATES + Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode, 0, EVS_MONO ); +#else Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode ); +#endif /* udate past excitation signals for LD music post-filter */ IF( hMusicPF != NULL ) @@ -1343,9 +1388,15 @@ ivas_error acelp_core_dec_fx( * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES + FEC_scale_syn_ivas_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, + &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, + exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 ); +#else FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); +#endif } /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ @@ -1440,7 +1491,11 @@ ivas_error acelp_core_dec_fx( Copy( syn_fx, temp_buf + L_SYN_MEM, L_FRAME16k ); st_fx->hPFstat->on = 1; move16(); +#ifdef REMOVE_EVS_DUPLICATES + formant_post_filt_ivas_fx( st_fx->hPFstat, temp_buf + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME16k, st_fx->lp_noise, st_fx->total_brate, 0 ); +#else formant_post_filt_fx( st_fx->hPFstat, temp_buf + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME16k, st_fx->lp_noise, st_fx->total_brate, 0 ); +#endif } ELSE IF( GE_16( st_fx->last_bwidth, WB ) ) { diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 24427c5d2..8d6b63833 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -47,12 +47,15 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" +static void rescale_fdCngDec( HANDLE_FD_CNG_DEC hFdCngDec, Word16 old_NoiseExp ); + + /*-------------------------------------------------------------------* * acelp_core_dec_ivas_fx() * * ACELP core decoder *-------------------------------------------------------------------*/ -static void rescale_fdCngDec( HANDLE_FD_CNG_DEC hFdCngDec, Word16 old_NoiseExp ); + ivas_error acelp_core_dec_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/ @@ -350,6 +353,7 @@ ivas_error acelp_core_dec_ivas_fx( int_fs = INT_FS_16k; move16(); } + test(); /* reset post-filter in case of switching */ if ( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) ) @@ -368,6 +372,7 @@ ivas_error acelp_core_dec_ivas_fx( move16(); } test(); + /* TD stereo parameters */ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) { @@ -1225,7 +1230,11 @@ ivas_error acelp_core_dec_ivas_fx( Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6 ); // Q0 FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, +#ifdef REMOVE_EVS_DUPLICATES + exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); +#else exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 ); +#endif test(); test(); test(); @@ -1380,7 +1389,11 @@ ivas_error acelp_core_dec_ivas_fx( FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, +#ifdef REMOVE_EVS_DUPLICATES + exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); +#else exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 ); +#endif } /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 1abd3d58b..190431fb8 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -809,8 +809,18 @@ ivas_error decod_gen_voic_ivas_fx( } ELSE { - enhancer_ivas_fx2( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, - norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, + norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); + } + ELSE +#endif + { + enhancer_ivas_fx2( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, + norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); + } } p_Aq_fx += ( M + 1 ); diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index c237bc987..93c346a7d 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -1514,7 +1514,17 @@ void gsc_dec_ivas_fx( { i--; } - mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ + +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ + } + ELSE +#endif + { + mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ + } #else mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); -- GitLab From ef2485345725198d55c50d1db33506c25ea13845 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 10 Feb 2025 16:13:32 +0100 Subject: [PATCH 02/28] fix --- lib_dec/dec_gen_voic_fx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 190431fb8..8ee335e3f 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -699,7 +699,16 @@ ivas_error decod_gen_voic_ivas_fx( } /* update LP filtered gains for the case of frame erasures */ - lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); + } + ELSE +#endif + { + lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); + } /*----------------------------------------------------------------------* * Find the total excitation -- GitLab From 68e8c9810d6eea2113b278f0d618cd629340e9c2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 10 Feb 2025 17:04:05 +0100 Subject: [PATCH 03/28] fix --- lib_com/gs_noisefill_fx.c | 5 +++++ lib_dec/acelp_core_dec_fx.c | 3 +-- lib_dec/gs_dec_fx.c | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 5cf285bf2..1ccc697fb 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1496,7 +1496,12 @@ void highband_exc_dct_in_ivas_fx( Q_hb_exc = 0; move16(); envelop_modify_fx( exc_diffQ, seed_tcx, last_bin, Ener_per_bd_iQ, *Q_exc, &Q_hb_exc ); +#ifdef REMOVE_EVS_DUPLICATES + test(); + IF( GT_16( *Q_exc, Q_hb_exc ) && GT_16( element_mode, EVS_MONO ) ) +#else IF( GT_16( *Q_exc, Q_hb_exc ) ) +#endif { Scale_sig( exc_wo_nf, L_frame, sub( Q_hb_exc, *Q_exc ) ); *Q_exc = Q_hb_exc; diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index e3770b997..779df2fa4 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1046,8 +1046,7 @@ ivas_error acelp_core_dec_fx( ELSE IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) ) ) { #ifdef REMOVE_EVS_DUPLICATES - decod_audio_ivas_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf, - 0, 0, 0, NULL ); + decod_audio_ivas_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf, 0, 0, 0, NULL ); #else decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf #ifdef ADD_LRTD diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 93c346a7d..72e07e57f 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -993,9 +993,11 @@ void decod_audio_ivas_fx( } } #endif + Word16 Q_exc_old = st_fx->Q_exc; move16(); gsc_dec_ivas_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc ); + IF( NE_16( Q_exc_old, st_fx->Q_exc ) ) { Q_exc_old = sub( Q_exc_old, st_fx->Q_exc ); -- GitLab From fb7b4020601f61bc9e4fd51df65763967bf977a6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 10 Feb 2025 17:47:12 +0100 Subject: [PATCH 04/28] fix --- lib_dec/dec_uv_fx.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index ffb49be38..6a15732a0 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -247,10 +247,18 @@ void decod_unvoiced_ivas_fx( * Excitation enhancements (update of total excitation signal) *----------------------------------------------------------------*/ - /*enhancer_fx(st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, - norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &(st_fx->dm_fx), st_fx->Q_exc);*/ - enhancer_ivas_fx( MODE1, st_fx->core_brate, uc_two_stage_flag, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, - norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx /*Q9/Q12?*/, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + enhancer_fx( st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, + norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); + } + ELSE +#endif + { + enhancer_ivas_fx( MODE1, st_fx->core_brate, uc_two_stage_flag, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, + norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx /*Q9/Q12?*/, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); + } Word16 tmp_idx; tmp_idx = 0; @@ -258,9 +266,16 @@ void decod_unvoiced_ivas_fx( if ( i_subfr_fx != 0 ) { idiv1616( i_subfr_fx, L_SUBFR ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + tmp_idx = idiv1616( i_subfr_fx, L_SUBFR ); + } +#endif } voice_factors_fx[tmp_idx] = 0; move16(); + interp_code_5over2_fx( &exc_fx[i_subfr_fx], &bwe_exc_fx[( ( i_subfr_fx * 2 * HIBND_ACB_L_FAC ) >> 1 )], L_SUBFR ); p_Aq_fx += ( M + 1 ); -- GitLab From ba6f7e27c1e7cf4abb7f2cdd755c9afa0fe11ba8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Feb 2025 10:35:49 +0100 Subject: [PATCH 05/28] REMOVE_EVS_DUPLICATES2 --- lib_com/options.h | 1 + lib_dec/acelp_core_dec_fx.c | 15 ++++++++++++++- lib_dec/fd_cng_dec_fx.c | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index c34882a0e..f45ee973d 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,4 +156,5 @@ #define SVD_WMOPS_OPT /* Ittiam : SVD related optimizations */ #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions */ +#define REMOVE_EVS_DUPLICATES2 #endif diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 779df2fa4..46826654e 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -432,7 +432,11 @@ ivas_error acelp_core_dec_fx( } /* update synthesis filter memories */ +#ifdef REMOVE_EVS_DUPLICATES2 + ivas_synth_mem_updt2_fx( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec ); +#else synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec ); +#endif #else synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, DEC ); #endif @@ -630,8 +634,11 @@ ivas_error acelp_core_dec_fx( /* decode CNG parameters */ IF( st_fx->cng_type == LP_CNG ) { - +#ifdef REMOVE_EVS_DUPLICATES2 + CNG_dec_ivas_fx( st_fx, st_fx->last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env ); +#else CNG_dec_fx( st_fx, st_fx->last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env ); +#endif #ifdef IVAS_CODE local_element_mode = st_fx->element_mode; move16(); @@ -684,6 +691,7 @@ ivas_error acelp_core_dec_fx( } } #endif + //generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 1, nchan_out ); generate_comfort_noise_dec_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 2, -1 ); FdCng_exc( st_fx->hFdCngDec->hFdCngCom, &st_fx->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx, st_fx->first_CNG, st_fx->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); @@ -1556,12 +1564,17 @@ ivas_error acelp_core_dec_fx( move32(); } /*Noise estimate*/ +#ifdef REMOVE_EVS_DUPLICATES2 + IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) && !st_fx->cng_ism_flag ) +#else IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) /* && !st->cng_ism_flag IVAS_CODE */ ) +#endif { #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT PMT( "Code for IVAS_CODE_CNG_FIX185_PLC_FADEOUT not done" ) ApplyFdCng_fx( syn, st_fx->Q_syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); #else + //ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, realBuffer, imagBuffer, NULL, st_fx, 0, ( st_fx->coder_type == AUDIO && !st_fx->GSC_noisy_speech ) ); ApplyFdCng_fx( syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st_fx, 0, ( EQ_16( st_fx->coder_type, AUDIO ) && st_fx->GSC_noisy_speech == 0 ) ); #endif } diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index c683b25b6..0b2682f3a 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -955,7 +955,12 @@ Word16 ApplyFdCng_fx( test(); IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { +#ifdef REMOVE_EVS_DUPLICATES2 + scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); + +#else scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); +#endif } hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; move16(); @@ -1037,8 +1042,13 @@ Word16 ApplyFdCng_fx( IF( LT_32( hFdCngCom->msFrCnt_init_counter, L_deposit_l( hFdCngCom->msFrCnt_init_thresh ) ) ) { /* At initialization, interpolate the bin/band-wise levels from the partition levels */ +#ifdef REMOVE_EVS_DUPLICATES2 + scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, + hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); +#else scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); +#endif *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } @@ -1054,8 +1064,13 @@ Word16 ApplyFdCng_fx( /* Interpolate the CLDFB band levels from the SID (partition) levels */ IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) ) { +#ifdef REMOVE_EVS_DUPLICATES2 + scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, + hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); +#else scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); +#endif *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); -- GitLab From 3241b0c1448ff4da5a680ef8e0c7c026c905b809 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Feb 2025 13:10:14 +0100 Subject: [PATCH 06/28] REMOVE_EVS_DUPLICATES2 --- lib_dec/acelp_core_dec_fx.c | 129 ++++++++++++++++++++++++++++++++++-- lib_dec/fd_cng_dec_fx.c | 45 +++++++++++-- 2 files changed, 164 insertions(+), 10 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 46826654e..db6ba759d 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -661,7 +661,7 @@ ivas_error acelp_core_dec_fx( test(); IF( EQ_32( st_fx->core_brate, SID_2k40 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { - FdCng_decodeSID_fx( st_fx->hFdCngDec->hFdCngCom, st_fx ); + FdCng_decodeSID_fx( st_fx->hFdCngDec->hFdCngCom, st_fx ); // VE: 2 variants needed *sid_bw = 0; move16(); } @@ -691,8 +691,7 @@ ivas_error acelp_core_dec_fx( } } #endif - //generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 1, nchan_out ); - generate_comfort_noise_dec_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 2, -1 ); + generate_comfort_noise_dec_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 2, -1 ); // VE: 2 variants needed FdCng_exc( st_fx->hFdCngDec->hFdCngCom, &st_fx->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx, st_fx->first_CNG, st_fx->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); @@ -709,10 +708,29 @@ ivas_error acelp_core_dec_fx( } i = st_fx->Q_exc; move16(); +#ifdef REMOVE_EVS_DUPLICATES2 + test(); + IF( st_fx->hMusicPF && st_fx->hGSCDec ) + { + Rescale_exc( st_fx->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, + imult1616( st_fx->L_frame, HIBND_ACB_L_FAC ), 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE ); + } + IF( st_fx->hPFstat != NULL ) + { + Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale, + &st_fx->mem_deemph_fx, st_fx->hBPF->pst_old_syn_fx, &st_fx->hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 0, 0, NULL ); + } + ELSE + { + Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale, + &st_fx->mem_deemph_fx, NULL, NULL, &st_fx->agc_mem_fx[1], NULL, 0, 0, NULL ); + } +#else Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, st_fx->L_frame * HIBND_ACB_L_FAC, 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE ); Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 0, 0, NULL ); +#endif Copy_Scale_sig( exc2_fx, exc2_fx, st_fx->L_frame, sub( st_fx->Q_exc, i ) ); // Q_exc /* update past excitation signals for LD music post-filter */ @@ -725,7 +743,7 @@ ivas_error acelp_core_dec_fx( FOR( i = 0; i < DCT_L_POST; i++ ) { /*st_fx->filt_lfE_fx[i] = 0.3f + 0.7f * st_fx->filt_lfE_fx[i];*/ - hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) ); + hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) ); // VE: 2 variants needed move16(); } } @@ -1574,8 +1592,11 @@ ivas_error acelp_core_dec_fx( PMT( "Code for IVAS_CODE_CNG_FIX185_PLC_FADEOUT not done" ) ApplyFdCng_fx( syn, st_fx->Q_syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); #else - //ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, realBuffer, imagBuffer, NULL, st_fx, 0, ( st_fx->coder_type == AUDIO && !st_fx->GSC_noisy_speech ) ); +#ifdef REMOVE_EVS_DUPLICATES2 + ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, realBuffer, imagBuffer, NULL, st_fx, 0, ( st_fx->coder_type == AUDIO && !st_fx->GSC_noisy_speech ) ); +#else ApplyFdCng_fx( syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st_fx, 0, ( EQ_16( st_fx->coder_type, AUDIO ) && st_fx->GSC_noisy_speech == 0 ) ); +#endif #endif } /* CNA: Generate additional comfort noise to mask potential coding artefacts */ @@ -1759,6 +1780,82 @@ ivas_error acelp_core_dec_fx( bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn_fx, st_fx->L_frame, pitch_buf_fx, st_fx->bpf_off, st_fx->stab_fac_fx, &st_fx->stab_fac_smooth_fx, st_fx->coder_type, st_fx->Q_syn, bpf_error_signal ); } + +#ifdef REMOVE_EVS_DUPLICATES2 + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + /* analysis of the synthesis at internal sampling rate */ + cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer ); + + scaleFactor.hb_scale = scaleFactor.lb_scale; + move16(); + + /* analysis and add the BPF error signal */ + i = 0; + move16(); + if ( st_fx->bpf_off == 0 ) + { + i = CLDFB_NO_COL_MAX; + move16(); + } + + addBassPostFilter_fx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate( st_fx->Q_syn ), + i, st_fx->cldfbAna->no_col, st_fx->cldfbAna->no_channels, &scaleFactor ); + + /* set output mask for upsampling */ + IF( EQ_16( st_fx->bwidth, NB ) ) + { + /* set NB mask for upsampling */ + st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, 10 ); + move16(); + } + ELSE IF( NE_16( st_fx->cldfbSyn->bandsToZero, sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ) ) ) + { + /* in case of BW switching, re-init to default */ + st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ); + move16(); + } + + /*WB/SWB-FD_CNG*/ + scaleFactor.hb_scale = scaleFactor.lb_scale; + move16(); + + test(); + IF( !st_fx->cng_sba_flag || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + test(); + test(); + test(); + IF( ( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) && ( EQ_16( st_fx->cng_type, FD_CNG ) ) && ( LT_16( st_fx->hFdCngDec->hFdCngCom->numCoreBands, st_fx->cldfbSyn->no_channels ) ) ) + { + generate_comfort_noise_dec_hf_fx( realBuffer, imagBuffer, &scaleFactor.hb_scale, st_fx ); + + st_fx->cldfbSyn->bandsToZero = 0; + move16(); + IF( LT_16( st_fx->hFdCngDec->hFdCngCom->regularStopBand, st_fx->cldfbSyn->no_channels ) ) + { + st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->hFdCngDec->hFdCngCom->regularStopBand ); + move16(); + } + st_fx->cldfbSyn->lsb = st_fx->cldfbAna->no_channels; + move16(); + } + } + + /* synthesis of the combined signal */ + st_fx->Q_syn2 = st_fx->Q_syn; + move16(); + cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer ); + + /* Bring CLDFB output to Q0 */ + Scale_sig( synth_out, output_frame, negate( st_fx->Q_syn2 ) ); + st_fx->Q_syn2 = 0; + move16(); + + /* save synthesis - needed in case of core switching */ + Copy( synth_out, st_fx->previoussynth_fx, output_frame ); + } +#else test(); IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) { @@ -1881,6 +1978,7 @@ ivas_error acelp_core_dec_fx( /* save synthesis - needed in case of core switching */ Copy( synth_out, st_fx->previoussynth_fx, output_frame ); } +#endif #ifdef IVAS_CODE ELSE { @@ -1924,13 +2022,34 @@ ivas_error acelp_core_dec_fx( IF( ( EQ_16( st_fx->L_frame, L_FRAME ) && NE_16( st_fx->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) && ( EQ_16( st_fx->extl, -1 ) || EQ_16( st_fx->extl, SWB_CNG ) || ( EQ_16( st_fx->extl, WB_BWE ) && st_fx->extl_brate == 0 && NE_16( st_fx->coder_type, AUDIO ) ) ) ) ) { +#ifdef REMOVE_EVS_DUPLICATES2 + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, + st_fx->Q_syn2, st_fx->hBWE_zero->delay_syn_hf_fx, &st_fx->hBWE_zero->memExp1, st_fx->hBWE_zero->mem_hp_interp_fx, st_fx->extl, st_fx->CNG_mode ); + } + ELSE + { + hf_synth_reset_fx( st_fx->hBWE_zero ); + } +#else hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, st_fx->Q_syn2, st_fx->hBWE_zero->delay_syn_hf_fx, &st_fx->hBWE_zero->memExp1, st_fx->hBWE_zero->mem_hp_interp_fx, st_fx->extl, st_fx->CNG_mode ); + +#endif } +#ifdef REMOVE_EVS_DUPLICATES2 ELSE { hf_synth_reset_fx( st_fx->hBWE_zero ); +#ifdef MSAN_FIX + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) // TBV: tmp hack - it is a bug in EVS but conditon is here to keep EVS bit-exact + { + set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); + } +#endif } +#endif } /*-----------------------------------------------------------------* diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 0b2682f3a..7b4eef9f2 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -957,7 +957,6 @@ Word16 ApplyFdCng_fx( { #ifdef REMOVE_EVS_DUPLICATES2 scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); - #else scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); #endif @@ -1279,7 +1278,16 @@ Word16 ApplyFdCng_ivas_fx( ( !st->BER_detect ) ) { /* Perform noise estimation at the decoder */ - perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); +#ifdef REMOVE_EVS_DUPLICATES2 + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); + } + ELSE +#endif + { + perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); + } /* Update the shaping parameters */ test(); @@ -1522,7 +1530,16 @@ Word16 ApplyFdCng_ivas_fx( IF( hFdCngCom->active_frame_counter > 0 ) { /* Perform noise estimation in active frames in the decoder for downward updates */ - perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); +#ifdef REMOVE_EVS_DUPLICATES2 + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); + } + ELSE +#endif + { + perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); + } } } @@ -1580,7 +1597,16 @@ Word16 ApplyFdCng_ivas_fx( IF( st != NULL && EQ_16( st->cng_type, LP_CNG ) ) { /* Perform noise estimation on inactive phase at the decoder */ - perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); +#ifdef REMOVE_EVS_DUPLICATES2 + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); + } + ELSE +#endif + { + perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); + } /* Update the shaping parameters */ @@ -1833,7 +1859,16 @@ Word16 ApplyFdCng_ivas_fx( IF( EQ_16( st->codec_mode, MODE2 ) ) { /* Generate comfort noise during SID or zero frames */ - generate_comfort_noise_dec_ivas_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 ); +#ifdef REMOVE_EVS_DUPLICATES2 + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + generate_comfort_noise_dec_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 ); + } + ELSE +#endif + { + generate_comfort_noise_dec_ivas_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 ); + } } BREAK; -- GitLab From ee29e3294f378e60e425a50e62ffa1b2875de886 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Feb 2025 13:54:52 +0100 Subject: [PATCH 07/28] fix --- lib_dec/fd_cng_dec_fx.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 7b4eef9f2..bf10d9c17 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -955,11 +955,7 @@ Word16 ApplyFdCng_fx( test(); IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { -#ifdef REMOVE_EVS_DUPLICATES2 - scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); -#else scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); -#endif } hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; move16(); @@ -1041,13 +1037,8 @@ Word16 ApplyFdCng_fx( IF( LT_32( hFdCngCom->msFrCnt_init_counter, L_deposit_l( hFdCngCom->msFrCnt_init_thresh ) ) ) { /* At initialization, interpolate the bin/band-wise levels from the partition levels */ -#ifdef REMOVE_EVS_DUPLICATES2 - scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, - hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); -#else scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); -#endif *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } @@ -1063,14 +1054,8 @@ Word16 ApplyFdCng_fx( /* Interpolate the CLDFB band levels from the SID (partition) levels */ IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) ) { -#ifdef REMOVE_EVS_DUPLICATES2 - scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, - hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); -#else scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); -#endif - *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } -- GitLab From 5e2edf84fe18ea27bb9d8c91ff2d6f0e7ffcd9cb Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Feb 2025 14:34:33 +0100 Subject: [PATCH 08/28] fix --- lib_dec/amr_wb_dec_fx.c | 8 ++++++++ lib_dec/evs_dec_fx.c | 4 ++++ lib_dec/fd_cng_dec_fx.c | 30 ++++++++++++++++++++++++++---- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index d45655903..b3fbc0233 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -374,7 +374,11 @@ ivas_error amr_wb_dec_fx( IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) { /* decode CNG parameters */ +#ifdef REMOVE_EVS_DUPLICATES2 + CNG_dec_ivas_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env ); +#else CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env ); +#endif /* comfort noise generation */ CNG_exc_fx( st_fx->core_brate, L_FRAME, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate, @@ -795,8 +799,12 @@ ivas_error amr_wb_dec_fx( #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT PMT( "Fixed point not done here " ) ApplyFdCng_fx( syn, NULL, NULL, NULL, st, 0, 0 ); +#else +#ifdef REMOVE_EVS_DUPLICATES2 + ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, NULL, NULL, NULL, st_fx, 0, 0 ); #else ApplyFdCng_fx( syn_fx, st_fx->Q_syn, NULL, NULL, NULL, st_fx, 0, 0 ); +#endif #endif st_fx->hFdCngDec->hFdCngCom->frame_type_previous = st_fx->m_frame_type; move16(); diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index de6448433..fee893c4b 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -999,8 +999,12 @@ ivas_error evs_dec_fx( move32(); #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT ApplyFdCng_fx( output, NULL, realBuffer, imagBuffer, st, concealWholeFrame, 0 ); +#else +#ifdef REMOVE_EVS_DUPLICATES2 + ApplyFdCng_ivas_fx( output_sp, 0, NULL, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 ); #else ApplyFdCng_fx( output_sp, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 ); +#endif #endif /* Generate additional comfort noise to mask potential coding artefacts */ test(); diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index bf10d9c17..0fba4e644 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1276,7 +1276,14 @@ Word16 ApplyFdCng_ivas_fx( /* Update the shaping parameters */ test(); - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) +#ifdef REMOVE_EVS_DUPLICATES2 + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); + } + ELSE +#endif + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); } @@ -1596,7 +1603,14 @@ Word16 ApplyFdCng_ivas_fx( /* Update the shaping parameters */ test(); - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) +#ifdef REMOVE_EVS_DUPLICATES2 + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); + } + ELSE +#endif + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); } @@ -1675,8 +1689,16 @@ Word16 ApplyFdCng_ivas_fx( IF( LT_32( hFdCngCom->msFrCnt_init_counter, L_deposit_l( hFdCngCom->msFrCnt_init_thresh ) ) ) { /* At initialization, interpolate the bin/band-wise levels from the partition levels */ - scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, - hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); +#ifdef REMOVE_EVS_DUPLICATES2 + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); + } + ELSE +#endif + { + scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); + } *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } -- GitLab From 5826482915088a6b53715c625a974c00d21004a1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Feb 2025 15:19:24 +0100 Subject: [PATCH 09/28] fix --- lib_dec/fd_cng_dec_fx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 0fba4e644..af670f0d0 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1711,8 +1711,16 @@ Word16 ApplyFdCng_ivas_fx( /* Interpolate the CLDFB band levels from the SID (partition) levels */ IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) ) { - scalebands_fx( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, - hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); +#ifdef REMOVE_EVS_DUPLICATES2 + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); + } + ELSE +#endif + { + scalebands_fx( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); + } *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); -- GitLab From e8fa2b8809206c5783edfbecea256352e97d28f3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Feb 2025 15:52:56 +0100 Subject: [PATCH 10/28] fix --- lib_dec/acelp_core_dec_fx.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index db6ba759d..3a96a6225 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -712,8 +712,19 @@ ivas_error acelp_core_dec_fx( test(); IF( st_fx->hMusicPF && st_fx->hGSCDec ) { - Rescale_exc( st_fx->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, - imult1616( st_fx->L_frame, HIBND_ACB_L_FAC ), 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE ); +#ifdef REMOVE_EVS_DUPLICATES2 + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + // VE: TBV: 'st_fx->L_frame * HIBND_ACB_L_FAC' should be corrected + Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, + st_fx->L_frame * HIBND_ACB_L_FAC, 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE ); + } + ELSE +#endif + { + Rescale_exc( st_fx->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, + imult1616( st_fx->L_frame, HIBND_ACB_L_FAC ), 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE ); + } } IF( st_fx->hPFstat != NULL ) { @@ -2043,7 +2054,7 @@ ivas_error acelp_core_dec_fx( { hf_synth_reset_fx( st_fx->hBWE_zero ); #ifdef MSAN_FIX - IF( NE_16( st_fx->element_mode, EVS_MONO ) ) // TBV: tmp hack - it is a bug in EVS but conditon is here to keep EVS bit-exact + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but conditon is here to keep EVS bit-exact { set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); } -- GitLab From 4276239737d482ee265d2eec90166ed4ee51c48a Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Feb 2025 20:34:33 +0100 Subject: [PATCH 11/28] remove acelp_core_dec_fx() --- lib_dec/acelp_core_dec_fx.c | 18 +- lib_dec/acelp_core_dec_ivas_fx.c | 905 +++++++++++++++++++------------ lib_dec/amr_wb_dec_fx.c | 4 +- lib_dec/decision_matrix_dec_fx.c | 15 + lib_dec/evs_dec_fx.c | 7 +- lib_dec/fd_cng_dec_fx.c | 16 +- 6 files changed, 606 insertions(+), 359 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 3a96a6225..fc35cb754 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -432,7 +432,7 @@ ivas_error acelp_core_dec_fx( } /* update synthesis filter memories */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES ivas_synth_mem_updt2_fx( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec ); #else synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec ); @@ -634,7 +634,7 @@ ivas_error acelp_core_dec_fx( /* decode CNG parameters */ IF( st_fx->cng_type == LP_CNG ) { -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES CNG_dec_ivas_fx( st_fx, st_fx->last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env ); #else CNG_dec_fx( st_fx, st_fx->last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env ); @@ -708,11 +708,11 @@ ivas_error acelp_core_dec_fx( } i = st_fx->Q_exc; move16(); -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES test(); IF( st_fx->hMusicPF && st_fx->hGSCDec ) { -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { // VE: TBV: 'st_fx->L_frame * HIBND_ACB_L_FAC' should be corrected @@ -1593,7 +1593,7 @@ ivas_error acelp_core_dec_fx( move32(); } /*Noise estimate*/ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) && !st_fx->cng_ism_flag ) #else IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) /* && !st->cng_ism_flag IVAS_CODE */ ) @@ -1603,7 +1603,7 @@ ivas_error acelp_core_dec_fx( PMT( "Code for IVAS_CODE_CNG_FIX185_PLC_FADEOUT not done" ) ApplyFdCng_fx( syn, st_fx->Q_syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); #else -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, realBuffer, imagBuffer, NULL, st_fx, 0, ( st_fx->coder_type == AUDIO && !st_fx->GSC_noisy_speech ) ); #else ApplyFdCng_fx( syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st_fx, 0, ( EQ_16( st_fx->coder_type, AUDIO ) && st_fx->GSC_noisy_speech == 0 ) ); @@ -1792,7 +1792,7 @@ ivas_error acelp_core_dec_fx( st_fx->stab_fac_fx, &st_fx->stab_fac_smooth_fx, st_fx->coder_type, st_fx->Q_syn, bpf_error_signal ); } -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { /* analysis of the synthesis at internal sampling rate */ @@ -2033,7 +2033,7 @@ ivas_error acelp_core_dec_fx( IF( ( EQ_16( st_fx->L_frame, L_FRAME ) && NE_16( st_fx->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) && ( EQ_16( st_fx->extl, -1 ) || EQ_16( st_fx->extl, SWB_CNG ) || ( EQ_16( st_fx->extl, WB_BWE ) && st_fx->extl_brate == 0 && NE_16( st_fx->coder_type, AUDIO ) ) ) ) ) { -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, @@ -2049,7 +2049,7 @@ ivas_error acelp_core_dec_fx( #endif } -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES ELSE { hf_synth_reset_fx( st_fx->hBWE_zero ); diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 8d6b63833..f02e6d337 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -151,7 +151,6 @@ ivas_error acelp_core_dec_ivas_fx( error = IVAS_ERR_OK; move32(); - test(); test(); test(); @@ -664,11 +663,21 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; - move16(); - FdCng_decodeSID_ivas_fx( st ); - rescale_fdCngDec( st->hFdCngDec, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); - Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); // Qx +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); + } + ELSE +#endif + { + Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; + move16(); + FdCng_decodeSID_ivas_fx( st ); + rescale_fdCngDec( st->hFdCngDec, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); + Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); // Qx + } + *sid_bw = 0; move16(); } @@ -720,7 +729,16 @@ ivas_error acelp_core_dec_ivas_fx( } } - generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + generate_comfort_noise_dec_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 2, -1 ); + } + ELSE +#endif + { + generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out ); + } FdCng_exc( st->hFdCngDec->hFdCngCom, &st->CNG_mode, st->L_frame, st->lsp_old_fx, st->first_CNG, st->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); @@ -740,8 +758,19 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( st->hMusicPF && st->hGSCDec ) { - Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, - imult1616( st->L_frame, HIBND_ACB_L_FAC ), 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + // VE: TBV: 'st_fx->L_frame * HIBND_ACB_L_FAC' should be corrected + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, + st->L_frame * HIBND_ACB_L_FAC, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); + } + ELSE +#endif + { + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, + imult1616( st->L_frame, HIBND_ACB_L_FAC ), 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); + } } IF( st->hPFstat != NULL ) { @@ -763,14 +792,26 @@ ivas_error acelp_core_dec_ivas_fx( /* Update music post processing values */ /* Filter energies update */ - FOR( i = 0; i < DCT_L_POST; i++ ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) { - st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); // Q15, 9830 =.3f in Q15, 22937=.7f in Q15 - move16(); + FOR( i = 0; i < DCT_L_POST; i++ ) + { + st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) ); + move16(); + } + } + ELSE +#endif + { + FOR( i = 0; i < DCT_L_POST; i++ ) + { + st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); // Q15, 9830 =.3f in Q15, 22937=.7f in Q15 + move16(); + } } } - /* synthesis at 12.8kHz sampling rate */ #ifndef FIX_1100_REMOVE_LPC_RESCALING Aq_fx[0] = ONE_IN_Q12; @@ -778,15 +819,28 @@ ivas_error acelp_core_dec_ivas_fx( move16(); syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn ); - st->Q_syn_cng = st->Q_syn; - move16(); - st->Q_exc_cng = st->Q_exc; - move16(); + /* reset the decoder */ CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx ); - /* update st->mem_syn1 for ACELP core switching */ - Copy_Scale_sig( st->mem_syn3_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); // Q(-1) + +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + /* update st_fx->mem_syn1 for ACELP core switching */ + Copy( st->mem_syn3_fx, st->mem_syn1_fx, M ); + } + ELSE +#endif + { + st->Q_syn_cng = st->Q_syn; + move16(); + st->Q_exc_cng = st->Q_exc; + move16(); + + /* update st->mem_syn1 for ACELP core switching */ + Copy_Scale_sig( st->mem_syn3_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); // Q(-1) + } /* update old synthesis for classification */ Copy( syn1_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); @@ -1157,13 +1211,30 @@ ivas_error acelp_core_dec_ivas_fx( Word16 qdct = 0; move16(); /* Extrapolation of the last future part, windowing and high resolution DCT transform */ - Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + // VE: TBV: this is a bug in EVS - 'st->last_coder_type' should be replaced by 'st->core_brate' + Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_coder_type, st->element_mode, pitch_buf_fx, + st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); + } + ELSE +#endif + { + Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); + } /* LD music post-filter */ LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct ); /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ - Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/ +#ifdef REMOVE_EVS_DUPLICATES + IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS +#endif + { + Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/ + } + Post_music_postP_fx( dct_buffer_fx, exc2_fx, st->mem_syn2_fx, st->mem_syn2_fx, Aq_fx, psyn_fx, &st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx ); @@ -1209,6 +1280,7 @@ ivas_error acelp_core_dec_ivas_fx( /*------------------------------------------------------------* * FEC - Estimate the classification information *------------------------------------------------------------*/ + FEC_clas_estim_fx( st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx, psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst, NULL, NULL, NULL, NULL, 0, NULL, st->Q_syn, temp_buf_fx, @@ -1586,19 +1658,28 @@ ivas_error acelp_core_dec_ivas_fx( } ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) { - IF( st->idchan == 0 ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) { - IF( NE_16( st->element_mode, last_element_mode ) ) + generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 ); + } + ELSE +#endif + { + IF( st->idchan == 0 ) { - set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); + IF( NE_16( st->element_mode, last_element_mode ) ) + { + set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); + } + Word32 psyn_32_fx[L_FRAME16k]; + Word16 exp; + Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6 + Copy_Scale_sig_16_32_no_sat( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), Q15 ); // Q15 + generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); + Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn + Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 } - Word32 psyn_32_fx[L_FRAME16k]; - Word16 exp; - Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6 - Copy_Scale_sig_16_32_no_sat( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), Q15 ); // Q15 - generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); - Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn - Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 } } } @@ -1685,36 +1766,27 @@ ivas_error acelp_core_dec_ivas_fx( * Bass post-filter *----------------------------------------------------------------*/ - /* check if the CLDFB works on the right sample rate */ - IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) { - resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); - resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + CLDFB_SCALE_FACTOR scaleFactor; + Word32 workBuffer[128 * 3]; - IF( st->ini_frame > 0 ) + /* check if the CLDFB works on the right sample rate */ + IF( ( st->cldfbAna->usb * st->cldfbAna->no_col ) != st->L_frame ) { - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); - move16(); - } - } - - /* analyze pitch coherence for bass post-filter */ + /* resample to ACELP internal sampling rate */ + Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + resampleCldfb( st->cldfbAna, newCldfbBands, st->L_frame, 0 ); + resampleCldfb( st->cldfbBPF, newCldfbBands, st->L_frame, 0 ); - Word32 pitch_buf_fx_q20[12]; - - Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); // Q(x+4) - Word16 lim = shr( st->L_frame, 6 ); - FOR( Word16 lp = 0; lp < lim; lp++ ) - { - pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 ); - move32(); - } - bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 ); - Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 ); // Qx + IF( st->ini_frame > 0 ) + { + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); + move16(); + } + } - test(); - IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) ) - { test(); IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) ) { @@ -1730,89 +1802,26 @@ ivas_error acelp_core_dec_ivas_fx( bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off, st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx ); - } - Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx; - set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR ); - syn_32_fx = syn_tmp_32_fx + L_SUBFR; - test(); - IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) - { - /* analysis of the synthesis at internal sampling rate */ - Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX]; - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - pRealSave_fx[i] = realBufferSave_fx[i]; - pImagSave_fx[i] = imagBufferSave_fx[i]; - } -#ifndef MSAN_FIX - Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 -#endif - IF( st->p_bpf_noise_buf_32 ) - { -#ifdef MSAN_FIX - Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 -#endif - Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); - Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 - } -#ifdef MSAN_FIX - FOR( i = 0; i < st->L_frame; i++ ) -#else - for ( i = 0; i < L_FRAME16k; i++ ) -#endif - { - syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12 - move32(); - } + /* analysis of the synthesis at internal sampling rate */ + cldfbAnalysisFiltering( st->cldfbAna, realBuffer_fx, imagBuffer_fx, &scaleFactor, psyn_fx, negate( st->Q_syn ), CLDFB_NO_COL_MAX, workBuffer ); - Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 - st->cldfbAna->Q_cldfb_state = Q12; + scaleFactor.hb_scale = scaleFactor.lb_scale; move16(); - cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna ); - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 - st->cldfbAna->Q_cldfb_state = Q11; - move16(); - /* analysis and add the BPF error signal */ - Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; - Word16 q_bpf_error_signal; - Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); - q_bpf_error_signal = Q6; - move16(); -#ifdef MSAN_FIX -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 -#else - Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 -#endif -#else - Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn ); // Q6 -#endif - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 - Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 - } - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) - st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; - move16(); - tmp = -1; + /* analysis and add the BPF error signal */ + i = 0; move16(); - if ( st->bpf_off ) + if ( st->bpf_off == 0 ) { - tmp = 0; + i = CLDFB_NO_COL_MAX; move16(); } - addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( ( sub( q_bpf_error_signal, Q10 ) ) ) ); // Q10 - st->cldfbBPF->Q_cldfb_state = Q10; - move16(); + addBassPostFilter_fx( bpf_error_signal_16fx, realBuffer_fx, imagBuffer_fx, st->cldfbBPF, workBuffer, negate( st->Q_syn ), + i, st->cldfbAna->no_col, st->cldfbAna->no_channels, &scaleFactor ); + /* set output mask for upsampling */ IF( EQ_16( st->bwidth, NB ) ) { @@ -1826,118 +1835,405 @@ ivas_error acelp_core_dec_ivas_fx( st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); move16(); } + + /*WB/SWB-FD_CNG*/ + scaleFactor.hb_scale = scaleFactor.lb_scale; + move16(); + test(); - IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + test(); + test(); + IF( ( ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) { - test(); - test(); - test(); - /*WB/SWB-FD_CNG*/ - IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) + generate_comfort_noise_dec_hf_fx( realBuffer_fx, imagBuffer_fx, &scaleFactor.hb_scale, st ); + + st->cldfbSyn->bandsToZero = 0; + move16(); + IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) { - Word16 tmpBufferScale = 0; + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); move16(); - generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag ); + } + st->cldfbSyn->lsb = st->cldfbAna->no_channels; + move16(); + } - FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ ) - { - Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 - Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 - } + /* synthesis of the combined signal */ + st->Q_syn2 = st->Q_syn; + move16(); + cldfbSynthesisFiltering( st->cldfbSyn, realBuffer_fx, imagBuffer_fx, &scaleFactor, synth_fx16, negate( st->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer ); + + /* Bring CLDFB output to Q0 */ + Scale_sig( synth_fx16, output_frame, negate( st->Q_syn2 ) ); + st->Q_syn2 = 0; + move16(); + + /* save synthesis - needed in case of core switching */ + Copy( synth_fx16, st->previoussynth_fx, output_frame ); + } + ELSE +#endif + { + /* check if the CLDFB works on the right sample rate */ + IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) ) + { + resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + + IF( st->ini_frame > 0 ) + { + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); + move16(); + } + } + + /* analyze pitch coherence for bass post-filter */ + + Word32 pitch_buf_fx_q20[12]; - IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) + Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); // Q(x+4) + Word16 lim = shr( st->L_frame, 6 ); + FOR( Word16 lp = 0; lp < lim; lp++ ) + { + pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 ); + move32(); + } + bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 ); + Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 ); // Qx + + test(); + IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) ) + { + test(); + IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) ) + { + IF( EQ_16( st->L_frame, L_FRAME ) ) { - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); - move16(); + retro_interp5_4_fx( st->hBPF->pst_old_syn_fx ); } - ELSE + ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) ) { - st->cldfbSyn->bandsToZero = 0; - move16(); + retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx ); } } + + bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off, + st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx ); } - IF( save_hb_synth_fx16 != NULL ) + Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx; + set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR ); + syn_32_fx = syn_tmp_32_fx + L_SUBFR; + test(); + IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) { - /* save and then zero-out lowband */ - Word16 Q_real = 0, Q_imag = 0; - Word32 max_real = 0, max_imag = 0; + /* analysis of the synthesis at internal sampling rate */ + Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX]; + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + pRealSave_fx[i] = realBufferSave_fx[i]; + pImagSave_fx[i] = imagBufferSave_fx[i]; + } +#ifndef MSAN_FIX + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 +#endif + IF( st->p_bpf_noise_buf_32 ) + { +#ifdef MSAN_FIX + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 +#endif + Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 + } + +#ifdef MSAN_FIX + FOR( i = 0; i < st->L_frame; i++ ) +#else + for ( i = 0; i < L_FRAME16k; i++ ) +#endif + { + syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12 + move32(); + } + + Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 + st->cldfbAna->Q_cldfb_state = Q12; move16(); + cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna ); + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 + st->cldfbAna->Q_cldfb_state = Q11; move16(); - move32(); - move32(); + /* analysis and add the BPF error signal */ + Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; + Word16 q_bpf_error_signal; + Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); + + q_bpf_error_signal = Q6; + move16(); +#ifdef MSAN_FIX +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 +#else + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 +#endif +#else + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn ); // Q6 +#endif FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); - max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); - } + Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 + Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 } - Word32 max_val = L_max( max_real, max_imag ); - Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */; - Q_real = Q_imag; + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) + st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; move16(); - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + tmp = -1; + move16(); + if ( st->bpf_off ) { - scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag ); // Q_imag + tmp = 0; + move16(); } - scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) - st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); + + addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( ( sub( q_bpf_error_signal, Q10 ) ) ) ); // Q10 + st->cldfbBPF->Q_cldfb_state = Q10; move16(); -#ifndef MSAN_FIX - Scale_sig32( save_hb_synth_fx, L_FRAME48k, sub( Q_real, 1 ) ); // Q_real-1 -#endif + /* set output mask for upsampling */ + IF( EQ_16( st->bwidth, NB ) ) + { + /* set NB mask for upsampling */ + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 ); + move16(); + } + ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) ) + { + /* in case of BW switching, re-init to default */ + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); + move16(); + } + test(); + IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + test(); + test(); + test(); + /*WB/SWB-FD_CNG*/ + IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) + { + Word16 tmpBufferScale = 0; + move16(); + generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag ); + + FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ ) + { + Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 + Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 + } - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) + { + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); + move16(); + } + ELSE + { + st->cldfbSyn->bandsToZero = 0; + move16(); + } + } + } + + IF( save_hb_synth_fx16 != NULL ) { + /* save and then zero-out lowband */ + Word16 Q_real = 0, Q_imag = 0; + Word32 max_real = 0, max_imag = 0; + move16(); + move16(); + move32(); + move32(); FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { - realBufferSave_fx[i][j] = realBuffer_fx[i][j]; - imagBufferSave_fx[i][j] = imagBuffer_fx[i][j]; - move32(); - move32(); - IF( LT_16( j, st->hFdCngDec->hFdCngCom->numCoreBands ) && LT_16( i, st->hFdCngDec->hFdCngCom->numSlots ) ) + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); + max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); + } + } + Word32 max_val = L_max( max_real, max_imag ); + Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */; + Q_real = Q_imag; + move16(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag ); // Q_imag + } + scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) + st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); + move16(); +#ifndef MSAN_FIX + Scale_sig32( save_hb_synth_fx, L_FRAME48k, sub( Q_real, 1 ) ); // Q_real-1 +#endif + + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { - realBuffer_fx[i][j] = 0; - imagBuffer_fx[i][j] = 0; + realBufferSave_fx[i][j] = realBuffer_fx[i][j]; + imagBufferSave_fx[i][j] = imagBuffer_fx[i][j]; move32(); move32(); + IF( LT_16( j, st->hFdCngDec->hFdCngCom->numCoreBands ) && LT_16( i, st->hFdCngDec->hFdCngCom->numSlots ) ) + { + realBuffer_fx[i][j] = 0; + imagBuffer_fx[i][j] = 0; + move32(); + move32(); + } } } - } - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, st->cldfbSynHB ); + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, st->cldfbSynHB ); - Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0 - Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSynHB->Q_cldfb_state = Q10; - move16(); - /* restore lowband */ - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0 + Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + st->cldfbSynHB->Q_cldfb_state = Q10; + move16(); + /* restore lowband */ + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + realBuffer_fx[i][j] = realBufferSave_fx[i][j]; + imagBuffer_fx[i][j] = imagBufferSave_fx[i][j]; + move32(); + move32(); + } + } + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1 + st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); + move16(); + cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, st->cldfbSyn ); + Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0 + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + st->cldfbSynHB->Q_cldfb_state = Q10; + move16(); + } + ELSE { + /* synthesis of the combined signal */ + Word16 Q_real, Q_imag; + Word32 max_real, max_imag; + Q_real = 0; + Q_imag = 0; + max_real = 0; + max_imag = 0; + move16(); + move16(); + move32(); + move32(); FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { - realBuffer_fx[i][j] = realBufferSave_fx[i][j]; - imagBuffer_fx[i][j] = imagBufferSave_fx[i][j]; - move32(); - move32(); + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); + max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); + } } + Word32 max_val = L_max( max_real, max_imag ); + Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */; + Q_real = Q_imag; + move16(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + } + scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) + st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); + move16(); +#ifndef MSAN_FIX + Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 ); +#endif + + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, st->cldfbSyn ); +#ifdef MSAN_FIX + scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 +#else + Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) ); +#endif + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + st->cldfbSyn->Q_cldfb_state = Q10; + move16(); } - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1 - st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); - move16(); - cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, st->cldfbSyn ); - Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0 - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSynHB->Q_cldfb_state = Q10; - move16(); + + /* save synthesis - needed in case of core switching */ + Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 } ELSE { - /* synthesis of the combined signal */ + Word16 nSamples = NS2SA_FX2( i_mult( st->L_frame, FRAMES_PER_SEC ), FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ + + /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ +#ifndef MSAN_FIX + for ( i = 0; i < L_FRAME16k; i++ ) +#else + FOR( i = 0; i < st->L_frame; i++ ) +#endif + { + syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); + move32(); + } + + Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 + st->cldfbAna->Q_cldfb_state = Q12; + move16(); + cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna ); + + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 + st->cldfbAna->Q_cldfb_state = Q11; + move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ + Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; + Word16 q_bpf_error_signal; + Word16 cldfb_state_offset; + cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); + + // Get Q-factor + q_bpf_error_signal = Q6; + move16(); +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 +#else + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 +#endif + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 + Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 + } + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) + st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; + move16(); + tmp = 0; + move16(); + if ( !st->bpf_off ) + { + tmp = nSamples; + move16(); + } + addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); + + + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( sub( q_bpf_error_signal, Q10 ) ) ); // Q10 + st->cldfbBPF->Q_cldfb_state = Q10; + move16(); + /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ Word16 Q_real, Q_imag; Word32 max_real, max_imag; Q_real = 0; @@ -1966,151 +2262,46 @@ ivas_error acelp_core_dec_ivas_fx( scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) - st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); - move16(); #ifndef MSAN_FIX Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 ); #endif - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, st->cldfbSyn ); + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn ); + #ifdef MSAN_FIX - scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 + Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 #else Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) ); #endif - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSyn->Q_cldfb_state = Q10; move16(); - } - - /* save synthesis - needed in case of core switching */ - Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 - } - ELSE - { - Word16 nSamples = NS2SA_FX2( i_mult( st->L_frame, FRAMES_PER_SEC ), FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ + IF( st->p_bpf_noise_buf_32 ) + { + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 + Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); - /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ -#ifndef MSAN_FIX - for ( i = 0; i < L_FRAME16k; i++ ) -#else - FOR( i = 0; i < st->L_frame; i++ ) -#endif - { - syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); - move32(); - } + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 + } - Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 - st->cldfbAna->Q_cldfb_state = Q12; - move16(); - cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna ); - - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 - st->cldfbAna->Q_cldfb_state = Q11; - move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ - Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; - Word16 q_bpf_error_signal; - Word16 cldfb_state_offset; - cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); - - // Get Q-factor - q_bpf_error_signal = Q6; - move16(); -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 -#else - Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 -#endif - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 - Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 - } - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) - st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; - move16(); - tmp = 0; - move16(); - if ( !st->bpf_off ) - { - tmp = nSamples; - move16(); + set32_fx( synth_fx, 0, output_frame ); } - addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); - - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( sub( q_bpf_error_signal, Q10 ) ) ); // Q10 - st->cldfbBPF->Q_cldfb_state = Q10; - move16(); - /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ - Word16 Q_real, Q_imag; - Word32 max_real, max_imag; - Q_real = 0; - Q_imag = 0; - max_real = 0; - max_imag = 0; - move16(); - move16(); - move32(); - move32(); - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); - max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); - } - } - Word32 max_val = L_max( max_real, max_imag ); - Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */; - Q_real = Q_imag; - move16(); - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - } - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) + /* Copy output signal */ #ifndef MSAN_FIX - Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 ); -#endif - - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn ); - -#ifdef MSAN_FIX - Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 + Scale_sig( syn_tmp_fx, L_FRAME16k + L_SUBFR, -st->Q_syn ); #else - Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) ); + Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0 #endif - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSyn->Q_cldfb_state = Q10; - move16(); - IF( st->p_bpf_noise_buf_32 ) + IF( st->element_mode > EVS_MONO ) { - Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 - Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); - - Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 + Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ } - set32_fx( synth_fx, 0, output_frame ); - } - - /* Copy output signal */ -#ifndef MSAN_FIX - Scale_sig( syn_tmp_fx, L_FRAME16k + L_SUBFR, -st->Q_syn ); -#else - Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0 -#endif - IF( st->element_mode > EVS_MONO ) - { - Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ + st->Q_syn2 = 0; + move16(); } - st->Q_syn2 = 0; - move16(); /*-----------------------------------------------------------------* * Bandwidth extension 6kHz-7kHz *-----------------------------------------------------------------*/ @@ -2126,26 +2317,41 @@ ivas_error acelp_core_dec_ivas_fx( IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) && ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) ) { +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, + st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &st->hBWE_zero->memExp1, st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode ); + } + ELSE +#endif + { #ifdef MSAN_FIX - Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0 + Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0 #else - Copy_Scale_sig_32_16( synth_fx, synth_fx16, L_FRAME48k, 0 ); + Copy_Scale_sig_32_16( synth_fx, synth_fx16, L_FRAME48k, 0 ); #endif - hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, - psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &st->hBWE_zero->memExp1, - st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode ); + hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, + psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &st->hBWE_zero->memExp1, + st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode ); #ifdef MSAN_FIX - Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); + Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); #else - Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, L_FRAME48k, 0 ); + Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, L_FRAME48k, 0 ); #endif + } } ELSE { hf_synth_reset_fx( st->hBWE_zero ); +#ifdef REMOVE_EVS_DUPLICATES2 + IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but conditon is here to keep EVS bit-exact +#endif + { #ifdef MSAN_FIX - set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); #endif + } } } @@ -2180,13 +2386,23 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( !st->ppp_mode_dec && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) { +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, + st->coder_type, voice_factors_fx, st->L_frame ); + } + ELSE +#endif + { #ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc #else - Copy_Scale_sig_16_32_DEPREC( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + Copy_Scale_sig_16_32_DEPREC( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc #endif - non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); - Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); + Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + } } test(); if ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) @@ -2195,6 +2411,7 @@ ivas_error acelp_core_dec_ivas_fx( move32(); } } + /*----------------------------------------------------------------------* * Updates *----------------------------------------------------------------------*/ @@ -2205,10 +2422,19 @@ ivas_error acelp_core_dec_ivas_fx( IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) { /* update CNG parameters in active frames */ - cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, - st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, - st->hFdCngDec->hFdCngCom->CngBandwidth ); - +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, + st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); + } + ELSE +#endif + { + cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, + st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, + st->hFdCngDec->hFdCngCom->CngBandwidth ); + } /* Set 16k LSP flag for CNG buffer */ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0; @@ -2220,6 +2446,9 @@ ivas_error acelp_core_dec_ivas_fx( } } +#ifdef REMOVE_EVS_DUPLICATES + IF( NE_16( st->element_mode, EVS_MONO ) ) +#endif { IF( save_hb_synth_fx16 ) { diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index b3fbc0233..8a2ef7b40 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -374,7 +374,7 @@ ivas_error amr_wb_dec_fx( IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) { /* decode CNG parameters */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES CNG_dec_ivas_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env ); #else CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env ); @@ -800,7 +800,7 @@ ivas_error amr_wb_dec_fx( PMT( "Fixed point not done here " ) ApplyFdCng_fx( syn, NULL, NULL, NULL, st, 0, 0 ); #else -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, NULL, NULL, NULL, st_fx, 0, 0 ); #else ApplyFdCng_fx( syn_fx, st_fx->Q_syn, NULL, NULL, NULL, st_fx, 0, 0 ); diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index 9c0020223..ff03f8bc5 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -713,5 +713,20 @@ void decision_matrix_dec_fx( move16(); } +#ifdef REMOVE_EVS_DUPLICATES2 + /*-----------------------------------------------------------------* + * set inactive coder_type flag in ACELP core + *-----------------------------------------------------------------*/ + + st->inactive_coder_type_flag = 0; /* AVQ by default */ + move16(); + + if ( LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) ) + { + st->inactive_coder_type_flag = 1; /* GSC */ + move16(); + } + +#endif return; } diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index fee893c4b..2f0873ba5 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -346,8 +346,11 @@ ivas_error evs_dec_fx( IF( EQ_16( st_fx->core, ACELP_CORE ) ) { /* ACELP core decoder */ - +#ifdef REMOVE_EVS_DUPLICATES2 + IF( ( error = acelp_core_dec_ivas_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) +#else IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1000,7 +1003,7 @@ ivas_error evs_dec_fx( #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT ApplyFdCng_fx( output, NULL, realBuffer, imagBuffer, st, concealWholeFrame, 0 ); #else -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES ApplyFdCng_ivas_fx( output_sp, 0, NULL, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 ); #else ApplyFdCng_fx( output_sp, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 ); diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index af670f0d0..a3c9b5826 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1263,7 +1263,7 @@ Word16 ApplyFdCng_ivas_fx( ( !st->BER_detect ) ) { /* Perform noise estimation at the decoder */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); @@ -1276,7 +1276,7 @@ Word16 ApplyFdCng_ivas_fx( /* Update the shaping parameters */ test(); -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); @@ -1522,7 +1522,7 @@ Word16 ApplyFdCng_ivas_fx( IF( hFdCngCom->active_frame_counter > 0 ) { /* Perform noise estimation in active frames in the decoder for downward updates */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); @@ -1589,7 +1589,7 @@ Word16 ApplyFdCng_ivas_fx( IF( st != NULL && EQ_16( st->cng_type, LP_CNG ) ) { /* Perform noise estimation on inactive phase at the decoder */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); @@ -1603,7 +1603,7 @@ Word16 ApplyFdCng_ivas_fx( /* Update the shaping parameters */ test(); -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); @@ -1689,7 +1689,7 @@ Word16 ApplyFdCng_ivas_fx( IF( LT_32( hFdCngCom->msFrCnt_init_counter, L_deposit_l( hFdCngCom->msFrCnt_init_thresh ) ) ) { /* At initialization, interpolate the bin/band-wise levels from the partition levels */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); @@ -1711,7 +1711,7 @@ Word16 ApplyFdCng_ivas_fx( /* Interpolate the CLDFB band levels from the SID (partition) levels */ IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) ) { -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); @@ -1874,7 +1874,7 @@ Word16 ApplyFdCng_ivas_fx( IF( EQ_16( st->codec_mode, MODE2 ) ) { /* Generate comfort noise during SID or zero frames */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { generate_comfort_noise_dec_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 ); -- GitLab From 3fcb6e833731821485d4855821e600021da26cec Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Feb 2025 08:56:01 +0100 Subject: [PATCH 12/28] fix NB PF - tmp hack --- lib_dec/acelp_core_dec_ivas_fx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index f02e6d337..90360d635 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1498,7 +1498,18 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( st->last_bwidth == NB && st->hPFstat != NULL ) { - Copy( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); + } + ELSE +#endif + { + // VE: TBV: tmp hack - this is a bug in IVAS + Copy( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr ); + } + IF( st->bwidth == NB ) { st->hPFstat->on = 1; -- GitLab From 0a01289c10e58a9ab2ecfa93a0061768fd7d11fc Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Feb 2025 09:55:43 +0100 Subject: [PATCH 13/28] try revert acelp_core_dec_fx() --- lib_dec/evs_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 2f0873ba5..ada1a68de 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -346,7 +346,7 @@ ivas_error evs_dec_fx( IF( EQ_16( st_fx->core, ACELP_CORE ) ) { /* ACELP core decoder */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES2aa IF( ( error = acelp_core_dec_ivas_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) #else IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) -- GitLab From b2e1ffd8a00ee1b64d0a8f963182946b67874649 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Feb 2025 10:27:06 +0100 Subject: [PATCH 14/28] fix CNA --- lib_dec/acelp_core_dec_ivas_fx.c | 22 +++++++++++++++++++--- lib_dec/evs_dec_fx.c | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 90360d635..09d370760 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1748,10 +1748,26 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) ) { - FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) { - psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) ); - move16(); + // VE:TBC - in FLP, it is: + // v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 ); + // v_add( temp_buf, syn, syn, st->L_frame / 2 ); + FOR( i = 0; i < st->L_frame / 2; i++ ) + { + psyn_fx[i] = add( psyn_fx[i], shr_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->L_frame / 4], negate( st->Q_syn ) ) ); + move16(); + } + } + ELSE +#endif + { + FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ ) + { + psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) ); + move16(); + } } } diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index ada1a68de..2f0873ba5 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -346,7 +346,7 @@ ivas_error evs_dec_fx( IF( EQ_16( st_fx->core, ACELP_CORE ) ) { /* ACELP core decoder */ -#ifdef REMOVE_EVS_DUPLICATES2aa +#ifdef REMOVE_EVS_DUPLICATES2 IF( ( error = acelp_core_dec_ivas_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) #else IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) -- GitLab From 94c98bdb687a8609009c9fe94b80c33329734b41 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Feb 2025 11:30:34 +0100 Subject: [PATCH 15/28] REMOVE_EVS_DUPLICATES3 --- lib_com/bits_alloc_fx.c | 3 ++- lib_com/gs_inact_switching_fx.c | 5 +++-- lib_com/prot_fx.h | 32 ++++++++++++++++++++---------- lib_dec/FEC_fx.c | 4 ++++ lib_dec/FEC_scale_syn_fx.c | 3 ++- lib_dec/acelp_core_switch_dec_fx.c | 6 ++++++ lib_dec/amr_wb_dec_fx.c | 17 ++++++++++++++++ lib_dec/cng_dec_fx.c | 3 ++- lib_dec/dec_ace_fx.c | 6 ++++++ lib_dec/dec_gen_voic_fx.c | 3 ++- lib_dec/dec_pit_exc_fx.c | 3 +++ lib_dec/dec_uv_fx.c | 3 ++- lib_dec/evs_dec_fx.c | 2 +- lib_dec/fd_cng_dec_fx.c | 4 +++- lib_dec/gs_dec_fx.c | 18 +++++++++++++++-- lib_dec/lsf_dec_fx.c | 3 ++- lib_enc/acelp_core_enc_fx.c | 28 ++++++++++++++++++++++++-- lib_enc/acelp_core_switch_enc_fx.c | 6 ++++++ lib_enc/transition_enc_fx.c | 27 +++++++++++++++++++++++++ 19 files changed, 152 insertions(+), 24 deletions(-) diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index 83a98a85f..53c5ca474 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -761,6 +761,7 @@ static ivas_error acelp_FCB_allocator_ivas( * - per channel bitrate minimum is 13250 kbps for ACELP@16kHz *--------------------------------------------------------------------*/ +#ifndef REMOVE_EVS_DUPLICATES ivas_error config_acelp1( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ @@ -1875,7 +1876,7 @@ ivas_error config_acelp1( * - should be in range of <6700; 24350> for ACELP@12.8kHz * - per channel bitrate minimum is 13250 kbps for ACELP@16kHz *--------------------------------------------------------------------*/ - +#endif ivas_error config_acelp1_IVAS( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index 52635d502..5e74feb0c 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -38,6 +38,8 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*========================================================================*/ + +#ifndef REMOVE_EVS_DUPLICATES void Inac_swtch_ematch_fx( Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ @@ -155,8 +157,7 @@ void Inac_swtch_ematch_fx( return; } - - +#endif void Inac_switch_ematch_ivas_fx( Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index bef07e952..f80814a0e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4776,6 +4776,7 @@ Word16 BITS_ALLOC_config_acelp( const Word16 narrowband, const Word16 nb_subfr ); +#ifndef REMOVE_EVS_DUPLICATES3 ivas_error config_acelp1( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ @@ -4802,7 +4803,7 @@ ivas_error config_acelp1( const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); - +#endif Word16 set_ACELP_flag( const Word16 element_mode, /* i : element mode */ const Word32 element_brate, /* i : element bitrate */ @@ -5762,6 +5763,7 @@ void tcx_ltp_post32( Word32 *tcx_buf, /* sig_q */ Word16 sig_q ); +#ifndef REMOVE_EVS_DUPLICATES3 // gs_inact_switching_fx.c void Inac_swtch_ematch_fx( Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ @@ -5777,6 +5779,7 @@ void Inac_swtch_ematch_fx( const short last_core, /* i : Last core used */ const short last_codec_mode /* i : Last codec mode */ ); +#endif void Inac_switch_ematch_ivas_fx( Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ @@ -6035,6 +6038,7 @@ void td_bwe_dec_init_fx( const Word32 output_Fs /* i : output sampling rate */ ); +#ifndef REMOVE_EVS_DUPLICATES3 // lsf_dec_fx.c void lsf_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ @@ -6048,7 +6052,7 @@ void lsf_dec_fx( , const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ ); - +#endif void lsf_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 tc_subfr, /* i : TC subframe index Q0*/ @@ -6204,6 +6208,7 @@ void lsf_mid_dec_fx( Word16 lsp_mid[] /* o : quantized LSPs Q15*/ ); +#ifndef REMOVE_EVS_DUPLICATES3 // cng_dec_fx.c void CNG_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ @@ -6214,7 +6219,7 @@ void CNG_dec_fx( Word16 *allow_cn_step, /* o : allow CN step Q0 */ Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ Word32 *q_env ); - +#endif void CNG_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 last_element_mode, /* i : last element mode Q0 */ @@ -6819,6 +6824,7 @@ void PulseResynchronization_fx( Word32 /*float*/ const pitchEnd /*i Q16*/ ); +#ifndef REMOVE_EVS_DUPLICATES3 // gs_dec_fx.c void decod_audio_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -6833,7 +6839,7 @@ void decod_audio_fx( , Word16 *gain_buf /*Q14*/ ); - +#endif void decod_audio_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ @@ -6852,6 +6858,7 @@ void decod_audio_ivas_fx( const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ ); +#ifndef REMOVE_EVS_DUPLICATES3 void gsc_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ @@ -6864,7 +6871,7 @@ void gsc_dec_fx( const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 Q_exc ); - +#endif void gsc_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ @@ -7080,6 +7087,7 @@ void re8_PPV_fx( Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ ); +#ifndef REMOVE_EVS_DUPLICATES3 // dec_pit_exc_fx.c void dec_pit_exc_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -7099,7 +7107,7 @@ void dec_pit_exc_fx( const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ #endif ); - +#endif void dec_pit_exc_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* i : LP filter coefficient */ @@ -7539,6 +7547,7 @@ void configureFdCngDec_fx( const Word16 Last_L_frame, const Word16 element_mode ); +#ifndef REMOVE_EVS_DUPLICATES3 /* Apply the CLDFB-based CNG */ Word16 ApplyFdCng_fx( Word16 *timeDomainInput, /* i : pointer to time domain i */ @@ -7552,7 +7561,7 @@ Word16 ApplyFdCng_fx( Decoder_State *st, const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */ Word16 is_music ); - +#endif Word16 ApplyFdCng_ivas_fx( Word16 *timeDomainInput, /* i : pointer to time domain input */ Word16 Q, @@ -8185,6 +8194,7 @@ void FEC_pitch_estim_fx( Word16 element_mode /* i : element mode */ ); +#ifndef REMOVE_EVS_DUPLICATES3 // FEC_scale_sync_fx.c void FEC_scale_syn_fx( const Word16 L_frame, /* i : length of the frame */ @@ -8215,7 +8225,7 @@ void FEC_scale_syn_fx( const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ const Word16 force_scaling /* i: force scaling */ ); - +#endif void FEC_scale_syn_ivas_fx( const Word16 L_frame, /* i : length of the frame */ Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ @@ -8532,6 +8542,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ ); +#ifndef REMOVE_EVS_DUPLICATES3 // dec_uv_fx.c void decod_unvoiced_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -8544,7 +8555,7 @@ void decod_unvoiced_fx( Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ Word16 *gain_buf ); - +#endif void decod_unvoiced_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ @@ -8588,6 +8599,7 @@ void gaus_L2_dec( Word16 *seed_acelp /*i/o : random seed Q0 */ ); +#ifndef REMOVE_EVS_DUPLICATES3 // dec_gen_voic_fx.c ivas_error decod_gen_voic_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -8604,7 +8616,7 @@ ivas_error decod_gen_voic_fx( Word16 *unbits, /* number of unused bits */ Word16 *gain_buf /*Q14*/ ); - +#endif ivas_error decod_gen_voic_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 L_frame, /* i : length of the frame */ diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c index 0686996f3..ae222b3ca 100644 --- a/lib_dec/FEC_fx.c +++ b/lib_dec/FEC_fx.c @@ -511,6 +511,9 @@ void FEC_exc_estim_fx( /* st_fx->L_frame / L_SUBFR */ tmp = shr( st_fx->L_frame, 6 ); /* Replication of the last spectrum, with a slight downscaling of its dynamic */ +#ifdef REMOVE_EVS_DUPLICATES + gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc ); +#else IF( st_fx->element_mode == EVS_MONO ) { gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); @@ -519,6 +522,7 @@ void FEC_exc_estim_fx( { gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc ); } +#endif *tmp_noise = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ move16(); /* Transform back to time domain */ diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c index f6439b166..714a60166 100644 --- a/lib_dec/FEC_scale_syn_fx.c +++ b/lib_dec/FEC_scale_syn_fx.c @@ -50,6 +50,7 @@ /* _ None */ /*========================================================================*/ +#ifndef REMOVE_EVS_DUPLICATES void FEC_scale_syn_fx( const Word16 L_frame, /* i : length of the frame */ Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ @@ -614,7 +615,7 @@ void FEC_scale_syn_fx( return; } - +#endif void FEC_scale_syn_ivas_fx( const Word16 L_frame, /* i : length of the frame */ Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index f347cdb7e..6bdf57083 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -128,7 +128,13 @@ ivas_error acelp_core_switch_dec_fx( /*----------------------------------------------------------------* * Excitation decoding *----------------------------------------------------------------*/ + +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 ); +#else config_acelp1( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 ); +#endif + decod_gen_voic_core_switch_fx( st_fx, L_frame_for_cs, 0, Aq, exc, cbrate, &st_fx->Q_exc ); /*----------------------------------------------------------------* diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 8a2ef7b40..8881b26ba 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -631,9 +631,15 @@ ivas_error amr_wb_dec_fx( move16(); } +#ifdef REMOVE_EVS_DUPLICATES + FEC_scale_syn_ivas_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, + &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, + exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 ); +#else FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); +#endif frame_ener_fx( L_FRAME, st_fx->clas_dec, syn_fx, pitch_buf_tmp[3], &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 ); } @@ -712,10 +718,17 @@ ivas_error amr_wb_dec_fx( * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES + FEC_scale_syn_ivas_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, + MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, + st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, + st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, 0, 0 ); +#else FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, 0, 0 ); +#endif /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ frame_ener_fx( L_FRAME, st_fx->last_good, syn_fx, shr( FEC_pitch_fx, 6 ), &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 ); @@ -772,7 +785,11 @@ ivas_error amr_wb_dec_fx( st_fx->hPFstat->on = 1; move16(); test(); +#ifdef REMOVE_EVS_DUPLICATES + formant_post_filt_ivas_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, sub( amr_io_class, AUDIO_CLAS ) == 0 ); +#else formant_post_filt_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, sub( amr_io_class, AUDIO_CLAS ) == 0 ); +#endif } /*----------------------------------------------------------------* diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 3590dae71..3f6a97b98 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -26,6 +26,7 @@ static void shb_CNG_decod_ivas_fx( Decoder_State *st_fx, const Word16 *synth_fx, * Decode residual signal energy *-----------------------------------------------------------------*/ +#ifndef REMOVE_EVS_DUPLICATES void CNG_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 last_element_mode, /* i : last element mode Q0 */ @@ -696,7 +697,7 @@ void CNG_dec_fx( return; } - +#endif void CNG_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 last_element_mode, /* i : last element mode Q0 */ diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index e327d4cfb..cb7556b24 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -681,9 +681,15 @@ void decoder_acelp_fx( move16(); } +#ifdef REMOVE_EVS_DUPLICATES + FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, syn, pBuf_scaleSyn, st->enr_old_fx, 0, + st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, + exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, force_scale_syn ); +#else FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, syn, pBuf_scaleSyn, st->enr_old_fx, 0, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, force_scale_syn ); +#endif } /* update ACELP synthesis memory */ Copy( mem_syn, st->mem_syn2_fx, M ); diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 8ee335e3f..c369c4865 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -36,6 +36,7 @@ /* _ None */ /*======================================================================*/ +#ifndef REMOVE_EVS_DUPLICATES ivas_error decod_gen_voic_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 L_frame, /* i : length of the frame */ @@ -503,7 +504,7 @@ ivas_error decod_gen_voic_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================*/ - +#endif ivas_error decod_gen_voic_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 L_frame, /* i : length of the frame */ diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 4e18eebce..bc12fd306 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -29,6 +29,8 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*==========================================================================*/ + +#ifndef REMOVE_EVS_DUPLICATES void dec_pit_exc_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* i : LP filter coefficient */ @@ -456,6 +458,7 @@ void dec_pit_exc_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*==========================================================================*/ +#endif void dec_pit_exc_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* i : LP filter coefficient */ diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index 6a15732a0..e98858996 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -25,6 +25,7 @@ static void gain_dec_gacelp_uv_fx( * Decode unvoiced (UC) frames *-------------------------------------------------------------------*/ +#ifndef REMOVE_EVS_DUPLICATES void decod_unvoiced_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ @@ -112,7 +113,7 @@ void decod_unvoiced_fx( * * Decode unvoiced (UC) frames *-------------------------------------------------------------------*/ - +#endif void decod_unvoiced_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 2f0873ba5..ada1a68de 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -346,7 +346,7 @@ ivas_error evs_dec_fx( IF( EQ_16( st_fx->core, ACELP_CORE ) ) { /* ACELP core decoder */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES2aa IF( ( error = acelp_core_dec_ivas_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) #else IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index a3c9b5826..b17113495 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -572,6 +572,8 @@ void deleteFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec ) Returns: error */ + +#ifndef REMOVE_EVS_DUPLICATES Word16 ApplyFdCng_fx( Word16 *timeDomainInput, /* i : pointer to time domain input Q*/ Word16 Q, @@ -1160,7 +1162,7 @@ Word16 ApplyFdCng_fx( return 0; } - +#endif Word16 ApplyFdCng_ivas_fx( Word16 *timeDomainInput, /* i : pointer to time domain input Q*/ Word16 Q, diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 72e07e57f..622fe6a26 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -31,6 +31,8 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*==========================================================================*/ + +#ifndef REMOVE_EVS_DUPLICATES void decod_audio_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ @@ -96,12 +98,18 @@ void decod_audio_fx( st_fx->GSC_noisy_speech = 0; /* Q0 */ move16(); } + /* set bit-allocation */ #ifdef ADD_LRTD config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#else +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #endif +#endif + /*---------------------------------------------------------------* * Decode energy dynamics *---------------------------------------------------------------*/ @@ -529,6 +537,7 @@ void decod_audio_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*==========================================================================*/ +#endif void decod_audio_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ @@ -600,12 +609,14 @@ void decod_audio_ivas_fx( st_fx->GSC_noisy_speech = 0; move16(); } + /* set bit-allocation */ -#if 1 // def ADD_LRTD +#if 1 // def ADD_LRTD or def REMOVE_EVS_DUPLICATES config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #endif + /*---------------------------------------------------------------* * Decode energy dynamics *---------------------------------------------------------------*/ @@ -825,7 +836,7 @@ void decod_audio_ivas_fx( Es_pred_dec_fx( &Es_pred, indice, nbits, 0 ); } -#if 1 // def ADD_LRTD +#if 1 // def ADD_LRTD or def REMOVE_EVS_DUPLICATES dec_pit_exc_ivas_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); #else dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf ); @@ -1077,6 +1088,8 @@ void decod_audio_ivas_fx( /* RETURN ARGUMENTS : */ /* _None */ /*==========================================================================*/ + +#ifndef REMOVE_EVS_DUPLICATES void gsc_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ @@ -1404,6 +1417,7 @@ void gsc_dec_fx( /* RETURN ARGUMENTS : */ /* _None */ /*==========================================================================*/ +#endif void gsc_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 50b5ec341..40628a5bb 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -100,6 +100,7 @@ static void dqlsf_CNG_fx( /* _ None */ /*===========================================================================*/ +#ifndef REMOVE_EVS_DUPLICATES void lsf_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 tc_subfr, /* i : TC subframe index Q0*/ @@ -353,7 +354,7 @@ void lsf_dec_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*===========================================================================*/ - +#endif void lsf_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 tc_subfr, /* i : TC subframe index Q0*/ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 6449367c8..97254972d 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -401,10 +401,17 @@ ivas_error acelp_core_enc_fx( test(); IF( !nelp_mode && !ppp_mode ) { +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, + st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, + st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); + +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#endif } /*-----------------------------------------------------------------* @@ -537,9 +544,15 @@ ivas_error acelp_core_enc_fx( { tc_classif_enc_fx( Q_new, st_fx->L_frame, &tc_subfr_fx, &position, attack_flag, st_fx->pitch[0], res_fx ); +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, + -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, + tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#endif } /*---------------------------------------------------------------* @@ -604,9 +617,15 @@ ivas_error acelp_core_enc_fx( lsp_mid_bck_fx, mCb1_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen_fx ); /* Configure ACELP bit allocation */ +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, + -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, + st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#endif /* redo LSF quantization */ #ifdef LSF_RE_USE_SECONDARY_CHANNEL @@ -1267,7 +1286,9 @@ ivas_error acelp_core_enc_ivas_fx( test(); IF( !nelp_mode && !ppp_mode ) { - config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, + st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, + st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); } /*-----------------------------------------------------------------* @@ -1404,7 +1425,9 @@ ivas_error acelp_core_enc_ivas_fx( { tc_classif_enc_fx( Q_new, st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res_fx ); - config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, + -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, + st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); } /*---------------------------------------------------------------* @@ -1461,6 +1484,7 @@ ivas_error acelp_core_enc_ivas_fx( { /* restore memories of LSF quantizer and synthesis filter */ lsf_syn_mem_restore_ivas_fx( st, tilt_code_bck_fx, gc_threshold_bck_fx, clip_var_bck_fx, next_force_sf_bck, lsp_new, lsp_mid, clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen ); + /* Configure ACELP bit allocation */ config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index d521d85a2..70a84c198 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -148,8 +148,14 @@ void acelp_core_switch_enc_fx( /*----------------------------------------------------------------* * Excitation encoding *----------------------------------------------------------------*/ + +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, + GENERIC, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); +#else config_acelp1( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, GENERIC, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); +#endif encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 02372138d..adb529ca6 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -213,10 +213,16 @@ void transition_enc_fx( IF( EQ_16( *tc_subfr, TC_0_0 ) ) { /* this is called only to compute unused bits */ +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, + L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, TC_0_0, 3, NULL, unbits_ACELP, + st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, TC_0_0, 3, NULL, unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#endif } *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) ); move16(); @@ -325,10 +331,17 @@ void transition_enc_fx( IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) { +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, + st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, *tc_subfr, 2, NULL, + unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, *tc_subfr, 2, NULL, unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#endif } + /*-----------------------------------------------------------------* * get number of bits for pitch encoding *-----------------------------------------------------------------*/ @@ -1033,11 +1046,18 @@ void transition_enc_ivas_fx( IF( EQ_16( *tc_subfr, TC_0_0 ) ) { +#ifdef REMOVE_EVS_DUPLICATES + /* this is called only to compute unused bits */ + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, + L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, TC_0_0, 3, NULL, unbits_ACELP, + st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#else /* this is called only to compute unused bits */ config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, TC_0_0, 3, NULL, unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#endif } *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) ); move16(); @@ -1146,10 +1166,17 @@ void transition_enc_ivas_fx( IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) { +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, + st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, *tc_subfr, 2, NULL, + unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, *tc_subfr, 2, NULL, unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#endif } + /*-----------------------------------------------------------------* * get number of bits for pitch encoding *-----------------------------------------------------------------*/ -- GitLab From b45ca67f12f69b4f452fa9facf50911748af6f74 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Feb 2025 12:00:06 +0100 Subject: [PATCH 16/28] fix build --- lib_com/bits_alloc_fx.c | 3 ++- lib_com/prot_fx.h | 3 ++- lib_dec/acelp_core_switch_dec_fx.c | 6 +++++- lib_dec/dec_amr_wb_fx.c | 5 +++++ lib_dec/dec_gen_voic_fx.c | 3 ++- lib_dec/dec_uv_fx.c | 11 ++++++++++- lib_dec/pit_dec_fx.c | 4 ++-- 7 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index 53c5ca474..1d8a90048 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -439,6 +439,7 @@ static Word16 fcb_table( * Routine to allocate fixed innovation codebook bit-budget *--------------------------------------------------------------------*/ +#ifndef REMOVE_EVS_DUPLICATES static ivas_error acelp_FCB_allocator( Word16 *nBits, /* i/o: available bit-budget */ Word16 fixed_cdk_index[], /* o : codebook index Q0 */ @@ -599,7 +600,7 @@ static ivas_error acelp_FCB_allocator( return error; } - +#endif static ivas_error acelp_FCB_allocator_ivas( Word16 *nBits, /* i/o: available bit-budget */ Word16 fixed_cdk_index[], /* o : codebook index Q0 */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index f80814a0e..34b72e544 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7166,6 +7166,7 @@ void Mode2_delta_pit_dec( Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ ); +#ifndef REMOVE_EVS_DUPLICATES3 Word16 pit_decode_fx( /* o : floating pitch value */ Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -7185,7 +7186,7 @@ Word16 pit_decode_fx( /* o : floating pitch value const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ #endif ); - +#endif Word16 pit_decode_ivas_fx( /* o : floating pitch value */ Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 6bdf57083..36bac44ec 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -825,7 +825,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( #ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( syn, syn32, L_FRAME16k, Qtmp ); // Q(11) #else - Copy_Scale_sig_16_32_DEPREC( syn, syn32, L_FRAME16k, Qtmp ); // Q(11) + Copy_Scale_sig_16_32_DEPREC( syn, syn32, L_FRAME16k, Qtmp ); // Q(11) #endif IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbAna ) ), IVAS_ERR_OK ) ) { @@ -919,7 +919,11 @@ static void decod_gen_voic_core_switch_fx( * Decode pitch lag *----------------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES3 + pitch = pit_decode_ivas_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); /*Q6*/ +#else pitch = pit_decode_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); /*Q6*/ +#endif /*--------------------------------------------------------------* * Find the adaptive codebook vector. diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index baea98a2c..8a980f68d 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -71,12 +71,17 @@ void decod_amr_wb_fx( * Decode pitch lag *----------------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES + *pt_pitch_fx = pit_decode_ivas_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); +#else *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR #ifdef ADD_LRTD , 0, NULL #endif ); +#endif + /*--------------------------------------------------------------* * Find the adaptive codebook vector *--------------------------------------------------------------*/ diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index c369c4865..bcbef190f 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -677,6 +677,7 @@ ivas_error decod_gen_voic_ivas_fx( IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) { + // VE: function to be merged? gain_dec_lbr_ivas_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR ); } ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) ) @@ -801,7 +802,7 @@ ivas_error decod_gen_voic_ivas_fx( { idx = idiv1616( i_subfr_fx, L_SUBFR ); } - + // VE: function to be merged prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index e98858996..6a9fbcf3f 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -208,7 +208,16 @@ void decod_unvoiced_ivas_fx( move16(); /* update LP filtered gains for the case of frame erasures */ - lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); + } + ELSE +#endif + { + lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); + } /*-------------------------------------------------------* * - Find the total excitation. * diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c index b72c2bae1..6c37bb906 100644 --- a/lib_dec/pit_dec_fx.c +++ b/lib_dec/pit_dec_fx.c @@ -319,7 +319,7 @@ void Mode2_delta_pit_dec( /* _ (Word16 ) pitch : close loop integer pitch Q6 */ /*=======================================================================*/ - +#ifndef REMOVE_EVS_DUPLICATES3 Word16 pit_decode_fx( /* o : floating pitch value */ Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -599,7 +599,7 @@ Word16 pit_decode_fx( /* o : floating pitch value /* _ (Word16 ) pitch : close loop integer pitch Q6 */ /*=======================================================================*/ - +#endif Word16 pit_decode_ivas_fx( /* o : floating pitch value */ Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ -- GitLab From 4bc1b7981ad272a770c662102f661f5f7adf6837 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Feb 2025 12:51:07 +0100 Subject: [PATCH 17/28] REMOVE_EVS_DUPLICATES3 --- lib_com/options.h | 2 +- lib_com/prot_fx.h | 3 ++- lib_dec/acelp_core_dec_ivas_fx.c | 2 +- lib_dec/acelp_core_switch_dec_fx.c | 2 +- lib_dec/dec_post_fx.c | 10 +++++++--- lib_dec/decision_matrix_dec_fx.c | 2 +- lib_dec/evs_dec_fx.c | 2 +- lib_dec/post_dec_fx.c | 16 ++++++++++++++++ 8 files changed, 30 insertions(+), 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f45ee973d..b30960266 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,5 +156,5 @@ #define SVD_WMOPS_OPT /* Ittiam : SVD related optimizations */ #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions */ -#define REMOVE_EVS_DUPLICATES2 +#define REMOVE_EVS_DUPLICATES3 #endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 34b72e544..8c823e1f1 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6639,6 +6639,7 @@ void nb_post_filt_fx( const Word16 disable_hpf /* i : flag to diabled HPF */ ); +#ifndef REMOVE_EVS_DUPLICATES void formant_post_filt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ @@ -6649,7 +6650,7 @@ void formant_post_filt_fx( Word32 rate, /* (i) : bit-rate */ const Word16 off_flag /* i : off flag */ ); - +#endif void formant_post_filt_ivas_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 09d370760..7c9e50b85 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -2371,7 +2371,7 @@ ivas_error acelp_core_dec_ivas_fx( ELSE { hf_synth_reset_fx( st->hBWE_zero ); -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but conditon is here to keep EVS bit-exact #endif { diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 36bac44ec..7a6348905 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -920,7 +920,7 @@ static void decod_gen_voic_core_switch_fx( *----------------------------------------------------------------------*/ #ifdef REMOVE_EVS_DUPLICATES3 - pitch = pit_decode_ivas_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); /*Q6*/ + pitch = pit_decode_ivas_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); /*Q6*/ #else pitch = pit_decode_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); /*Q6*/ #endif diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index a6e06db54..df3fb1f8f 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -33,8 +33,9 @@ static void calc_st_filt_local_fx( Word16 *apond2, Word16 *apond1, Word16 *parco static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor ); +#ifndef REMOVE_EVS_DUPLICATES static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); - +#endif static void Dec_formant_postfilt_ivas_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl ); @@ -255,6 +256,8 @@ static void Dec_postfilt_fx( * * Main routine to perform formant post filtering *--------------------------------------------------------------------------*/ + +#ifndef REMOVE_EVS_DUPLICATES void formant_post_filt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ @@ -379,7 +382,7 @@ void formant_post_filt_fx( p_Aq += ( M + 1 ); } } - +#endif void formant_post_filt_ivas_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ @@ -519,6 +522,7 @@ void formant_post_filt_ivas_fx( * k1 = 1st parcor calculated on {hi} * gamma3 = gamma3_minus if k1<0, gamma3_plus if k1>0 *----------------------------------------------------------------------------*/ +#ifndef REMOVE_EVS_DUPLICATES static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/ @@ -597,7 +601,7 @@ static void Dec_formant_postfilt_fx( return; } - +#endif static void Dec_formant_postfilt_ivas_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/ diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index ff03f8bc5..8433960b2 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -713,7 +713,7 @@ void decision_matrix_dec_fx( move16(); } -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES /*-----------------------------------------------------------------* * set inactive coder_type flag in ACELP core *-----------------------------------------------------------------*/ diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index ada1a68de..1a7338315 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -346,7 +346,7 @@ ivas_error evs_dec_fx( IF( EQ_16( st_fx->core, ACELP_CORE ) ) { /* ACELP core decoder */ -#ifdef REMOVE_EVS_DUPLICATES2aa +#ifdef REMOVE_EVS_DUPLICATES IF( ( error = acelp_core_dec_ivas_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) #else IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index d581f810a..b5d56d8fb 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -139,13 +139,21 @@ void post_decoder( { st->hPFstat->on = 1; move16(); +#ifdef REMOVE_EVS_DUPLICATES + formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); +#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); +#endif } ELSE { st->hPFstat->on = 0; move16(); +#ifdef REMOVE_EVS_DUPLICATES + formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); +#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); +#endif } } @@ -302,13 +310,21 @@ void post_decoder_ivas_fx( { st->hPFstat->on = 1; move16(); +#ifdef REMOVE_EVS_DUPLICATES + formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); +#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); +#endif } ELSE { st->hPFstat->on = 0; move16(); +#ifdef REMOVE_EVS_DUPLICATES + formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); +#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); +#endif } } -- GitLab From e4e68a27ef3d8305598a922e2fd8e7916282b9dc Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Feb 2025 15:29:00 +0100 Subject: [PATCH 18/28] fix old_syn_12k8_16k_fx[] --- lib_dec/acelp_core_dec_ivas_fx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 7c9e50b85..e7b1032a2 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -849,7 +849,16 @@ ivas_error acelp_core_dec_ivas_fx( Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn IF( st->hBWE_FD != NULL ) { - save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - this is likely a bug in IVAS + { + save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); + } + ELSE +#endif + { + save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); + } } } -- GitLab From 9ad83d1c7250046e9403523c67c33ac488bcafc5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Feb 2025 17:09:53 +0100 Subject: [PATCH 19/28] REMOVE_EVS_DUPLICATES2 --- lib_com/options.h | 4 +- lib_com/prot_fx.h | 32 +++++++++------ lib_com/swb_tbe_com_fx.c | 3 +- lib_dec/acelp_core_dec_fx.c | 12 +++--- lib_dec/acelp_core_dec_ivas_fx.c | 11 +++-- lib_dec/acelp_core_switch_dec_fx.c | 2 +- lib_dec/dec_LPD_fx.c | 5 +++ lib_dec/dec_ace_fx.c | 5 +++ lib_dec/dec_gen_voic_fx.c | 3 +- lib_dec/dec_tran_fx.c | 8 ++++ lib_dec/gain_dec_fx.c | 4 +- lib_dec/init_dec_fx.c | 1 - lib_dec/pit_dec_fx.c | 2 +- lib_enc/analy_lp_fx.c | 65 +++++++++++++++++++----------- lib_enc/cod_ace_fx.c | 6 +++ lib_enc/enc_gen_voic_fx.c | 7 ++++ lib_enc/enc_tran_fx.c | 5 +++ lib_enc/init_enc_fx.c | 1 - lib_enc/ivas_core_pre_proc.c | 9 +++++ lib_enc/ivas_core_pre_proc_front.c | 4 ++ lib_enc/ivas_front_vad.c | 5 +++ lib_enc/pre_proc_fx.c | 10 ++++- lib_enc/prot_fx_enc.h | 31 ++++++++------ 23 files changed, 163 insertions(+), 72 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b30960266..dd2eef974 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,6 +155,6 @@ #define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */ #define SVD_WMOPS_OPT /* Ittiam : SVD related optimizations */ -#define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions */ -#define REMOVE_EVS_DUPLICATES3 +#define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ +#define REMOVE_EVS_DUPLICATES2 #endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 8c823e1f1..c90b7551a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3220,6 +3220,7 @@ void synthesise_fb_high_band_fx( Word16 bpf_memory_Q[], Word16 Qout ); +#ifndef REMOVE_EVS_DUPLICATES2 void prep_tbe_exc_fx( const Word16 L_frame_fx, /* i : length of the frame */ #ifdef ADD_IVAS_TBE_CODE @@ -3247,6 +3248,7 @@ void prep_tbe_exc_fx( const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ #endif ); +#endif void prep_tbe_exc_ivas_fx( const Word16 L_frame_fx, /* i : length of the frame */ @@ -4776,7 +4778,7 @@ Word16 BITS_ALLOC_config_acelp( const Word16 narrowband, const Word16 nb_subfr ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES ivas_error config_acelp1( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ @@ -5763,7 +5765,7 @@ void tcx_ltp_post32( Word32 *tcx_buf, /* sig_q */ Word16 sig_q ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES // gs_inact_switching_fx.c void Inac_swtch_ematch_fx( Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ @@ -6038,7 +6040,7 @@ void td_bwe_dec_init_fx( const Word32 output_Fs /* i : output sampling rate */ ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES // lsf_dec_fx.c void lsf_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ @@ -6208,7 +6210,7 @@ void lsf_mid_dec_fx( Word16 lsp_mid[] /* o : quantized LSPs Q15*/ ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES // cng_dec_fx.c void CNG_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ @@ -6825,7 +6827,7 @@ void PulseResynchronization_fx( Word32 /*float*/ const pitchEnd /*i Q16*/ ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES // gs_dec_fx.c void decod_audio_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -6859,7 +6861,7 @@ void decod_audio_ivas_fx( const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES void gsc_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ @@ -6940,6 +6942,7 @@ void gain_dec_mless_fx( Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/ ); +#ifndef REMOVE_EVS_DUPLICATES void gain_dec_lbr_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ @@ -6954,6 +6957,7 @@ void gain_dec_lbr_fx( , const Word16 L_subfr /* i : subfr lenght */ ); +#endif void gain_dec_lbr_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -7088,7 +7092,7 @@ void re8_PPV_fx( Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES // dec_pit_exc_fx.c void dec_pit_exc_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -7167,7 +7171,7 @@ void Mode2_delta_pit_dec( Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES Word16 pit_decode_fx( /* o : floating pitch value */ Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -7549,7 +7553,7 @@ void configureFdCngDec_fx( const Word16 Last_L_frame, const Word16 element_mode ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES /* Apply the CLDFB-based CNG */ Word16 ApplyFdCng_fx( Word16 *timeDomainInput, /* i : pointer to time domain i */ @@ -8196,7 +8200,7 @@ void FEC_pitch_estim_fx( Word16 element_mode /* i : element mode */ ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES // FEC_scale_sync_fx.c void FEC_scale_syn_fx( const Word16 L_frame, /* i : length of the frame */ @@ -8544,7 +8548,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES // dec_uv_fx.c void decod_unvoiced_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -8601,7 +8605,7 @@ void gaus_L2_dec( Word16 *seed_acelp /*i/o : random seed Q0 */ ); -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES // dec_gen_voic_fx.c ivas_error decod_gen_voic_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -9565,6 +9569,8 @@ void d_gain_pred_fx( Word16 *Es_pred, /* o : predicited scaled innovation energy */ Word16 **pt_indice /* i/o: pointer to the buffer of indices */ ); + +#ifndef REMOVE_EVS_DUPLICATES // acelp_core_dec_fx.c ivas_error acelp_core_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -9590,7 +9596,7 @@ ivas_error acelp_core_dec_fx( STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ const Word16 read_sid_info /* i : read SID info flag */ ); - +#endif // evs_dec_fx.c ivas_error evs_dec_fx( Decoder_State *st_fx, /* i/o : Decoder state structure */ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 92271c1f1..c7a8fd1f0 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -7131,6 +7131,7 @@ void tbe_celp_exc( /* _ None */ /*======================================================================================*/ +#ifndef REMOVE_EVS_DUPLICATES2 void prep_tbe_exc_fx( const Word16 L_frame_fx, /* i : length of the frame */ #ifdef ADD_IVAS_TBE_CODE @@ -7299,7 +7300,7 @@ void prep_tbe_exc_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================================*/ - +#endif void prep_tbe_exc_ivas_fx( const Word16 L_frame_fx, /* i : length of the frame */ #if 1 // def ADD_IVAS_TBE_CODE diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index fc35cb754..e81ae0428 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -10,6 +10,8 @@ #include "ivas_prot_fx.h" #include "ivas_cnst.h" /* Common constants */ #include "cnst.h" /* Common constants */ + +#ifndef REMOVE_EVS_DUPLICATES /*==========================================================================*/ /* FUNCTION : void acelp_core_dec_fx () */ /*--------------------------------------------------------------------------*/ @@ -661,7 +663,7 @@ ivas_error acelp_core_dec_fx( test(); IF( EQ_32( st_fx->core_brate, SID_2k40 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { - FdCng_decodeSID_fx( st_fx->hFdCngDec->hFdCngCom, st_fx ); // VE: 2 variants needed + FdCng_decodeSID_fx( st_fx->hFdCngDec->hFdCngCom, st_fx ); *sid_bw = 0; move16(); } @@ -691,7 +693,7 @@ ivas_error acelp_core_dec_fx( } } #endif - generate_comfort_noise_dec_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 2, -1 ); // VE: 2 variants needed + generate_comfort_noise_dec_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 2, -1 ); FdCng_exc( st_fx->hFdCngDec->hFdCngCom, &st_fx->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx, st_fx->first_CNG, st_fx->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); @@ -715,7 +717,6 @@ ivas_error acelp_core_dec_fx( #ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { - // VE: TBV: 'st_fx->L_frame * HIBND_ACB_L_FAC' should be corrected Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, st_fx->L_frame * HIBND_ACB_L_FAC, 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE ); } @@ -754,7 +755,7 @@ ivas_error acelp_core_dec_fx( FOR( i = 0; i < DCT_L_POST; i++ ) { /*st_fx->filt_lfE_fx[i] = 0.3f + 0.7f * st_fx->filt_lfE_fx[i];*/ - hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) ); // VE: 2 variants needed + hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) ); move16(); } } @@ -2054,7 +2055,7 @@ ivas_error acelp_core_dec_fx( { hf_synth_reset_fx( st_fx->hBWE_zero ); #ifdef MSAN_FIX - IF( NE_16( st_fx->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but conditon is here to keep EVS bit-exact + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); } @@ -2132,3 +2133,4 @@ ivas_error acelp_core_dec_fx( return IVAS_ERR_OK; } +#endif diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index e7b1032a2..fcfbe1e66 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -761,7 +761,7 @@ ivas_error acelp_core_dec_ivas_fx( #ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { - // VE: TBV: 'st_fx->L_frame * HIBND_ACB_L_FAC' should be corrected + // VE: TBV: should 'st_fx->L_frame * HIBND_ACB_L_FAC' be corrected in EVS? Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, st->L_frame * HIBND_ACB_L_FAC, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); } @@ -1223,7 +1223,7 @@ ivas_error acelp_core_dec_ivas_fx( #ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { - // VE: TBV: this is a bug in EVS - 'st->last_coder_type' should be replaced by 'st->core_brate' + // VE: TBV: this is likely a bug in EVS - 'st->last_coder_type' should be replaced by 'st->core_brate' Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_coder_type, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); } @@ -1760,7 +1760,7 @@ ivas_error acelp_core_dec_ivas_fx( #ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { - // VE:TBC - in FLP, it is: + // VE: TBV - is it correct in EVS? in FLP, it is: // v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 ); // v_add( temp_buf, syn, syn, st->L_frame / 2 ); FOR( i = 0; i < st->L_frame / 2; i++ ) @@ -2381,7 +2381,7 @@ ivas_error acelp_core_dec_ivas_fx( { hf_synth_reset_fx( st->hBWE_zero ); #ifdef REMOVE_EVS_DUPLICATES - IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but conditon is here to keep EVS bit-exact + IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment #endif { #ifdef MSAN_FIX @@ -2425,8 +2425,7 @@ ivas_error acelp_core_dec_ivas_fx( #ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { - non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, - st->coder_type, voice_factors_fx, st->L_frame ); + non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); } ELSE #endif diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 7a6348905..81beffb34 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -919,7 +919,7 @@ static void decod_gen_voic_core_switch_fx( * Decode pitch lag *----------------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES3 +#ifdef REMOVE_EVS_DUPLICATES pitch = pit_decode_ivas_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); /*Q6*/ #else pitch = pit_decode_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); /*Q6*/ diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index f3443349a..c722418f7 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -555,7 +555,12 @@ void decoder_LPD_fx( st->relax_prev_lsf_interp = 2; move16(); } + +#ifdef REMOVE_EVS_DUPLICATES2 + int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); +#else int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); +#endif } ELSE { diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index cb7556b24..5d644c289 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -532,6 +532,10 @@ void decoder_acelp_fx( move16(); IF( st->igf != 0 ) { +#ifdef REMOVE_EVS_DUPLICATES2 + prep_tbe_exc_ivas_fx( st->L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc, + gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 ); +#else prep_tbe_exc_fx( st->L_frame, #ifdef ADD_IVAS_TBE_CODE L_SUBFR, @@ -543,6 +547,7 @@ void decoder_acelp_fx( st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 #endif ); +#endif } /*---------------------------------------------------------* diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index bcbef190f..c369c4865 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -677,7 +677,6 @@ ivas_error decod_gen_voic_ivas_fx( IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) { - // VE: function to be merged? gain_dec_lbr_ivas_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR ); } ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) ) @@ -802,7 +801,7 @@ ivas_error decod_gen_voic_ivas_fx( { idx = idiv1616( i_subfr_fx, L_SUBFR ); } - // VE: function to be merged + prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index e886fd337..96eace777 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -253,9 +253,17 @@ void decod_tran_fx( { tmp_idx_2 = idiv1616( i_subfr, L_SUBFR ); } + +#ifdef REMOVE_EVS_DUPLICATES2 + prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, + &voice_factors_fx[tmp_idx_2], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, + st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, + st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); +#else prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[tmp_idx_2], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate ); +#endif /*----------------------------------------------------------------* * Excitation enhancements (update of total excitation signal) diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 5e1712231..00eca187d 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -601,6 +601,8 @@ void gain_dec_mless_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*==================================================================================*/ + +#ifndef REMOVE_EVS_DUPLICATES void gain_dec_lbr_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ @@ -969,7 +971,7 @@ void gain_dec_lbr_fx( return; } - +#endif void gain_dec_lbr_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index d709ff5fc..8aa4f45e1 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -483,7 +483,6 @@ ivas_error init_decoder_fx( } /* TCX core */ - // VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172 IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c index 6c37bb906..b7f0abec3 100644 --- a/lib_dec/pit_dec_fx.c +++ b/lib_dec/pit_dec_fx.c @@ -319,7 +319,7 @@ void Mode2_delta_pit_dec( /* _ (Word16 ) pitch : close loop integer pitch Q6 */ /*=======================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES3 +#ifndef REMOVE_EVS_DUPLICATES Word16 pit_decode_fx( /* o : floating pitch value */ Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index c2f9d0585..b5764ec43 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -24,19 +24,22 @@ * - update LSPs for the next frame *-------------------------------------------------------------------*/ void analy_lp_ivas_fx( - const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ - const Word16 L_frame, /* i :(q0) length of the frame */ - const Word16 L_look, /* i :(q0) look-ahead */ - Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ - Word16 A[], /* o :(q14) A(z) filter coefficients */ - Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 lsp_new[], /* o :(q15) current frame LSPs */ - Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ - Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ - const Word16 Top[2], /* i :(q0) open loop pitch lag */ - const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ - const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ + const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ + const Word16 L_frame, /* i :(q0) length of the frame */ + const Word16 L_look, /* i :(q0) look-ahead */ + Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ + Word16 A[], /* o :(q14) A(z) filter coefficients */ + Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 lsp_new[], /* o :(q15) current frame LSPs */ + Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ + Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ + const Word16 Top[2], /* i :(q0) open loop pitch lag */ + const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ + const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ +#ifdef REMOVE_EVS_DUPLICATES2 + const Word16 element_mode, /* i : element mode */ +#endif const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ Word16 Q_new, /*i: stores Q for speech*/ Word16 *Q_r /*stores q for ener*/ ) @@ -74,19 +77,24 @@ void analy_lp_ivas_fx( /* Autocorrelations */ autocorr_fx( pt, M, r_h, r_l, &Q_r[1 - i_subfr], wind_length, wind, 0, 0 ); - /*if ( r[0] < 100.0f && no_thr == 0 )*/ - /*r[0] = 100.0f*/ - IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_Comp( r_h[0], r_l[0] ) /* Q_r[1 - i_subfr]*/, sub( 31, add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ) ), 100 /*q0*/, 31 ), -1 ) ) +#ifdef REMOVE_EVS_DUPLICATES2 + IF( NE_16( element_mode, EVS_MONO ) ) +#endif { - /*Q_min stores min of 24 and the actual Q for r*/ - Word16 Q_min = s_min( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), 24 ); /* comparing q with 24 because exponent of 100 is 7 so max q should be 24*/ - L_Extract( L_shl( 100, Q_min ), &r_h[0], &r_l[0] ); /*extracting high and low components of r[0]*/ - FOR( i = 1; i < 17; i++ ) + /*if ( r[0] < 100.0f && no_thr == 0 )*/ + /*r[0] = 100.0f*/ + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_Comp( r_h[0], r_l[0] ) /* Q_r[1 - i_subfr]*/, sub( 31, add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ) ), 100 /*q0*/, 31 ), -1 ) ) { - L_Extract( L_shr( L_Comp( r_h[i], r_l[i] ), sub( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), Q_min ) ), &r_h[i], &r_l[i] ); /*scaling all the values to q24*/ + /*Q_min stores min of 24 and the actual Q for r*/ + Word16 Q_min = s_min( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), 24 ); /* comparing q with 24 because exponent of 100 is 7 so max q should be 24*/ + L_Extract( L_shl( 100, Q_min ), &r_h[0], &r_l[0] ); /*extracting high and low components of r[0]*/ + FOR( i = 1; i < 17; i++ ) + { + L_Extract( L_shr( L_Comp( r_h[i], r_l[i] ), sub( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), Q_min ) ), &r_h[i], &r_l[i] ); /*scaling all the values to q24*/ + } + Q_r[1 - i_subfr] = sub( Q_min, shl( Q_new, 1 ) ); /*updating the q (subtracting shl( Q_new, 1 ) as in later part it is being added-> to maintain q24 )*/ + move16(); } - Q_r[1 - i_subfr] = sub( Q_min, shl( Q_new, 1 ) ); /*updating the q (subtracting shl( Q_new, 1 ) as in later part it is being added-> to maintain q24 )*/ - move16(); } /* Lag windowing */ @@ -124,6 +132,7 @@ void analy_lp_ivas_fx( return; } +#ifndef REMOVE_EVS_DUPLICATES2 void analy_lp_fx( const Word16 speech[], /* i : pointer to the speech frame Q_new*/ const Word16 L_frame, /* i : length of the frame Q0*/ @@ -195,12 +204,20 @@ void analy_lp_fx( IF( EQ_16( sec_chan_low_rate, 1 ) ) { /* LSP interpolation */ +#ifdef REMOVE_EVS_DUPLICATES2 + int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); +#else int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); +#endif } ELSE { /* LSP interpolation */ +#ifdef REMOVE_EVS_DUPLICATES2 + int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); +#else int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); +#endif } Copy( lsp_new, lsp_old, M ); /* Q15 */ *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */ @@ -208,7 +225,7 @@ void analy_lp_fx( return; } - +#endif /*-------------------------------------------------------------------* * analy_lp_AMR_WB() diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index e701b8e46..aa823cbda 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -409,8 +409,14 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * IF( st->igf != 0 ) { +#ifdef REMOVE_EVS_DUPLICATES2 + prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], + bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate, + st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); +#else prep_tbe_exc_fx( L_frame, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate ); +#endif } /*---------------------------------------------------------* diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 6f71b8ba1..39cdba524 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -368,9 +368,16 @@ void encod_gen_voic_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES2 + prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, + &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, + T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, + st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); +#else prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate ); +#endif /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index b4495d4ff..66167c138 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -309,8 +309,13 @@ Word16 encod_tran_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES2 + prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], + bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); +#else prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate ); +#endif /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 89bbdc898..be2355f08 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -760,7 +760,6 @@ ivas_error init_encoder_fx( * TCX core *-----------------------------------------------------------------*/ - // VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172 test(); IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 541cc620c..bce78a8ee 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -1134,11 +1134,20 @@ ivas_error ivas_compute_core_buffers_fx( IF( Q_new ) { +#ifdef REMOVE_EVS_DUPLICATES2 + analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, sub( *Q_new, 1 ), Q_r ); +#else analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, sub( *Q_new, 1 ), Q_r ); +#endif } ELSE { +#ifdef REMOVE_EVS_DUPLICATES2 + analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r ); + +#else analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, -1, Q_r ); +#endif } /*--------------------------------------------------------------* diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index fd9b79617..24112da14 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -1196,8 +1196,12 @@ ivas_error pre_proc_front_ivas_fx( move16(); } +#ifdef REMOVE_EVS_DUPLICATES2 + analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, Q_new_loc, Q_r ); +#else analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, i, Q_new_loc, Q_r ); +#endif FOR( Word16 idx = 0; idx < M + 1; idx++ ) { diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index f52bdadb4..751744102 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -673,7 +673,12 @@ ivas_error front_vad_spar_fx( hFrontVad->q_buffer_12k8 = Q_inp_12k8; move16(); +#ifdef REMOVE_EVS_DUPLICATES2 + analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, st->element_mode, 0, Q_inp_12k8, Q_r ); +#else analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, 0 /* <-- sec_chan_low_rate */, Q_inp_12k8, Q_r ); +#endif + FOR( Word16 i = 0; i <= M; i++ ) { epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] ); // Q_r[0] diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index bd3d4cb34..c119b59dc 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -214,7 +214,7 @@ void pre_proc_fx( * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ Word16 Q_new_inp, mem_decim_size; // TO be removed - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* @@ -419,7 +419,11 @@ void pre_proc_fx( alw_voicing[1] = st->voicing_fx[2]; move16(); +#ifdef REMOVE_EVS_DUPLICATES2 + analy_lp_ivas_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, EVS_MONO, 0, *Q_new, Q_r ); +#else analy_lp_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r ); +#endif lsp2lsf_fx( lsp_new, lsf_new, M, INT_FS_12k8 ); stab_fac = lsf_stab_fx( lsf_new, st->lsf_old1_fx, 0, L_FRAME ); @@ -1152,7 +1156,11 @@ void pre_proc_fx( Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); } +#ifdef REMOVE_EVS_DUPLICATES2 + analy_lp_ivas_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, EVS_MONO, 0, *Q_new, Q_r ); +#else analy_lp_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r ); +#endif /*--------------------------------------------------------------* * Compute Weighted Input diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index bc08aae24..666192389 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -70,23 +70,27 @@ ivas_error acelp_core_enc_fx( #endif ); void analy_lp_ivas_fx( - const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ - const Word16 L_frame, /* i :(q0) length of the frame */ - const Word16 L_look, /* i :(q0) look-ahead */ - Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ - Word16 A[], /* o :(q14) A(z) filter coefficients */ - Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 lsp_new[], /* o :(q15) current frame LSPs */ - Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ - Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ - const Word16 Top[2], /* i :(q0) open loop pitch lag */ - const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ - const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ + const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ + const Word16 L_frame, /* i :(q0) length of the frame */ + const Word16 L_look, /* i :(q0) look-ahead */ + Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ + Word16 A[], /* o :(q14) A(z) filter coefficients */ + Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 lsp_new[], /* o :(q15) current frame LSPs */ + Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ + Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ + const Word16 Top[2], /* i :(q0) open loop pitch lag */ + const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ + const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ +#ifdef REMOVE_EVS_DUPLICATES2 + const Word16 element_mode, /* i : element mode */ +#endif const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ Word16 Q_new, /*i: stores Q for speech*/ Word16 *Q_r /*stores q for ener*/ ); +#ifndef REMOVE_EVS_DUPLICATES2 void analy_lp_fx( const Word16 speech[], /* i : pointer to the speech frame Q_new*/ const Word16 L_frame, /* i : length of the frame Q0*/ @@ -104,6 +108,7 @@ void analy_lp_fx( const Word16 sec_chan_low_rate, /* i : flag to signal second channel Q0*/ Word16 Q_new, Word16 *Q_r ); +#endif void AVQ_cod_fx( /* o: comfort noise gain factor */ const Word16 xri[], /* i: vector to quantize */ -- GitLab From 2cc9768f631e7f312c11885862964c999769dd40 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 6 Mar 2025 14:43:59 +0100 Subject: [PATCH 20/28] clang-format --- lib_dec/fd_cng_dec_fx.c | 4 ++-- lib_enc/pre_proc_fx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 65a20bfae..11af48a85 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1243,7 +1243,7 @@ Word16 ApplyFdCng_ivas_fx( } ELSE #endif - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); } @@ -1570,7 +1570,7 @@ Word16 ApplyFdCng_ivas_fx( } ELSE #endif - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); } diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 88eb78a60..062dc3fa4 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -214,7 +214,7 @@ void pre_proc_fx( * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ Word16 Q_new_inp, mem_decim_size; // TO be removed - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* -- GitLab From ba11d5e9e26ead4c2d50d98825b80dcfef56024d Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 19 Mar 2025 13:20:45 +0100 Subject: [PATCH 21/28] merge REMOVE_EVS_DUPLICATES2 into REMOVE_EVS_DUPLICATES --- lib_com/options.h | 1 - lib_com/prot_fx.h | 2 +- lib_com/swb_tbe_com_fx.c | 2 +- lib_dec/acelp_core_dec_fx.c | 3 +-- lib_dec/dec_LPD_fx.c | 2 +- lib_dec/dec_ace_fx.c | 2 +- lib_dec/dec_tran_fx.c | 2 +- lib_enc/analy_lp_fx.c | 10 +++++----- lib_enc/cod_ace_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 2 +- lib_enc/enc_tran_fx.c | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 2 +- lib_enc/ivas_core_pre_proc_fx.c | 4 ++-- lib_enc/ivas_front_vad_fx.c | 2 +- lib_enc/pre_proc_fx.c | 6 +++--- lib_enc/prot_fx_enc.h | 4 ++-- 16 files changed, 23 insertions(+), 25 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4e17909b0..9d6f852ac 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -176,5 +176,4 @@ #define FIX_ISSUE_1376 /* VA: Fix for issue 1376 (issue with GSC excitation) */ #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ -#define REMOVE_EVS_DUPLICATES2 #endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 99925342c..8c42651b2 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3284,7 +3284,7 @@ void synthesise_fb_high_band_fx( Word16 bpf_memory_Q[], Word16 Qout ); -#ifndef REMOVE_EVS_DUPLICATES2 +#ifndef REMOVE_EVS_DUPLICATES void prep_tbe_exc_fx( const Word16 L_frame_fx, /* i : length of the frame */ #ifdef ADD_IVAS_TBE_CODE diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index e279f0d48..af0a37011 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -7324,7 +7324,7 @@ void tbe_celp_exc( /* _ None */ /*======================================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES2 +#ifndef REMOVE_EVS_DUPLICATES void prep_tbe_exc_fx( const Word16 L_frame_fx, /* i : length of the frame */ #ifdef ADD_IVAS_TBE_CODE diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index b0fe937cd..d336c80ed 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1658,8 +1658,7 @@ ivas_error acelp_core_dec_fx( hf_synth_reset_fx( st_fx->hBWE_zero ); } #else - hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, - st_fx->Q_syn2, st_fx->hBWE_zero->delay_syn_hf_fx, &st_fx->hBWE_zero->memExp1, st_fx->hBWE_zero->mem_hp_interp_fx, st_fx->extl, st_fx->CNG_mode ); + hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, st_fx->Q_syn2 ); #endif } diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index f74c3e913..f53234ded 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -556,7 +556,7 @@ void decoder_LPD_fx( move16(); } -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); #else int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index 5d644c289..16f749156 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -532,7 +532,7 @@ void decoder_acelp_fx( move16(); IF( st->igf != 0 ) { -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES prep_tbe_exc_ivas_fx( st->L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc, gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 ); #else diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 96eace777..c5b06724a 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -254,7 +254,7 @@ void decod_tran_fx( tmp_idx_2 = idiv1616( i_subfr, L_SUBFR ); } -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[tmp_idx_2], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index b5764ec43..78a02eeec 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -37,7 +37,7 @@ void analy_lp_ivas_fx( const Word16 Top[2], /* i :(q0) open loop pitch lag */ const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES const Word16 element_mode, /* i : element mode */ #endif const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ @@ -77,7 +77,7 @@ void analy_lp_ivas_fx( /* Autocorrelations */ autocorr_fx( pt, M, r_h, r_l, &Q_r[1 - i_subfr], wind_length, wind, 0, 0 ); -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES IF( NE_16( element_mode, EVS_MONO ) ) #endif { @@ -132,7 +132,7 @@ void analy_lp_ivas_fx( return; } -#ifndef REMOVE_EVS_DUPLICATES2 +#ifndef REMOVE_EVS_DUPLICATES void analy_lp_fx( const Word16 speech[], /* i : pointer to the speech frame Q_new*/ const Word16 L_frame, /* i : length of the frame Q0*/ @@ -204,7 +204,7 @@ void analy_lp_fx( IF( EQ_16( sec_chan_low_rate, 1 ) ) { /* LSP interpolation */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); #else int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); @@ -213,7 +213,7 @@ void analy_lp_fx( ELSE { /* LSP interpolation */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); #else int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index aa823cbda..743874351 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -409,7 +409,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * IF( st->igf != 0 ) { -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index e82b1d243..519fd776b 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -367,7 +367,7 @@ void encod_gen_voic_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 25368fac5..fce1ceb0c 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -308,7 +308,7 @@ Word16 encod_tran_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); #else diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 6920aa6f5..d686f109f 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1210,7 +1210,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); } -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, Q_new_loc, Q_r ); #else analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 6be8c474e..cbc0bd5a6 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1138,7 +1138,7 @@ ivas_error ivas_compute_core_buffers_fx( IF( Q_new ) { -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, sub( *Q_new, 1 ), Q_r ); #else analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, sub( *Q_new, 1 ), Q_r ); @@ -1146,7 +1146,7 @@ ivas_error ivas_compute_core_buffers_fx( } ELSE { -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r ); #else diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index eaa6e6146..3e9ff3284 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -647,7 +647,7 @@ ivas_error front_vad_spar_fx( hFrontVad->q_buffer_12k8 = Q_inp_12k8; move16(); -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, st->element_mode, 0, Q_inp_12k8, Q_r ); #else analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, 0 /* <-- sec_chan_low_rate */, Q_inp_12k8, Q_r ); diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 062dc3fa4..a5d619359 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -214,7 +214,7 @@ void pre_proc_fx( * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ Word16 Q_new_inp, mem_decim_size; // TO be removed - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* @@ -415,7 +415,7 @@ void pre_proc_fx( alw_voicing[1] = st->voicing_fx[2]; move16(); -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES analy_lp_ivas_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, EVS_MONO, 0, *Q_new, Q_r ); #else analy_lp_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r ); @@ -1136,7 +1136,7 @@ void pre_proc_fx( Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); } -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES analy_lp_ivas_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, EVS_MONO, 0, *Q_new, Q_r ); #else analy_lp_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 8bfce57a0..2427d92a8 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -82,14 +82,14 @@ void analy_lp_ivas_fx( const Word16 Top[2], /* i :(q0) open loop pitch lag */ const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ -#ifdef REMOVE_EVS_DUPLICATES2 +#ifdef REMOVE_EVS_DUPLICATES const Word16 element_mode, /* i : element mode */ #endif const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ Word16 Q_new, /*i: stores Q for speech*/ Word16 *Q_r /*stores q for ener*/ ); -#ifndef REMOVE_EVS_DUPLICATES2 +#ifndef REMOVE_EVS_DUPLICATES void analy_lp_fx( const Word16 speech[], /* i : pointer to the speech frame Q_new*/ const Word16 L_frame, /* i : length of the frame Q0*/ -- GitLab From fe1734da642d7873d24d1ba64cb20dccf9c06be1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 19 Mar 2025 13:36:13 +0100 Subject: [PATCH 22/28] cleaning --- lib_dec/acelp_core_dec_fx.c | 202 +----------------------------------- 1 file changed, 4 insertions(+), 198 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index d336c80ed..71976a730 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -359,11 +359,7 @@ ivas_error acelp_core_dec_fx( } /* update synthesis filter memories */ -#ifdef REMOVE_EVS_DUPLICATES - ivas_synth_mem_updt2_fx( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec ); -#else synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec ); -#endif Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); // Q_exc Copy_Scale_sig( st_fx->mem_syn2_fx, st_fx->mem_syn1_fx, M, sub( -1, st_fx->Q_syn ) ); /*Q-1*/ @@ -559,11 +555,8 @@ ivas_error acelp_core_dec_fx( /* decode CNG parameters */ IF( st_fx->cng_type == LP_CNG ) { -#ifdef REMOVE_EVS_DUPLICATES - CNG_dec_ivas_fx( st_fx, st_fx->last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env ); -#else + CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env ); -#endif /* comfort noise generation */ CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate, @@ -599,39 +592,10 @@ ivas_error acelp_core_dec_fx( } i = st_fx->Q_exc; move16(); -#ifdef REMOVE_EVS_DUPLICATES - test(); - IF( st_fx->hMusicPF && st_fx->hGSCDec ) - { -#ifdef REMOVE_EVS_DUPLICATES - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, - st_fx->L_frame * HIBND_ACB_L_FAC, 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE ); - } - ELSE -#endif - { - Rescale_exc( st_fx->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, - imult1616( st_fx->L_frame, HIBND_ACB_L_FAC ), 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE ); - } - } - IF( st_fx->hPFstat != NULL ) - { - Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale, - &st_fx->mem_deemph_fx, st_fx->hBPF->pst_old_syn_fx, &st_fx->hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 0, 0, NULL ); - } - ELSE - { - Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale, - &st_fx->mem_deemph_fx, NULL, NULL, &st_fx->agc_mem_fx[1], NULL, 0, 0, NULL ); - } -#else Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, st_fx->L_frame * HIBND_ACB_L_FAC, 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE ); Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 0, 0, NULL ); -#endif Copy_Scale_sig( exc2_fx, exc2_fx, st_fx->L_frame, sub( st_fx->Q_exc, i ) ); // Q_exc /* update past excitation signals for LD music post-filter */ @@ -705,11 +669,7 @@ ivas_error acelp_core_dec_fx( } #ifdef NONBE_FIX_GSC_BSTR -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#endif #else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #endif @@ -719,11 +679,7 @@ ivas_error acelp_core_dec_fx( IF( EQ_16( st_fx->coder_type, TRANSITION ) && LT_16( tc_subfr_fx, L_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) { #ifdef NONBE_FIX_GSC_BSTR -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, TRANSITION, -1, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#endif #else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #endif @@ -815,11 +771,7 @@ ivas_error acelp_core_dec_fx( IF( st_fx->stab_fac_fx == 0 && st_fx->old_bfi_cnt > 0 && NE_16( st_fx->clas_dec, VOICED_CLAS ) && NE_16( st_fx->clas_dec, ONSET ) && st_fx->relax_prev_lsf_interp == 0 && !( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) ) { -#ifdef REMOVE_EVS_DUPLICATES - int_lsp4_ivas_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); -#else int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); -#endif } /*---------------------------------------------------------------* @@ -851,11 +803,7 @@ ivas_error acelp_core_dec_fx( ELSE IF( EQ_16( st_fx->coder_type, UNVOICED ) ) { /* UNVOICED frames */ -#ifdef REMOVE_EVS_DUPLICATES - decod_unvoiced_ivas_fx( st_fx, Aq_fx, Es_pred_fx, uc_two_stage_flag, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); -#else decod_unvoiced_fx( st_fx, Aq_fx, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); -#endif } ELSE IF( EQ_16( st_fx->ppp_mode_dec, 1 ) ) { @@ -872,28 +820,16 @@ ivas_error acelp_core_dec_fx( } ELSE IF( EQ_16( st_fx->coder_type, TRANSITION ) ) { -#ifdef REMOVE_EVS_DUPLICATES - decod_tran_ivas_fx( st_fx, st_fx->L_frame, tc_subfr_fx, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf ); -#else decod_tran_fx( st_fx, st_fx->L_frame, tc_subfr_fx, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf ); -#endif } ELSE IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) ) ) { -#ifdef REMOVE_EVS_DUPLICATES - decod_audio_ivas_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf ); -#else decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf ); -#endif tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ } ELSE { -#ifdef REMOVE_EVS_DUPLICATES - IF( NE_32( ( error = decod_gen_voic_ivas_fx( st_fx, st_fx->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf, 0, NULL ) ), IVAS_ERR_OK ) ) -#else IF( NE_32( ( error = decod_gen_voic_fx( st_fx, st_fx->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf /*, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf*/ ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -906,7 +842,6 @@ ivas_error acelp_core_dec_fx( /* synthesis for ACELP core switching and SWB BWE */ syn_12k8_fx( st_fx->L_frame, Aq_fx, exc_fx, temp_buf_fx, st_fx->mem_syn1_fx, 1, st_fx->Q_exc, -1 ); - /* save and delay synthesis to be used by SWB BWE */ IF( hBWE_FD != NULL ) { @@ -917,11 +852,7 @@ ivas_error acelp_core_dec_fx( * Apply energy matching when switching to inactive frames *-----------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES - Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode, 0, EVS_MONO ); -#else Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode ); -#endif /*------------------------------------------------------------* * Decode information and modify the excitation signal of stationary unvoiced frames *------------------------------------------------------------*/ @@ -1049,13 +980,9 @@ ivas_error acelp_core_dec_fx( k = add( k, 1 ); } -#ifdef REMOVE_EVS_DUPLICATES - FEC_scale_syn_ivas_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, - &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, - exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 ); -#else - FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); -#endif + FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, + &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, + exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); test(); test(); @@ -1134,13 +1061,8 @@ ivas_error acelp_core_dec_fx( { save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx ); } - /* Apply energy matching when switching to inactive frames */ -#ifdef REMOVE_EVS_DUPLICATES - Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode, 0, EVS_MONO ); -#else Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode ); -#endif /* udate past excitation signals for LD music post-filter */ IF( hMusicPF != NULL ) @@ -1214,15 +1136,9 @@ ivas_error acelp_core_dec_fx( * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES - FEC_scale_syn_ivas_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, - &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, - exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 ); -#else FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); -#endif } /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ @@ -1317,11 +1233,7 @@ ivas_error acelp_core_dec_fx( Copy( syn_fx, temp_buf + L_SYN_MEM, L_FRAME16k ); st_fx->hPFstat->on = 1; move16(); -#ifdef REMOVE_EVS_DUPLICATES - formant_post_filt_ivas_fx( st_fx->hPFstat, temp_buf + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME16k, st_fx->lp_noise, st_fx->total_brate, 0 ); -#else formant_post_filt_fx( st_fx->hPFstat, temp_buf + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME16k, st_fx->lp_noise, st_fx->total_brate, 0 ); -#endif } ELSE IF( GE_16( st_fx->last_bwidth, WB ) ) { @@ -1383,21 +1295,13 @@ ivas_error acelp_core_dec_fx( move32(); } /*Noise estimate*/ -#ifdef REMOVE_EVS_DUPLICATES - IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) && !st_fx->cng_ism_flag ) -#else IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) /* && !st->cng_ism_flag IVAS_CODE */ ) -#endif { #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT PMT( "Code for IVAS_CODE_CNG_FIX185_PLC_FADEOUT not done" ) ApplyFdCng_fx( syn, st_fx->Q_syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#else -#ifdef REMOVE_EVS_DUPLICATES - ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, realBuffer, imagBuffer, NULL, st_fx, 0, ( st_fx->coder_type == AUDIO && !st_fx->GSC_noisy_speech ) ); #else ApplyFdCng_fx( syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st_fx, 0, ( EQ_16( st_fx->coder_type, AUDIO ) && st_fx->GSC_noisy_speech == 0 ) ); -#endif #endif } /* CNA: Generate additional comfort noise to mask potential coding artefacts */ @@ -1480,82 +1384,6 @@ ivas_error acelp_core_dec_fx( bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn_fx, st_fx->L_frame, pitch_buf_fx, st_fx->bpf_off, st_fx->stab_fac_fx, &st_fx->stab_fac_smooth_fx, st_fx->coder_type, st_fx->Q_syn, bpf_error_signal ); } - -#ifdef REMOVE_EVS_DUPLICATES - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - /* analysis of the synthesis at internal sampling rate */ - cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer ); - - scaleFactor.hb_scale = scaleFactor.lb_scale; - move16(); - - /* analysis and add the BPF error signal */ - i = 0; - move16(); - if ( st_fx->bpf_off == 0 ) - { - i = CLDFB_NO_COL_MAX; - move16(); - } - - addBassPostFilter_fx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate( st_fx->Q_syn ), - i, st_fx->cldfbAna->no_col, st_fx->cldfbAna->no_channels, &scaleFactor ); - - /* set output mask for upsampling */ - IF( EQ_16( st_fx->bwidth, NB ) ) - { - /* set NB mask for upsampling */ - st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, 10 ); - move16(); - } - ELSE IF( NE_16( st_fx->cldfbSyn->bandsToZero, sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ) ) ) - { - /* in case of BW switching, re-init to default */ - st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ); - move16(); - } - - /*WB/SWB-FD_CNG*/ - scaleFactor.hb_scale = scaleFactor.lb_scale; - move16(); - - test(); - IF( !st_fx->cng_sba_flag || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - test(); - test(); - test(); - IF( ( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) && ( EQ_16( st_fx->cng_type, FD_CNG ) ) && ( LT_16( st_fx->hFdCngDec->hFdCngCom->numCoreBands, st_fx->cldfbSyn->no_channels ) ) ) - { - generate_comfort_noise_dec_hf_fx( realBuffer, imagBuffer, &scaleFactor.hb_scale, st_fx ); - - st_fx->cldfbSyn->bandsToZero = 0; - move16(); - IF( LT_16( st_fx->hFdCngDec->hFdCngCom->regularStopBand, st_fx->cldfbSyn->no_channels ) ) - { - st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->hFdCngDec->hFdCngCom->regularStopBand ); - move16(); - } - st_fx->cldfbSyn->lsb = st_fx->cldfbAna->no_channels; - move16(); - } - } - - /* synthesis of the combined signal */ - st_fx->Q_syn2 = st_fx->Q_syn; - move16(); - cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer ); - - /* Bring CLDFB output to Q0 */ - Scale_sig( synth_out, output_frame, negate( st_fx->Q_syn2 ) ); - st_fx->Q_syn2 = 0; - move16(); - - /* save synthesis - needed in case of core switching */ - Copy( synth_out, st_fx->previoussynth_fx, output_frame ); - } -#else test(); IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) { @@ -1630,7 +1458,6 @@ ivas_error acelp_core_dec_fx( /* save synthesis - needed in case of core switching */ Copy( synth_out, st_fx->previoussynth_fx, output_frame ); } -#endif /*-----------------------------------------------------------------* * Bandwidth extension 6kHz-7kHz @@ -1647,33 +1474,12 @@ ivas_error acelp_core_dec_fx( IF( ( EQ_16( st_fx->L_frame, L_FRAME ) && NE_16( st_fx->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) && ( EQ_16( st_fx->extl, -1 ) || EQ_16( st_fx->extl, SWB_CNG ) || ( EQ_16( st_fx->extl, WB_BWE ) && st_fx->extl_brate == 0 && NE_16( st_fx->coder_type, AUDIO ) ) ) ) ) { -#ifdef REMOVE_EVS_DUPLICATES - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, - st_fx->Q_syn2, st_fx->hBWE_zero->delay_syn_hf_fx, &st_fx->hBWE_zero->memExp1, st_fx->hBWE_zero->mem_hp_interp_fx, st_fx->extl, st_fx->CNG_mode ); - } - ELSE - { - hf_synth_reset_fx( st_fx->hBWE_zero ); - } -#else hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, st_fx->Q_syn2 ); - -#endif } -#ifdef REMOVE_EVS_DUPLICATES ELSE { hf_synth_reset_fx( st_fx->hBWE_zero ); -#ifdef MSAN_FIX - IF( NE_16( st_fx->element_mode, EVS_MONO ) ) - { - set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); - } -#endif } -#endif } /*-----------------------------------------------------------------* -- GitLab From aeb3579d8691ce91d31fe54a95f1fd7be2417b5c Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 19 Mar 2025 14:39:36 +0100 Subject: [PATCH 23/28] clang-format --- lib_dec/acelp_core_switch_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 1a856bcda..0b0e7f1b4 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -826,7 +826,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( #ifdef FIX_ISSUE_1237 Copy_Scale_sig_16_32_no_sat( syn, syn32, L_FRAME16k, Qtmp ); // Q(11) #else - Copy_Scale_sig_16_32_DEPREC( syn, syn32, L_FRAME16k, Qtmp ); // Q(11) + Copy_Scale_sig_16_32_DEPREC( syn, syn32, L_FRAME16k, Qtmp ); // Q(11) #endif IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbAna ) ), IVAS_ERR_OK ) ) { -- GitLab From 35a2935e2ff025aa9fd7b0b0524c0745f361551e Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 19 Mar 2025 14:45:27 +0100 Subject: [PATCH 24/28] fix merge issue causing build error --- lib_dec/acelp_core_dec_ivas_fx.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 86cbb3618..35e71287e 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -45,8 +45,6 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" -static void rescale_fdCngDec( HANDLE_FD_CNG_DEC hFdCngDec, Word16 old_NoiseExp ); - /*-------------------------------------------------------------------* * acelp_core_dec_ivas_fx() @@ -2589,9 +2587,3 @@ ivas_error acelp_core_dec_ivas_fx( pop_wmops(); return error; } - - -static void rescale_fdCngDec( HANDLE_FD_CNG_DEC hFdCngDec, Word16 Exp_diff ) -{ - Scale_sig32( hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, Exp_diff ); -} -- GitLab From 3660990879c1d4c8526770e863e0e30abe6c0aaf Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 28 Mar 2025 19:49:59 +0100 Subject: [PATCH 25/28] fix --- lib_dec/fd_cng_dec_fx.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 6579de9fa..b3fbb225e 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1574,15 +1574,25 @@ Word16 ApplyFdCng_ivas_fx( /* This sets the new CNG levels until a SID update overwrites it */ Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it */ /*Q31 - hFdCngDec->bandNoiseShape_exp*/ - Word16 shift1 = L_norm_arr( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); - Word16 shift2 = L_norm_arr( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ) ); - Word16 shift = s_max( sub( hFdCngDec->bandNoiseShape_exp, shift1 ), sub( *cngNoiseLevel_exp, shift2 ) ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp; + move16(); + } + ELSE +#endif + { + Word16 shift1 = L_norm_arr( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); + Word16 shift2 = L_norm_arr( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ) ); + Word16 shift = s_max( sub( hFdCngDec->bandNoiseShape_exp, shift1 ), sub( *cngNoiseLevel_exp, shift2 ) ); - scale_sig32( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( sub( hFdCngDec->bandNoiseShape_exp, shift1 ), shift ) ); - scale_sig32( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ), sub( sub( *cngNoiseLevel_exp, shift2 ), shift ) ); + scale_sig32( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( sub( hFdCngDec->bandNoiseShape_exp, shift1 ), shift ) ); + scale_sig32( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ), sub( sub( *cngNoiseLevel_exp, shift2 ), shift ) ); - *cngNoiseLevel_exp = shift; - move16(); + *cngNoiseLevel_exp = shift; + move16(); + } /*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/ tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); -- GitLab From c227804b934b0cb380dd4cd5ec60c20660266d43 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 15 Apr 2025 19:41:45 +0200 Subject: [PATCH 26/28] clang-format --- lib_dec/acelp_core_dec_ivas_fx.c | 11 +---------- lib_dec/fd_cng_dec_fx.c | 4 ++-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 6cecf8323..ad8ca9b50 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -848,16 +848,7 @@ ivas_error acelp_core_dec_ivas_fx( Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn -> Q(-1) IF( st->hBWE_FD != NULL ) { -#ifdef REMOVE_EVS_DUPLICATES - IF( EQ_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - this is likely a bug in IVAS - { - save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); - } - ELSE -#endif - { - save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); - } + save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); } } diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index f881d252d..dbb13de12 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1241,7 +1241,7 @@ Word16 ApplyFdCng_ivas_fx( } ELSE #endif - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); } @@ -1565,7 +1565,7 @@ Word16 ApplyFdCng_ivas_fx( } ELSE #endif - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); } -- GitLab From 930e90a4fc862e5165ba4f81a77dce68b745449e Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 16 Apr 2025 10:10:41 +0200 Subject: [PATCH 27/28] fix in ApplyFdCng_ivas_fx() --- lib_dec/fd_cng_dec_fx.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index dbb13de12..5c649df9b 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1241,7 +1241,7 @@ Word16 ApplyFdCng_ivas_fx( } ELSE #endif - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); } @@ -1565,7 +1565,7 @@ Word16 ApplyFdCng_ivas_fx( } ELSE #endif - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); } @@ -1757,15 +1757,35 @@ Word16 ApplyFdCng_ivas_fx( } } - Word16 shift1 = L_norm_arr( cngNoiseLevel, j ); - Word16 shift2 = L_norm_arr( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ) ); - Word16 shift = s_max( sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift1 ), sub( *cngNoiseLevel_exp, shift2 ) ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + /* adapt scaling for rest of the buffer */ + s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) ); + FOR( ; k < hFdCngCom->npart; k++ ) + { + FOR( ; j <= hFdCngCom->part[k]; j++ ) + { + cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/ + move32(); + } + } + *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 ); + move16(); + } + ELSE +#endif + { + Word16 shift1 = L_norm_arr( cngNoiseLevel, j ); + Word16 shift2 = L_norm_arr( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ) ); + Word16 shift = s_max( sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift1 ), sub( *cngNoiseLevel_exp, shift2 ) ); - scale_sig32( cngNoiseLevel, j, sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift ) ); - scale_sig32( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ), sub( *cngNoiseLevel_exp, shift ) ); + scale_sig32( cngNoiseLevel, j, sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift ) ); + scale_sig32( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ), sub( *cngNoiseLevel_exp, shift ) ); - *cngNoiseLevel_exp = shift; - move16(); + *cngNoiseLevel_exp = shift; + move16(); + } } } ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) -- GitLab From 9d14ced3fbf85af53dec45d1e3f8c8c040f35d64 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 16 Apr 2025 10:24:15 +0200 Subject: [PATCH 28/28] clang-format --- lib_dec/fd_cng_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 2bab16e04..d0fd178f2 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1241,7 +1241,7 @@ Word16 ApplyFdCng_ivas_fx( } ELSE #endif - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); } @@ -1565,7 +1565,7 @@ Word16 ApplyFdCng_ivas_fx( } ELSE #endif - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); } -- GitLab