Loading lib_dec/ivas_svd_dec.c +77 −75 Original line number Diff line number Diff line Loading @@ -58,8 +58,8 @@ static float GivensRotation( const float x, const float z ); #ifdef NONBE_SVD_OPTIMIZATION static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel ); static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g ); static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g ); static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g ); #else static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *sig_x, float *g ); static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *sig_x, float *g ); Loading Loading @@ -491,17 +491,22 @@ static void HouseholderReduction( float *eps_x ) { int16_t nCh; float g = 0.0f; #ifndef NONBE_SVD_OPTIMIZATION #ifdef NONBE_SVD_OPTIMIZATION float g_left = 0.0f; float g_right = 0.0f; #else float sig_x = 0.0f; float g = 0.0f; #endif /* Bidiagonal Reduction for every channel */ for ( nCh = 0; nCh < nChannelsC; nCh++ ) /* nChannelsC */ { #ifdef NONBE_SVD_OPTIMIZATION biDiagonalReductionLeft( singularVectors_Left, singularValues, nChannelsL, nChannelsC, nCh ); biDiagonalReductionRight( singularVectors_Left, secDiag, nChannelsL, nChannelsC, nCh, &g ); secDiag[nCh] = g_right; /* from the previous channel */ biDiagonalReductionLeft( singularVectors_Left, nChannelsL, nChannelsC, nCh, &g_left ); singularValues[nCh] = g_left; biDiagonalReductionRight( singularVectors_Left, nChannelsL, nChannelsC, nCh, &g_right ); #else biDiagonalReductionLeft( singularVectors_Left, singularValues, secDiag, nChannelsL, nChannelsC, nCh, &sig_x, &g ); biDiagonalReductionRight( singularVectors_Left, secDiag, nChannelsL, nChannelsC, nCh, &sig_x, &g ); Loading @@ -518,25 +523,24 @@ static void HouseholderReduction( } #ifdef NONBE_SVD_OPTIMIZATION /*------------------------------------------------------------------------- * biDiagonalReductionLeft() * * *-------------------------------------------------------------------------*/ #ifdef NONBE_SVD_OPTIMIZATION static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel ) const int16_t currChannel, float *g ) { int16_t iCh, jCh; float norm_x, f, r, g; float norm_x, f, r; /* Setting values to 0 */ g = 0.0f; ( *g ) = 0.0f; if ( currChannel < nChannelsL ) /* i <= m */ { Loading @@ -549,9 +553,9 @@ static void biDiagonalReductionLeft( } if ( ( norm_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ { g = -( singularVectors[currChannel][currChannel] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); r = g * singularVectors[currChannel][currChannel] - norm_x; singularVectors[currChannel][currChannel] = ( singularVectors[currChannel][currChannel] - g ); ( *g ) = -( singularVectors[currChannel][currChannel] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); r = ( *g ) * singularVectors[currChannel][currChannel] - norm_x; singularVectors[currChannel][currChannel] = ( singularVectors[currChannel][currChannel] - ( *g ) ); for ( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ { Loading @@ -570,8 +574,60 @@ static void biDiagonalReductionLeft( } } } } return; } /*------------------------------------------------------------------------- * biDiagonalReductionRight() * * *-------------------------------------------------------------------------*/ static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g ) { int16_t iCh, jCh, idx; float norm_x, r; /* Setting values to 0 */ ( *g ) = 0.0f; if ( currChannel < nChannelsL && currChannel != ( nChannelsC - 1 ) ) /* i <=m && i !=n */ { idx = currChannel + 1; norm_x = 0.0f; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /*nChannelsC */ { norm_x += ( singularVectors[currChannel][jCh] * singularVectors[currChannel][jCh] ); } singularValues[currChannel] = g; if ( norm_x ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ { ( *g ) = -( singularVectors[currChannel][idx] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); r = ( *g ) * singularVectors[currChannel][idx] - norm_x; singularVectors[currChannel][idx] = ( singularVectors[currChannel][idx] - ( *g ) ); for ( iCh = currChannel + 1; iCh < nChannelsL; iCh++ ) /* nChannelsL */ { norm_x = 0.0f; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { norm_x += ( singularVectors[iCh][jCh] * singularVectors[currChannel][jCh] ); } norm_x /= r; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { singularVectors[iCh][jCh] += ( norm_x * singularVectors[currChannel][jCh] ); } } } } return; Loading @@ -579,6 +635,11 @@ static void biDiagonalReductionLeft( #else /*------------------------------------------------------------------------- * biDiagonalReductionLeft() * * *-------------------------------------------------------------------------*/ static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], Loading Loading @@ -657,65 +718,6 @@ static void biDiagonalReductionLeft( * *-------------------------------------------------------------------------*/ #ifdef NONBE_SVD_OPTIMIZATION static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g ) { int16_t iCh, jCh, idx; float norm_x, r; float abs_x; secDiag[currChannel] = *g; /* Setting values to 0 */ ( *g ) = 0.0f; if ( currChannel < nChannelsL && currChannel != ( nChannelsC - 1 ) ) /* i <=m && i !=n */ { idx = currChannel + 1; norm_x = 0.0f; abs_x = 0.0f; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /*nChannelsC */ { norm_x += ( singularVectors[currChannel][jCh] * singularVectors[currChannel][jCh] ); abs_x += fabs( singularVectors[currChannel][jCh] ); } if ( norm_x ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ { ( *g ) = -( singularVectors[currChannel][idx] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); r = ( *g ) * singularVectors[currChannel][idx] - norm_x; singularVectors[currChannel][idx] = ( singularVectors[currChannel][idx] - ( *g ) ); for ( iCh = currChannel + 1; iCh < nChannelsL; iCh++ ) /* nChannelsL */ { norm_x = 0.0f; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { norm_x += ( singularVectors[iCh][jCh] * singularVectors[currChannel][jCh] ); } norm_x /= r; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { singularVectors[iCh][jCh] += ( norm_x * singularVectors[currChannel][jCh] ); } } for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { secDiag[jCh] = ( singularVectors[currChannel][jCh] * abs_x ) / maxWithSign( r ); } } } return; } #else static void biDiagonalReductionRight( Loading Loading
lib_dec/ivas_svd_dec.c +77 −75 Original line number Diff line number Diff line Loading @@ -58,8 +58,8 @@ static float GivensRotation( const float x, const float z ); #ifdef NONBE_SVD_OPTIMIZATION static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel ); static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g ); static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g ); static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g ); #else static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *sig_x, float *g ); static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *sig_x, float *g ); Loading Loading @@ -491,17 +491,22 @@ static void HouseholderReduction( float *eps_x ) { int16_t nCh; float g = 0.0f; #ifndef NONBE_SVD_OPTIMIZATION #ifdef NONBE_SVD_OPTIMIZATION float g_left = 0.0f; float g_right = 0.0f; #else float sig_x = 0.0f; float g = 0.0f; #endif /* Bidiagonal Reduction for every channel */ for ( nCh = 0; nCh < nChannelsC; nCh++ ) /* nChannelsC */ { #ifdef NONBE_SVD_OPTIMIZATION biDiagonalReductionLeft( singularVectors_Left, singularValues, nChannelsL, nChannelsC, nCh ); biDiagonalReductionRight( singularVectors_Left, secDiag, nChannelsL, nChannelsC, nCh, &g ); secDiag[nCh] = g_right; /* from the previous channel */ biDiagonalReductionLeft( singularVectors_Left, nChannelsL, nChannelsC, nCh, &g_left ); singularValues[nCh] = g_left; biDiagonalReductionRight( singularVectors_Left, nChannelsL, nChannelsC, nCh, &g_right ); #else biDiagonalReductionLeft( singularVectors_Left, singularValues, secDiag, nChannelsL, nChannelsC, nCh, &sig_x, &g ); biDiagonalReductionRight( singularVectors_Left, secDiag, nChannelsL, nChannelsC, nCh, &sig_x, &g ); Loading @@ -518,25 +523,24 @@ static void HouseholderReduction( } #ifdef NONBE_SVD_OPTIMIZATION /*------------------------------------------------------------------------- * biDiagonalReductionLeft() * * *-------------------------------------------------------------------------*/ #ifdef NONBE_SVD_OPTIMIZATION static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel ) const int16_t currChannel, float *g ) { int16_t iCh, jCh; float norm_x, f, r, g; float norm_x, f, r; /* Setting values to 0 */ g = 0.0f; ( *g ) = 0.0f; if ( currChannel < nChannelsL ) /* i <= m */ { Loading @@ -549,9 +553,9 @@ static void biDiagonalReductionLeft( } if ( ( norm_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ { g = -( singularVectors[currChannel][currChannel] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); r = g * singularVectors[currChannel][currChannel] - norm_x; singularVectors[currChannel][currChannel] = ( singularVectors[currChannel][currChannel] - g ); ( *g ) = -( singularVectors[currChannel][currChannel] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); r = ( *g ) * singularVectors[currChannel][currChannel] - norm_x; singularVectors[currChannel][currChannel] = ( singularVectors[currChannel][currChannel] - ( *g ) ); for ( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ { Loading @@ -570,8 +574,60 @@ static void biDiagonalReductionLeft( } } } } return; } /*------------------------------------------------------------------------- * biDiagonalReductionRight() * * *-------------------------------------------------------------------------*/ static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g ) { int16_t iCh, jCh, idx; float norm_x, r; /* Setting values to 0 */ ( *g ) = 0.0f; if ( currChannel < nChannelsL && currChannel != ( nChannelsC - 1 ) ) /* i <=m && i !=n */ { idx = currChannel + 1; norm_x = 0.0f; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /*nChannelsC */ { norm_x += ( singularVectors[currChannel][jCh] * singularVectors[currChannel][jCh] ); } singularValues[currChannel] = g; if ( norm_x ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ { ( *g ) = -( singularVectors[currChannel][idx] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); r = ( *g ) * singularVectors[currChannel][idx] - norm_x; singularVectors[currChannel][idx] = ( singularVectors[currChannel][idx] - ( *g ) ); for ( iCh = currChannel + 1; iCh < nChannelsL; iCh++ ) /* nChannelsL */ { norm_x = 0.0f; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { norm_x += ( singularVectors[iCh][jCh] * singularVectors[currChannel][jCh] ); } norm_x /= r; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { singularVectors[iCh][jCh] += ( norm_x * singularVectors[currChannel][jCh] ); } } } } return; Loading @@ -579,6 +635,11 @@ static void biDiagonalReductionLeft( #else /*------------------------------------------------------------------------- * biDiagonalReductionLeft() * * *-------------------------------------------------------------------------*/ static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], Loading Loading @@ -657,65 +718,6 @@ static void biDiagonalReductionLeft( * *-------------------------------------------------------------------------*/ #ifdef NONBE_SVD_OPTIMIZATION static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g ) { int16_t iCh, jCh, idx; float norm_x, r; float abs_x; secDiag[currChannel] = *g; /* Setting values to 0 */ ( *g ) = 0.0f; if ( currChannel < nChannelsL && currChannel != ( nChannelsC - 1 ) ) /* i <=m && i !=n */ { idx = currChannel + 1; norm_x = 0.0f; abs_x = 0.0f; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /*nChannelsC */ { norm_x += ( singularVectors[currChannel][jCh] * singularVectors[currChannel][jCh] ); abs_x += fabs( singularVectors[currChannel][jCh] ); } if ( norm_x ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ { ( *g ) = -( singularVectors[currChannel][idx] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); r = ( *g ) * singularVectors[currChannel][idx] - norm_x; singularVectors[currChannel][idx] = ( singularVectors[currChannel][idx] - ( *g ) ); for ( iCh = currChannel + 1; iCh < nChannelsL; iCh++ ) /* nChannelsL */ { norm_x = 0.0f; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { norm_x += ( singularVectors[iCh][jCh] * singularVectors[currChannel][jCh] ); } norm_x /= r; for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { singularVectors[iCh][jCh] += ( norm_x * singularVectors[currChannel][jCh] ); } } for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { secDiag[jCh] = ( singularVectors[currChannel][jCh] * abs_x ) / maxWithSign( r ); } } } return; } #else static void biDiagonalReductionRight( Loading