From 11527d4407a16d4ab100d55c31ebbb12f0762c51 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 12 Nov 2025 10:25:04 +0100 Subject: [PATCH] Add saturations of DFT stereo related signales to avoid crashes from issue #2205 and #2206. --- lib_com/options.h | 3 +++ lib_enc/ivas_cpe_enc_fx.c | 6 +++++- lib_enc/ivas_stereo_switching_enc_fx.c | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8fb55599e..7cf66743a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,6 +108,9 @@ #define FIX_2217_ASSERT_IN_IVAS_CORE_DECODER_WITH_MC /* FhG: Adjust Q_real to prevent overflow in st->cldfbSyn->cldfb_state_fx scaling */ #define FIX_2211_ASSERT_IN_REND_CREND_CONVOLER /* FhG: Add headroom to p_output_fx to prevent overflow in ivas_rend_crendProcessSubframe_fx() */ +#define NONBE_FIX_2205_SATURATE_ALTERNATIVE +#define NONBE_FIX_2206_SATURATE_ALTERNATIVE + /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index da4bec541..9f206be4d 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -826,9 +826,13 @@ ivas_error ivas_cpe_enc_fx( move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL ); - +#ifdef NONBE_FIX_2205_SATURATE_ALTERNATIVE + Scale_sig32( sts[0]->input32_fx - input_frame, add( out_start_ind, input_frame ), sub( Q15, sts[0]->q_old_inp32 ) ); // scaling initial part of the input buffer + Scale_sig32( sts[0]->input32_fx + out_end_ind, sub( input_frame, out_end_ind ), sub( Q15, sts[0]->q_inp32 ) ); // scaling initial part of the input buffer +#else scale_sig32( sts[0]->input32_fx - input_frame, add( out_start_ind, input_frame ), sub( Q15, sts[0]->q_old_inp32 ) ); // scaling initial part of the input buffer scale_sig32( sts[0]->input32_fx + out_end_ind, sub( input_frame, out_end_ind ), sub( Q15, sts[0]->q_inp32 ) ); // scaling initial part of the input buffer +#endif sts[0]->q_inp32 = Q15; sts[0]->q_old_inp32 = Q15; move16(); diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index b9fc815a7..0b27de0f6 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -682,7 +682,11 @@ void stereo_switching_enc_fx( /* window DFT synthesis overlap memory @input_Fs, primary channel */ FOR( i = 0; i < dft_ovl; i++ ) { +#ifdef NONBE_FIX_2206_SATURATE_ALTERNATIVE + hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl_sat( Mpy_32_32_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ), sub( 15, q_inp ) ); // Q15 +#else hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl( Mpy_32_32_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ), sub( 15, q_inp ) ); // Q15 +#endif move32(); } /* reset 48kHz BWE overlap memory */ -- GitLab