From c6fdb542d08b51d1d7c8fe8b527f8c96a1c2f2f8 Mon Sep 17 00:00:00 2001 From: Tommy Date: Fri, 8 Jul 2022 11:05:09 -0400 Subject: [PATCH 1/2] Update from main -- GitLab From bc579bf3f6845780d99504a65eff3771214a5fb7 Mon Sep 17 00:00:00 2001 From: Tommy Date: Fri, 8 Jul 2022 12:54:38 -0400 Subject: [PATCH 2/2] [Fix-038] Fix a potential decoder crash during frame lost --- lib_com/options.h | 2 ++ lib_dec/ivas_cpe_dec.c | 9 ++++++++- lib_enc/ivas_cpe_enc.c | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5dc02362a4..9b4fb901db 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -157,6 +157,8 @@ #define SBA_CLEANING /* SBA maintenance related to ticket #45 */ +#define FIX_038_TV_FIX_DEC_CRASH_DURING_FEC /* IVAS-038 Fixed potential decoder crash on frame lost, due to loss of synchronisation between encoder and decoder */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index cf0d5b508d..19c1ad43fb 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -75,7 +75,9 @@ ivas_error ivas_cpe_dec( float res_buf[STEREO_DFT_N_8k]; CPE_DEC_HANDLE hCPE; Decoder_State **sts; +#ifndef FIX_038_TV_FIX_DEC_CRASH_DURING_FEC int16_t last_tdm_LRTD_flag; +#endif int32_t ivas_total_brate; ivas_error error; @@ -94,12 +96,13 @@ ivas_error ivas_cpe_dec( sts[0]->BER_detect |= st_ivas->BER_detect; sts[1]->BER_detect |= st_ivas->BER_detect; +#ifndef FIX_038_TV_FIX_DEC_CRASH_DURING_FEC last_tdm_LRTD_flag = 0; if ( hCPE->hStereoTD != NULL ) { last_tdm_LRTD_flag = hCPE->hStereoTD->tdm_LRTD_flag; } - +#endif /*------------------------------------------------------------------* * Read stereo technology info & audio bandwidth *-----------------------------------------------------------------*/ @@ -186,7 +189,11 @@ ivas_error ivas_cpe_dec( } } +#ifdef FIX_038_TV_FIX_DEC_CRASH_DURING_FEC + if ( hCPE->element_mode == IVAS_CPE_TD ) +#else if ( hCPE->element_mode == IVAS_CPE_TD && last_tdm_LRTD_flag != hCPE->hStereoTD->tdm_LRTD_flag ) +#endif { if ( hCPE->hStereoTD->tdm_LRTD_flag ) { diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index e4e383e2e1..1fabe9ddac 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -87,7 +87,11 @@ ivas_error ivas_cpe_enc( float currFlatness[CPE_CHANNELS]; /* flatness parameter */ float fft_buff[CPE_CHANNELS][2 * L_FFT]; /* FFT buffer */ int16_t tdm_ratio_idx, tdm_ratio_idx_SM; /* temp. TD stereo parameters */ +#ifdef FIX_038_TV_FIX_DEC_CRASH_DURING_FEC + int16_t tdm_SM_or_LRTD_Pri; /* temp. TD stereo parameters */ +#else int16_t tdm_SM_or_LRTD_Pri, last_tdm_LRTD_flag; /* temp. TD stereo parameters */ +#endif float tdm_last_ratio; /* temp. TD stereo parameters */ int16_t nb_bits; /* number of DFT stereo side bits */ float fr_bands[CPE_CHANNELS][2 * NB_BANDS]; /* energy in frequency bands */ @@ -121,16 +125,19 @@ ivas_error ivas_cpe_enc( *-----------------------------------------------------------------*/ tdm_SM_or_LRTD_Pri = 0; +#ifndef FIX_038_TV_FIX_DEC_CRASH_DURING_FEC last_tdm_LRTD_flag = 0; +#endif tdm_ratio_idx = -1; tdm_ratio_idx_SM = -1; tdm_last_ratio = 0; +#ifndef FIX_038_TV_FIX_DEC_CRASH_DURING_FEC if ( hCPE->hStereoTD != NULL ) { last_tdm_LRTD_flag = hCPE->hStereoTD->tdm_LRTD_flag; } - +#endif #ifdef DEBUGGING if ( hCPE->hCoreCoder[0]->ini_frame == 0 ) { @@ -283,8 +290,11 @@ ivas_error ivas_cpe_enc( stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } } - +#ifdef FIX_038_TV_FIX_DEC_CRASH_DURING_FEC + if ( hCPE->element_mode == IVAS_CPE_TD ) +#else if ( hCPE->element_mode == IVAS_CPE_TD && last_tdm_LRTD_flag != hCPE->hStereoTD->tdm_LRTD_flag ) +#endif { if ( hCPE->hStereoTD->tdm_LRTD_flag ) { -- GitLab