From f4841292622dedf5c306eaef745227262318bc56 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 13 Aug 2025 11:25:25 +0200 Subject: [PATCH 1/6] port MR 1722 from ivas-basop --- lib_com/options.h | 1 + lib_dec/ivas_svd_dec.c | 133 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 131 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2605893371..29d23a6cf6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -176,6 +176,7 @@ #define NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS /* Nokia: issue 1339: Apply scaling to the object-part of OMASA for binaural rendering in IVAS_rend. */ #define NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING /* Nokia: Fix OMASA to MASA1 rendering in IVAS_rend */ #define NONBE_1360_LFE_DELAY /* Dlb: LFE delay alignment when rendering in CLDFB domain*/ +#define NONBE_SVD_OPTIMIZATION /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 1d6282b39c..f7af0ac9fb 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -60,9 +60,17 @@ static float GivensRotation( const float x, const float z ); +#ifdef NONBE_SVD_OPTIMIZATION +static void biDiagonalReductionLeft( 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 ); +#endif +#ifdef NONBE_SVD_OPTIMIZATION +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 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 ); +#endif static void singularVectorsAccumulationLeft( float singularVectors_Left[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC ); @@ -489,13 +497,28 @@ static void HouseholderReduction( float *eps_x ) { int16_t nCh; - float g = 0.0f, sig_x = 0.0f; +#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 + 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 ); +#endif + *eps_x = max( *eps_x, ( fabsf( singularValues[nCh] ) + fabsf( secDiag[nCh] ) ) ); } @@ -512,7 +535,59 @@ static void HouseholderReduction( * * *-------------------------------------------------------------------------*/ +#ifdef NONBE_SVD_OPTIMIZATION +static void biDiagonalReductionLeft( + float singularVectors[][MAX_OUTPUT_CHANNELS], + const int16_t nChannelsL, + const int16_t nChannelsC, + const int16_t currChannel, + float *g +) +{ + int16_t iCh, jCh; + float norm_x, f, r; + + /* Setting values to 0 */ + ( *g ) = 0.0f; + + if ( currChannel < nChannelsL ) /* i <= m */ + { + norm_x = 0.0f; + + + for ( jCh = currChannel; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { + norm_x += ( singularVectors[jCh][currChannel] * singularVectors[jCh][currChannel] ); + } + + 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 ) ); + + for ( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ + { + norm_x = 0.0f; + for ( jCh = currChannel; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { + norm_x += ( singularVectors[jCh][currChannel] * singularVectors[jCh][iCh] ); + } + + f = norm_x / maxWithSign( r ); + + for ( jCh = currChannel; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { + singularVectors[jCh][iCh] += ( f * singularVectors[jCh][currChannel] ); + } + } + } + } + + return; +} +#else static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], @@ -583,7 +658,7 @@ static void biDiagonalReductionLeft( return; } - +#endif /*------------------------------------------------------------------------- * biDiagonalReductionRight() @@ -591,6 +666,57 @@ static void biDiagonalReductionLeft( * *-------------------------------------------------------------------------*/ +#ifdef NONBE_SVD_OPTIMIZATION +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] ); + } + + 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; +} +#else static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], @@ -601,6 +727,7 @@ static void biDiagonalReductionRight( float *g ) { int16_t iCh, jCh, idx; + float norm_x, r; /* Setting values to 0 */ @@ -657,7 +784,7 @@ static void biDiagonalReductionRight( return; } - +#endif /*------------------------------------------------------------------------- * singularVectorsAccumulationLeft() -- GitLab From 1950b68753d5643dc2b6be6adf08043b84b3d0bf Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 13 Aug 2025 11:27:45 +0200 Subject: [PATCH 2/6] fix formatting --- lib_dec/ivas_svd_dec.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index f7af0ac9fb..8957c8e060 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -536,13 +536,12 @@ static void HouseholderReduction( * *-------------------------------------------------------------------------*/ #ifdef NONBE_SVD_OPTIMIZATION -static void biDiagonalReductionLeft( +static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, - float *g -) + float *g ) { int16_t iCh, jCh; float norm_x, f, r; @@ -559,7 +558,7 @@ static void biDiagonalReductionLeft( { norm_x += ( singularVectors[jCh][currChannel] * singularVectors[jCh][currChannel] ); } - + if ( ( norm_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ { ( *g ) = -( singularVectors[currChannel][currChannel] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x ); @@ -672,8 +671,7 @@ static void biDiagonalReductionRight( const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, - float *g -) + float *g ) { int16_t iCh, jCh, idx; float norm_x, r; -- GitLab From 4c640e08469b6ccb87321e533981997aade53d09 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 13 Aug 2025 15:38:58 +0200 Subject: [PATCH 3/6] experiment: set testcase_timeout=360 for renderer-sanitizer-job --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3b3e268c4a..0f0b74e10d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -570,7 +570,7 @@ renderer-smoke-test: - mv IVAS_dec IVAS_dec_ref - mv IVAS_rend IVAS_rend_ref - mv ISAR_post_rend ISAR_post_rend_ref - - testcase_timeout=180 + - testcase_timeout=360 # test renderer executable with cmake + asan renderer-asan: -- GitLab From a4cca8026c0608c8fc75382873c1fb4d4aff6b26 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 13 Aug 2025 16:16:13 +0200 Subject: [PATCH 4/6] undo CI change --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0f0b74e10d..3b3e268c4a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -570,7 +570,7 @@ renderer-smoke-test: - mv IVAS_dec IVAS_dec_ref - mv IVAS_rend IVAS_rend_ref - mv ISAR_post_rend ISAR_post_rend_ref - - testcase_timeout=360 + - testcase_timeout=180 # test renderer executable with cmake + asan renderer-asan: -- GitLab From c54cf8098c700bac145a676fe42ee50bc25bbc2c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 13 Aug 2025 17:43:37 +0200 Subject: [PATCH 5/6] increase renderer-sanitizer time limit again --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3b3e268c4a..9164815cba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -550,7 +550,7 @@ renderer-smoke-test: - .rules-merge-request-to-main needs: ["build-codec-linux-cmake"] stage: test - timeout: "30 minutes" + timeout: "60 minutes" artifacts: name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" expire_in: 1 week @@ -570,7 +570,7 @@ renderer-smoke-test: - mv IVAS_dec IVAS_dec_ref - mv IVAS_rend IVAS_rend_ref - mv ISAR_post_rend ISAR_post_rend_ref - - testcase_timeout=180 + - testcase_timeout=360 # test renderer executable with cmake + asan renderer-asan: -- GitLab From c7dd05978207677bc5693a135f67afa15c3299a4 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 14 Aug 2025 09:32:25 +0200 Subject: [PATCH 6/6] undo CI change again --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9164815cba..3b3e268c4a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -550,7 +550,7 @@ renderer-smoke-test: - .rules-merge-request-to-main needs: ["build-codec-linux-cmake"] stage: test - timeout: "60 minutes" + timeout: "30 minutes" artifacts: name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" expire_in: 1 week @@ -570,7 +570,7 @@ renderer-smoke-test: - mv IVAS_dec IVAS_dec_ref - mv IVAS_rend IVAS_rend_ref - mv ISAR_post_rend ISAR_post_rend_ref - - testcase_timeout=360 + - testcase_timeout=180 # test renderer executable with cmake + asan renderer-asan: -- GitLab