From 86cd9778c6a570353d60cf0f0ff62c6034319b88 Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 2 Jun 2026 18:11:50 +0200 Subject: [PATCH 1/2] residual PLC burst attenuation: apply divide/Sqrt32 exponent so fac tracks exponent correctly --- lib_com/options.h | 1 + lib_dec/ivas_stereo_dft_plc_fx.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index a38e20b61..55ea11a82 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,6 +110,7 @@ #define FIX_2588_MISSING_CONDITIONS /* VA: Proposed fix to 2588, addition of a condition in lsf_dec */ #define FIX_BASOP_2442_MASA2TC_TO_MONO_AND_AMBI /* Nokia: BASOP issue 2442: Increase accuracy of computations and add additional gain clamp for low energy decorrelated signal rendering. */ #define FIX_FMSW_DEC_EXT /* float issue 1566: fix EXT output in format switching */ +#define FIX_ISSUE_2618_PLC_RES_ATT_SCALING /* FhG: BASOP #2618: residual PLC burst attenuation, apply divide/Sqrt32 exponent so fac tracks exponent correctly */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index 92cf02405..4672e284c 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -738,24 +738,41 @@ void stereo_dft_res_ecu_burst_att_fx( ) { Word32 fac; +#ifndef FIX_ISSUE_2618_PLC_RES_ATT_SCALING Word16 q_fac; +#endif Word16 exponent; +#ifndef FIX_ISSUE_2618_PLC_RES_ATT_SCALING q_fac = 0; move16(); +#endif exponent = 0; move16(); /* attenuation of residual; follow attenuation of DMX */ IF( hStereoDft->core_hist[0] == ACELP_CORE ) { +#ifdef FIX_ISSUE_2618_PLC_RES_ATT_SCALING + fac = L_deposit_h( BASOP_Util_Divide3232_Scale( dmx_nrg, hStereoDft->past_dmx_nrg_fx, &exponent ) ); /* ratio mantissa Q31, exp 'exponent' */ + fac = Sqrt32( fac, &exponent ); /* sqrt: Q31 mantissa, exponent halved */ + fac = Mpy_32_16_1( fac, (Word16) ( 0x0CCD ) ); /* * 0.1f (Q15) */ +#else + fac = Mpy_32_16_1( Sqrt32( L_deposit_h( BASOP_Util_Divide3232_Scale( dmx_nrg, hStereoDft->past_dmx_nrg_fx, &q_fac ) ), &exponent ), (Word16) ( 0x0CCD ) ); /* Q0 */ +#endif } ELSE { +#ifdef FIX_ISSUE_2618_PLC_RES_ATT_SCALING + fac = L_sub( MAX_32, L_deposit_h( BASOP_Util_Divide3232_Scale( L_sub( hStereoDft->time_offs, L_ana ), L_add( hStereoDft->time_offs, L_ana ), &exponent ) ) ); /* Q0 */ +#else fac = L_sub( MAX_32, L_deposit_h( BASOP_Util_Divide3232_Scale( L_sub( hStereoDft->time_offs, L_ana ), L_add( hStereoDft->time_offs, L_ana ), &q_fac ) ) ); /* Q0 */ +#endif } - +#ifdef FIX_ISSUE_2618_PLC_RES_ATT_SCALING + fac = L_shl_sat( fac, exponent ); /* Q31 */ +#endif v_multc_fx( pDFT_RES, fac, pDFT_RES, shl( L_res, 1 ) ); return; -- GitLab From 5f1be5aca0bbad8e2d4bc24ef1781c0be542a6fe Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 2 Jun 2026 19:29:07 +0200 Subject: [PATCH 2/2] scale fac only in ACLEP branch --- lib_dec/ivas_stereo_dft_plc_fx.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index 4672e284c..f3517c6b3 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -754,9 +754,10 @@ void stereo_dft_res_ecu_burst_att_fx( IF( hStereoDft->core_hist[0] == ACELP_CORE ) { #ifdef FIX_ISSUE_2618_PLC_RES_ATT_SCALING - fac = L_deposit_h( BASOP_Util_Divide3232_Scale( dmx_nrg, hStereoDft->past_dmx_nrg_fx, &exponent ) ); /* ratio mantissa Q31, exp 'exponent' */ - fac = Sqrt32( fac, &exponent ); /* sqrt: Q31 mantissa, exponent halved */ - fac = Mpy_32_16_1( fac, (Word16) ( 0x0CCD ) ); /* * 0.1f (Q15) */ + fac = L_deposit_h( BASOP_Util_Divide3232_Scale( dmx_nrg, hStereoDft->past_dmx_nrg_fx, &exponent ) ); + fac = Sqrt32( fac, &exponent ); + fac = Mpy_32_16_1( fac, (Word16) ( 0x0CCD ) ); /* * 0.1f (Q15) */ + fac = L_shl_sat( fac, exponent ); /* Q31 */ #else fac = Mpy_32_16_1( Sqrt32( L_deposit_h( BASOP_Util_Divide3232_Scale( dmx_nrg, hStereoDft->past_dmx_nrg_fx, &q_fac ) ), &exponent ), (Word16) ( 0x0CCD ) ); /* Q0 */ @@ -770,9 +771,7 @@ void stereo_dft_res_ecu_burst_att_fx( fac = L_sub( MAX_32, L_deposit_h( BASOP_Util_Divide3232_Scale( L_sub( hStereoDft->time_offs, L_ana ), L_add( hStereoDft->time_offs, L_ana ), &q_fac ) ) ); /* Q0 */ #endif } -#ifdef FIX_ISSUE_2618_PLC_RES_ATT_SCALING - fac = L_shl_sat( fac, exponent ); /* Q31 */ -#endif + v_multc_fx( pDFT_RES, fac, pDFT_RES, shl( L_res, 1 ) ); return; -- GitLab