From 230098538cbf864ec269555989e18b1abcdce707 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 5 Feb 2025 09:58:35 +0100 Subject: [PATCH 1/2] added minor WMOPS tuning for SVD module, extends MR1010 --- lib_com/options.h | 2 ++ lib_dec/ivas_svd_dec.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 573b619bf..2508663d9 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,3 +150,5 @@ #define FIX_ISSUE_1237 /* VA: replacement of Copy_Scale_sig_16_32_DEPREC() that are doing 16 bits left shift by Copy_Scale_sig_16_32_no_sat() */ #define FIX_ISSUE_1237_KEEP_EVS_BE /* VA: Fix to keep EVS bitexactness to 26.444 */ #endif +#define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */ + diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index dc1965a5b..663dba21f 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -919,6 +919,7 @@ static void ApplyRotation_fx( *g = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), add( c_e, x12_e ), Mpy_32_32( L_negate( s ), x11 ), add( s_e, x11_e ), g_e ); /* exp(g_e) */ move32(); +#ifndef FIX_MINOR_SVD_WMOPS_MR1010X FOR( ch = 0; ch < nChannels; ch++ ) { x11 = singularVector[ch][currentIndex2]; @@ -934,6 +935,24 @@ static void ApplyRotation_fx( singularVector[ch][currentIndex1] = L_shl_sat( singularVector[ch][currentIndex1], temp_exp ); /* exp(temp_exp) */ move32(); } +#else + Word32 s_neg = L_negate(s); + Word32 temp; + FOR( ch = 0; ch < nChannels; ch++ ) + { + x11 = singularVector[ch][currentIndex2]; + move32(); + x12 = singularVector[ch][currentIndex1]; + move32(); + temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x11 ), c_e, Mpy_32_32( s, x12 ), s_e, &temp_exp ); /* exp(temp_exp) */ + singularVector[ch][currentIndex2] = L_shl_sat( temp, temp_exp ); /* exp(temp_exp) */ + move32(); + temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), c_e, Mpy_32_32( s_neg, x11 ), s_e, &temp_exp ); /* exp(temp_exp) */ + singularVector[ch][currentIndex1] = L_shl_sat( temp, temp_exp ); /* exp(temp_exp) */ + move32(); + } + +#endif return; } @@ -1160,6 +1179,7 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ L_temp = Sqrt32( norm_x, &L_temp_e ); L_temp = L_shl_r( L_temp, L_temp_e ); // Q31 //( *g ) = L_negate( GE_32( singularVectors[currChannel][idx], 0 ) ? L_temp : L_negate( L_temp ) ); +#ifndef FIX_MINOR_SVD_WMOPS_MR1010X IF( singularVectors[currChannel][idx] >= 0 ) { ( *g ) = L_negate( L_temp ); @@ -1170,6 +1190,14 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ ( *g ) = L_negate( L_negate( L_temp ) ); move32(); } +#else + if ( singularVectors[currChannel][idx] >= 0 ) + { + L_temp = L_negate( L_temp ); + } + ( *g ) = L_temp ; + move32(); +#endif #ifndef FIX_1010_OPT_SINGLE_RESCALE r = BASOP_Util_Add_Mant32Exp( Mpy_32_32( ( *g ), singularVectors[currChannel][idx] ), sing_exp[currChannel], -norm_x, norm_x_e, &r_e ); /* exp(r_e) */ @@ -1868,6 +1896,7 @@ static Word32 maxWithSign_fx( const Word32 a /* Qx */ ) { +#ifndef FIX_MINOR_SVD_WMOPS_MR1010X IF( GT_32( L_abs( a ), SVD_MINIMUM_VALUE_FX ) ) { return a; @@ -1880,6 +1909,18 @@ static Word32 maxWithSign_fx( { return SVD_MINIMUM_VALUE_FX; } +#else + Word32 result; + if (a >= 0) + { + result = L_max( a, SVD_MINIMUM_VALUE_FX ); + } + if (a < 0) + { + result = L_min( a, -SVD_MINIMUM_VALUE_FX ); + } + return result; +#endif } /*------------------------------------------------------------------------- -- GitLab From 539feaf6f37edd1cbcfd7b6a3f61f61ee1ff6b59 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 5 Feb 2025 10:30:00 +0100 Subject: [PATCH 2/2] fix clang-format issues --- lib_com/options.h | 1 - lib_dec/ivas_svd_dec.c | 28 ++++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2508663d9..dcf5bd052 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -151,4 +151,3 @@ #define FIX_ISSUE_1237_KEEP_EVS_BE /* VA: Fix to keep EVS bitexactness to 26.444 */ #endif #define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */ - diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 663dba21f..942a2b5b0 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -936,7 +936,7 @@ static void ApplyRotation_fx( move32(); } #else - Word32 s_neg = L_negate(s); + Word32 s_neg = L_negate( s ); Word32 temp; FOR( ch = 0; ch < nChannels; ch++ ) { @@ -945,10 +945,10 @@ static void ApplyRotation_fx( x12 = singularVector[ch][currentIndex1]; move32(); temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x11 ), c_e, Mpy_32_32( s, x12 ), s_e, &temp_exp ); /* exp(temp_exp) */ - singularVector[ch][currentIndex2] = L_shl_sat( temp, temp_exp ); /* exp(temp_exp) */ + singularVector[ch][currentIndex2] = L_shl_sat( temp, temp_exp ); /* exp(temp_exp) */ move32(); temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), c_e, Mpy_32_32( s_neg, x11 ), s_e, &temp_exp ); /* exp(temp_exp) */ - singularVector[ch][currentIndex1] = L_shl_sat( temp, temp_exp ); /* exp(temp_exp) */ + singularVector[ch][currentIndex1] = L_shl_sat( temp, temp_exp ); /* exp(temp_exp) */ move32(); } @@ -1159,7 +1159,7 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ #ifndef FIX_1010_OPT_SINGLE_RESCALE sing_exp[jCh] = sub( add( invVal_e, sub( *singularVectors_e, *sig_x_e ) ), temp_e ); move16(); - norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sing_exp[jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */ + norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sing_exp[jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */ #else singularVectors2_e[jCh][currChannel] = sub( add( invVal_e, sub( singularVectors2_e[jCh][currChannel], *sig_x_e ) ), temp_e ); move16(); @@ -1178,7 +1178,7 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ move16(); L_temp = Sqrt32( norm_x, &L_temp_e ); L_temp = L_shl_r( L_temp, L_temp_e ); // Q31 - //( *g ) = L_negate( GE_32( singularVectors[currChannel][idx], 0 ) ? L_temp : L_negate( L_temp ) ); + //( *g ) = L_negate( GE_32( singularVectors[currChannel][idx], 0 ) ? L_temp : L_negate( L_temp ) ); #ifndef FIX_MINOR_SVD_WMOPS_MR1010X IF( singularVectors[currChannel][idx] >= 0 ) { @@ -1191,12 +1191,12 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ move32(); } #else - if ( singularVectors[currChannel][idx] >= 0 ) - { - L_temp = L_negate( L_temp ); - } - ( *g ) = L_temp ; - move32(); + if ( singularVectors[currChannel][idx] >= 0 ) + { + L_temp = L_negate( L_temp ); + } + ( *g ) = L_temp; + move32(); #endif #ifndef FIX_1010_OPT_SINGLE_RESCALE @@ -1911,15 +1911,15 @@ static Word32 maxWithSign_fx( } #else Word32 result; - if (a >= 0) + if ( a >= 0 ) { result = L_max( a, SVD_MINIMUM_VALUE_FX ); } - if (a < 0) + if ( a < 0 ) { result = L_min( a, -SVD_MINIMUM_VALUE_FX ); } - return result; + return result; #endif } -- GitLab