From 4d7394ff7c9f60f972a5129cec90994df453d67e Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 22 Aug 2025 13:27:39 +0200 Subject: [PATCH 1/6] Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() --- lib_com/options.h | 2 +- lib_rend/ivas_reverb_fx.c | 54 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a9501c3a9..97399273b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -106,7 +106,7 @@ #endif #define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ #define FIX_1844_MISSING_FREE /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */ - +#define FIX_1942_ASSERTION_LOWSHELF /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() /* #################### Start BASOP porting switches ############################ */ #define FIX_1372_ISAR_POST_REND diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index ddcd6ef15..453a62c3b 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -106,6 +106,11 @@ static Word16 wrap_rad_fixed( #define MAX_NR_OUTPUTS ( 2 ) +#ifdef FIX_1942_ASSERTION_LOWSHELF +#define M60Q8 (-15360) //-60 in Q8 +#define M120Q8 (-30720) //-120 in Q8 +#endif + const Word16 init_loop_delay[IVAS_REV_MAX_NR_BRANCHES] = { 37, 31, 29, 23, 19, 17, 13, 11 }; const Word16 default_loop_delay_48k[IVAS_REV_MAX_NR_BRANCHES] = { 2309, 1861, 1523, 1259, 1069, 919, 809, 719 }; const Word16 default_loop_delay_32k[IVAS_REV_MAX_NR_BRANCHES] = { 1531, 1237, 1013, 839, 709, 613, 541, 479 }; @@ -658,15 +663,19 @@ static ivas_error compute_t60_coeffs_fx( { Word16 bin_idx, loop_idx, tf_T60_len, len; ivas_error error; - +#ifdef FIX_1942_ASSERTION_LOWSHELF + Word16 loop_delay_sec_fx, tmp, tmp_e; +#else Word16 loop_delay_sec_fx, tmp; +#endif Word32 freq_Nyquist_fx = L_shr( output_Fs, 1 ); Word16 target_gains_db_fx[RV_LENGTH_NR_FC]; // Q8 Word16 norm_f_fx[RV_LENGTH_NR_FC]; Word16 *pCoeffs_a_fx, *pCoeffs_b_fx; Word16 e; +#ifndef FIX_1942_ASSERTION_LOWSHELF const Word16 min120q8 = -30720; // -120 in Q8 - +#endif error = IVAS_ERR_OK; move32(); tf_T60_len = nr_fc_fft_filter; @@ -692,11 +701,42 @@ static ivas_error compute_t60_coeffs_fx( IF( EQ_32( pParams->pRt60_fx[bin_idx], 0 ) ) { // If RT60 is 0, target gain is -120dB +#ifdef FIX_1942_ASSERTION_LOWSHELF + target_gains_db_fx[bin_idx] = M120Q8; +#else target_gains_db_fx[bin_idx] = min120q8; +#endif } ELSE { tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e ); +#ifdef FIX_1942_ASSERTION_LOWSHELF + tmp_e = sub( add( e, 0 ), 5 ); //L_deposit_h( loop_delay_sec_fx ):Q31, pParams->pRt60_fx[bin_idx]:Q26 + target_gains_db_fx[bin_idx] = mult( M60Q8, tmp ); + + // gain < - 120 ? -120: gain + IF( GT_16( tmp_e, 0 ) ) // target_gains_db_fx:Q8+Qtmp --> if(Q8+Qtmp < Q8) = if(Qtmp < 0) = if(tmp_e > 0) + { + IF( LT_16( target_gains_db_fx[bin_idx], shr( M120Q8, tmp_e ) ) ) + { + target_gains_db_fx[bin_idx] = M120Q8; // Q8 + move16(); + } + ELSE + { + target_gains_db_fx[bin_idx] = shl( target_gains_db_fx[bin_idx], tmp_e ); // Q8, gain must be less than 128 + } + } + ELSE + { + target_gains_db_fx[bin_idx] = shl( target_gains_db_fx[bin_idx], tmp_e ); //Q8, gain must be less than 128 + IF( LT_16( target_gains_db_fx[bin_idx], M120Q8 ) ) + { + target_gains_db_fx[bin_idx] = M120Q8; //Q8 + move16(); + } + } +#else IF( LT_16( e, -1 ) ) { target_gains_db_fx[bin_idx] = min120q8; @@ -706,13 +746,16 @@ static ivas_error compute_t60_coeffs_fx( tmp = shr( tmp, sub( 5, e ) ); // scaling tmp to Q15 target_gains_db_fx[bin_idx] = mult( shr( min120q8, 1 ), tmp ); // Q8 } +#endif } +#ifndef FIX_1942_ASSERTION_LOWSHELF // gain < - 120 ? -120: gain IF( LT_16( target_gains_db_fx[bin_idx], -30720 ) ) { target_gains_db_fx[bin_idx] = -30720; move16(); } +#endif } pCoeffs_a_fx = &pParams->pT60_filter_coeff_fx[add( shl( i_mult( len, loop_idx ), 1 ), len )]; // Q14 @@ -996,6 +1039,13 @@ static ivas_error calc_jot_t60_coeffs_fx( L_tmp = BASOP_util_Pow2( L_deposit_h( tmp_fx ), exph, &e ); lin_gain_hf_fx = extract_l( L_shr( L_tmp, sub( 16, e ) ) ); +#ifdef FIX_1942_ASSERTION_LOWSHELF + IF( EQ_16( lin_gain_hf_fx, 0 ) ) + { + lin_gain_hf_fx = 1; + move16(); + } +#endif /* call low-pass iir shelf */ calc_low_shelf_first_order_filter_fx( pCoeffB_fx, pCoeffA_fx, f0_fx, lin_gain_lf_fx, lin_gain_hf_fx ); return IVAS_ERR_OK; -- GitLab From 42a7d394d936db0ba264d9054a2441f99ace6f6e Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 22 Aug 2025 13:52:18 +0200 Subject: [PATCH 2/6] Applied clang formatting patch. --- lib_rend/ivas_reverb_fx.c | 136 +++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 69 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 453a62c3b..4a43a20ab 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -107,8 +107,8 @@ static Word16 wrap_rad_fixed( #define MAX_NR_OUTPUTS ( 2 ) #ifdef FIX_1942_ASSERTION_LOWSHELF -#define M60Q8 (-15360) //-60 in Q8 -#define M120Q8 (-30720) //-120 in Q8 +#define M60Q8 ( -15360 ) //-60 in Q8 +#define M120Q8 ( -30720 ) //-120 in Q8 #endif const Word16 init_loop_delay[IVAS_REV_MAX_NR_BRANCHES] = { 37, 31, 29, 23, 19, 17, 13, 11 }; @@ -696,89 +696,87 @@ static ivas_error compute_t60_coeffs_fx( loop_delay_sec_fx = BASOP_Util_Divide3232_Scale( pParams->pLoop_delays[loop_idx], output_Fs, &e ); loop_delay_sec_fx = shl( loop_delay_sec_fx, e ); // Q15 - FOR( bin_idx = 0; bin_idx < tf_T60_len; bin_idx++ ) - { - IF( EQ_32( pParams->pRt60_fx[bin_idx], 0 ) ) - { - // If RT60 is 0, target gain is -120dB + FOR( bin_idx = 0; bin_idx < tf_T60_len; bin_idx++ ){ + IF( EQ_32( pParams->pRt60_fx[bin_idx], 0 ) ){ + // If RT60 is 0, target gain is -120dB #ifdef FIX_1942_ASSERTION_LOWSHELF target_gains_db_fx[bin_idx] = M120Q8; #else target_gains_db_fx[bin_idx] = min120q8; #endif + } + ELSE + { + tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e ); +#ifdef FIX_1942_ASSERTION_LOWSHELF + tmp_e = sub( add( e, 0 ), 5 ); // L_deposit_h( loop_delay_sec_fx ):Q31, pParams->pRt60_fx[bin_idx]:Q26 + target_gains_db_fx[bin_idx] = mult( M60Q8, tmp ); + + // gain < - 120 ? -120: gain + IF( GT_16( tmp_e, 0 ) ) // target_gains_db_fx:Q8+Qtmp --> if(Q8+Qtmp < Q8) = if(Qtmp < 0) = if(tmp_e > 0) + { + IF( LT_16( target_gains_db_fx[bin_idx], shr( M120Q8, tmp_e ) ) ) + { + target_gains_db_fx[bin_idx] = M120Q8; // Q8 + move16(); } ELSE { - tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e ); -#ifdef FIX_1942_ASSERTION_LOWSHELF - tmp_e = sub( add( e, 0 ), 5 ); //L_deposit_h( loop_delay_sec_fx ):Q31, pParams->pRt60_fx[bin_idx]:Q26 - target_gains_db_fx[bin_idx] = mult( M60Q8, tmp ); - - // gain < - 120 ? -120: gain - IF( GT_16( tmp_e, 0 ) ) // target_gains_db_fx:Q8+Qtmp --> if(Q8+Qtmp < Q8) = if(Qtmp < 0) = if(tmp_e > 0) - { - IF( LT_16( target_gains_db_fx[bin_idx], shr( M120Q8, tmp_e ) ) ) - { - target_gains_db_fx[bin_idx] = M120Q8; // Q8 - move16(); - } - ELSE - { - target_gains_db_fx[bin_idx] = shl( target_gains_db_fx[bin_idx], tmp_e ); // Q8, gain must be less than 128 - } - } - ELSE - { - target_gains_db_fx[bin_idx] = shl( target_gains_db_fx[bin_idx], tmp_e ); //Q8, gain must be less than 128 - IF( LT_16( target_gains_db_fx[bin_idx], M120Q8 ) ) - { - target_gains_db_fx[bin_idx] = M120Q8; //Q8 - move16(); - } - } -#else - IF( LT_16( e, -1 ) ) - { - target_gains_db_fx[bin_idx] = min120q8; - } - ELSE - { - tmp = shr( tmp, sub( 5, e ) ); // scaling tmp to Q15 - target_gains_db_fx[bin_idx] = mult( shr( min120q8, 1 ), tmp ); // Q8 - } -#endif + target_gains_db_fx[bin_idx] = shl( target_gains_db_fx[bin_idx], tmp_e ); // Q8, gain must be less than 128 } -#ifndef FIX_1942_ASSERTION_LOWSHELF - // gain < - 120 ? -120: gain - IF( LT_16( target_gains_db_fx[bin_idx], -30720 ) ) + } + ELSE + { + target_gains_db_fx[bin_idx] = shl( target_gains_db_fx[bin_idx], tmp_e ); // Q8, gain must be less than 128 + IF( LT_16( target_gains_db_fx[bin_idx], M120Q8 ) ) { - target_gains_db_fx[bin_idx] = -30720; + target_gains_db_fx[bin_idx] = M120Q8; // Q8 move16(); } -#endif } - - pCoeffs_a_fx = &pParams->pT60_filter_coeff_fx[add( shl( i_mult( len, loop_idx ), 1 ), len )]; // Q14 - pCoeffs_b_fx = &pParams->pT60_filter_coeff_fx[shl( i_mult( len, loop_idx ), 1 )]; // Q14 - - move16(); - - Word16 val = 7; - - IF( NE_32( ( error = calc_jot_t60_coeffs_fx( target_gains_db_fx, val, tf_T60_len, norm_f_fx, pCoeffs_a_fx, pCoeffs_b_fx, extract_l( freq_Nyquist_fx ) ) ), IVAS_ERR_OK ) ) +#else + IF( LT_16( e, -1 ) ) { - return error; + target_gains_db_fx[bin_idx] = min120q8; } + ELSE + { + tmp = shr( tmp, sub( 5, e ) ); // scaling tmp to Q15 + target_gains_db_fx[bin_idx] = mult( shr( min120q8, 1 ), tmp ); // Q8 + } +#endif } - - len = shr( ( add( pParams->t60_filter_order, 1 ) ), 1 ); // Q0// /* == floor( (order+1) / 2) */ - FOR( loop_idx = 0; loop_idx < pParams->nr_loops; loop_idx++ ) +#ifndef FIX_1942_ASSERTION_LOWSHELF + // gain < - 120 ? -120: gain + IF( LT_16( target_gains_db_fx[bin_idx], -30720 ) ) { - pParams->pLoop_delays[loop_idx] = sub( pParams->pLoop_delays[loop_idx], len ); // Q0 + target_gains_db_fx[bin_idx] = -30720; move16(); } +#endif +} + +pCoeffs_a_fx = &pParams->pT60_filter_coeff_fx[add( shl( i_mult( len, loop_idx ), 1 ), len )]; // Q14 +pCoeffs_b_fx = &pParams->pT60_filter_coeff_fx[shl( i_mult( len, loop_idx ), 1 )]; // Q14 + +move16(); + +Word16 val = 7; + +IF( NE_32( ( error = calc_jot_t60_coeffs_fx( target_gains_db_fx, val, tf_T60_len, norm_f_fx, pCoeffs_a_fx, pCoeffs_b_fx, extract_l( freq_Nyquist_fx ) ) ), IVAS_ERR_OK ) ) +{ return error; } +} + +len = shr( ( add( pParams->t60_filter_order, 1 ) ), 1 ); // Q0// /* == floor( (order+1) / 2) */ +FOR( loop_idx = 0; loop_idx < pParams->nr_loops; loop_idx++ ) +{ + pParams->pLoop_delays[loop_idx] = sub( pParams->pLoop_delays[loop_idx], len ); // Q0 + move16(); +} +return error; +} /*-----------------------------------------------------------------------------------------* @@ -1464,11 +1462,11 @@ static ivas_error setup_FDN_branches_fx( * Allocate and initialize FDN reverberation handle *------------------------------------------------------------------------*/ #else - /*------------------------------------------------------------------------- - * ivas_reverb_open_fx() - * - * Allocate and initialize Crend reverberation handle - *------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * ivas_reverb_open_fx() + * + * Allocate and initialize Crend reverberation handle + *------------------------------------------------------------------------*/ #endif ivas_error ivas_reverb_open_fx( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ -- GitLab From 6120e8bffffb6b4c2e6443217d74ff3bb5d5c096 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 22 Aug 2025 14:10:47 +0200 Subject: [PATCH 3/6] Modify macro comment in options.h --- lib_com/options.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 97399273b..085db5f95 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,9 +104,9 @@ #define REUSE_EVS_BE_GAINQ_LBR // BE by adding one condition, but could be harmonized in a non-BE way. There is a small difference in how Etot is computed #endif -#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ -#define FIX_1844_MISSING_FREE /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */ -#define FIX_1942_ASSERTION_LOWSHELF /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() +#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ +#define FIX_1844_MISSING_FREE /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */ +#define FIX_1942_ASSERTION_LOWSHELF /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */ /* #################### Start BASOP porting switches ############################ */ #define FIX_1372_ISAR_POST_REND -- GitLab From 221a11ed77bcf74cc6dffb53614a70474926c804 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 22 Aug 2025 18:03:58 +0200 Subject: [PATCH 4/6] Replace shl with shl_r to improve precision in compute_t60_coeffs_fx(). --- lib_rend/ivas_reverb_fx.c | 123 +++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 61 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 4a43a20ab..03ecc37f4 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -107,7 +107,7 @@ static Word16 wrap_rad_fixed( #define MAX_NR_OUTPUTS ( 2 ) #ifdef FIX_1942_ASSERTION_LOWSHELF -#define M60Q8 ( -15360 ) //-60 in Q8 +#define M60Q9 ( -30720 ) //-60 in Q9 #define M120Q8 ( -30720 ) //-120 in Q8 #endif @@ -696,87 +696,88 @@ static ivas_error compute_t60_coeffs_fx( loop_delay_sec_fx = BASOP_Util_Divide3232_Scale( pParams->pLoop_delays[loop_idx], output_Fs, &e ); loop_delay_sec_fx = shl( loop_delay_sec_fx, e ); // Q15 - FOR( bin_idx = 0; bin_idx < tf_T60_len; bin_idx++ ){ - IF( EQ_32( pParams->pRt60_fx[bin_idx], 0 ) ){ - // If RT60 is 0, target gain is -120dB + FOR( bin_idx = 0; bin_idx < tf_T60_len; bin_idx++ ) + { + IF( EQ_32( pParams->pRt60_fx[bin_idx], 0 ) ) + { + // If RT60 is 0, target gain is -120dB #ifdef FIX_1942_ASSERTION_LOWSHELF target_gains_db_fx[bin_idx] = M120Q8; #else target_gains_db_fx[bin_idx] = min120q8; #endif - } - ELSE - { - tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e ); -#ifdef FIX_1942_ASSERTION_LOWSHELF - tmp_e = sub( add( e, 0 ), 5 ); // L_deposit_h( loop_delay_sec_fx ):Q31, pParams->pRt60_fx[bin_idx]:Q26 - target_gains_db_fx[bin_idx] = mult( M60Q8, tmp ); - - // gain < - 120 ? -120: gain - IF( GT_16( tmp_e, 0 ) ) // target_gains_db_fx:Q8+Qtmp --> if(Q8+Qtmp < Q8) = if(Qtmp < 0) = if(tmp_e > 0) - { - IF( LT_16( target_gains_db_fx[bin_idx], shr( M120Q8, tmp_e ) ) ) - { - target_gains_db_fx[bin_idx] = M120Q8; // Q8 - move16(); } ELSE { - target_gains_db_fx[bin_idx] = shl( target_gains_db_fx[bin_idx], tmp_e ); // Q8, gain must be less than 128 + tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e ); +#ifdef FIX_1942_ASSERTION_LOWSHELF + tmp_e = sub( add( e, 0 ), 5 ); // L_deposit_h( loop_delay_sec_fx ):Q0.31, pParams->pRt60_fx[bin_idx]:Q5.26 + target_gains_db_fx[bin_idx] = mult( M60Q9, tmp ); + tmp_e = add( tmp_e, 6 ); // + Q6.9(Q9) + // gain < - 120 ? -120: gain + IF( GT_16( tmp_e, 7 ) ) // Q7.8(Q8) + { + IF( LT_16( target_gains_db_fx[bin_idx], shr( M120Q8, tmp_e - 7 ) ) ) + { + target_gains_db_fx[bin_idx] = M120Q8; // Q8 + move16(); + } + ELSE + { + target_gains_db_fx[bin_idx] = shl_r( target_gains_db_fx[bin_idx], tmp_e - 7 ); // Q8, gain must be less than 128 + } + } + ELSE + { + target_gains_db_fx[bin_idx] = shl_r( target_gains_db_fx[bin_idx], tmp_e - 7 ); // Q8, gain must be less than 128 + IF( LT_16( target_gains_db_fx[bin_idx], M120Q8 ) ) + { + target_gains_db_fx[bin_idx] = M120Q8; // Q8 + move16(); + } + } } - } - ELSE - { - target_gains_db_fx[bin_idx] = shl( target_gains_db_fx[bin_idx], tmp_e ); // Q8, gain must be less than 128 - IF( LT_16( target_gains_db_fx[bin_idx], M120Q8 ) ) +#else + IF( LT_16( e, -1 ) ) + { + target_gains_db_fx[bin_idx] = min120q8; + } + ELSE + { + tmp = shr( tmp, sub( 5, e ) ); // scaling tmp to Q15 + target_gains_db_fx[bin_idx] = mult( shr( min120q8, 1 ), tmp ); // Q8 + } + } + // gain < - 120 ? -120: gain + IF( LT_16( target_gains_db_fx[bin_idx], -30720 ) ) { - target_gains_db_fx[bin_idx] = M120Q8; // Q8 + target_gains_db_fx[bin_idx] = -30720; move16(); } +#endif } -#else - IF( LT_16( e, -1 ) ) - { - target_gains_db_fx[bin_idx] = min120q8; - } - ELSE + + pCoeffs_a_fx = &pParams->pT60_filter_coeff_fx[add( shl( i_mult( len, loop_idx ), 1 ), len )]; // Q14 + pCoeffs_b_fx = &pParams->pT60_filter_coeff_fx[shl( i_mult( len, loop_idx ), 1 )]; // Q14 + + move16(); + + Word16 val = 7; + + IF( NE_32( ( error = calc_jot_t60_coeffs_fx( target_gains_db_fx, val, tf_T60_len, norm_f_fx, pCoeffs_a_fx, pCoeffs_b_fx, extract_l( freq_Nyquist_fx ) ) ), IVAS_ERR_OK ) ) { - tmp = shr( tmp, sub( 5, e ) ); // scaling tmp to Q15 - target_gains_db_fx[bin_idx] = mult( shr( min120q8, 1 ), tmp ); // Q8 + return error; } -#endif } -#ifndef FIX_1942_ASSERTION_LOWSHELF - // gain < - 120 ? -120: gain - IF( LT_16( target_gains_db_fx[bin_idx], -30720 ) ) + + len = shr( ( add( pParams->t60_filter_order, 1 ) ), 1 ); // Q0// /* == floor( (order+1) / 2) */ + FOR( loop_idx = 0; loop_idx < pParams->nr_loops; loop_idx++ ) { - target_gains_db_fx[bin_idx] = -30720; + pParams->pLoop_delays[loop_idx] = sub( pParams->pLoop_delays[loop_idx], len ); // Q0 move16(); } -#endif -} - -pCoeffs_a_fx = &pParams->pT60_filter_coeff_fx[add( shl( i_mult( len, loop_idx ), 1 ), len )]; // Q14 -pCoeffs_b_fx = &pParams->pT60_filter_coeff_fx[shl( i_mult( len, loop_idx ), 1 )]; // Q14 - -move16(); - -Word16 val = 7; - -IF( NE_32( ( error = calc_jot_t60_coeffs_fx( target_gains_db_fx, val, tf_T60_len, norm_f_fx, pCoeffs_a_fx, pCoeffs_b_fx, extract_l( freq_Nyquist_fx ) ) ), IVAS_ERR_OK ) ) -{ return error; } -} - -len = shr( ( add( pParams->t60_filter_order, 1 ) ), 1 ); // Q0// /* == floor( (order+1) / 2) */ -FOR( loop_idx = 0; loop_idx < pParams->nr_loops; loop_idx++ ) -{ - pParams->pLoop_delays[loop_idx] = sub( pParams->pLoop_delays[loop_idx], len ); // Q0 - move16(); -} -return error; -} /*-----------------------------------------------------------------------------------------* -- GitLab From 9a99d91e8350b49df4dbb6936907207b7ee9b7e6 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 25 Aug 2025 13:36:21 +0200 Subject: [PATCH 5/6] Change exponent calculation to make the code more readable in compute_t60_coeffs_fx(). --- lib_rend/ivas_reverb_fx.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 03ecc37f4..e05166d8d 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -703,6 +703,7 @@ static ivas_error compute_t60_coeffs_fx( // If RT60 is 0, target gain is -120dB #ifdef FIX_1942_ASSERTION_LOWSHELF target_gains_db_fx[bin_idx] = M120Q8; + move16(); #else target_gains_db_fx[bin_idx] = min120q8; #endif @@ -711,25 +712,28 @@ static ivas_error compute_t60_coeffs_fx( { tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e ); #ifdef FIX_1942_ASSERTION_LOWSHELF - tmp_e = sub( add( e, 0 ), 5 ); // L_deposit_h( loop_delay_sec_fx ):Q0.31, pParams->pRt60_fx[bin_idx]:Q5.26 + tmp_e = add( e, sub( 0 , 5 ) ); // L_deposit_h( loop_delay_sec_fx ):Q0.31, pParams->pRt60_fx[bin_idx]:Q5.26 + + tmp_e = add( tmp_e, 6 ); // + Q6.9(M60Q9) target_gains_db_fx[bin_idx] = mult( M60Q9, tmp ); - tmp_e = add( tmp_e, 6 ); // + Q6.9(Q9) + // gain < - 120 ? -120: gain - IF( GT_16( tmp_e, 7 ) ) // Q7.8(Q8) + tmp_e = sub( tmp_e, 7 ); // - Q7.8(M120Q8) + IF( GT_16( tmp_e, 0 ) ) { - IF( LT_16( target_gains_db_fx[bin_idx], shr( M120Q8, tmp_e - 7 ) ) ) + IF( LT_16( target_gains_db_fx[bin_idx], shr( M120Q8, tmp_e ) ) ) { target_gains_db_fx[bin_idx] = M120Q8; // Q8 move16(); } ELSE { - target_gains_db_fx[bin_idx] = shl_r( target_gains_db_fx[bin_idx], tmp_e - 7 ); // Q8, gain must be less than 128 + target_gains_db_fx[bin_idx] = shl_r( target_gains_db_fx[bin_idx], tmp_e ); // Q8, gain must be less than 128 } } ELSE { - target_gains_db_fx[bin_idx] = shl_r( target_gains_db_fx[bin_idx], tmp_e - 7 ); // Q8, gain must be less than 128 + target_gains_db_fx[bin_idx] = shl_r( target_gains_db_fx[bin_idx], tmp_e ); // Q8, gain must be less than 128 IF( LT_16( target_gains_db_fx[bin_idx], M120Q8 ) ) { target_gains_db_fx[bin_idx] = M120Q8; // Q8 -- GitLab From 8c828ad193e2f7bf9850bfff6c7777130df897ea Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 25 Aug 2025 13:41:13 +0200 Subject: [PATCH 6/6] Apply Clang formatting patch. --- lib_rend/ivas_reverb_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index e05166d8d..92f428884 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -712,11 +712,11 @@ static ivas_error compute_t60_coeffs_fx( { tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e ); #ifdef FIX_1942_ASSERTION_LOWSHELF - tmp_e = add( e, sub( 0 , 5 ) ); // L_deposit_h( loop_delay_sec_fx ):Q0.31, pParams->pRt60_fx[bin_idx]:Q5.26 - + tmp_e = add( e, sub( 0, 5 ) ); // L_deposit_h( loop_delay_sec_fx ):Q0.31, pParams->pRt60_fx[bin_idx]:Q5.26 + tmp_e = add( tmp_e, 6 ); // + Q6.9(M60Q9) target_gains_db_fx[bin_idx] = mult( M60Q9, tmp ); - + // gain < - 120 ? -120: gain tmp_e = sub( tmp_e, 7 ); // - Q7.8(M120Q8) IF( GT_16( tmp_e, 0 ) ) -- GitLab