From 56daf71c038fa96de7290b17992e1cedf1584c4c Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Fri, 19 Sep 2025 12:26:26 +0200 Subject: [PATCH 1/3] improved WMOPS performance of IGF_getWhiteSpectralData_ivas() by reimplementing a window sum. --- lib_dec/igf_dec_fx.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 206627d92..22b2e498b 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -2905,6 +2905,8 @@ 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; + Word64 left_one; assert( LT_16( stop, IGF_START_MX + MAX_IGF_SFB_LEN ) ); /* inits */ @@ -2930,15 +2932,21 @@ 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; + left_one = 0; + move64(); + 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_sub( window_sum, left_one ); /* subtract the left one */ + window_sum = W_mac_32_32( window_sum, in[i + level], in[i + level] ); /* add the right one */ + left_one = W_mult_32_32( in[i - level], in[i - level] ); + ak = Mult_32_16( W_shl_sat_l( window_sum, shift ), quo ); // add( shl( level, 1 ), 1 ), &tmp_e ) ); n = sub( ak_e, norm_l( ak ) ); -- GitLab From 76e569b00292250e0f769805a63dd2b86dc39397 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 22 Sep 2025 10:01:01 +0200 Subject: [PATCH 2/3] improved the second half of IGF_getWhiteSpectralData_ivas(). --- lib_dec/igf_dec_fx.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 22b2e498b..79b31095a 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -2906,7 +2906,6 @@ static void IGF_getWhiteSpectralData_ivas( Word16 out_e_arr[IGF_START_MX + MAX_IGF_SFB_LEN]; Word16 max_out_e; Word64 window_sum; - Word64 left_one; assert( LT_16( stop, IGF_START_MX + MAX_IGF_SFB_LEN ) ); /* inits */ @@ -2933,20 +2932,17 @@ static void IGF_getWhiteSpectralData_ivas( ak_e = sub( ak_e, 1 ); window_sum = 0; - left_one = 0; move64(); - move64(); - FOR( j = start - level; j < start + level ; j++ ) + 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++ ) { - window_sum = W_sub( window_sum, left_one ); /* subtract the left one */ window_sum = W_mac_32_32( window_sum, in[i + level], in[i + level] ); /* add the right one */ - left_one = W_mult_32_32( in[i - level], in[i - level] ); 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 ) ); @@ -2959,15 +2955,8 @@ 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 = 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 bc9df892d5b87af6a483f6815745515e1cc8975b Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Mon, 22 Sep 2025 10:29:22 +0200 Subject: [PATCH 3/3] applied the clang patch. --- lib_dec/igf_dec_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 79b31095a..59485575e 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -2940,8 +2940,8 @@ static void IGF_getWhiteSpectralData_ivas( FOR( i = start; i < stop - level; i++ ) { - 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_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 */ @@ -2957,7 +2957,7 @@ static void IGF_getWhiteSpectralData_ivas( { 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 + 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