diff --git a/lib_com/options.h b/lib_com/options.h index 8eabb752669c2394428f3a67503bcbe7fc344aea..50743d32d79c024f1c349ed80a45a5a01307cd0f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -173,6 +173,7 @@ #define NONBE_FIX_904_JBM_SBA_RS_FOA /* FhG: issue #904: fix JBM SBA RS to FOA decoding */ #define NONBE_FIX_898_ISM_BRATE_CRASH /* VA: issue 898: fix decoder crash in ISM bitrate switching with DTX and binaural output */ #define NONBE_FIX_862_UBSAN_SPAR_DEC_BR_SW_PLC /* DLB: issue 862 : UBSAN: out-of-bound error in SPAR for OSBA bitrate switching with PLC*/ +#define NONBE_FIX_DISCRETE_ISM_NOISE_SEED_HANDLING /* FhG: fix handling of common and differing noise seeds in SCEs for ISM DTX */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 5e36f024f8507f402390b9863c88408ffbc90bb3..348cfd1227746158a630aebf6f3f9669431d7eab 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1104,10 +1104,17 @@ void generate_comfort_noise_dec( c2 = (float) sqrt( 1 - hFdCngCom->coherence ); seed2 = &( hFdCngCom->seed2 ); +#ifdef NONBE_FIX_DISCRETE_ISM_NOISE_SEED_HANDLING + if ( st->element_mode == IVAS_CPE_MDCT && st->idchan == 1 ) + { + seed2 = &( hFdCngCom->seed3 ); + } +#else if ( ( st->element_mode == IVAS_CPE_MDCT && st->idchan == 1 ) || ( st->element_mode == IVAS_SCE && st->cng_ism_flag ) ) { seed2 = &( hFdCngCom->seed3 ); } +#endif /* Generate Gaussian random noise in real and imaginary parts of the FFT bins Amplitudes are adjusted to the estimated noise level cngNoiseLevel in each bin */ @@ -1354,11 +1361,16 @@ void generate_comfort_noise_dec_hf( float scale = CLDFB_SCALING / hFdCngCom->scalingFactor; int16_t *seed2 = &( hFdCngCom->seed ); + float tmp1, tmp2, c1 = 0.f, c2 = 0.f; if ( cng_coh_flag ) { +#ifdef NONBE_FIX_DISCRETE_ISM_NOISE_SEED_HANDLING + seed2 = &( hFdCngCom->seed2 ); +#else seed2 = &( hFdCngCom->seed3 ); +#endif c1 = (float) sqrt( hFdCngCom->coherence ); c2 = (float) sqrt( 1 - hFdCngCom->coherence ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 7c1d81b6b818fc3ff963b30a402722793063e321..a2e53ceb064b6750940bfe0b318fcd72f12db637 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1361,10 +1361,24 @@ ivas_error ivas_init_decoder( st_ivas->hISMDTX.sce_id_dtx = 0; +#ifdef NONBE_FIX_DISCRETE_ISM_NOISE_SEED_HANDLING + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3; + } + else if ( st_ivas->ism_mode == ISM_MODE_DISC ) + { + for ( sce_id = 0; sce_id < st_ivas->nSCE; ++sce_id ) + { + st_ivas->hSCE[sce_id]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = 2 + sce_id; + } + } +#else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st_ivas->hSCE[1]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2; } +#endif } else if ( st_ivas->ivas_format == SBA_FORMAT ) { diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 446b9aa9e42801cfabb7eebc8c75b07c19bcd5b4..1c53749d7bc3c893bb9cee027ba57f1717e8c9ab 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -154,6 +154,17 @@ ivas_error ivas_ism_dtx_dec( } } +#ifdef NONBE_FIX_DISCRETE_ISM_NOISE_SEED_HANDLING + /* synch common seed between SCEs */ + if ( st_ivas->ism_mode == ISM_MODE_DISC ) + { + for ( ch = 0; ch < nchan_ism; ++ch ) + { + st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed = st_ivas->hSCE[st_ivas->hISMDTX.sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed; + } + } +#endif + update_last_metadata( nchan_ism, st_ivas->hIsmMetaData, md_diff_flag ); st_ivas->hISMDTX.ism_dtx_hangover_cnt = 0;