From 78b340e6f9b61d2a6eeae6a53c3b35ecf0ad5b92 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 10 Oct 2025 13:09:00 +0200 Subject: [PATCH] Add fix NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING to port MR2017 --- lib_com/options.h | 1 + lib_dec/FEC_HQ_phase_ecu_fx.c | 54 ++++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c941842df..0fe93c63d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -151,6 +151,7 @@ #define FIX_1387_INIT_PRM_SQQ /* FhG: initialize pointer prm_sqQ, which might be uninitialized in case of bfi == 1 */ #define NONBE_1296_TDREND_ITD_OUT_OF_BOUNDS_ACCESS /* Eri: issue 1296: ITD resampling can occasionally read out of bounds, especially when the requested subframes are short (1.25 ms). Seen for headtracking+JBM. */ #define FIX_1349_TNS_CRASH /* FhG: Fix crash in TNS entropy coding, in case order of joint TNS coding is reduced to 0 */ +#define NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING /* Ericsson: issue 1180, corrected long term mute loop attnuation after 200ms in PhECU-PLC */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index ac802a1eb..022137306 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -63,7 +63,11 @@ static Word16 sqrt2ndOrder( const Word16 ); static void windowing( const Word16 *, Word16 *, const Word16 *, const Word16, const Word16 ); static void windowing_ROM_optimized( const Word16 *, Word16 *, const Word16, const Word16, const Word16 ); static void fft_spec2_fx( const Word16[], Word32[], const Word16 ); +#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING +static void trans_ana_fx( const Word16 *, Word16 *, Word16 *, Word16 *, const Word16, const Word16, const Word16, const Word16, const Word16, Word16 *, Word16 *, Word16 *, Word16 * ); +#else static void trans_ana_fx( const Word16 *, Word16 *, Word16 *, Word16 *, const Word16, const Word16, const Word16, const Word16, Word16 *, Word16 *, Word16 *, Word16 * ); +#endif static void peakfinder_fx( const Word16 *, const Word16, Word16 *, Word16 *, const Word16 ); static Word16 imax_fx( const Word16 *, const Word16 ); static void spec_ana_fx( const Word16 *prevsynth, Word16 *plocs, Word32 *plocsi, Word16 *num_plocs, Word16 *X_sav, const Word16 output_frame, const Word16 bwidth_fx, Word16 *Q ); @@ -230,10 +234,13 @@ static void trans_ana_fx( const Word16 time_offs, /* i : Time offset (integral multiple of output_frame) */ const Word16 est_mus_content, /* i : 0.0=speech_like ... 1.0=Music (==st->env_stab ) */ const Word16 last_fec, /* i : signal that previous frame was concealed with fec_alg */ - Word16 *alpha, /* o : Magnitude modification factors for fade to average */ - Word16 *beta, /* o : Magnitude modification factors for fade to average */ - Word16 *beta_mute, /* o : Factor for long-term mute Q15 */ - Word16 *Xavg /* o : Frequency group average gain to fade to */ +#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING + const Word16 element_mode, /* i : element_mode req to handle EVS_MONO specific BE path */ +#endif + Word16 *alpha, /* o : Magnitude modification factors for fade to average */ + Word16 *beta, /* o : Magnitude modification factors for fade to average */ + Word16 *beta_mute, /* o : Factor for long-term mute Q15 */ + Word16 *Xavg /* o : Frequency group average gain to fade to */ ) { const Word16 *w_hamm, *pFftTbl; @@ -555,11 +562,30 @@ static void trans_ana_fx( mag_chg[k] = mult_r( mag_chg_1st[k], att_val ); /* Q15 */ move16(); +#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING + IF( NE_16( element_mode, EVS_MONO ) ) + { + IF( EQ_16( k, 0 ) && GT_16( burst_len, BETA_MUTE_THR ) ) /* beta_mute final long term attenuation adjusted only once per frame in the first sub-band, Ref Eq(184) in 26.447 */ + { + *beta_mute = shr( *beta_mute, 1 ); + move16(); + } + } + ELSE + { + IF( GT_16( burst_len, BETA_MUTE_THR ) ) /* legacy incorrect(too fast) EVS_MONO operation, still kept for BE. To be updated after EVS CR, ref Eq (184) in 26.447 */ + { + *beta_mute = shr( *beta_mute, 1 ); + move16(); + } + } +#else IF( GT_16( burst_len, BETA_MUTE_THR ) ) { *beta_mute = shr( *beta_mute, 1 ); move16(); } +#endif alpha[k] = mag_chg[k]; move16(); /*beta[k] = sqrt(1.0f - SQR(alpha[k])) * *beta_mute;*/ @@ -4507,8 +4533,13 @@ static void ivas_hq_phase_ecu_fx( } offset = add( sub( sub( shl( output_frame, 1 ), lprot ), *time_offs ), ph_ecu_lookahead ); +#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING + trans_ana_fx( prevsynth + offset, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, + *last_fec, element_mode, alpha, beta, beta_mute, Xavg ); +#else trans_ana_fx( prevsynth + offset, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, *last_fec, alpha, beta, beta_mute, Xavg ); +#endif ivas_spec_ana_fx( prevsynth + offset, plocs, plocsi, num_p, X_sav, output_frame, bwidth_fx, Q_spec, element_mode, &noise_fac, pcorr ); @@ -4524,8 +4555,13 @@ static void ivas_hq_phase_ecu_fx( *time_offs = add_sat( *time_offs, output_frame ); move16(); offset = sub( shl( output_frame, 1 ), lprot ); +#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING + trans_ana_fx( prevsynth + offset, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, + 0, element_mode, alpha, beta, beta_mute, Xavg ); +#else trans_ana_fx( prevsynth + offset, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, 0, alpha, beta, beta_mute, Xavg ); +#endif } Copy( X_sav, X, lprot ); @@ -4612,8 +4648,13 @@ static void hq_phase_ecu_fx( } offset = sub( sub( shl( output_frame, 1 ), lprot ), *time_offs ); +#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING + trans_ana_fx( prevsynth + offset, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, + *last_fec, EVS_MONO, alpha, beta, beta_mute, Xavg ); +#else trans_ana_fx( prevsynth + offset, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, *last_fec, alpha, beta, beta_mute, Xavg ); +#endif spec_ana_fx( prevsynth + offset, plocs, plocsi, num_p, X_sav, output_frame, bwidth_fx, Q_spec ); @@ -4630,8 +4671,13 @@ static void hq_phase_ecu_fx( move16(); offset = sub( shl( output_frame, 1 ), lprot ); +#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING + trans_ana_fx( prevsynth + offset, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, + 0, EVS_MONO, alpha, beta, beta_mute, Xavg ); +#else trans_ana_fx( prevsynth + offset, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, 0, alpha, beta, beta_mute, Xavg ); +#endif } Copy( X_sav, X, lprot ); -- GitLab