diff --git a/lib_com/ivas_rotation_com_fx.c b/lib_com/ivas_rotation_com_fx.c index 4106e5d059bbb2f49259c6b8601781547dd48b3f..5fc6261a955b8f0fbee67a48d693230994521342 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 *------------------------------------------------------------------------*/ @@ -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_com/options.h b/lib_com/options.h index 51bd5a3f340e3f8fc8a819cfe3a960f785297a6c..0ea316a82a8cdacb4562394ba7ad6b5cd236a9bd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,6 +118,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 */ #define FIX_1283_STEREO_DFT_COLLAPSE /* FhG: float issue 1283: fix for critical issue with DFT stereo core coder */ #define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */ #define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */ diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index 571106b6c160d57eaa4926e61b682222313a4c21..18fabc03252f67e43a4ee01e1fcfb9b8624b57b5 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -482,11 +482,21 @@ static Word32 VectorLength_fx( IVAS_VECTOR3 p, Word16 *q_fact ) { +#ifdef FIX_BASOP_2361_OTR + Word16 sqrt_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; } @@ -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; } @@ -824,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 ) ) { @@ -889,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, 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 ) ); @@ -897,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 ); @@ -950,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 ); diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index c6758b6b1a5030d40316a8e6c0f6d862669f815e..27a21d21e8904a62acf01681ec8da719f0ab268d 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 );