From 15fc641866e7b590aa1e3dcd04971c601002d064 Mon Sep 17 00:00:00 2001 From: Tommy Date: Fri, 8 May 2026 11:54:05 -0400 Subject: [PATCH 1/2] proposed fix for 2584 --- lib_com/options.h | 2 +- lib_enc/ivas_stereo_td_analysis_fx.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index c357e4d4d..a39dcb18d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,7 +133,7 @@ #define FIX_FLOAT_1578_OMASA_REND_SPIKES /* Nokia: Float issue 1578: Fix spikes and collapsed perception in OMASA/MASA rendering to FOA/HOA */ #define FIX_1521_SBA_LOUDNESS_STEREO /* FhG: issue 1521: Fix loudness for SBA to stereo rendering */ #define FIX_1559 /* Eri/FhG: fix for Issue 1559 in FD CNG with bitrate/bw switching */ - +#define FIX_2584_TD_SM_ISSUE /* VA: Fix inconsistencies in the SM part of the TD stereo */ /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c index 61aa03ab8..5911dfcbd 100644 --- a/lib_enc/ivas_stereo_td_analysis_fx.c +++ b/lib_enc/ivas_stereo_td_analysis_fx.c @@ -971,7 +971,11 @@ static Word16 Get_dt_lt_ener_fx( test(); IF( GE_16( *tdm_hyst_cnt, 2 ) && EQ_16( tmp_SM_flag, 1 ) && ( GT_16( sts[0]->tdm_pc, PC_LIMIT ) || GT_16( sts[1]->tdm_pc, PC_LIMIT ) ) ) { +#ifndef FIX_2584_TD_SM_ISSUE tdm_hyst_cnt++; +#else + *tdm_hyst_cnt = add( *tdm_hyst_cnt, 1 ); +#endif *tdm_NOOP_SM_flag_loc = tmp_SM_flag; move16(); *tdm_hyst_cnt = 0; @@ -980,7 +984,11 @@ static Word16 Get_dt_lt_ener_fx( ELSE IF( GE_16( *tdm_hyst_cnt, 20 ) && tmp_SM_flag == 0 && ( GT_16( sts[0]->tdm_pc, PC_LIMIT ) || GT_16( sts[1]->tdm_pc, PC_LIMIT ) ) && ( LE_32( *tdm_LT_es_em, ONE_IN_Q20 /* 0.5f in Q21 */ ) || LT_32( es_em_fx, -20971520 /* -10.0f in Q21 */ ) ) ) { +#ifndef FIX_2584_TD_SM_ISSUE tdm_hyst_cnt++; +#else + *tdm_hyst_cnt = add( *tdm_hyst_cnt, 1 ); +#endif *tdm_NOOP_SM_flag_loc = tmp_SM_flag; move16(); *tdm_hyst_cnt = 0; @@ -1573,14 +1581,24 @@ static Word16 stereo_tdm_ener_analysis_SM_fx( test(); test(); test(); +#ifndef FIX_2584_TD_SM_ISSUE IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 - Q24 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN_FX_Q20 ) ) || ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 - Q24 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN_FX_Q20 ) ) ) /* Q20 */ +#else + IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 - Q16 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q16 ), RMS_MIN_FX_Q20 ) ) || + ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 - Q16 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q16 ), RMS_MIN_FX_Q20 ) ) ) /* Q20 */ +#endif { test(); test(); test(); +#ifndef FIX_2584_TD_SM_ISSUE IF( ( LT_16( sts[0]->old_corr_fx, CORR_THRES_FX_Q15 ) && LT_16( sts[1]->old_corr_fx, CORR_THRES_FX_Q15 ) ) || ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) ) ) +#else + IF( ( LT_16( sts[0]->old_corr_fx, CORR_THRES_FX_Q15 ) && LT_16( sts[1]->old_corr_fx, CORR_THRES_FX_Q15 ) ) || + ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q16 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q16 ), RMS_MIN2_FX_Q21 ) ) ) +#endif { side_can_change = 1; move16(); @@ -1590,8 +1608,13 @@ static Word16 stereo_tdm_ener_analysis_SM_fx( test(); test(); test(); +#ifndef FIX_2584_TD_SM_ISSUE IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN2_FX_Q21 ) ) || ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN2_FX_Q21 ) ) ) /* Q21 */ +#else + IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q16 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q16 ), RMS_MIN2_FX_Q21 ) ) || + ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q16 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q16 ), RMS_MIN2_FX_Q21 ) ) ) /* Q21 */ +#endif { test(); test(); -- GitLab From f312fbfded2f2aac21791fcb2b5c2f6d5bb45b11 Mon Sep 17 00:00:00 2001 From: Tommy Date: Fri, 8 May 2026 11:57:53 -0400 Subject: [PATCH 2/2] fix clang --- lib_enc/ivas_stereo_td_analysis_fx.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c index 5911dfcbd..39422d2c6 100644 --- a/lib_enc/ivas_stereo_td_analysis_fx.c +++ b/lib_enc/ivas_stereo_td_analysis_fx.c @@ -971,11 +971,11 @@ static Word16 Get_dt_lt_ener_fx( test(); IF( GE_16( *tdm_hyst_cnt, 2 ) && EQ_16( tmp_SM_flag, 1 ) && ( GT_16( sts[0]->tdm_pc, PC_LIMIT ) || GT_16( sts[1]->tdm_pc, PC_LIMIT ) ) ) { -#ifndef FIX_2584_TD_SM_ISSUE +#ifndef FIX_2584_TD_SM_ISSUE tdm_hyst_cnt++; -#else +#else *tdm_hyst_cnt = add( *tdm_hyst_cnt, 1 ); -#endif +#endif *tdm_NOOP_SM_flag_loc = tmp_SM_flag; move16(); *tdm_hyst_cnt = 0; @@ -984,11 +984,11 @@ static Word16 Get_dt_lt_ener_fx( ELSE IF( GE_16( *tdm_hyst_cnt, 20 ) && tmp_SM_flag == 0 && ( GT_16( sts[0]->tdm_pc, PC_LIMIT ) || GT_16( sts[1]->tdm_pc, PC_LIMIT ) ) && ( LE_32( *tdm_LT_es_em, ONE_IN_Q20 /* 0.5f in Q21 */ ) || LT_32( es_em_fx, -20971520 /* -10.0f in Q21 */ ) ) ) { -#ifndef FIX_2584_TD_SM_ISSUE +#ifndef FIX_2584_TD_SM_ISSUE tdm_hyst_cnt++; -#else +#else *tdm_hyst_cnt = add( *tdm_hyst_cnt, 1 ); -#endif +#endif *tdm_NOOP_SM_flag_loc = tmp_SM_flag; move16(); *tdm_hyst_cnt = 0; @@ -1581,24 +1581,24 @@ static Word16 stereo_tdm_ener_analysis_SM_fx( test(); test(); test(); -#ifndef FIX_2584_TD_SM_ISSUE +#ifndef FIX_2584_TD_SM_ISSUE IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 - Q24 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN_FX_Q20 ) ) || ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 - Q24 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN_FX_Q20 ) ) ) /* Q20 */ #else IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 - Q16 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q16 ), RMS_MIN_FX_Q20 ) ) || ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 - Q16 ), RMS_MIN_FX_Q20 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q19 /* adjusted for 2 in RHS */ - Q16 ), RMS_MIN_FX_Q20 ) ) ) /* Q20 */ -#endif +#endif { test(); test(); test(); -#ifndef FIX_2584_TD_SM_ISSUE +#ifndef FIX_2584_TD_SM_ISSUE IF( ( LT_16( sts[0]->old_corr_fx, CORR_THRES_FX_Q15 ) && LT_16( sts[1]->old_corr_fx, CORR_THRES_FX_Q15 ) ) || ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) ) ) #else IF( ( LT_16( sts[0]->old_corr_fx, CORR_THRES_FX_Q15 ) && LT_16( sts[1]->old_corr_fx, CORR_THRES_FX_Q15 ) ) || ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q16 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q16 ), RMS_MIN2_FX_Q21 ) ) ) -#endif +#endif { side_can_change = 1; move16(); @@ -1608,13 +1608,13 @@ static Word16 stereo_tdm_ener_analysis_SM_fx( test(); test(); test(); -#ifndef FIX_2584_TD_SM_ISSUE +#ifndef FIX_2584_TD_SM_ISSUE IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN2_FX_Q21 ) ) || ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q24 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q24 ), RMS_MIN2_FX_Q21 ) ) ) /* Q21 */ #else IF( ( LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q21 - Q16 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q16 ), RMS_MIN2_FX_Q21 ) ) || ( LE_32( L_shl( hStereoTD->tdm_lt_rms_R_SM_fx, Q21 - Q16 ), RMS_MIN2_FX_Q21 ) && LE_32( L_shl( hStereoTD->tdm_lt_rms_L_SM_fx, Q20 /* adjusted for 2 in RHS */ - Q16 ), RMS_MIN2_FX_Q21 ) ) ) /* Q21 */ -#endif +#endif { test(); test(); -- GitLab