diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 4975876357e8d2d973ec5cb7168406626378e000..9b13274d8799938f6a6f7df8da87d0eadf8629e9 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -112,6 +112,10 @@ void initFdCngCom( move16(); hFdCngCom->stopFFTbin = 0; move16(); +#ifdef FIX_1559 + hFdCngCom->nFFTpart = 0; + move16(); +#endif hFdCngCom->frameSize = 0; move16(); hFdCngCom->fftlen = 0; diff --git a/lib_com/options.h b/lib_com/options.h index 66f09059ca958bd8b4fc18c56496f0ec814319f0..0d3c1fa93ae22bd5693c752dd96248ce04339906 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,6 +155,7 @@ #define FIX_BASOP_2559_Q_SYNTH_HISTORY_RESET /* FhG: BASOP issue 2559: reset hTcxDec->q_synth_history_fx in allocate_CoreCoder_TCX_fx() */ #define FIX_FLOAT_1578_OMASA_REND_SPIKES /* Nokia: Float issue 1578: Fix spikes and collapsed perception in OMASA/MASA rendering to FOA/HOA */ #define FIX_1521_SBA_LOUDNESS_STEREO /* FhG: issue 1521: Fix loudness for SBA to stereo rendering */ +#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_fx.c b/lib_dec/fd_cng_dec_fx.c index 5fced60ad842dcbd8c5b13e0d8860e319e0352dd..6f4363229c6ae7d31467862e636aed6eada94e37 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -4155,6 +4155,9 @@ void configureFdCngDec_ivas_fx( { Word16 j, stopBandFR; HANDLE_FD_CNG_COM hsCom = hFdCngDec->hFdCngCom; +#ifdef FIX_1559 + Word16 nFFTpart_prev; +#endif hsCom->CngBandwidth = bwidth; /*Q0*/ move16(); @@ -4289,6 +4292,10 @@ void configureFdCngDec_ivas_fx( hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[( hsCom->FdCngSetup.numPartitions - 1 )], 1 ); /*Q0*/ initPartitions( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0 ); +#ifdef FIX_1559 + nFFTpart_prev = hsCom->nFFTpart; + move16(); +#endif IF( EQ_16( hsCom->stopFFTbin, 160 ) ) { hsCom->nFFTpart = 17; @@ -4314,6 +4321,21 @@ void configureFdCngDec_ivas_fx( move16(); } +#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( NE_16( nFFTpart_prev, 0 ) ) + { + FOR( j = nFFTpart_prev; j < hsCom->nFFTpart; ++j ) + { + hFdCngDec->partNoiseShape[j] = hFdCngDec->partNoiseShape[nFFTpart_prev - 1]; + move16(); + } + } +#endif + stopBandFR = 40; //(Word16)floor(1000.f /*Hz*/ / 25.f /*Hz/Bin*/); move16(); if ( GT_16( stopBandFR, hsCom->stopFFTbin ) )