Commit 009aad4e authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

- fix alpha computation missing 2pi factor

- remove unnecessary caching of q value before call to VectorLength_fx()
parent e14a1f0c
Loading
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -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 );