Commit 3332b8a8 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch '3gpp_issue_975_fix' into 'main'

Fix for 3GPP issue 975: Higher MLD in MDCT-Stereo mono output than in stereo out [allow regression]

See merge request !771
parents a2b7ed0f c29561ba
Loading
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -604,7 +604,7 @@ void stereo_decoder_tcx_fx(
    Word16 i, k, sfb, nSubframes;
    STEREO_MDCT_BAND_PARAMETERS *sfbConf = NULL;
    Word32 nrgRatio, inv_nrgRatio, tmp_32;
    Word16 tmp, tmp_e, shift;
    Word16 tmp_e, shift;

    nSubframes = 2;
    move16();
@@ -717,11 +717,12 @@ void stereo_decoder_tcx_fx(

        IF( !mct_on )
        {
            tmp = BASOP_Util_Divide3216_Scale( ( SMDCT_ILD_RANGE << 26 ), hStereoMdct->global_ild[k], &tmp_e );
            tmp_32 = L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) ); /* nrgRatio = nrg[1]/nrg[0] */ // Q26
            nrgRatio = L_sub( tmp_32, 67108864 );                                                     /* 1.0f in Q26 */
            tmp_32 = BASOP_Util_Divide3232_Scale_cadence( SMDCT_ILD_RANGE << 16, L_deposit_h( hStereoMdct->global_ild[k] ), &tmp_e );
            tmp_32 = L_shr( tmp_32, sub( 5, tmp_e ) ); /* nrgRatio = nrg[1]/nrg[0] */ // Q26
            nrgRatio = L_sub( tmp_32, ONE_IN_Q26 );                                   // Q26

            hStereoMdct->smooth_ratio_fx = L_add( Mpy_32_32( POINT_8_FIXED, hStereoMdct->smooth_ratio_fx ), Mpy_32_32( POINT_2_FIXED, nrgRatio ) ); // Q26
            hStereoMdct->smooth_ratio_fx = W_extract_h( W_mac_32_32( W_mult_32_32( POINT_8_FIXED, hStereoMdct->smooth_ratio_fx ), POINT_2_FIXED, nrgRatio ) ); // Q26
            move32();
            /* set flag to reverse dmx computation in case of right-side panning, only relevant for mono output */
            IF( GT_32( hStereoMdct->smooth_ratio_fx, ONE_POINT_3_FIXED ) )
            {
@@ -771,8 +772,7 @@ void stereo_decoder_tcx_fx(
            }
            ELSE IF( ( LT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, tmp2 ) ) )
            {
                tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q26, nrgRatio, &tmp_e );
                inv_nrgRatio = L_deposit_h( tmp ); /* Q31 - tmp_e */
                inv_nrgRatio = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q26, nrgRatio, &tmp_e );
                shift = sub( 5, tmp_e );
                v_multc_fixed( spec_l[k], inv_nrgRatio, spec_l[k], L_frameTCX_l ); /* spec_r will be in Qx - tmp_e */
                Scale_sig32( spec_l[k], L_frameTCX_l, sub( 5, shift ) );           /* Qx */