From 34dad4536be6ee4e880dd44acd14a0ba536a45d9 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 12 Sep 2025 14:53:36 +0200 Subject: [PATCH 1/3] corrected bwe_exc_fx[] scaling in the decoder --- lib_com/options.h | 2 +- lib_dec/dec_gen_voic_fx.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d2ffa2ca1..318107e45 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -98,7 +98,7 @@ #define FIX_2009_HIGH_NOISE_FLOOR_FOR_FX_DEC /* FhG: Corrected the q_input in the input of generate_masking_noise_dirac_ivas_fx() */ #define FIX_ISSUE_2013_MDCT_STEREO_DTX_DISCONTINUITIES /* Eri/FhG: Issue 2013 fix for dtx discontinuities */ #define FIX_ISSUE_2013_MDCT_STEREO_FER_DISCONTINUITIES /* Eri/FhG: Issue 2013 fix for FER discontinuities */ - +#define FIX_2010_HF_ENERGY_LOSS /* FhG: corrected bwe_exc_fx[] scaling in the decoder */ /* #################### Start BASOP porting switches ############################ */ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index ac1df74b2..6bcc8ced9 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -357,7 +357,12 @@ ivas_error decod_gen_voic_fx( gain_buf[idx] = gain_pit_fx; // Q14 move16(); } - +#ifdef FIX_2010_HF_ENERGY_LOSS + IF( LT_32( MIN_BRATE_AVQ_EXC, st_fx->core_brate ) ) + { + Scale_sig( bwe_exc_fx, shl( st_fx->L_frame, 1 ), 1 ); + } +#endif /* FEC fast recovery */ IF( do_WI_fx ) -- GitLab From cfa2e0aafa5916bd19490d4b31f6457d54894610 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 12 Sep 2025 16:48:16 +0200 Subject: [PATCH 2/3] corrected gain_code_fx and gain_preQ_fx scaling before prep_tbe_exc_fx() --- lib_dec/dec_gen_voic_fx.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 6bcc8ced9..9f54911e5 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -321,7 +321,13 @@ ivas_error decod_gen_voic_fx( { idx = idiv1616( i_subfr_fx, L_SUBFR ); } - +#ifdef FIX_2010_HF_ENERGY_LOSS + IF( LT_32( MIN_BRATE_AVQ_EXC, st_fx->core_brate ) ) + { + gain_code_fx = L_shl( gain_code_fx, 1 ); + gain_preQ_fx = shl( gain_preQ_fx, 1 ); + } +#endif prep_tbe_exc_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, @@ -357,12 +363,7 @@ ivas_error decod_gen_voic_fx( gain_buf[idx] = gain_pit_fx; // Q14 move16(); } -#ifdef FIX_2010_HF_ENERGY_LOSS - IF( LT_32( MIN_BRATE_AVQ_EXC, st_fx->core_brate ) ) - { - Scale_sig( bwe_exc_fx, shl( st_fx->L_frame, 1 ), 1 ); - } -#endif + /* FEC fast recovery */ IF( do_WI_fx ) -- GitLab From bd1f492061f66eb813fc161639093a80d94415ea Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 12 Sep 2025 17:51:19 +0200 Subject: [PATCH 3/3] replace shl with shl_sat. --- lib_dec/dec_gen_voic_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 9f54911e5..998e15786 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -324,8 +324,8 @@ ivas_error decod_gen_voic_fx( #ifdef FIX_2010_HF_ENERGY_LOSS IF( LT_32( MIN_BRATE_AVQ_EXC, st_fx->core_brate ) ) { - gain_code_fx = L_shl( gain_code_fx, 1 ); - gain_preQ_fx = shl( gain_preQ_fx, 1 ); + gain_code_fx = L_shl_sat( gain_code_fx, 1 ); + gain_preQ_fx = shl_sat( gain_preQ_fx, 1 ); } #endif prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, -- GitLab