From 50aab657cf06aaea4bb4b3dfec899844b3e25d88 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 19 Nov 2024 12:58:16 +0100 Subject: [PATCH] port fix for issue 1024 from float repo --- lib_com/options.h | 1 + lib_dec/ivas_stereo_mdct_core_dec.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index f4bcf0a2b..680c58215 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,6 +169,7 @@ #define FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC_FP /* Nokia: Fixes ivas_decode_masaism_metadata decision logic change due to precision difference; this is the fix in floating point */ #define NONBE_FIX_1205_TD_STEREO_MOD_CT /* VA: fix mismatch of coder_type (mod_ct) btw. TD stereo encoder and decoder */ #define NONBE_FIX_1213_SBA_DET_MAT_INV_3BY3 /*Dolby: issue 1213: fix for inverse of det < 0*/ +#define NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING /* FhG: fixes for decoder-side noise level estimation in MDCT-Stereo to prevent noise bursts in stereo switching */ /* #################### End FIXES switches ############################ */ diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index c95729bc2..60430fd22 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -620,24 +620,48 @@ static void run_min_stats( computed only once (for ch == 0) and not again in the second run sive the outcome will be the same anyway */ if ( ( will_estimate_noise_on_channel[0] == will_estimate_noise_on_channel[1] ) || ch == 0 ) { +#ifdef NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING + float power_spec_scale_fac; + + /* calculate power spectrum from MDCT coefficients and estimated MDST coeffs */ + power_spec_scale_fac = 1.f / (float) ( L_FRAME16k * L_FRAME16k ); + power_spec[0] = spec_in[0] * spec_in[0] * power_spec_scale_fac; + power_spec[L_FRAME16k - 1] = spec_in[L_FRAME16k - 1] * spec_in[L_FRAME16k - 1] * power_spec_scale_fac; +#else /* calculate power spectrum from MDCT coefficients and estimated MDST coeffs */ power_spec[0] = spec_in[0] * spec_in[0]; power_spec[L_FRAME16k - 1] = spec_in[L_FRAME16k - 1] * spec_in[L_FRAME16k - 1]; +#endif for ( int16_t i = 1; i < L_FRAME16k - 1; i++ ) { float mdst; mdst = spec_in[i + 1] - spec_in[i - 1]; +#ifdef NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING + power_spec[i] = power_spec_scale_fac * ( spec_in[i] * spec_in[i] + mdst * mdst ); +#else power_spec[i] = spec_in[i] * spec_in[i] + mdst * mdst; +#endif } } +#ifndef NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING noisy_speech_detection( st->hFdCngDec, st->VAD && st->m_frame_type == ACTIVE_FRAME, power_spec ); st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = 0.99f * st->hFdCngDec->hFdCngCom->likelihood_noisy_speech + 0.01f * (float) st->hFdCngDec->hFdCngCom->flag_noisy_speech; st->lp_noise = st->hFdCngDec->lp_noise; +#endif } +#ifdef NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING + if ( st->core == TCX_20_CORE ) + { + noisy_speech_detection( st->hFdCngDec, save_VAD[ch] && st->m_frame_type == ACTIVE_FRAME, x[ch][0] ); + st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = 0.99f * st->hFdCngDec->hFdCngCom->likelihood_noisy_speech + 0.01f * (float) st->hFdCngDec->hFdCngCom->flag_noisy_speech; + st->lp_noise = st->hFdCngDec->lp_noise; + } +#endif + if ( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] || st->bfi ) { ApplyFdCng( NULL, st->bfi ? NULL : power_spec, NULL, NULL, st, st->bfi, 0 ); -- GitLab