Unverified Commit a4087c46 authored by norvell's avatar norvell
Browse files

Fix 1-bit headroom in TDREND_SPATIAL_VecNormalize_fx

parent 3c36f203
Loading
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -77,8 +77,13 @@ Word32 TDREND_SPATIAL_VecNorm_fx(
{
    Word32 tmp;
    Word16 tmp_e;
#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION
    tmp = L_add( L_add( Mpy_32_32( L_shr( Vec_p[0], 1 ), Vec_p[0] ), Mpy_32_32( L_shr( Vec_p[1], 1 ), Vec_p[1] ) ), Mpy_32_32( L_shr( Vec_p[2], 1 ), Vec_p[2] ) );
    tmp_e = add( shl( in_exp, 1 ), 1 ); // 2 * in_exp + 1
#else
    tmp = L_add( L_add( Mpy_32_32( Vec_p[0], Vec_p[0] ), Mpy_32_32( Vec_p[1], Vec_p[1] ) ), Mpy_32_32( Vec_p[2], Vec_p[2] ) );
    tmp_e = shl( in_exp, 1 ); // 2 * in_exp
#endif
    tmp = Sqrt32( tmp, &tmp_e );
    *out_exp = tmp_e;
    move16();
@@ -96,8 +101,13 @@ void TDREND_SPATIAL_VecNormalize_fx(
    Word32 sqrd_sum;
    Word16 exp, shift;

#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION
    sqrd_sum = L_add( Mpy_32_32( L_shr( Vec_p_fx[0], 1 ), Vec_p_fx[0] ), L_add( Mpy_32_32( L_shr( Vec_p_fx[1], 1 ), Vec_p_fx[1] ), Mpy_32_32( L_shr( Vec_p_fx[2], 1 ), Vec_p_fx[2] ) ) );
    exp = add( shl( sub( 31, q ), 1 ), 1 );
#else
    sqrd_sum = L_add( Mpy_32_32( Vec_p_fx[0], Vec_p_fx[0] ), L_add( Mpy_32_32( Vec_p_fx[1], Vec_p_fx[1] ), Mpy_32_32( Vec_p_fx[2], Vec_p_fx[2] ) ) );
    exp = shl( sub( 31, q ), 1 );
#endif
    scaler_fx = ISqrt32( sqrd_sum, &exp );

    VecNorm_p_fx[0] = Mpy_32_32( scaler_fx, Vec_p_fx[0] ); // Q: ( q + ( 31 - exp ) ) - 31