From 8d829881983ed9ee7552b7de7fd4a625ee623e02 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Nov 2023 11:20:01 +0100 Subject: [PATCH 1/3] issue 898: fix decoder crash in ISM bitrate switching with DTX and binaural output; under NONBE_FIX_898_ISM_BRATE_CRASH --- lib_com/options.h | 1 + lib_dec/ivas_init_dec.c | 23 +++++++++++++++++++++++ lib_dec/ivas_ism_dtx_dec.c | 4 ++++ 3 files changed, 28 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index f44ad78c49..6608c4fd31 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -165,6 +165,7 @@ #define NONBE_FIX_871_ACELP_CRASH_IN_OSBA /* FhG: isse 871: crash in ACELP core encoder with OSBA */ #define NONBE_FIX_225_MASA_EXT_REND /* Nokia: Resolve #225: Complete MASA external renderer implementation */ #define NONBE_FIX_897_USAN_WITH_MASA_RENDERING /* Nokia: issue #897: USAN null pointer in MASA external renderer to Ambisonics */ +#define NONBE_FIX_898_ISM_BRATE_CRASH /* VA: issue 898: fix decoder crash in ISM bitrate switching with DTX and binaural output */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index d9e32229c8..2001301be7 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -636,8 +636,16 @@ ivas_error ivas_dec_setup( } } +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + if ( st_ivas->ivas_format == ISM_FORMAT ) +#else if ( st_ivas->ini_frame == 0 && st_ivas->ivas_format == ISM_FORMAT ) +#endif { +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + ISM_MODE last_ism_mode = st_ivas->ism_mode; +#endif + /* read the number of objects */ st_ivas->nchan_transport = 1; nchan_ism = 1; @@ -660,10 +668,25 @@ ivas_error ivas_dec_setup( st_ivas->ism_mode = (ISM_MODE) ( idx + 1 ); } +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + if ( st_ivas->ini_frame == 0 ) + { + last_ism_mode = st_ivas->ism_mode; + } +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif #endif { return error; diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 8899696bec..50f2ee39c3 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -86,6 +86,9 @@ ivas_error ivas_ism_dtx_dec( last_ism_mode = st_ivas->ism_mode; +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + /* ism_mode was read in ivas_dec_setup() as well as reconfiguration ivas_ism_dec_config() */ +#else /* read ism_mode */ if ( nchan_ism > 2 ) { @@ -104,6 +107,7 @@ ivas_error ivas_ism_dtx_dec( { return error; } +#endif } else { -- GitLab From ec5d8afa97f44c475f1f81b48f0d23cd0d02cc47 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Nov 2023 11:40:12 +0100 Subject: [PATCH 2/3] extend NONBE_FIX_898_ISM_BRATE_CRASH to further simplify the function ivas_ism_dtx_dec() --- lib_com/ivas_prot.h | 4 ++++ lib_dec/ivas_dec.c | 4 ++++ lib_dec/ivas_init_dec.c | 7 +++++++ lib_dec/ivas_ism_dtx_dec.c | 25 ++++++++++++++++++++++--- lib_dec/ivas_jbm_dec.c | 4 ++++ 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c796afaecc..b493bf4240 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1154,7 +1154,11 @@ int16_t ivas_ism_dtx_enc( int16_t *sid_flag /* o : indication of SID frame */ ); +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH +void ivas_ism_dtx_dec( +#else ivas_error ivas_ism_dtx_dec( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ int16_t *nb_bits_metadata /* o : number of metadata bits */ ); diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 04a0cf6b20..5756abef22 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -172,10 +172,14 @@ ivas_error ivas_dec( /* Metadata decoding and configuration */ if ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) { +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ); +#else if ( ( error = ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) { return error; } +#endif /* decode dominant object first so the noise energy of the other objects can be limited */ if ( ( error = ivas_sce_dec( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 2001301be7..9aa17a9ce4 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -657,6 +657,13 @@ ivas_error ivas_dec_setup( } k--; +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + if ( nchan_ism != st_ivas->nchan_ism ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" ); + } +#endif + st_ivas->nchan_ism = nchan_ism; /* read ism_mode */ diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 50f2ee39c3..446b9aa9e4 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -47,17 +47,29 @@ * ISM DTX Metadata decoding routine *-------------------------------------------------------------------*/ +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH +void ivas_ism_dtx_dec( +#else ivas_error ivas_ism_dtx_dec( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ int16_t *nb_bits_metadata /* o : number of metadata bits */ ) { +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + int16_t ch, nchan_ism, nchan_ism_prev; +#else int16_t ch, pos, nchan_ism, nchan_ism_prev; +#endif int32_t ivas_total_brate; int16_t md_diff_flag[MAX_NUM_OBJECTS]; +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + int16_t flag_noisy_speech, sce_id_dtx; +#else int16_t idx, flag_noisy_speech, sce_id_dtx; ISM_MODE last_ism_mode, ism_mode_bstr; ivas_error error; +#endif Decoder_State *st; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -67,6 +79,12 @@ ivas_error ivas_ism_dtx_dec( if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 ) { +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + /* 'nchan_ism' was read in ivas_dec_setup() */ + nchan_ism = st_ivas->nchan_ism; + + /* ism_mode was read in ivas_dec_setup() as well as reconfiguration ivas_ism_dec_config() */ +#else /* read number of objects */ nchan_ism = 1; pos = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 - SID_FORMAT_NBITS ); @@ -86,9 +104,6 @@ ivas_error ivas_ism_dtx_dec( last_ism_mode = st_ivas->ism_mode; -#ifdef NONBE_FIX_898_ISM_BRATE_CRASH - /* ism_mode was read in ivas_dec_setup() as well as reconfiguration ivas_ism_dec_config() */ -#else /* read ism_mode */ if ( nchan_ism > 2 ) { @@ -163,7 +178,11 @@ ivas_error ivas_ism_dtx_dec( } } +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + return; +#else return IVAS_ERR_OK; +#endif } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 9229336f78..6f37693cc3 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -143,10 +143,14 @@ ivas_error ivas_jbm_dec_tc( /* Metadata decoding and configuration */ if ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) { +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ); +#else if ( ( error = ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) { return error; } +#endif /* decode dominant object first so the noise energy of the other objects can be limited */ if ( ( error = ivas_sce_dec( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) -- GitLab From 58b4cf71865e1a2c1ff6c1d178652b5cf6ed17d7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Nov 2023 12:32:51 +0100 Subject: [PATCH 3/3] fix first frame SID case --- lib_dec/ivas_init_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 9aa17a9ce4..ea60e71a2f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -658,7 +658,7 @@ ivas_error ivas_dec_setup( k--; #ifdef NONBE_FIX_898_ISM_BRATE_CRASH - if ( nchan_ism != st_ivas->nchan_ism ) + if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" ); } -- GitLab