Commit 398d808c authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch...

Merge branch 'basop-2398-precision-issues-for-orientation-tracking-ref_vec-mode-in-vectorrotationtoquaternion_fx' into 'main'

[allow-regression][split-non-BE] [non-BE] Resolve "Precision issues for Orientation tracking REF_VEC mode in VectorRotationToQuaternion_fx"

Closes #2398

See merge request !2874
parents f3c8fd1f 6e5956a5
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@
#define FIX_BASOP_2472_IGF_SP_AUD_DEC_CHAN              /* FhG: always use channel 1 for sp_aud_decision0[] being passed to ProcessIGF_ivas_fx() */
#define FIX_BASOP_REMOVE_SYNTH2_FX                      /* FhG: Replace 32bit olapBufferSynth2_fx with 16bit olapBufferSynth2 buffer */
#define FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION  /* Nokia: float issue 1528: Fixes incorrect compensation for ISM metadata delay in 5ms TD rendering */
#define FIX_2398_PRECISSION_ORIENTATION_TRACKING        /* FhG: use refinement of Sqrt32 within certain functions*/
#define FIX_2462_PARCOR_FIX                             /* VA: issue 2462: Fix bug in calculating parcor coefficient in Calc_rc0_h() */

/* ##################### End NON-BE switches ########################### */
+46 −1
Original line number Diff line number Diff line
@@ -52,6 +52,44 @@
 * Local functions
 *------------------------------------------------------------------------------------------*/

#ifdef FIX_2398_PRECISSION_ORIENTATION_TRACKING
/*------------------------------------------------------------------------------------------*
 * Sqrt32 with Newton-Raphson Correction
 *
 * This is simply a wrapper for Sqrt32() which performs Newton-Raphson correction
 * As final step. The number of Newton-Raphson iterations can be set by 3rd parameter n
 *------------------------------------------------------------------------------------------*/

static Word32 Sqrt32_NewtonRaphson( Word32 mantissa, Word16 *e, Word16 n )
{
    /*higher precission by Newton-Raphson iterations*/
    Word32 result_fx_0;
    Word16 result_fx_e, result_fx_0_e;
    Word32 tmp;
    Word16 scale;

    result_fx_e = *e;
    move32();
    result_fx_0 = Sqrt32( mantissa, &result_fx_e );
    result_fx_0_e = result_fx_e;
    move32();
    result_fx_e = *e;
    move32();

    FOR( int NRi = 0; NRi < n; NRi++ )
    {
        tmp = BASOP_Util_Divide3232_Scale_newton( mantissa, result_fx_0, &scale );
        tmp = BASOP_Util_Add_Mant32Exp( tmp, add( sub( result_fx_e, result_fx_0_e ), scale ), result_fx_0, result_fx_0_e, &scale );
        result_fx_0 = tmp;
        move32();
        result_fx_0_e = sub( scale, 1 );
    }
    *e = result_fx_0_e;
    move32();
    return result_fx_0;
}
#endif

/*------------------------------------------------------------------------------------------*
 * IdentityQuaternion()
 *
@@ -191,7 +229,11 @@ static void QuaternionNormalize_fx(
    Word32 sqrt_fx;
    Word32 dot_prod_fx = QuaternionDotProduct_fx( q_fx, q_fx, &q_dot );
    sqrt_e = sub( Q31, q_dot );
#ifdef FIX_2398_PRECISSION_ORIENTATION_TRACKING
    sqrt_fx = Sqrt32_NewtonRaphson( dot_prod_fx, &sqrt_e, 1 );
#else
    sqrt_fx = Sqrt32( dot_prod_fx, &sqrt_e );
#endif
    QuaternionDivision_fx( q_fx, sqrt_fx, r_fx, sqrt_e );
    return;
}
@@ -486,8 +528,11 @@ static Word32 VectorLength_fx(
    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 */

#ifndef FIX_2398_PRECISSION_ORIENTATION_TRACKING
    result_fx = Sqrt32( result_fx, &sqrt_e );
#else
    result_fx = Sqrt32_NewtonRaphson( result_fx, &sqrt_e, 1 );
#endif
    *q_fact = sub( 31, sqrt_e ); /* back to Q again */
    move16();
    return result_fx;