From 79c09e17ae4b1632305bb37b1289795986bac3be Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Tue, 11 Nov 2025 11:33:02 +0200 Subject: [PATCH] Port float MR 2334 to ivas-float-update --- lib_com/ivas_cnst.h | 4 ++++ lib_com/options.h | 1 + lib_dec/ivas_ism_renderer.c | 14 ++++++++++++++ lib_dec/ivas_sba_dirac_stereo_dec.c | 15 ++++++++++++++- lib_rend/ivas_dirac_dec_binaural_functions.c | 14 ++++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 690b02e0b..a1c7f63b1 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1495,6 +1495,10 @@ typedef enum #define VBAP_NUM_SEARCH_SECTORS 4 +#ifdef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL +#define LS_ANGLE_RAD_30_DEG 0.52359879f /* 30.0f * PI_OVER_180 */ +#define INV_TAN_LS_ANGLE_RAD_30_DEG 1.7320507f /* 1.0f/tanf(30.0f * PI_OVER_180) */ +#endif /*----------------------------------------------------------------------------------* * Binaural Rendering Constants diff --git a/lib_com/options.h b/lib_com/options.h index cb68eab0c..641a2004b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -204,6 +204,7 @@ #define NONBE_FIX_NONBE_BETWEEN_OPTIMIZATION_LEVELS_2 /* FhG: fix even more non-BEnesses */ #define FIX_1437_LC3PLUS_EXTREND_HIRES /* FhG: fix external renderer split bitstream header writing causing a crash for LC3plus High-res mode */ #define FIX_GAIN_EDIT_LIMITS /* Harmonize gain edit limits for all opertation points. For all modes, limit to max +12dB. For parametric modes, limit to min -24dB. */ +#define NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL /* Nokia: Adjustments in remaining stereo panning functions to make them BE between Debug and Release */ // object-editing feature porting #define FIX_HRTF_LOAD_API // solves API conflicts between HRTF and object-editing features diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 82fabafcf..d3897bba6 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -315,7 +315,9 @@ void ivas_ism_get_stereo_gains( { float aziRad, eleRad; float y, mappedX, aziRadMapped, A, A2, A3; +#ifndef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL const float LsAngleRad = 30.0f * PI_OVER_180; +#endif /* Convert azi and ele to an azi value of the cone of confusion */ aziRad = azimuth * PI_OVER_180; @@ -325,19 +327,31 @@ void ivas_ism_get_stereo_gains( aziRadMapped = atan2f( y, mappedX ); /* Determine the amplitude panning gains */ +#ifdef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL + if ( aziRadMapped >= LS_ANGLE_RAD_30_DEG ) +#else if ( aziRadMapped >= LsAngleRad ) +#endif { /* Left side */ *left_gain = 1.0f; *right_gain = 0.0f; } +#ifdef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL + else if ( aziRadMapped <= -LS_ANGLE_RAD_30_DEG ) +#else else if ( aziRadMapped <= -LsAngleRad ) +#endif { /* Right side */ *left_gain = 0.0f; *right_gain = 1.0f; } else /* Tangent panning law */ { +#ifdef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL + A = tanf( aziRadMapped ) * INV_TAN_LS_ANGLE_RAD_30_DEG; +#else A = tanf( aziRadMapped ) / tanf( LsAngleRad ); +#endif A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f ); A3 = 1.0f / ( A2 * A2 + 1.0f ); *left_gain = sqrtf( A3 ); diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 52262a9e8..b20afdca4 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -187,8 +187,9 @@ static float get_panning( { float aziRad, eleRad, y, mappedX, aziRadMapped, panning; float A, A2, A3; +#ifndef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL const float LsAngleRad = 30.0f * PI_OVER_180; - +#endif aziRad = aziDeg * PI_OVER_180; eleRad = eleDeg * PI_OVER_180; y = ( sinf( aziRad ) * cosf( eleRad ) ); @@ -197,17 +198,29 @@ static float get_panning( /* Determine the real valued amplitude panning gains */ panning = 0.0f; +#ifdef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL + if ( aziRadMapped >= LS_ANGLE_RAD_30_DEG ) +#else if ( aziRadMapped >= LsAngleRad ) +#endif { /* Left side */ panning = 1.0f; } +#ifdef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL + else if ( aziRadMapped <= -LS_ANGLE_RAD_30_DEG ) +#else else if ( aziRadMapped <= -LsAngleRad ) +#endif { /* Right side */ panning = -1.0f; } else /* Tangent panning law */ { +#ifdef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL + A = tanf( aziRadMapped ) * INV_TAN_LS_ANGLE_RAD_30_DEG; +#else A = tanf( aziRadMapped ) / tanf( LsAngleRad ); +#endif A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f ); A3 = 1.0f / ( A2 * A2 + 1.0f ); panning = 2 * A3 - 1.0f; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index b0578f92c..0b83be14a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -2474,7 +2474,9 @@ static void getDirectPartGains( { float aziRad, eleRad; float y, mappedX, aziRadMapped, A, A2, A3; +#ifndef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL const float LsAngleRad = 30.0f * PI_OVER_180; +#endif if ( renderStereoOutputInsteadOfBinaural ) /* In stereo (i.e. non-binaural) rendering mode */ { @@ -2495,19 +2497,31 @@ static void getDirectPartGains( aziRadMapped = atan2f( y, mappedX ); /* Determine the real valued amplitude panning gains */ +#ifdef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL + if ( aziRadMapped >= LS_ANGLE_RAD_30_DEG ) +#else if ( aziRadMapped >= LsAngleRad ) +#endif { /* Left side */ *lRealp = 1.0f; *rRealp = 0.0f; } +#ifdef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL + else if ( aziRadMapped <= -LS_ANGLE_RAD_30_DEG ) +#else else if ( aziRadMapped <= -LsAngleRad ) +#endif { /* Right side */ *lRealp = 0.0f; *rRealp = 1.0f; } else /* Tangent panning law */ { +#ifdef NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL + A = tanf( aziRadMapped ) * INV_TAN_LS_ANGLE_RAD_30_DEG; +#else A = tanf( aziRadMapped ) / tanf( LsAngleRad ); +#endif A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f ); A3 = 1.0f / ( A2 * A2 + 1.0f ); *lRealp = sqrtf( A3 ); -- GitLab