From c29561ba43940cefae2d4a956d104b64b187346d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 13 Nov 2024 09:41:36 +0530 Subject: [PATCH] Fix for 3GPP issue 975: Higher MLD in MDCT-Stereo mono output than in stereo out --- lib_dec/ivas_stereo_mdct_stereo_dec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index b83432db3..91c192c5b 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -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 */ -- GitLab