diff --git a/lib_com/options.h b/lib_com/options.h index 83328c4532b8380a02f5597e7e3e65bc4fe229ee..eb172a83c4475baf18db442bc8f389c214bb06bf 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -111,6 +111,8 @@ #define RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE /* Dolby: CR for split rendering codec framesize signalling in Toc Byte */ +#define NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES /* FhG: Adjust scaleFactor according to st->cldfbSyn->cldfb_state_fx too to avoid overflow in cldfbSynthesis_ivas_fx() */ + /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 1d734bed010d765c43967abca192a3fb4144053b..272dc45c8002602743f881ce97995e17dd483365 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -1818,13 +1818,23 @@ static void isar_rend_CldfbSplitPostRendProcessTdIn( { RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch_idx][slot_idx]; ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch_idx][slot_idx]; +#ifdef NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES + scaleFactor = s_min( scaleFactor, s_min( L_norm_arr( RealBuffer_fx[slot_idx], num_cldfb_bands ), L_norm_arr( ImagBuffer_fx[slot_idx], num_cldfb_bands ) ) ); + scaleFactor = s_min( scaleFactor, L_norm_arr( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_length ) ); +#else scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); +#endif } scaleFactor = s_min( sub( scaleFactor, 6 ), Q24 ); // guarded bits FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { +#ifdef NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES + Scale_sig32( RealBuffer_fx[slot_idx], num_cldfb_bands, scaleFactor ); + Scale_sig32( ImagBuffer_fx[slot_idx], num_cldfb_bands, scaleFactor ); +#else Scale_sig32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); Scale_sig32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); +#endif } Q_cldfb = add( scaleFactor, Q_in ); Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); @@ -1880,14 +1890,24 @@ void isar_rend_CldfbSplitPostRendProcess( { RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch_idx][slot_idx]; ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch_idx][slot_idx]; +#ifdef NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES + scaleFactor = s_min( scaleFactor, s_min( L_norm_arr( RealBuffer_fx[slot_idx], num_cldfb_bands ), L_norm_arr( ImagBuffer_fx[slot_idx], num_cldfb_bands ) ) ); + scaleFactor = s_min( scaleFactor, L_norm_arr( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_length ) ); +#else scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); +#endif } scaleFactor = s_min( sub( scaleFactor, 6 ), Q24 ); // guarded bits FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { +#ifdef NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES + Scale_sig32( RealBuffer_fx[slot_idx], num_cldfb_bands, scaleFactor ); + Scale_sig32( ImagBuffer_fx[slot_idx], num_cldfb_bands, scaleFactor ); +#else Scale_sig32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); Scale_sig32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); +#endif } Q_cldfb = scaleFactor + Q_cldfb_in; Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) );