diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 8c4929417208c564f5bea057db46bc4ca15398bd..fa4a2f9ad4b47e8c7de442f9efab42ba8b209015 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1498,6 +1498,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 e9b3222400f9c4a134d84c8e0edba529f8b0cf1b..830d779e62093411a41a52f6e006b7cdd49b021d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -205,6 +205,7 @@ #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_1380_OMASA_BUILD_DIFF /* Nokia: Fix for issue #1380: Large differences in OMASA output between Debug and Release builds */ +#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 82fabafcfa92a63c11daf9ff369d8f075a8d5764..d3897bba64d44da215ceeeecf0557f480685ac34 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 52262a9e8fe2af2205b2146115a6dc6e45651467..b20afdca419156bd75d5b8aa574f5f803d49d379 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 b0578f92c21f6c33462ec2119afdd6813d6bd1af..0b83be14a1c69f6713aa265cb64409dc8bb2aeee 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 );