From b1164c83b379271fa9d91eca1a3e659fa78e1478 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 28 Oct 2024 19:08:38 +0100 Subject: [PATCH 1/4] add proposed fix for correct power spec scaling --- lib_com/options.h | 1 + lib_dec/ivas_stereo_mdct_core_dec.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 9bdfec8eed..9bf175b104 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -188,6 +188,7 @@ #define FIX_1139_REV_COLORATION_SHORT_T60 /* Nokia,FhG: Fix issue 1139, prevent sound coloration artefacts at very low reverberation times */ #define NONBE_FIX_1208_DFT_STEREO_PLC_BURST /* Ericsson: Issue 1208, fix for overflow of sample offset counter for burst error in DFT Stereo PLC. */ #define FIX_1206_ZERO_OUT_IMDCT_BUFFERS_FOR_MCT_IGNORE /* FhG: zero out all relevant imdct buffers in MCT decoding of channels with mct_chan_mode == MCT_CHAN_MODE_IGNORE */ +#define NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index 9ee33e7ad7..c96a8d4e86 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -620,14 +620,27 @@ 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 } } -- GitLab From 4040d977eda7bada1107d3ef059c369581200ba5 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 8 Nov 2024 14:48:03 +0100 Subject: [PATCH 2/4] explicitly pass nullptr to param that is anyway unused --- lib_dec/ivas_stereo_mdct_core_dec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index c96a8d4e86..c20dfdd5a5 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -644,7 +644,11 @@ static void run_min_stats( } } +#ifdef NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING + noisy_speech_detection( st->hFdCngDec, st->VAD && st->m_frame_type == ACTIVE_FRAME, NULL ); +#else noisy_speech_detection( st->hFdCngDec, st->VAD && st->m_frame_type == ACTIVE_FRAME, power_spec ); +#endif st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = 0.99f * st->hFdCngDec->hFdCngCom->likelihood_noisy_speech + 0.01f * (float) st->hFdCngDec->hFdCngCom->flag_noisy_speech; -- GitLab From 5e9fb905b784214d741624f8e1f96371ef09232b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 8 Nov 2024 16:06:32 +0100 Subject: [PATCH 3/4] fix noisy_speech_detection for MDCT-Stereo --- lib_dec/ivas_stereo_mdct_core_dec.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index c20dfdd5a5..20e4dcc8a0 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -643,18 +643,25 @@ static void run_min_stats( #endif } } +#ifndef NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING -#ifdef NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING - noisy_speech_detection( st->hFdCngDec, st->VAD && st->m_frame_type == ACTIVE_FRAME, NULL ); -#else noisy_speech_detection( st->hFdCngDec, st->VAD && st->m_frame_type == ACTIVE_FRAME, power_spec ); -#endif 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 From fbb7f7033db68fdf7171ae3801416f367bbc4a40 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 14 Nov 2024 13:51:07 +0100 Subject: [PATCH 4/4] add comment to switch in options.h --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 10476a4f9d..bd56720b60 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -196,7 +196,7 @@ #define FIX_1139_REV_COLORATION_SHORT_T60 /* Nokia,FhG: Fix issue 1139, prevent sound coloration artefacts at very low reverberation times */ #define NONBE_FIX_1208_DFT_STEREO_PLC_BURST /* Ericsson: Issue 1208, fix for overflow of sample offset counter for burst error in DFT Stereo PLC. */ #define FIX_1206_ZERO_OUT_IMDCT_BUFFERS_FOR_MCT_IGNORE /* FhG: zero out all relevant imdct buffers in MCT decoding of channels with mct_chan_mode == MCT_CHAN_MODE_IGNORE */ -#define NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING +#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 */ #define NONBE_1199_OMASA_JBM_BRATE_SW_FLUSH /* VA: issue 1199: fix bug in renderer flush in OMASA JBM bitrate switching */ #define NONBE_1200_ISM_JBM_BRATE_SW_FLUSH /* VA: issue 1200: fix bug in renderer flush in ISM JBM bitrate switching */ -- GitLab