From ff910e8916731097fa517825b87be81746e8b964 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 13 Jun 2025 12:51:21 +0200 Subject: [PATCH 1/5] changes for fixing issue 1744, NON-BE, fixes several coding errors, should improve quality --- lib_com/options.h | 3 +++ lib_dec/ivas_spar_md_dec_fx.c | 22 +++++++++++++++++++--- lib_enc/ivas_dirac_enc_fx.c | 17 +++++++++++++++-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9dc7e7fd1..de111668a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -111,4 +111,7 @@ #define FIX_1733_CLDFB_BUG #define FIX_1740_MISING_POP_WMOPS /* VA: fix issue 1740: missing pop_wmops() */ +#define FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC /* FhG: NON-BE!!! Simplify azimuth & elevation calculations, remove parameter mismatch for divide3232, fix copy/paste error for elevation */ +#define FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG /* FhG: NON-BE!!! Simplify threshold - comparison, change (wrong) Equal-comparion to (correct) Greater-Than-comparison */ + #endif diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 7f487a75c..3e7a4b3f5 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -44,6 +44,9 @@ /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ +#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC +#define INV_PI_DEG180_Q_22 ( (Word32) 0x394BB835 ) /* 2.0/PI in Q31 times DEGREE_180_Q_22) */ +#endif #define IVAS_DEFAULT_DTX_CNG_RAMP ( 8 ) @@ -2946,8 +2949,13 @@ void ivas_spar_to_dirac_fx( radius_fx = Sqrt32( temp, &q_temp ); Word16 check_azi_fx = BASOP_util_atan2( dvy_fx[band], dvx_fx[band], 0 ); /*Q13*/ - Word32 check_azi_fx_32 = L_shl( check_azi_fx, 16 ); /*Q29*/ + +#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC + Word32 azi_intermediate = Mpy_32_16_1( INV_PI_DEG180_Q_22, check_azi_fx ); +#else Word16 check_azi_fx_res; + Word32 check_azi_fx_32 = L_shl( check_azi_fx, 16 ); /*Q29*/ + IF( check_azi_fx_32 < 0 ) { check_azi_fx_res = negate( divide3232( L_negate( check_azi_fx_32 ), 1686629760 /*3.145f in Q29*/ ) ); /*Q15*/ @@ -2957,6 +2965,8 @@ void ivas_spar_to_dirac_fx( check_azi_fx_res = divide3232( check_azi_fx_32, 1686629760 /*3.145f in Q29*/ ); /*Q15*/ } Word32 azi_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_azi_fx_res ); /*Q22*/ +#endif + azi_intermediate = L_add( azi_intermediate, ONE_IN_Q21 ); /*Q22*/ Word16 azi_res; @@ -2970,9 +2980,14 @@ void ivas_spar_to_dirac_fx( } Word16 check_ele_fx = BASOP_util_atan2( dvz_fx[band], radius_fx, sub( add( 9, q_dvnorm ), q_temp ) ); /*Q13*/ - Word32 check_ele_fx_32 = L_shl( check_ele_fx, 16 ); /*Q29*/ +#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC + Word32 ele_intermediate = Mpy_32_16_1( INV_PI_DEG180_Q_22, check_ele_fx ); +#else + Word16 check_ele_fx_res; - IF( check_azi_fx_32 < 0 ) + Word32 check_ele_fx_32 = L_shl( check_ele_fx, 16 ); /*Q29*/ + + IF( check_ele_fx_32 < 0 ) { check_ele_fx_res = negate( divide3232( L_negate( check_ele_fx_32 ), 1686629760 /*3.145f in Q29*/ ) ); /*Q15*/ } @@ -2981,6 +2996,7 @@ void ivas_spar_to_dirac_fx( check_ele_fx_res = divide3232( check_ele_fx_32, 1686629760 /*3.145f in Q29*/ ); /*Q15*/ } Word32 ele_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_ele_fx_res ); /*Q22*/ +#endif ele_intermediate = L_add( ele_intermediate, ONE_IN_Q21 ); /*Q22*/ Word16 ele_res; diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index be15b5048..5e9a50497 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -660,8 +660,20 @@ static Word16 ivas_dirac_get_mono_flag_fx( move32(); move16(); } - - IF( BASOP_Util_Cmp_Mant32Exp( divide3232( W_band_power, other_ch_band_power ), 31, threshold, threshold_e ) == 0 ) +#ifdef FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG + IF( BASOP_Util_Cmp_Mant32Exp( W_band_power, 31-16, Mpy_32_32(other_ch_band_power, threshold), threshold_e ) == 1 ) + /* -16 is needed because divide3232() returned a 16-Bit value, and this 16-bit value was passed to an 32-bit mantissa argument*/ + { + any_mono_band = 1; + move16(); + } + ELSE + { + any_mc_band = 1; + move16(); + } +#else + IF( BASOP_Util_Cmp_Mant32Exp( divide3232( W_band_power, other_ch_band_power ), 31, threshold, threshold_e ) == 1 ) { any_mono_band = 1; move16(); @@ -671,6 +683,7 @@ static Word16 ivas_dirac_get_mono_flag_fx( any_mc_band = 1; move16(); } +#endif } } } -- GitLab From 0ee162a3996b7bc58e7bc9ccc0011daef42df3d6 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 13 Jun 2025 13:19:16 +0200 Subject: [PATCH 2/5] fix clang format issues --- lib_dec/ivas_spar_md_dec_fx.c | 4 ++-- lib_enc/ivas_dirac_enc_fx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 3e7a4b3f5..be31cebbb 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -2967,7 +2967,7 @@ void ivas_spar_to_dirac_fx( Word32 azi_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_azi_fx_res ); /*Q22*/ #endif - azi_intermediate = L_add( azi_intermediate, ONE_IN_Q21 ); /*Q22*/ + azi_intermediate = L_add( azi_intermediate, ONE_IN_Q21 ); /*Q22*/ Word16 azi_res; IF( azi_intermediate < 0 ) @@ -2997,7 +2997,7 @@ void ivas_spar_to_dirac_fx( } Word32 ele_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_ele_fx_res ); /*Q22*/ #endif - ele_intermediate = L_add( ele_intermediate, ONE_IN_Q21 ); /*Q22*/ + ele_intermediate = L_add( ele_intermediate, ONE_IN_Q21 ); /*Q22*/ Word16 ele_res; IF( ele_intermediate < 0 ) diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 5e9a50497..0941e0e85 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -661,7 +661,7 @@ static Word16 ivas_dirac_get_mono_flag_fx( move16(); } #ifdef FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG - IF( BASOP_Util_Cmp_Mant32Exp( W_band_power, 31-16, Mpy_32_32(other_ch_band_power, threshold), threshold_e ) == 1 ) + IF( BASOP_Util_Cmp_Mant32Exp( W_band_power, 31 - 16, Mpy_32_32( other_ch_band_power, threshold ), threshold_e ) == 1 ) /* -16 is needed because divide3232() returned a 16-Bit value, and this 16-bit value was passed to an 32-bit mantissa argument*/ { any_mono_band = 1; -- GitLab From df97c617fb4859bbee367cbf1ed1fc63a6f23a3f Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 13 Jun 2025 20:08:58 +0200 Subject: [PATCH 3/5] fixed issue 1744 (mr 1778) with exponent setting for divide3232 --- lib_enc/ivas_dirac_enc_fx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 0941e0e85..4ad039fae 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -661,8 +661,7 @@ static Word16 ivas_dirac_get_mono_flag_fx( move16(); } #ifdef FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG - IF( BASOP_Util_Cmp_Mant32Exp( W_band_power, 31 - 16, Mpy_32_32( other_ch_band_power, threshold ), threshold_e ) == 1 ) - /* -16 is needed because divide3232() returned a 16-Bit value, and this 16-bit value was passed to an 32-bit mantissa argument*/ + IF( BASOP_Util_Cmp_Mant32Exp( W_band_power, W_band_power_e, Mpy_32_32( other_ch_band_power, threshold ), other_ch_band_power_e + threshold_e ) == 1 ) { any_mono_band = 1; move16(); @@ -673,7 +672,7 @@ static Word16 ivas_dirac_get_mono_flag_fx( move16(); } #else - IF( BASOP_Util_Cmp_Mant32Exp( divide3232( W_band_power, other_ch_band_power ), 31, threshold, threshold_e ) == 1 ) + IF( BASOP_Util_Cmp_Mant32Exp( divide3232( W_band_power, other_ch_band_power ), 31, threshold, threshold_e ) == 0 ) { any_mono_band = 1; move16(); -- GitLab From 866710036f0ed869162200391bbbea931f63b67a Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 18 Jun 2025 00:18:49 +0200 Subject: [PATCH 4/5] fixed typo --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index cd71a7768..cf6c67104 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,7 +119,6 @@ #define FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC /* FhG: NON-BE!!! Simplify azimuth & elevation calculations, remove parameter mismatch for divide3232, fix copy/paste error for elevation */ #define FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG /* FhG: NON-BE!!! Simplify threshold - comparison, change (wrong) Equal-comparion to (correct) Greater-Than-comparison */ -======= #define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ #endif -- GitLab From a3c5954bb23bc5fc8b36beafcd72ecc1e59cafc3 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 9 Jul 2025 13:44:21 +0200 Subject: [PATCH 5/5] address comment on macro --- lib_dec/ivas_spar_md_dec_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 72d5e6599..fdb29e842 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -45,7 +45,7 @@ * Local constants *------------------------------------------------------------------------------------------*/ #ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC -#define INV_PI_DEG180_Q_22 ( (Word32) 0x394BB835 ) /* 2.0/PI in Q31 times DEGREE_180_Q_22) */ +#define DEG180_BY_PI_Q24 ( (Word32) 0x394BB835 ) /* 180.0/PI in Q24) */ #endif #define IVAS_DEFAULT_DTX_CNG_RAMP ( 8 ) @@ -2964,7 +2964,7 @@ void ivas_spar_to_dirac_fx( Word16 check_azi_fx = BASOP_util_atan2( dvy_fx[band], dvx_fx[band], 0 ); /*Q13*/ #ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC - Word32 azi_intermediate = Mpy_32_16_1( INV_PI_DEG180_Q_22, check_azi_fx ); + Word32 azi_intermediate = Mpy_32_16_1( DEG180_BY_PI_Q24, check_azi_fx ); #else Word16 check_azi_fx_res; Word32 check_azi_fx_32 = L_shl( check_azi_fx, 16 ); /*Q29*/ @@ -2994,7 +2994,7 @@ void ivas_spar_to_dirac_fx( Word16 check_ele_fx = BASOP_util_atan2( dvz_fx[band], radius_fx, sub( add( 9, q_dvnorm ), q_temp ) ); /*Q13*/ #ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC - Word32 ele_intermediate = Mpy_32_16_1( INV_PI_DEG180_Q_22, check_ele_fx ); + Word32 ele_intermediate = Mpy_32_16_1( DEG180_BY_PI_Q24, check_ele_fx ); #else Word16 check_ele_fx_res; -- GitLab