From 4b2db64bac8ba8e35ed1024f3dbffb5ecf7a832d Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Wed, 24 Sep 2025 09:48:30 +0200 Subject: [PATCH 1/2] the sliding window sum inside IGF_getWhiteSpectralData_ivas() was implemented more efficiently. --- lib_dec/igf_dec_fx.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 206627d92..59485575e 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -2905,6 +2905,7 @@ static void IGF_getWhiteSpectralData_ivas( Word16 tmp_e; Word16 out_e_arr[IGF_START_MX + MAX_IGF_SFB_LEN]; Word16 max_out_e; + Word64 window_sum; assert( LT_16( stop, IGF_START_MX + MAX_IGF_SFB_LEN ) ); /* inits */ @@ -2930,15 +2931,18 @@ static void IGF_getWhiteSpectralData_ivas( ak_e = add( tmp_e, sub( shl( sub( in_e, s_l ), 1 ), 15 ) ); // tmp_e + 2 * (in_e - s_l) - 15 ak_e = sub( ak_e, 1 ); + window_sum = 0; + move64(); + FOR( j = start - level; j < start + level; j++ ) + { + window_sum = W_mac_32_32( window_sum, in[j], in[j] ); + } + FOR( i = start; i < stop - level; i++ ) { - Word64 temp = 0; - move64(); - FOR( j = i - level; j < i + level + 1; j++ ) - { - temp = W_mac_32_32( temp, in[j], in[j] ); - } - ak = Mult_32_16( W_shl_sat_l( temp, shift ), quo ); // add( shl( level, 1 ), 1 ), &tmp_e ) ); + window_sum = W_mac_32_32( window_sum, in[i + level], in[i + level] ); /* add the right one */ + ak = Mult_32_16( W_shl_sat_l( window_sum, shift ), quo ); // add( shl( level, 1 ), 1 ), &tmp_e ) ); + window_sum = W_sub( window_sum, W_mult_32_32( in[i - level], in[i - level] ) ); /* subtract the left one */ n = sub( ak_e, norm_l( ak ) ); @@ -2951,16 +2955,9 @@ static void IGF_getWhiteSpectralData_ivas( FOR( ; i < stop; i++ ) { - Word64 temp = 0; - move64(); - - FOR( j = i - level; j < stop; j++ ) - { - temp = W_mac_32_32( temp, in[j], in[j] ); - } - - ak = L_deposit_h( BASOP_Util_Divide3216_Scale( W_shl_sat_l( temp, shift ), sub( stop, sub( i, level ) ), &tmp_e ) ); - ak_e = add( tmp_e, eff_e ); // tmp_e + 2 * (in_e - s_l) - 15 + ak = L_deposit_h( BASOP_Util_Divide3216_Scale( W_shl_sat_l( window_sum, shift ), sub( stop, sub( i, level ) ), &tmp_e ) ); + window_sum = W_sub( window_sum, W_mult_32_32( in[i - level], in[i - level] ) ); /* subtract the left one */ + ak_e = add( tmp_e, eff_e ); // tmp_e + 2 * (in_e - s_l) - 15 n = sub( ak_e, add( norm_l( ak ), 1 ) ); n = shr( n, 1 ); -- GitLab From e392e205d1490fe5a23d46b4f4c3751e52fa9b05 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 7 Oct 2025 14:17:28 +0200 Subject: [PATCH 2/2] wrap changes in OPT_IGF_GET_WHITE_SPEC_DATA --- lib_com/options.h | 1 + lib_dec/igf_dec_fx.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 464fc3e9e..020108162 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,6 +104,7 @@ #define FIX_2010_PREP_TBE_EXC /* FhG: fix issues with varying Q-values for code_preQ_fx[] */ #define FIX_2025_FDCNG_MULT /* Nokia, FhG: Fix LB FDCNG noise introduced by changing mult to i_mult */ +#define OPT_IGF_GET_WHITE_SPEC_DATA /* FhG: optimized version of IGF_getWhiteSpectralData_ivas() */ #define FIX_1962_FORMAT_CONV_SPECTRAL_DIFF /* FhG: Improved precision of targetEnergy in ivas_ls_setup_conversion_process_mdct_fx() */ #define FIX_2003_CON_TCX_OVERFLOW /* FhG: Use a dynamic scaling factor for the synth buffer at the output of con_tcx_ivas_fx() */ #define OPT_TCXLTP_FILTER_LOOP /* FhG: optimize loop in tcx_ltp_synth_filter */ diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index d9d8450ee..e2434ffd7 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -2905,7 +2905,9 @@ static void IGF_getWhiteSpectralData_ivas( Word16 tmp_e; Word16 out_e_arr[IGF_START_MX + MAX_IGF_SFB_LEN]; Word16 max_out_e; +#ifdef OPT_IGF_GET_WHITE_SPEC_DATA Word64 window_sum; +#endif assert( LT_16( stop, IGF_START_MX + MAX_IGF_SFB_LEN ) ); /* inits */ @@ -2931,19 +2933,30 @@ static void IGF_getWhiteSpectralData_ivas( ak_e = add( tmp_e, sub( shl( sub( in_e, s_l ), 1 ), 15 ) ); // tmp_e + 2 * (in_e - s_l) - 15 ak_e = sub( ak_e, 1 ); +#ifdef OPT_IGF_GET_WHITE_SPEC_DATA window_sum = 0; move64(); FOR( j = start - level; j < start + level; j++ ) { window_sum = W_mac_32_32( window_sum, in[j], in[j] ); } +#endif FOR( i = start; i < stop - level; i++ ) { +#ifdef OPT_IGF_GET_WHITE_SPEC_DATA window_sum = W_mac_32_32( window_sum, in[i + level], in[i + level] ); /* add the right one */ ak = Mult_32_16( W_shl_sat_l( window_sum, shift ), quo ); // add( shl( level, 1 ), 1 ), &tmp_e ) ); window_sum = W_sub( window_sum, W_mult_32_32( in[i - level], in[i - level] ) ); /* subtract the left one */ - +#else + Word64 temp = 0; + move64(); + FOR( j = i - level; j < i + level + 1; j++ ) + { + temp = W_mac_32_32( temp, in[j], in[j] ); + } + ak = Mult_32_16( W_shl_sat_l( temp, shift ), quo ); // add( shl( level, 1 ), 1 ), &tmp_e ) ); +#endif n = sub( ak_e, norm_l( ak ) ); n = shr( n, 1 ); @@ -2955,9 +2968,23 @@ static void IGF_getWhiteSpectralData_ivas( FOR( ; i < stop; i++ ) { +#ifdef OPT_IGF_GET_WHITE_SPEC_DATA ak = L_deposit_h( BASOP_Util_Divide3216_Scale( W_shl_sat_l( window_sum, shift ), sub( stop, sub( i, level ) ), &tmp_e ) ); window_sum = W_sub( window_sum, W_mult_32_32( in[i - level], in[i - level] ) ); /* subtract the left one */ ak_e = add( tmp_e, eff_e ); // tmp_e + 2 * (in_e - s_l) - 15 +#else + Word64 temp = 0; + move64(); + + FOR( j = i - level; j < stop; j++ ) + { + temp = W_mac_32_32( temp, in[j], in[j] ); + } + + ak = L_deposit_h( BASOP_Util_Divide3216_Scale( W_shl_sat_l( temp, shift ), sub( stop, sub( i, level ) ), &tmp_e ) ); + ak_e = add( tmp_e, eff_e ); // tmp_e + 2 * (in_e - s_l) - 15 +#endif + n = sub( ak_e, add( norm_l( ak ), 1 ) ); n = shr( n, 1 ); -- GitLab