Commit 5153a91f authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch '3gpp_issue_1123_fix' into 'main'

[allow regression] Fix for 3GPP issue 1123: MLD in the range of 5 to 12 between signals decoded...

See merge request !1698
parents 59da8e0e a31c149e
Loading
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -1392,25 +1392,33 @@ void tcx_scalar_quantization_ivas_fx(
        s = sub( add( x_e, gain_e ), 15 );
    }

    /* substract 0x8000 to affect the mac_r in the following loop
    so it acts like extract_h. the 0x4000 will be multiplied by 2
    by the mac_r to get to 0x8000 and disable the round. */
    offset = sub( offset, 0x4000 );

    FOR( ; i >= 0; i-- )
    {
        offs32 = Mpy_32_16_1( L_abs( x[i] ), gain ); /* multiply */
        offs32 = Mpy_32_16_1( x[i], gain ); /* multiply */
        offs32 = L_shl_sat( offs32, s );    /* convert to 15Q16 */
        tmp16 = mac_r_sat( offs32, offset, 1 );      /* add offset and truncate */
        IF( x[i] < 0 )
        IF( x[i] > 0 )
        {
            tmp16 = negate( tmp16 ); /* restore sign */
            offs32 = L_add_sat( offs32, L_shl( offset, 1 ) );
            tmp16 = extract_h( offs32 );
            IF( GT_32( L_deposit_h( tmp16 ), offs32 ) )
            {
                tmp16 = sub( tmp16, 1 );
            }
        }
        ELSE
        {
            offs32 = L_add_sat( offs32, L_shl( negate( offset ), 1 ) );
            tmp16 = extract_h( offs32 );
            IF( LT_32( L_deposit_h( tmp16 ), offs32 ) )
            {
                tmp16 = add( tmp16, 1 );
            }
        }

        xq[i] = tmp16;
        move16();
    }


    IF( alfe_flag == 0 )
    {
        AdaptLowFreqEmph_fx( x, x_e, xq, gain, gain_e,