Commit cd578008 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch '3gpp_issue_1480_fix' into 'main'

Fix for 3GPP issue 1480: BASOP assert in MDCT-Stereo Stereo pre-processing with music signal

See merge request !1397
parents ada94b5b 7ab90bd2
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -815,6 +815,7 @@ static UWord16 enc_ste_pre_mdct(
    Word16 mdst_exp1[2 * 960], mdst_exp2[2 * 960];
    Word16 x1, x2, x3, x4, ans, tmp;
    Word32 maxSqrValue_fx;
    Word64 sumL_64fx, sumR_64fx;

    IF( LT_16( nSamplesMax, 512 ) )
    {
@@ -885,7 +886,9 @@ static UWord16 enc_ste_pre_mdct(
    {
        return 0;
    }

    sumL_64fx = 0, sumR_64fx = 0;
    move64();
    move64();
    FOR( s = fadeInOff; s < nSampProc; s++ )
    {
        Word32 absMagnL_fx, absMagnR_fx;
@@ -898,8 +901,8 @@ static UWord16 enc_ste_pre_mdct(
        absMagnR_fx = Sqrt32( L_add( Mpy_32_32( sigR1_fx[s], sigR1_fx[s] ), Mpy_32_32( sigI1_fx[s], sigI1_fx[s] ) ), &absMagnR_e );

        corr_fx = L_add( corr_fx, L_add( Mpy_32_32( sigR0_fx[s], sigR1_fx[s] ), Mpy_32_32( sigI0_fx[s], sigI1_fx[s] ) ) ); // q_com*2 - 31
        sumL_fx = L_add( sumL_fx, L_add( L_shr( sigR0_fx[s], 1 ), L_shr( sigI0_fx[s], 1 ) ) );                             // q_com -1
        sumR_fx = L_add( sumR_fx, L_add( L_shr( sigR1_fx[s], 1 ), L_shr( sigI1_fx[s], 1 ) ) );                             // q_com - 1
        sumL_64fx = W_add( sumL_64fx, W_add( sigR0_fx[s], sigI0_fx[s] ) );                                                 // q_com
        sumR_64fx = W_add( sumR_64fx, W_add( sigR1_fx[s], sigI1_fx[s] ) );                                                 // q_com
        sumMagnL_fx = BASOP_Util_Add_Mant32Exp( sumMagnL_fx, sumMagnL_e, absMagnL_fx, absMagnL_e, &sumMagnL_e );
        sumMagnR_fx = BASOP_Util_Add_Mant32Exp( sumMagnR_fx, sumMagnR_e, absMagnR_fx, absMagnR_e, &sumMagnR_e );
        sumPrdLR_fx = BASOP_Util_Add_Mant32Exp( sumPrdLR_fx, sumPrdLR_e, Mpy_32_32( absMagnL_fx, absMagnR_fx ), add( absMagnL_e, absMagnR_e ), &sumPrdLR_e );
@@ -911,7 +914,14 @@ static UWord16 enc_ste_pre_mdct(
    temp1 = L_shl( preproLen, x1 );
    corr_fx = Mpy_32_32( corr_fx, temp1 );
    x1 = sub( 62, add( shl( *q_com, 1 ), x1 ) );
    corr_fx = BASOP_Util_Add_Mant32Exp( corr_fx, x1, Mpy_32_32( sumL_fx, sumR_fx ), sub( 62, shl( sub( *q_com, 1 ), 1 ) ), &x1 );

    x2 = W_norm( sumL_64fx );
    sumL_fx = W_extract_h( W_shl( sumL_64fx, x2 ) );

    x3 = W_norm( sumR_64fx );
    sumR_fx = W_extract_h( W_shl( sumR_64fx, x3 ) );

    corr_fx = BASOP_Util_Add_Mant32Exp( corr_fx, x1, Mpy_32_32( sumL_fx, sumR_fx ), sub( 62, add( sub( add( *q_com, x2 ), 32 ), sub( add( *q_com, x3 ), 32 ) ) ), &x1 );

    IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( corr_fx, x1, -maxSqrValue_fx, 52 ), -1 ) )
    {