From c315f4d62ba08043d46aeb861449bdc77a28eb92 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Wed, 13 Sep 2023 15:18:55 +0200 Subject: [PATCH 1/5] fix for MSAN issue 778 for TNS in unified stereo --- lib_com/options.h | 2 +- lib_enc/ivas_tcx_core_enc.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7b42e8dfa3..704094be72 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -194,7 +194,7 @@ #define NONBE_FIX_ISM_DTX_INFINITE_CNG_ON_TRAILING_SILENCE /* FhG: fix for cng in ISM DTX on sudden silence periods - JBM addon (issue 552) */ #define NONBE_FIX_738_SBA_BR_SW_ASAN /* FhG: issue 738: fixes bug when switching to an MCT bitrate and previous frame was ACELP */ #define NONBE_CR_FIX_735_SBA_HP20_BRATE_SWITCHING /* VA: Issue 735: Resolve "HP20 filtering bug in SBA/OSBA bitrate switching" */ - +#define NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN /* FhG: Issue 778: MSAN error due to uninitialized TNS configuration */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 7bcd80301a..747906c3e1 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -54,6 +54,9 @@ void stereo_tcx_init_enc( Encoder_State *st /* i/o: encoder state structure */ ) { +#ifdef NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN + int16_t prev_IsTNSAllowed; +#endif assert( st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA ); /* Get the raw coder type from signal analysis*/ @@ -100,11 +103,21 @@ void stereo_tcx_init_enc( st->hTcxCfg->resq = getResq( st->bits_frame_nominal * FRAMES_PER_SEC ); st->hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->bits_frame_nominal * FRAMES_PER_SEC, st->rf_mode, st->element_mode ); st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_mode ); +#ifdef NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN + prev_IsTNSAllowed = st->hTcxCfg->fIsTNSAllowed; +#endif if ( st->element_mode != EVS_MONO ) { st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode ); } +#ifdef NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN + if ( !prev_IsTNSAllowed && st->hTcxCfg->fIsTNSAllowed && st->element_mode == IVAS_CPE_DFT ) /*may happen in unified stereo when switching stereo technologies */ + { + InitTnsConfigs( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->bits_frame_nominal * FRAMES_PER_SEC, st->element_mode, 0 ); + SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, 0 ); + } +#endif st->core_brate = st->total_brate; return; -- GitLab From c151fe30b28a7fbc9226ca84e40ce4ebe4bddea4 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Wed, 13 Sep 2023 15:54:40 +0200 Subject: [PATCH 2/5] compliment fix at decoder side --- lib_dec/ivas_tcx_core_dec.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index f40b313125..f7d8b3608c 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -67,10 +67,16 @@ void stereo_tcx_init_dec( { TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; TCX_DEC_HANDLE hTcxDec = st->hTcxDec; +#if 1 + int16_t prev_fIsTNSAllowed; +#endif st->rate_switching_init = 0; st->m_frame_type = ACTIVE_FRAME; st->core_brate = st->total_brate; +#if 1 + prev_fIsTNSAllowed = st->hTcxCfg->fIsTNSAllowed; +#endif /*sampling rate*/ st->sr_core = getCoreSamplerateMode2( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format ); @@ -95,11 +101,19 @@ void stereo_tcx_init_dec( hTcxDec->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->bits_frame_nominal * FRAMES_PER_SEC, st->rf_flag, st->element_mode ); st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag ); - if ( - st->element_mode != EVS_MONO ) + if ( st->element_mode != EVS_MONO ) { st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode ); } + +#if 1 + if ( !prev_fIsTNSAllowed && st->hTcxCfg->fIsTNSAllowed && st->element_mode == IVAS_CPE_DFT ) + { + InitTnsConfigs( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, st->bits_frame_nominal * FRAMES_PER_SEC, st->element_mode, MCT_flag ); + + SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, 0 ); + } +#endif if ( hTcxLtpDec != NULL ) { hTcxLtpDec->tcxltp = getTcxLtp( st->sr_core ); -- GitLab From e1681e272be9933a92a54f6e2fe87f7f40e46821 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Wed, 13 Sep 2023 15:57:21 +0200 Subject: [PATCH 3/5] replace #1 with defines --- lib_dec/ivas_tcx_core_dec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index f7d8b3608c..79ca02c6b6 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -67,14 +67,14 @@ void stereo_tcx_init_dec( { TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; TCX_DEC_HANDLE hTcxDec = st->hTcxDec; -#if 1 +#ifdef NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN int16_t prev_fIsTNSAllowed; #endif st->rate_switching_init = 0; st->m_frame_type = ACTIVE_FRAME; st->core_brate = st->total_brate; -#if 1 +#ifdef NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN prev_fIsTNSAllowed = st->hTcxCfg->fIsTNSAllowed; #endif @@ -106,7 +106,7 @@ void stereo_tcx_init_dec( st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode ); } -#if 1 +#ifdef NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN if ( !prev_fIsTNSAllowed && st->hTcxCfg->fIsTNSAllowed && st->element_mode == IVAS_CPE_DFT ) { InitTnsConfigs( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, st->bits_frame_nominal * FRAMES_PER_SEC, st->element_mode, MCT_flag ); -- GitLab From 1d5766ab62085431b1b2d307a6cac8366a3fad90 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 14 Sep 2023 10:20:00 +0200 Subject: [PATCH 4/5] revert changes at decoder side --- lib_dec/ivas_tcx_core_dec.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 79ca02c6b6..f40b313125 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -67,16 +67,10 @@ void stereo_tcx_init_dec( { TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; TCX_DEC_HANDLE hTcxDec = st->hTcxDec; -#ifdef NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN - int16_t prev_fIsTNSAllowed; -#endif st->rate_switching_init = 0; st->m_frame_type = ACTIVE_FRAME; st->core_brate = st->total_brate; -#ifdef NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN - prev_fIsTNSAllowed = st->hTcxCfg->fIsTNSAllowed; -#endif /*sampling rate*/ st->sr_core = getCoreSamplerateMode2( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format ); @@ -101,19 +95,11 @@ void stereo_tcx_init_dec( hTcxDec->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->bits_frame_nominal * FRAMES_PER_SEC, st->rf_flag, st->element_mode ); st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag ); - if ( st->element_mode != EVS_MONO ) + if ( + st->element_mode != EVS_MONO ) { st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode ); } - -#ifdef NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN - if ( !prev_fIsTNSAllowed && st->hTcxCfg->fIsTNSAllowed && st->element_mode == IVAS_CPE_DFT ) - { - InitTnsConfigs( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, st->bits_frame_nominal * FRAMES_PER_SEC, st->element_mode, MCT_flag ); - - SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, 0 ); - } -#endif if ( hTcxLtpDec != NULL ) { hTcxLtpDec->tcxltp = getTcxLtp( st->sr_core ); -- GitLab From 6aa10942a10814079a5229b8b3a5af02660e4f1d Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 14 Sep 2023 10:20:25 +0200 Subject: [PATCH 5/5] formatting --- lib_dec/ivas_tcx_core_dec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index f40b313125..71e20a5df7 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -95,8 +95,7 @@ void stereo_tcx_init_dec( hTcxDec->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->bits_frame_nominal * FRAMES_PER_SEC, st->rf_flag, st->element_mode ); st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag ); - if ( - st->element_mode != EVS_MONO ) + if ( st->element_mode != EVS_MONO ) { st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode ); } -- GitLab