Commit f08d96c0 authored by fotopoulou's avatar fotopoulou
Browse files

Merge branch 'basop-2618-residual-plc-attenuation-ignores-q_fac-sqrt32-exponent' into 'main'

[non-BE] Resolve: "Residual PLC attenuation ignores q_fac / Sqrt32 exponent"

See merge request !3065
parents 9cd76149 1e758ec4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@
#define FIX_FMSW_DEC_EXT                                /* float issue 1566: fix EXT output in format switching */
#define FIX_BASOP_2612_RESET_DECIM_MEM                  /* FhG: BASOP #2612: reset (zero) the 16k resampler memory of the secondary channel on DFT->TD stereo switch (otherwise -> fx overshoot) */
#define FIX_BASOP_2621_STEREO_CNG_NOISY_SPEECH_QSHIFT   /* FhG: BASOP #2621: stereo_dft_generate_comfort_noise_fx flag_noisy_speech: compare (lp_speech-lp_noise) Q23 diff against 28.0 in Q23 (was vs integer 28 with q_lp_noise=0) */
#define FIX_ISSUE_2618_PLC_RES_ATT_SCALING              /* FhG: BASOP #2618: residual PLC burst attenuation, apply divide/Sqrt32 exponent so fac tracks exponent correctly */

/* ##################### End NON-BE switches ########################### */

+15 −0
Original line number Diff line number Diff line
@@ -738,22 +738,37 @@ void stereo_dft_res_ecu_burst_att_fx(
)
{
    Word32 fac;
#ifndef FIX_ISSUE_2618_PLC_RES_ATT_SCALING
    Word16 q_fac;
#endif
    Word16 exponent;

#ifndef FIX_ISSUE_2618_PLC_RES_ATT_SCALING
    q_fac = 0;
    move16();
#endif
    exponent = 0;
    move16();

    /* attenuation of residual; follow attenuation of DMX */
    IF( hStereoDft->core_hist[0] == ACELP_CORE )
    {
#ifdef FIX_ISSUE_2618_PLC_RES_ATT_SCALING
        fac = L_deposit_h( BASOP_Util_Divide3232_Scale( dmx_nrg, hStereoDft->past_dmx_nrg_fx, &exponent ) );
        fac = Sqrt32( fac, &exponent );
        fac = Mpy_32_16_1( fac, (Word16) ( 0x0CCD ) ); /* * 0.1f (Q15) */
        fac = L_shl_sat( fac, exponent );              /* Q31 */
#else
        fac = Mpy_32_16_1( Sqrt32( L_deposit_h( BASOP_Util_Divide3232_Scale( dmx_nrg, hStereoDft->past_dmx_nrg_fx, &q_fac ) ), &exponent ), (Word16) ( 0x0CCD ) ); /* Q0 */
#endif
    }
    ELSE
    {
#ifdef FIX_ISSUE_2618_PLC_RES_ATT_SCALING
        fac = L_sub( MAX_32, L_deposit_h( BASOP_Util_Divide3232_Scale( L_sub( hStereoDft->time_offs, L_ana ), L_add( hStereoDft->time_offs, L_ana ), &exponent ) ) ); /* Q31 */
#else
        fac = L_sub( MAX_32, L_deposit_h( BASOP_Util_Divide3232_Scale( L_sub( hStereoDft->time_offs, L_ana ), L_add( hStereoDft->time_offs, L_ana ), &q_fac ) ) ); /* Q0 */
#endif
    }

    v_multc_fx( pDFT_RES, fac, pDFT_RES, shl( L_res, 1 ) );