diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 42004a208ebda01d63fc248ba2dcb8aff783ec6c..dd2d6e7413777af7224a8118d0e7489780222834 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_1559 + hFdCngCom->nFFTpart = 0; +#endif hFdCngCom->frameSize = 0; hFdCngCom->fftlen = 0; hFdCngCom->seed = 0; diff --git a/lib_com/options.h b/lib_com/options.h index 23a486e6b9d11d3b9f679f58bbd305e5cada2bf6..bc8a6178edd199c9193a53888bed9fded6ea2b3d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -184,6 +184,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_1559 /* Eri/FhG: fix for Issue 1559 in FD CNG with bitrate/bw switching */ #define FIX_FMSW_DEC /* float issue 1542: fix JBM issue in format switching */ #define FIX_FMSW_DEC_2 /* float issue 1575: fix crash for format switching when bitsream starts with EVS */ #define FIX_1548_HARMONIZE_NON_DIEGETIC_PANNING_LAW /* Orange: float issue 1548: Harmonize non diegetic panning law in ISM and renderers */ diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index fef2ccdd7413012a6d8cd567cc2dbe6d8cedcbc2..73ff86959eac3f61bfe4624459fc16af0ae90a1a 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,6 +322,20 @@ void configureFdCngDec( hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[j + hsCom->nFFTpart]; } +#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. + Don't do this on initialization of the codec (nFFTpart_prev == 0)*/ + if ( nFFTpart_prev != 0 ) + { + for ( j = nFFTpart_prev; j < hsCom->nFFTpart; ++j ) + { + hFdCngDec->partNoiseShape[j] = hFdCngDec->partNoiseShape[nFFTpart_prev - 1]; + } + } +#endif + stopBandFR = (int16_t) floor( 1000.f /*Hz*/ / 25.f /*Hz/Bin*/ ); if ( stopBandFR > hsCom->stopFFTbin ) {