From a37e601cfab94976808a7f557a79567adead8bc4 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 28 Jan 2026 16:07:31 +0100 Subject: [PATCH 1/3] [fix] missing sqrt in VectorLength_fx() --- lib_com/ivas_rotation_com_fx.c | 2 +- lib_com/options.h | 1 + lib_rend/ivas_orient_trk_fx.c | 19 ++++++++++++++++++- lib_util/vector3_pair_file_reader.c | 5 +++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_rotation_com_fx.c b/lib_com/ivas_rotation_com_fx.c index 4106e5d05..917d901d8 100644 --- a/lib_com/ivas_rotation_com_fx.c +++ b/lib_com/ivas_rotation_com_fx.c @@ -113,7 +113,7 @@ void Copy_Quat_fx( /*------------------------------------------------------------------------- - * Scale_Quat_fx() + * modify_Quat_q_fx() * * Quaternion q factor modification *------------------------------------------------------------------------*/ diff --git a/lib_com/options.h b/lib_com/options.h index e11d5dffa..2c8a0221f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -111,6 +111,7 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ #define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching */ +#define FIX_BASOP_2361_OTR /* FhG: Basop issue 2361: Orientation tracking tests for equivalent rotations fail */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index 571106b6c..7b56efdd6 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -482,12 +482,22 @@ static Word32 VectorLength_fx( IVAS_VECTOR3 p, Word16 *q_fact ) { +#ifdef FIX_BASOP_2361_OTR + Word16 sqrt_e; +#endif Word32 result_fx = 0; move32(); result_fx = L_add( L_add( Mpy_32_32( p.x_fx, p.x_fx ), Mpy_32_32( p.y_fx, p.y_fx ) ), Mpy_32_32( p.z_fx, p.z_fx ) ); // // Q: ( p1.q_fact + p2.q_fact ) - 31 +#ifdef FIX_BASOP_2361_OTR + sqrt_e = sub( 31, sub( add( p.q_fact, p.q_fact ), 31 ) ); /* convert Q to E */ + result_fx = Sqrt32( result_fx, &sqrt_e ); + *q_fact = sub( 31, sqrt_e ); /* back to Q again */ +#else *q_fact = sub( add( p.q_fact, p.q_fact ), 31 ); +#endif move16(); + return result_fx; } @@ -702,7 +712,14 @@ ivas_error ivas_orient_trk_SetReferenceRotation_fx( Euler2Quat_fx( deg2rad_fx( refRot.x_fx ), deg2rad_fx( refRot.y_fx ), deg2rad_fx( refRot.z_fx ), &pOTR->refRot ); modify_Quat_q_fx( &pOTR->refRot, &pOTR->refRot, Q29 ); } - pOTR->refRot = refRot; +#ifdef FIX_BASOP_2361_OTR + ELSE + { +#endif + pOTR->refRot = refRot; +#ifdef FIX_BASOP_2361_OTR + } +#endif return IVAS_ERR_OK; } diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index c6758b6b1..27a21d21e 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -114,8 +114,13 @@ ivas_error Vector3PairFileReader_read( pSecond->y = y2; pSecond->z = z2; +#ifdef FIX_BASOP_2361_OTR + pFirst->q_fact = 27; // Q27 + pSecond->q_fact = 27; // Q27 +#else pFirst->q_fact = 29; // Q29 pSecond->q_fact = 29; // Q29 +#endif pFirst->x_fx = floatToFixed_32( pFirst->x, pFirst->q_fact ); pFirst->y_fx = floatToFixed_32( pFirst->y, pFirst->q_fact ); pFirst->z_fx = floatToFixed_32( pFirst->z, pFirst->q_fact ); -- GitLab From 009aad4e7200075c4c40a91f4feda2fd4b7fa547 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 30 Jan 2026 10:52:22 +0100 Subject: [PATCH 2/3] - fix alpha computation missing 2pi factor - remove unnecessary caching of q value before call to VectorLength_fx() --- lib_rend/ivas_orient_trk_fx.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index 7b56efdd6..7d6e3750f 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -841,11 +841,16 @@ ivas_error ivas_orient_trk_SetReferenceVector_fx( return IVAS_ERR_WRONG_PARAMS; } +#ifdef FIX_BASOP_2361_OTR + Word16 tmp_q; + acousticFrontVectorLength = VectorLength_fx( acousticFrontVector, &tmp_q ); +#else Word16 accoustic_q = acousticFrontVector.q_fact; move16(); acousticFrontVectorLength = VectorLength_fx( acousticFrontVector, &acousticFrontVector.q_fact ); acousticFrontVector.q_fact = accoustic_q; move16(); +#endif /* if the length is zero, the user has entered insensible listener and reference positions */ IF( LE_32( acousticFrontVectorLength, 0 ) ) { @@ -906,6 +911,18 @@ ivas_error ivas_orient_trk_Process_fx( /* Reset average orientation */ pOTR->absAvgRot = absRot; +#ifdef FIX_BASOP_2361_OTR + Word16 scale_e; + Word16 tmp; + tmp = BASOP_Util_Divide3232_Scale( PI2_C_ADP_RATE_Q31, updateRate_fx, &scale_e ); + scale_e = add( scale_e, sub( 23, 31 ) ); /* updateRate_fx is hardcoded in caller to Q23 */ + + /* sin(x) is approx x for small x */ + pOTR->alpha_fx = L_deposit_h( tmp ); + move32(); + pOTR->Q_alpha = sub( Q31, scale_e ); + move16(); +#else Word16 scale_e; Word32 div; div = L_deposit_h( BASOP_Util_Divide3232_Scale( pOTR->centerAdaptationRate_fx, updateRate_fx, &scale_e ) ); @@ -914,6 +931,7 @@ ivas_error ivas_orient_trk_Process_fx( // here div value is less so we can use sandwitch rule of sine// pOTR->alpha_fx = div; move32(); +#endif /* Compute relative orientation = (absolute orientation) - (reference orientation) */ QuaternionInverse_fx( pOTR->refRot, &pOTR->trkRot ); QuaternionProduct_fx( pOTR->trkRot, absRot, &pOTR->trkRot ); @@ -967,6 +985,8 @@ ivas_error ivas_orient_trk_Process_fx( cutoff_prod = L_shl( cutoff_prod, temp_diff ); /* Compute adaptivity cutoff frequency: interpolate between minimum (center) and maximum (off-center) values */ cutoffFrequency_fx = L_add( pOTR->centerAdaptationRate_fx, cutoff_prod ); // Q31 + + /* Compute filter coefficient corresponding to desired cutoff frequency */ cutoff_prod = Mpy_32_32( cutoffFrequency_fx, PI2_C_Q28 ); q_cutoff_prod = ( ( 31 + 28 ) - 31 ); temp_result = BASOP_Util_Divide3232_Scale( cutoff_prod, updateRate_fx, &result_e ); -- GitLab From 8fe12e33030330a1cf0a16755fb6234b6eb1be1b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 30 Jan 2026 14:17:20 +0100 Subject: [PATCH 3/3] implement reviewer suggestions --- lib_com/ivas_rotation_com_fx.c | 15 +++++++++++++++ lib_rend/ivas_orient_trk_fx.c | 16 ++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/lib_com/ivas_rotation_com_fx.c b/lib_com/ivas_rotation_com_fx.c index 917d901d8..5fc6261a9 100644 --- a/lib_com/ivas_rotation_com_fx.c +++ b/lib_com/ivas_rotation_com_fx.c @@ -124,10 +124,18 @@ void modify_Quat_q_fx( Word16 q_new /* i : quaternion describing the rotation */ ) { +#ifdef FIX_BASOP_2361_OTR + Word16 shift = sub( q_new, in_quat->q_fact ); + out_quat->w_fx = L_shl_sat( in_quat->w_fx, shift ); // q_new + out_quat->x_fx = L_shl_sat( in_quat->x_fx, shift ); // q_new + out_quat->y_fx = L_shl_sat( in_quat->y_fx, shift ); // q_new + out_quat->z_fx = L_shl_sat( in_quat->z_fx, shift ); // q_new +#else out_quat->w_fx = L_shl_sat( in_quat->w_fx, sub( q_new, in_quat->q_fact ) ); // q_new out_quat->x_fx = L_shl_sat( in_quat->x_fx, sub( q_new, in_quat->q_fact ) ); // q_new out_quat->y_fx = L_shl_sat( in_quat->y_fx, sub( q_new, in_quat->q_fact ) ); // q_new out_quat->z_fx = L_shl_sat( in_quat->z_fx, sub( q_new, in_quat->q_fact ) ); // q_new +#endif out_quat->q_fact = q_new; return; } @@ -147,12 +155,19 @@ void modify_Rmat_q_fx( ) { Word16 j, k; +#ifdef FIX_BASOP_2361_OTR + Word16 shift = sub( q_new, q_cur ); +#endif FOR( j = 0; j < 3; j++ ) { FOR( k = 0; k < 3; k++ ) { +#ifdef FIX_BASOP_2361_OTR + Rmat_out[j][k] = L_shl( Rmat_in[j][k], shift ); +#else Rmat_out[j][k] = L_shl( Rmat_in[j][k], sub( q_new, q_cur ) ); +#endif move32(); } } diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index 7d6e3750f..18fabc032 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -484,20 +484,20 @@ static Word32 VectorLength_fx( { #ifdef FIX_BASOP_2361_OTR Word16 sqrt_e; -#endif - Word32 result_fx = 0; - move32(); - result_fx = L_add( L_add( Mpy_32_32( p.x_fx, p.x_fx ), Mpy_32_32( p.y_fx, p.y_fx ) ), Mpy_32_32( p.z_fx, p.z_fx ) ); // // Q: ( p1.q_fact + p2.q_fact ) - 31 -#ifdef FIX_BASOP_2361_OTR - sqrt_e = sub( 31, sub( add( p.q_fact, p.q_fact ), 31 ) ); /* convert Q to E */ + Word32 result_fx; + result_fx = Madd_32_32( Madd_32_32( Mpy_32_32( p.x_fx, p.x_fx ), p.y_fx, p.y_fx ), p.z_fx, p.z_fx ); + sqrt_e = shl( sub( 31, p.q_fact ), 1 ); /* convert Q to E */ result_fx = Sqrt32( result_fx, &sqrt_e ); *q_fact = sub( 31, sqrt_e ); /* back to Q again */ #else + Word32 result_fx = 0; + move32(); + result_fx = L_add( L_add( Mpy_32_32( p.x_fx, p.x_fx ), Mpy_32_32( p.y_fx, p.y_fx ) ), Mpy_32_32( p.z_fx, p.z_fx ) ); // // Q: ( p1.q_fact + p2.q_fact ) - 31 + *q_fact = sub( add( p.q_fact, p.q_fact ), 31 ); #endif move16(); - return result_fx; } @@ -915,7 +915,7 @@ ivas_error ivas_orient_trk_Process_fx( Word16 scale_e; Word16 tmp; tmp = BASOP_Util_Divide3232_Scale( PI2_C_ADP_RATE_Q31, updateRate_fx, &scale_e ); - scale_e = add( scale_e, sub( 23, 31 ) ); /* updateRate_fx is hardcoded in caller to Q23 */ + scale_e = add( scale_e, 23 - 31 ); /* updateRate_fx is hardcoded in caller to Q23 */ /* sin(x) is approx x for small x */ pOTR->alpha_fx = L_deposit_h( tmp ); -- GitLab