From 0b3e8504945e6227c44833c4116e7e7dfa2d314a Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 25 Jul 2024 19:51:56 +0530 Subject: [PATCH] [3GPP-Issue #807] Fixes LTV Encoding crash issue observed for MASA DTX bitrate switching case --- lib_com/options.h | 1 + lib_dec/acelp_core_dec.c | 4 ++++ lib_dec/acelp_core_dec_fx.c | 4 ++++ lib_dec/acelp_core_dec_ivas_fx.c | 5 +++++ lib_enc/acelp_core_enc.c | 20 ++++++++++++++++++++ lib_enc/acelp_core_enc_fx.c | 5 +++++ 6 files changed, 39 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index d56b99de4..b9d043c2c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,6 +79,7 @@ #define NON_BE_1055_RESET_LP_MEMORIES /* VA: issue 1055: Correctly reset LP filter MA and AR memories in bitrate switching */ #define NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING /* VA: Add fix point bit allocation for special GSC mode such that float and fixed point have the same final bit allocation */ #define NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE /* VA: issue 1132: prevent division by extremely low energy value in SWB TBE */ +#define NON_BE_FIX_807_MASA_DTX_BRSW /* Nokia: adds fix to check existence of DTX encoder for secondary channel in TD mode */ /* #################### End FIXES switches ############################ */ diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index 61ff0b8c3..75c61452a 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -232,7 +232,11 @@ ivas_error acelp_core_dec( st->hGSCDec->Last_frame_ener = (float) MAX_32; } +#ifdef NON_BE_FIX_807_MASA_DTX_BRSW + if ( st->hFdCngDec != NULL && ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) ) +#else if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) ) +#endif { set_zero( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, FFTLEN ); set_zero( hStereoCng->olapBufferSynth22, FFTLEN ); diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 7fb5ff3bc..c0c0777e4 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -264,7 +264,11 @@ ivas_error acelp_core_dec_fx( move32(); } #ifdef IVAS_CODE +#ifdef NON_BE_FIX_807_MASA_DTX_BRSW + if ( st->hFdCngDec != NULL && ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) ) +#else if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) ) +#endif { set_zero( st->hFdCngDec->hFdCngCom->olapBufferSynth2, FFTLEN ); set_zero( hStereoCng->olapBufferSynth22, FFTLEN ); diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 62d6dc171..77c92e202 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -284,7 +284,12 @@ ivas_error acelp_core_dec_ivas_fx( test(); test(); test(); +#ifdef NON_BE_FIX_807_MASA_DTX_BRSW + test(); + IF( st->hFdCngDec != NULL && ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || st->last_core_brate == FRAME_NO_DATA ) ) +#else IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || st->last_core_brate == FRAME_NO_DATA ) ) +#endif { set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, FFTLEN ); set16_fx( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN ); diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index 6b95f3abf..fc418f652 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -414,7 +414,11 @@ ivas_error acelp_core_enc( * After inactive period, use the most up-to-date ISPs *-----------------------------------------------------------------*/ +#ifdef NON_BE_FIX_807_MASA_DTX_BRSW + if (st->hDtxEnc != NULL && (st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40)) +#else if ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) +#endif { mvr2r( st->hDtxEnc->lspCNG, st->lsp_old, M ); lsp2lsf( st->hDtxEnc->lspCNG, st->lsf_old, M, int_fs ); @@ -748,7 +752,11 @@ ivas_error acelp_core_enc( #if 0 floatToFixed_arr(st->lsp_old, st->lsp_old_fx, 15, M); +#ifdef NON_BE_FIX_807_MASA_DTX_BRSW + IF (st->hDtxEnc != NULL && (st->last_core_brate == FRAME_NO_DATA || EQ_32(st->last_core_brate, SID_2k40))) +#else IF(EQ_32(st->last_core_brate, FRAME_NO_DATA) || EQ_32(st->last_core_brate, SID_2k40)) +#endif { Copy(st->hDtxEnc->lspCNG_fx, st->lsp_old_fx, M); lsp2lsf_fx(st->hDtxEnc->lspCNG_fx, st->lsf_old_fx, M, int_fs); @@ -756,8 +764,12 @@ ivas_error acelp_core_enc( for (int i = 0; i < M; i++) { st->lsf_old[i] = st->lsf_old_fx[i] / 2.56; } +#else +#ifdef NON_BE_FIX_807_MASA_DTX_BRSW + if (st->hDtxEnc != NULL && (st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40)) #else if ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) +#endif { mvr2r( st->hDtxEnc->lspCNG, st->lsp_old, M ); lsp2lsf( st->hDtxEnc->lspCNG, st->lsf_old, M, int_fs ); @@ -1164,7 +1176,11 @@ ivas_error acelp_core_enc( * After inactive period, use the most up-to-date ISPs *-----------------------------------------------------------------*/ +#ifdef NON_BE_FIX_807_MASA_DTX_BRSW + if ( st->hDtxEnc != NULL && ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) ) +#else if ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) +#endif { mvr2r( st->hDtxEnc->lspCNG, st->lsp_old, M ); lsp2lsf( st->hDtxEnc->lspCNG, st->lsf_old, M, int_fs ); @@ -1838,7 +1854,11 @@ ivas_error acelp_core_enc( * After inactive period, use the most up-to-date ISPs *-----------------------------------------------------------------*/ +#ifdef NON_BE_FIX_807_MASA_DTX_BRSW + if ( st->hDtxEnc != NULL && ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) ) +#else if ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) +#endif { mvr2r( st->hDtxEnc->lspCNG, st->lsp_old, M ); lsp2lsf( st->hDtxEnc->lspCNG, st->lsf_old, M, int_fs ); diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index def676aa0..a21f4adbb 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -405,7 +405,12 @@ ivas_error acelp_core_enc_fx( *-----------------------------------------------------------------*/ test(); +#ifdef NON_BE_FIX_807_MASA_DTX_BRSW + test(); + IF( st_fx->hDtxEnc != NULL && ( st_fx->last_core_brate == FRAME_NO_DATA || EQ_32( st_fx->last_core_brate, SID_2k40 ) ) ) +#else IF( EQ_32( st_fx->last_core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->last_core_brate, SID_2k40 ) ) +#endif { Copy( hDtxEnc->lspCNG_fx, st_fx->lsp_old_fx, M ); -- GitLab