diff --git a/lib_com/options.h b/lib_com/options.h index de9b2f4d3f405ddedce60f109f4945b6a4e1a497..6bfe63675545869d26b63960f5671f6c88f9fb20 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -163,6 +163,7 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* Nokia: reintroduce format switching for g192 bitstreams */ #define FIX_1527_CMR_BITRATE_IDX /* Fix for incorrect bitrate idx packed in rtp CMR E-byte */ +#define FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN /* FhG: float issue 1560: Avoid optimizing the division on the result of maxWithSign() with -funsafe-math-optimizations */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 9ed74b0002fae3bff5cd0d7f9bfdd478147339cc..40997152936f7378fb490915031743d31c77bd82 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -272,7 +272,12 @@ static int16_t BidagonalDiagonalisation( ) { int16_t kCh, nCh, iCh, jCh, split; +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + volatile float c, s; + float f1, f2; +#else float c, s, f1, f2; +#endif float g = 0.0f; int16_t convergence, iteration, found_split; int16_t error = 0; @@ -385,9 +390,14 @@ static void ApplyQRTransform( ) { int16_t ch, split; +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + float d = 0.0f, g = 0.0f, r = 0.0f, x_ii = 0.0f, x_split = 0.0f, x_kk = 0.0f, aux = 0.0f; + volatile float mu = 0.0f, c = 1.0f, s = 1.0f; +#else float d = 0.0f, g = 0.0f, r = 0.0f, x_ii = 0.0f, x_split = 0.0f, x_kk = 0.0f, mu = 0.0f, aux = 0.0f; float c = 1.0f; float s = 1.0f; +#endif x_kk = singularValues[currentIndex]; x_ii = singularValues[startIndex]; @@ -525,10 +535,20 @@ static void biDiagonalReductionLeft( float *g ) { int16_t iCh, jCh; +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + volatile float norm_x, r; + volatile float f; + volatile float g_loc; +#else float norm_x, f, r; +#endif /* Setting values to 0 */ +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + g_loc = 0.0f; +#else ( *g ) = 0.0f; +#endif if ( currChannel < nChannelsL ) /* i <= m */ { @@ -541,9 +561,15 @@ static void biDiagonalReductionLeft( if ( ( norm_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ { +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + g_loc = -( singularVectors[currChannel][currChannel] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); + r = g_loc * singularVectors[currChannel][currChannel] - norm_x; + singularVectors[currChannel][currChannel] = ( singularVectors[currChannel][currChannel] - g_loc ); +#else ( *g ) = -( singularVectors[currChannel][currChannel] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); r = ( *g ) * singularVectors[currChannel][currChannel] - norm_x; singularVectors[currChannel][currChannel] = ( singularVectors[currChannel][currChannel] - ( *g ) ); +#endif for ( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ { @@ -564,6 +590,10 @@ static void biDiagonalReductionLeft( } } +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + *g = g_loc; +#endif + return; } @@ -582,10 +612,19 @@ static void biDiagonalReductionRight( float *g ) { int16_t iCh, jCh, idx; +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + volatile float norm_x, r; + volatile float g_loc; +#else float norm_x, r; +#endif /* Setting values to 0 */ +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + g_loc = 0.0f; +#else ( *g ) = 0.0f; +#endif if ( currChannel < nChannelsL && currChannel != ( nChannelsC - 1 ) ) /* i <=m && i !=n */ { @@ -600,9 +639,15 @@ static void biDiagonalReductionRight( if ( norm_x ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ { +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + g_loc = -( singularVectors[currChannel][idx] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); + r = g_loc * singularVectors[currChannel][idx] - norm_x; + singularVectors[currChannel][idx] = ( singularVectors[currChannel][idx] - g_loc ); +#else ( *g ) = -( singularVectors[currChannel][idx] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); r = ( *g ) * singularVectors[currChannel][idx] - norm_x; singularVectors[currChannel][idx] = ( singularVectors[currChannel][idx] - ( *g ) ); +#endif for ( iCh = currChannel + 1; iCh < nChannelsL; iCh++ ) /* nChannelsL */ { @@ -620,6 +665,10 @@ static void biDiagonalReductionRight( } } +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + *g = g_loc; +#endif + return; } @@ -638,7 +687,12 @@ static void singularVectorsAccumulationLeft( { int16_t nCh, iCh, k; int16_t nChannels; +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + float norm_y; + volatile float t_jj, t_ii; +#else float norm_y, t_jj, t_ii; +#endif /* Processing */ nChannels = min( nChannelsL, nChannelsC ); /* min(nChannelsL,ChannelsC) */ @@ -706,7 +760,12 @@ static void singularVectorsAccumulationRight( { int16_t nCh, iCh, k; int16_t nChannels; +#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN + float norm_y, t_ii; + volatile float ratio; +#else float norm_y, t_ii, ratio; +#endif /* Processing */ nChannels = nChannelsC; /* nChannelsC */