From 6f39834e42dc2005be7fbb8a2e5da194437686a3 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 27 Aug 2024 19:05:21 +0530 Subject: [PATCH] Scaling/BASOP updates to fix high MLD cases --- lib_com/swb_tbe_com_fx.c | 5 +---- lib_dec/FEC_HQ_phase_ecu_fx.c | 21 ++++++++++++--------- lib_dec/acelp_core_switch_dec_fx.c | 2 +- lib_dec/core_switching_dec_fx.c | 2 ++ lib_dec/dec_tcx_fx.c | 9 +++++++-- lib_dec/swb_tbe_dec.c | 2 +- 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 739771b06..faa6248c4 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -3127,10 +3127,7 @@ void GenShapedSHBExcitation_ivas_fx( #else L_tmp4 = L_shl( L_deposit_l( White_exc16k[k] ), tmp ); #endif - IF( excNoisyEnv[k] != 0 ) - { - L_tmp4 = L_mult( shr( excNoisyEnv[k], sub( Q_excTmp2, *Q_bwe_exc ) ), White_exc16k[k] ); /* (Q_bwe_exc) +5 +1*/ - } + L_tmp4 = L_mult( shr( excNoisyEnv[k], sub( Q_excTmp2, *Q_bwe_exc ) ), White_exc16k[k] ); /* (Q_bwe_exc) +5 +1*/ White_exc16k_32[k] = L_tmp4; move32(); L_tmp = L_max( L_tmp, L_abs( White_exc16k_32[k] ) ); diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 6dfa76313..4ca1ad94c 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -4155,6 +4155,7 @@ static void ivas_fec_ecu_dft_fx( *exp = add( tmp, add( 2, norm_s( *Nfft ) ) ); move16(); Copy_Scale_sig_16_32( Tfr16, Tfr32, *Nfft, *exp ); /*Qin+exp; */ + *exp = s_min( *exp, 15 ); DoRTFTn_fx( Tfr32, Tfi32, *Nfft ); N_LP = shr( *Nfft, 1 ); @@ -4617,7 +4618,8 @@ static void ivas_fec_noise_filling_fx( const Word16 HqVoicing, Word16 *gapsynth_fx, /*Qsynth */ const Word16 element_mode, /* i : IVAS element mode */ - const Word16 *old_out ) + const Word16 *old_out, + const Word16 Q_old_out ) { Word16 Rnd_N_noise; @@ -4757,11 +4759,11 @@ static void ivas_fec_noise_filling_fx( { L_tmp = L_mult( *sinq_tab, *sinq_tab ); /*Q30 */ sinq_tab++; - q2 = round_fx( L_sub( 2147483647, L_tmp ) ); /*Q15 */ - q1 = round_fx( L_tmp ); /*Q15 */ - L_tmp = L_mult( ( *pt1 ), q1 ); /*Qsynth+16 */ - L_tmp = L_mac( L_tmp, ( *pt6++ ), q2 ); /*Qsynth+16 */ - ( *pt1++ ) = round_fx( L_tmp ); /*Qsynth */ + q2 = round_fx( L_sub( 2147483647, L_tmp ) ); /*Q15 */ + q1 = round_fx( L_tmp ); /*Q15 */ + L_tmp = L_mult( ( *pt1 ), q1 ); /*Qsynth+16 */ + L_tmp = L_mac( L_tmp, shr( *pt6++, Q_old_out ), q2 ); /*Qsynth+16 */ + ( *pt1++ ) = round_fx( L_tmp ); /*Qsynth */ move16(); } @@ -4965,7 +4967,8 @@ static void ivas_fec_alg_fx( const Word16 HqVoicing, Word16 *gapsynth, /*Qin */ const Word16 element_mode, /* i : IVAS element mode */ - const Word16 *old_out ) + const Word16 *old_out, + const Word16 Q_old_out ) { Word16 Nfft; Word32 sum_Tf_abs; @@ -4980,7 +4983,7 @@ static void ivas_fec_alg_fx( sinusoidal_synthesis_fx( Tfr, Tfi, Tf_abs, N, output_frame, decimatefactor, Nfft, sum_Tf_abs, synthesis, HqVoicing, exp ); - ivas_fec_noise_filling_fx( prevsynth, synthesis, ni_seed_forfec, output_frame, i_mult2( N, decimatefactor ), HqVoicing, gapsynth, element_mode, old_out ); + ivas_fec_noise_filling_fx( prevsynth, synthesis, ni_seed_forfec, output_frame, i_mult2( N, decimatefactor ), HqVoicing, gapsynth, element_mode, old_out, Q_old_out ); n = R1_48 - R2_48; move16(); @@ -5456,7 +5459,7 @@ void ivas_hq_ecu_fx( IF( ( ( st_fx->element_mode == EVS_MONO ) && evs_mode_selection ) || ( ( st_fx->element_mode != EVS_MONO ) && evs_mode_selection && ivas_mode_selection ) ) { - ivas_fec_alg_fx( fec_alg_input, prevsynth_LP, &st_fx->hHQ_core->ni_seed_forfec, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth, st_fx->element_mode, st_fx->hHQ_core->old_out_fx ); + ivas_fec_alg_fx( fec_alg_input, prevsynth_LP, &st_fx->hHQ_core->ni_seed_forfec, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth, st_fx->element_mode, st_fx->hHQ_core->old_out_fx, st_fx->hHQ_core->Q_old_wtda ); *last_fec = 1; move16(); *ph_ecu_active = 0; diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 7d84788f5..6eab8f07d 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -845,7 +845,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( st_fx->cldfbSyn->Q_cldfb_state = sub( st_fx->cldfbSyn->Q_cldfb_state, 1 ); Copy_Scale_sig_32_16( synth32, synth_out, L_FRAME48k, -5 ); - Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); + // Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); cldfb_restore_memory_ivas_fx( st_fx->cldfbSyn ); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 97ac2de0b..174f33911 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2057,6 +2057,8 @@ ivas_error core_switching_post_dec_ivas_fx( { /* memory update needed for DFT stereo -> TD stereo switching, scaling synth to Q0 */ Copy_Scale_sig( synth + sub( output_frame, delay_comp ), st_fx->delay_buf_out_fx, delay_comp, negate( *Qsynth ) ); + hHQ_core->Q_old_postdec = 0; + move16(); } /* reset SWB BWE buffers */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 50c5b6a84..e5cede1e3 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3824,7 +3824,12 @@ void decoder_tcx_ivas_fx( } /* Scaling down buffers for decoder_tcx_imdct_fx*/ - Scale_sig( st->hTcxDec->syn_Overl, 320, -1 ); // Scaling to Q_syn + Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, 1 ); // Scaling to Q_syn + Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, 1 ); // Scaling to Q_syn + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, negate( st->hHQ_core->Q_old_out ) ); // Scaling to Q_syn + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, negate( st->hHQ_core->Q_old_out ) ); // Scaling to Q_syn + st->hHQ_core->Q_old_out = 0; + Scale_sig( st->hTcxDec->old_syn_Overl, 320, 1 ); // Scaling to Q_syn Copy_Scale_sig_16_32_no_sat( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( sub( 28, ( sub( 15, norm_s( sub( st->old_Aq_12_8_fx[0], 1 ) ) ) ) ) ) ); @@ -3837,7 +3842,7 @@ void decoder_tcx_ivas_fx( /* Scaling up again */ Scale_sig( synth_fx, L_frame_glob, negate( st->Q_syn ) ); Scale_sig( synthFB_fx, L_frameTCX_glob, negate( st->Q_syn ) ); - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, 1 ); + // Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, 1 ); st->hHQ_core->Q_old_wtda = st->Q_syn; // Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); st->hHQ_core->Q_old_wtda_LB = st->Q_syn; diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 5c1d9c583..7543d9c37 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -2357,7 +2357,7 @@ void ivas_swb_tbe_dec_fx( move16(); FOR( i = 0; i < L_FRAME16k; i++ ) { - max_val = s_max( max_val, shaped_shb_excitation_fx[i] ); /* Q0 */ + max_val = s_max( max_val, abs_s( shaped_shb_excitation_fx[i] ) ); /* Q0 */ } IF( max_val == 0 ) { -- GitLab