From 2eb26e382b80b3b2521c2bd405d16a3155088988 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 4 Dec 2025 11:25:48 +0100 Subject: [PATCH] Add FIX_1461_CNG_BW_SWITCHING to address BW switching in Stereo CNG --- lib_com/options.h | 2 +- lib_enc/ivas_cpe_enc_fx.c | 9 +++++++++ lib_enc/ivas_stereo_dft_enc_fx.c | 11 +++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1a7b596d5..6ad55f796 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,7 +96,7 @@ #define FIX_2015_PREMPH_SAT_ALT_PART2 /* VA: Add missing scaling factor to be passed to AVQ_cod() */ #define FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH /* VA: Fix Issue 2253 where the encoder and decoder could get out of sync */ #define NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES /* Dolby: Fix basop issue 1967 */ - +#define FIX_1461_CNG_BW_SWITCHING /* Eri: float issue 1461: Stereo parameters are not updated when SID/NODATA forces BW to stay the same */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 033e13034..4aea3ff61 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -130,6 +130,9 @@ ivas_error ivas_cpe_enc_fx( Word16 old_wsp_fx[CPE_CHANNELS][L_WSP]; Word16 e_old_wsp[CPE_CHANNELS], q_old_wsp; Word16 Q_new[CPE_CHANNELS] = { 0 }; +#ifdef FIX_1461_CNG_BW_SWITCHING + Word16 NFFT_inner; +#endif move16(); move16(); Word16 q_com, shift, q_min, gb; @@ -1124,6 +1127,12 @@ ivas_error ivas_cpe_enc_fx( IF( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA ) { /* Reconfigure DFT Stereo for inactive frames */ +#ifdef FIX_1461_CNG_BW_SWITCHING + /* -- nbands may need to be updated here in case the bandwidth was changed due to inactive frames */ + NFFT_inner = shl( inner_frame_tbl[sts[0]->bwidth], 1 ); + hCPE->hStereoDft->nbands = stereo_dft_band_config_fx( hCPE->hStereoDft->band_limits, hCPE->hStereoDft->hConfig->band_res, NFFT_inner, ENC ); + move16(); +#endif IF( EQ_32( sts[0]->core_brate, SID_2k40 ) ) { stereo_dft_config_fx( hConfigDft, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index e5522fb37..5f78defdd 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -3853,6 +3853,17 @@ static void stereo_dft_enc_compute_prm_fx( hStereoDft->nrg_past_pos = ( pos + 1 ) % STEREO_DFT_NRG_PAST_LEN; move16(); +#ifdef FIX_1461_CNG_BW_SWITCHING + /* Replicate last band for remaining bands in case the bandwidth is higher after SID/NODATA is considered */ + FOR( i = hStereoDft->nbands; i < STEREO_DFT_BAND_MAX; i++ ) + { + pPredGain[i] = pPredGain[i - 1]; + move32(); + pSideGain[i] = pSideGain[i - 1]; + move32(); + } +#endif + /*------------------------------------------------------------------* * Compute IPDs -- GitLab