From 93e9b08092f722943815f6cad9ca86bf818330b0 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 24 Apr 2026 11:25:49 +0200 Subject: [PATCH 1/4] Temporary fix FIX_TMP_1559 to indicate problem --- lib_com/options.h | 1 + lib_dec/fd_cng_dec.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 1b2eded86..cdf78c9d5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -178,6 +178,7 @@ #define FIX_FLOAT_1573_POSITION_UPDATE /* Eri: Float issue 1573: For static orientation and listener movement, the PoseUpdated flag is cleared and prevents 5 ms update rate. */ #define FIX_1576_LCLD_CRASH_DIFFERENT_CODEC_ISAR_FRAME_SIZE /* Dolby: float issue 1576: fix for crash in LCLD mode when codec frame size is less than isar frame size */ #define FIX_1452_DEFAULT_REVERB /* Nokia/Philips/FhG: Fix default room presets and their usage in renderer */ +#define FIX_TMP_1559 /* Eri/FhG: Temporary fix for Issue 1559 in FD CNG with bitrate/bw switching */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index fef2ccdd7..542f36764 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -315,6 +315,13 @@ void configureFdCngDec( hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[j + hsCom->nFFTpart]; } +#ifdef FIX_TMP_1559 + if ( last_L_frame == L_FRAME && L_frame == L_FRAME16k && hFdCngDec->partNoiseShape[20] == 0 ) + { + hFdCngDec->partNoiseShape[20] = hFdCngDec->partNoiseShape[19]; + } +#endif + stopBandFR = (int16_t) floor( 1000.f /*Hz*/ / 25.f /*Hz/Bin*/ ); if ( stopBandFR > hsCom->stopFFTbin ) { -- GitLab From 161e303c80558912a28f61bae2f558874cea4469 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 28 Apr 2026 13:58:09 +0200 Subject: [PATCH 2/4] generalize fix --- lib_com/options.h | 2 +- lib_dec/fd_cng_dec.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index cdf78c9d5..1133f06ff 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -178,7 +178,7 @@ #define FIX_FLOAT_1573_POSITION_UPDATE /* Eri: Float issue 1573: For static orientation and listener movement, the PoseUpdated flag is cleared and prevents 5 ms update rate. */ #define FIX_1576_LCLD_CRASH_DIFFERENT_CODEC_ISAR_FRAME_SIZE /* Dolby: float issue 1576: fix for crash in LCLD mode when codec frame size is less than isar frame size */ #define FIX_1452_DEFAULT_REVERB /* Nokia/Philips/FhG: Fix default room presets and their usage in renderer */ -#define FIX_TMP_1559 /* Eri/FhG: Temporary fix for Issue 1559 in FD CNG with bitrate/bw switching */ +#define FIX_1559 /* Eri/FhG: fix for Issue 1559 in FD CNG with bitrate/bw switching */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 542f36764..d3a183f71 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -191,6 +191,9 @@ void configureFdCngDec( { int16_t j, stopBandFR; HANDLE_FD_CNG_COM hsCom = hFdCngDec->hFdCngCom; +#ifdef FIX_1559 + int16_t nFFTpart_prev; +#endif hsCom->CngBandwidth = bwidth; if ( hsCom->CngBandwidth == FB ) @@ -296,6 +299,10 @@ void configureFdCngDec( hsCom->startBand = 2; hsCom->stopBand = hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1] + 1; initPartitions( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_inv, 0 ); +#ifdef FIX_1559 + + nFFTpart_prev = hsCom->nFFTpart; +#endif if ( hsCom->stopFFTbin == 160 ) { hsCom->nFFTpart = 17; @@ -315,10 +322,13 @@ void configureFdCngDec( hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[j + hsCom->nFFTpart]; } -#ifdef FIX_TMP_1559 - if ( last_L_frame == L_FRAME && L_frame == L_FRAME16k && hFdCngDec->partNoiseShape[20] == 0 ) +#ifdef FIX_1559 + /* In case of going from a lower number of partitions to a higher number, initialize + the higher ines which might be zero and/or outdated with the highest partitions value + this avoids almost-zero values to linger around and causing signal bursts after switching to higher bitrate */ + for ( j = nFFTpart_prev; j < hsCom->nFFTpart; ++j ) { - hFdCngDec->partNoiseShape[20] = hFdCngDec->partNoiseShape[19]; + hFdCngDec->partNoiseShape[j] = hFdCngDec->partNoiseShape[nFFTpart_prev - 1]; } #endif -- GitLab From 302a1e30d35f3db8beedcd7cfeb3abbe4646c310 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 28 Apr 2026 15:12:12 +0200 Subject: [PATCH 3/4] don't apply the fix on init to avoid use of uninit values --- lib_com/fd_cng_com.c | 3 +++ lib_dec/fd_cng_dec.c | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 42004a208..7e3a09b18 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -118,6 +118,9 @@ void initFdCngCom( hFdCngCom->stopBand = 0; hFdCngCom->startBand = 0; hFdCngCom->stopFFTbin = 0; +#ifdef FIX_TMP_1559 + hFdCngCom->nFFTpart = 0; +#endif hFdCngCom->frameSize = 0; hFdCngCom->fftlen = 0; hFdCngCom->seed = 0; diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index d3a183f71..73ff86959 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -324,11 +324,15 @@ void configureFdCngDec( #ifdef FIX_1559 /* In case of going from a lower number of partitions to a higher number, initialize - the higher ines which might be zero and/or outdated with the highest partitions value - this avoids almost-zero values to linger around and causing signal bursts after switching to higher bitrate */ - for ( j = nFFTpart_prev; j < hsCom->nFFTpart; ++j ) + the higher ines which might be zero and/or outdated with the highest partitions value + this avoids almost-zero values to linger around and causing signal bursts after switching to higher bitrate. + Don't do this on initialization of the codec (nFFTpart_prev == 0)*/ + if ( nFFTpart_prev != 0 ) { - hFdCngDec->partNoiseShape[j] = hFdCngDec->partNoiseShape[nFFTpart_prev - 1]; + for ( j = nFFTpart_prev; j < hsCom->nFFTpart; ++j ) + { + hFdCngDec->partNoiseShape[j] = hFdCngDec->partNoiseShape[nFFTpart_prev - 1]; + } } #endif -- GitLab From 335054bd653ab9a7e3a189e1bd67ede9f41bbbd3 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 28 Apr 2026 16:25:08 +0200 Subject: [PATCH 4/4] fix typo in define name --- lib_com/fd_cng_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 7e3a09b18..dd2d6e741 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -118,7 +118,7 @@ void initFdCngCom( hFdCngCom->stopBand = 0; hFdCngCom->startBand = 0; hFdCngCom->stopFFTbin = 0; -#ifdef FIX_TMP_1559 +#ifdef FIX_1559 hFdCngCom->nFFTpart = 0; #endif hFdCngCom->frameSize = 0; -- GitLab