Commit 6de6d147 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch '1326-complexity-issue-ism-4-32-kbps-fb-to-binaural-basop' into 'main'

Resolve "Complexity Issue ISM+4@32 kbps FB to BINAURAL - BASOP"

Closes #1326

See merge request !1181
parents eacec130 49363e47
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -176,4 +176,7 @@
#define FIX_ISSUE_1376                          /* VA: Fix for issue 1376 (issue with GSC excitation) */
#define OPT_SBA_AVOID_SPAR_RESCALE              /* Optimization made to spar decoder and IGF */
#define NONBE_FIX_1386_STEREO_DMX_EVS_PHA       /* Orange: Fix for stereo DMX / PHA mode : Change the filter taps resolution (Q31->Q30), improve precision for the IR window, for the ILD & IPD smoothing in sub-bands, for the ISD counters and for ICCr. */
#define FIX_1326_SUBSTITUTE_CMPMANT32EXP        /* FhG: Minor WMOPS tuning*/
#define FIX_1326_SUBSTITUTE_DIV_SQRT_IOSQRT     /* FhG: WMOPS tuning */
#define FIX_1326_SPEEDUP_eig2x2_fx              /* FhG: Minor WMOPS tuning*/
#endif
+53 −1
Original line number Diff line number Diff line
@@ -2151,6 +2151,14 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(

        tmp1 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), missingOutputEne_fx, sub( 31, q_missingOutputEne ), &exp1 );

#ifdef FIX_1326_SUBSTITUTE_DIV_SQRT_IOSQRT
        {
            tmp2 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), EPSILON_MANT, EPSILON_EXP, &exp2 );
            tmp2 = ISqrt32( tmp2, &exp2 );
            gain_fx = Mpy_32_32( tmp2, Sqrt32( tmp1, &exp1 ) );
            q_gain = sub( 31, add( exp2, exp1 ) );
        }
#else
        {
            Word16 exp_temp;
            tmp2 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), EPSILON_MANT, EPSILON_EXP, &exp_temp );
@@ -2159,6 +2167,8 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
        }
        gain_fx = Sqrt32( tmp2, &exp2 );
        q_gain = sub( 31, exp2 );
#endif


        // 1073741824 = 4 in Q28
        IF( LT_16( q_gain, Q28 ) )
@@ -3249,6 +3259,20 @@ static void eig2x2_fx(

    /* Numeric case, when input is practically zeros */
    // IF( D_fx[0] < EPSILON_FX )

#ifdef FIX_1326_SUBSTITUTE_CMPMANT32EXP
    IF( LT_32( L_shl_sat( D_fx[0], sub( sub( 31, *q_D ), EPSILON_EXP ) ), EPSILON_MANT ) )
    {
        Ure_fx[0][0] = ONE_IN_Q31;
        move32();
        Ure_fx[1][1] = ONE_IN_Q31;
        move32();
        *q_U = Q31;
        move16();

        return;
    }
#else
    IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( D_fx[0], *q_D, EPSILON_MANT, EPSILON_EXP ), -1 ) )
    {
        Ure_fx[0][0] = ONE_IN_Q31;
@@ -3260,6 +3284,7 @@ static void eig2x2_fx(

        return;
    }
#endif

    /* Numeric case, when input is near an identity matrix with a gain */
    tmp1 = Mpy_32_32( 2147484, add_fx ); // 2147484 = 1e-3f in Q31
@@ -3468,7 +3493,19 @@ static void eig2x2_fx(
            move16();
        }
    }
#ifdef FIX_1326_SPEEDUP_eig2x2_fx
    if ( q_U_1 != 0 )
    {
        *q_U = q_U_1;
        move16();
    }

    if ( q_U_1 == 0 )
    {
        *q_U = q_U_2;
        move16();
    }
#else
    IF( q_U_1 != 0 )
    {
        *q_U = q_U_1;
@@ -3478,6 +3515,7 @@ static void eig2x2_fx(
        *q_U = q_U_2;
    }
    move16();
#endif

    return;
}
@@ -4532,7 +4570,9 @@ static void formulate2x2MixingMatrix_fx(
        exp = sub( exp, sub( Q30, 62 ) );
#else
        temp = ONE_DIV_EPSILON_MANT; /* Result of 1.0/eps with full precision */
        move32();
        exp = ONE_DIV_EPSILON_EXP;
        move16();
#endif
    }
    ELSE
@@ -4543,6 +4583,18 @@ static void formulate2x2MixingMatrix_fx(
    div_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp
    move32();

#ifdef FIX_1326_SUBSTITUTE_DIV_SQRT_IOSQRT
    // Sqrt(1)
    div_fx[1] = L_add( 0, 2047986068 ); // Q = 31 - exp1
    exp1 = add( 0, 20 );

    IF( D_fx[1] != 0 ) // This is the new code: replace div sqrt by isqrt
    {
        exp1 = sub( 31, q_D );
        div_fx[1] = ISqrt32( D_fx[1], &exp1 );
        move32();
    }
#else
    IF( D_fx[1] == 0 )
    {
#ifndef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC
@@ -4560,7 +4612,7 @@ static void formulate2x2MixingMatrix_fx(
    }
    div_fx[1] = Sqrt32( temp, &exp1 ); // Q = 31 - exp1
    move32();

#endif
    q_div = sub( 31, s_max( exp, exp1 ) );

    div_fx[0] = L_shr( div_fx[0], sub( sub( 31, exp ), q_div ) ); // q_div