From dd56035911ceca03f27b60c6096dc137cbd5d14c Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 24 Jul 2025 14:40:37 +0200 Subject: [PATCH 1/7] Replaced zero eigenvalue with epsilon if det!=0. --- lib_com/options.h | 2 ++ lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 14b1c5eb8..02f5902eb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,4 +148,6 @@ #define FIX_1824 #define FIX_1822 +#define FIX_1819_EIGENVALUE_ERROR /* FhG: Workaround for zero eigenvalue: replace with epsilon if det != 0*/ + #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index b33aec768..95b73eb89 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -78,6 +78,10 @@ Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; #define MAX_GAIN_CACHE_SIZE ( ( MASA_MAXIMUM_DIRECTIONS * 3 ) + MAX_NUM_OBJECTS ) /* == different calls to get gains */ +#ifdef FIX_1819_EIGENVALUE_ERROR +#define EPSILON_EIGENVALUE 50 +#endif + typedef struct hrtfGainCache { Word16 azi; @@ -4399,6 +4403,19 @@ static void formulate2x2MixingMatrix_fx( eig2x2_fx( tmpRe_fx[0][0], tmpRe_fx[1][1], q_temp, tmpRe_fx[1][0], tmpIm_fx[1][0], q_temp, Ure_fx, Uim_fx, &q_U, D_fx, &q_D ); +#ifdef FIX_1819_EIGENVALUE_ERROR + IF( D_fx[0] != 0 && D_fx[1] == 0 ) + { + Word32 det_fx = L_sub( Mult_32_32( tmpRe_fx[0][0], tmpRe_fx[1][1] ), + L_add( + Mult_32_32( tmpRe_fx[1][0], tmpRe_fx[1][0] ), + Mult_32_32( tmpIm_fx[1][0], tmpIm_fx[1][0] ) ) ); + IF( det_fx != 0 ) + { + D_fx[1] = EPSILON_EIGENVALUE; + } + } +#endif IF( D_fx[0] == 0 ) { temp = ONE_DIV_EPSILON_MANT; /* Result of 1.0/eps with full precision */ -- GitLab From 3306bc825bd93b7cc18f450e79526e83bd1a2091 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 24 Jul 2025 14:49:26 +0200 Subject: [PATCH 2/7] Applied clang formatting patch. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 95b73eb89..54d2d182e 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -79,7 +79,7 @@ Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; #define MAX_GAIN_CACHE_SIZE ( ( MASA_MAXIMUM_DIRECTIONS * 3 ) + MAX_NUM_OBJECTS ) /* == different calls to get gains */ #ifdef FIX_1819_EIGENVALUE_ERROR -#define EPSILON_EIGENVALUE 50 +#define EPSILON_EIGENVALUE 50 #endif typedef struct hrtfGainCache @@ -4411,7 +4411,7 @@ static void formulate2x2MixingMatrix_fx( Mult_32_32( tmpRe_fx[1][0], tmpRe_fx[1][0] ), Mult_32_32( tmpIm_fx[1][0], tmpIm_fx[1][0] ) ) ); IF( det_fx != 0 ) - { + { D_fx[1] = EPSILON_EIGENVALUE; } } -- GitLab From a01aa6199368fb216e9c644d7c4bf2c8f161587a Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 24 Jul 2025 16:06:58 +0200 Subject: [PATCH 3/7] Add one-bit headroom to determinant calculation. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 54d2d182e..b53967877 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4406,10 +4406,10 @@ static void formulate2x2MixingMatrix_fx( #ifdef FIX_1819_EIGENVALUE_ERROR IF( D_fx[0] != 0 && D_fx[1] == 0 ) { - Word32 det_fx = L_sub( Mult_32_32( tmpRe_fx[0][0], tmpRe_fx[1][1] ), + Word32 det_fx = L_sub( L_shr( Mult_32_32( tmpRe_fx[0][0], tmpRe_fx[1][1] ), 1 ), L_add( - Mult_32_32( tmpRe_fx[1][0], tmpRe_fx[1][0] ), - Mult_32_32( tmpIm_fx[1][0], tmpIm_fx[1][0] ) ) ); + L_shr( Mult_32_32( tmpRe_fx[1][0], tmpRe_fx[1][0] ), 1 ), + L_shr( Mult_32_32( tmpIm_fx[1][0], tmpIm_fx[1][0] ), 1 ) ) ); IF( det_fx != 0 ) { D_fx[1] = EPSILON_EIGENVALUE; -- GitLab From 4155d899c06921fd5a65bf798345167ba14e2aaa Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 25 Jul 2025 11:07:30 +0200 Subject: [PATCH 4/7] Removed headroom to improve determinate precision; replaced L_add/L_sub with L_add_sat/L_sub_sat to avoid overflow assertions. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index b53967877..25f5ff4bb 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -79,7 +79,7 @@ Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; #define MAX_GAIN_CACHE_SIZE ( ( MASA_MAXIMUM_DIRECTIONS * 3 ) + MAX_NUM_OBJECTS ) /* == different calls to get gains */ #ifdef FIX_1819_EIGENVALUE_ERROR -#define EPSILON_EIGENVALUE 50 +#define SMALL_EIGENVALUE 50 #endif typedef struct hrtfGainCache @@ -4404,15 +4404,16 @@ static void formulate2x2MixingMatrix_fx( eig2x2_fx( tmpRe_fx[0][0], tmpRe_fx[1][1], q_temp, tmpRe_fx[1][0], tmpIm_fx[1][0], q_temp, Ure_fx, Uim_fx, &q_U, D_fx, &q_D ); #ifdef FIX_1819_EIGENVALUE_ERROR - IF( D_fx[0] != 0 && D_fx[1] == 0 ) + IF( D_fx[0] != 0 && D_fx[1] == 0 ) // Due to an eig2x2 error, sometimes D_fx[1] becomes zero, which implies that the input matrix should be singular (i.e., determinant = 0). { - Word32 det_fx = L_sub( L_shr( Mult_32_32( tmpRe_fx[0][0], tmpRe_fx[1][1] ), 1 ), - L_add( - L_shr( Mult_32_32( tmpRe_fx[1][0], tmpRe_fx[1][0] ), 1 ), - L_shr( Mult_32_32( tmpIm_fx[1][0], tmpIm_fx[1][0] ), 1 ) ) ); - IF( det_fx != 0 ) + Word32 det_fx = L_sub_sat( Mult_32_32( tmpRe_fx[0][0], tmpRe_fx[1][1] ), + L_add_sat( + Mult_32_32( tmpRe_fx[1][0], tmpRe_fx[1][0] ), + Mult_32_32( tmpIm_fx[1][0], tmpIm_fx[1][0] ) ) ); + if( det_fx != 0 ) { - D_fx[1] = EPSILON_EIGENVALUE; + D_fx[1] = SMALL_EIGENVALUE; // Setting D_fx[1] to epsilon has no effect, as the value is too small to affect the output. + move32(); } } #endif -- GitLab From 037c1bef64b916147672a0d8be3c3826896a69e6 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 25 Jul 2025 11:17:11 +0200 Subject: [PATCH 5/7] Applied Clang formatting. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 25f5ff4bb..bfcc93ac9 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4404,13 +4404,13 @@ static void formulate2x2MixingMatrix_fx( eig2x2_fx( tmpRe_fx[0][0], tmpRe_fx[1][1], q_temp, tmpRe_fx[1][0], tmpIm_fx[1][0], q_temp, Ure_fx, Uim_fx, &q_U, D_fx, &q_D ); #ifdef FIX_1819_EIGENVALUE_ERROR - IF( D_fx[0] != 0 && D_fx[1] == 0 ) // Due to an eig2x2 error, sometimes D_fx[1] becomes zero, which implies that the input matrix should be singular (i.e., determinant = 0). + IF( D_fx[0] != 0 && D_fx[1] == 0 ) // Due to an eig2x2 error, sometimes D_fx[1] becomes zero, which implies that the input matrix should be singular (i.e., determinant = 0). { Word32 det_fx = L_sub_sat( Mult_32_32( tmpRe_fx[0][0], tmpRe_fx[1][1] ), L_add_sat( Mult_32_32( tmpRe_fx[1][0], tmpRe_fx[1][0] ), Mult_32_32( tmpIm_fx[1][0], tmpIm_fx[1][0] ) ) ); - if( det_fx != 0 ) + if ( det_fx != 0 ) { D_fx[1] = SMALL_EIGENVALUE; // Setting D_fx[1] to epsilon has no effect, as the value is too small to affect the output. move32(); -- GitLab From 78001a25ead1669dbf675ea0e31487571150f104 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 25 Jul 2025 11:44:33 +0200 Subject: [PATCH 6/7] Small change to trigger a fresh pipeline run. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index bfcc93ac9..09c6b3a89 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -76,12 +76,12 @@ Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; #define ONE_DIV_EPSILON_EXP ( 40 ) #define ADAPT_HTPROTO_ROT_LIM_1 0.8f -#define MAX_GAIN_CACHE_SIZE ( ( MASA_MAXIMUM_DIRECTIONS * 3 ) + MAX_NUM_OBJECTS ) /* == different calls to get gains */ - #ifdef FIX_1819_EIGENVALUE_ERROR #define SMALL_EIGENVALUE 50 #endif +#define MAX_GAIN_CACHE_SIZE ( ( MASA_MAXIMUM_DIRECTIONS * 3 ) + MAX_NUM_OBJECTS ) /* == different calls to get gains */ + typedef struct hrtfGainCache { Word16 azi; -- GitLab From df25561828d7f0cb36a25bbb82ac88cd5f9b830e Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 20 Aug 2025 17:47:14 +0200 Subject: [PATCH 7/7] move macro in options.h --- lib_com/options.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d6faf67e2..1cc84206b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,7 @@ #define FIX_1781_SPECTRAL_GAPS /* FhG: Change internal calculation of tcx_noise_factor_ivas_fx() to 32-bit*/ #define FIX_ISSUE_1811_EXCEEDING_W_SHIFTS /* FhG: limit exceeding 64bit shifts */ - +#define FIX_1819_EIGENVALUE_ERROR /* FhG: Workaround for zero eigenvalue: replace with epsilon if det != 0*/ /* #################### Start BASOP porting switches ############################ */ #define FIX_1372_ISAR_POST_REND @@ -140,6 +140,4 @@ /* #################### End BASOP porting switches ############################ */ -#define FIX_1819_EIGENVALUE_ERROR /* FhG: Workaround for zero eigenvalue: replace with epsilon if det != 0*/ - #endif -- GitLab