From 15e944dd18434601add298938cd03fa97d145c0b Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 23 Jan 2023 21:14:13 +0100 Subject: [PATCH] issue 299 - fix Band-width switching issues in ISM format; under FIX_299_ISM_BWS --- lib_com/options.h | 2 ++ lib_dec/core_switching_dec.c | 6 +++++- lib_dec/init_dec.c | 3 +++ lib_dec/stat_dec.h | 3 +++ lib_dec/updt_dec.c | 2 ++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index da82759607..3664b450b9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,6 +156,8 @@ #define FIX_293_EXT_RENDERER_CLI /* FhG: Fix bugs in external renderer CLI */ #define FIX_268 /* Issue 268: Add low cost dry-run of memory analysis */ #define LOW_RATE_TRANS_FIX /* Eri: Fix for critical item during transitions */ +#define FIX_299_ISM_BWS /* VA: issue 299 - fix Band-width switching issues in ISM format */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 2d0e26b52c..8be04391a1 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -1039,7 +1039,11 @@ void bandwidth_switching_detect( { st->bws_cnt1 = 0; } - else if ( st->total_brate > ACELP_9k60 && st->last_core_brate < ACELP_9k60 && st->bwidth == SWB && st->last_bwidth == WB ) + else if ( st->total_brate > ACELP_9k60 && st->last_core_brate < ACELP_9k60 && st->bwidth == SWB && st->last_bwidth == WB +#ifdef FIX_299_ISM_BWS + && st->last_low_rate_mode == 0 +#endif + ) { st->bws_cnt1++; } diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index c1583eaf24..7714d85d57 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -107,6 +107,9 @@ ivas_error init_decoder( st->last_good = UNVOICED_CLAS; st->clas_dec = UNVOICED_CLAS; st->low_rate_mode = 0; +#ifdef FIX_299_ISM_BWS + st->last_low_rate_mode = 0; +#endif st->lp_gainp = 0.0f; st->lp_gainc = 0.0f; diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 9a42a00dd6..211b5ecb07 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -934,6 +934,9 @@ typedef struct Decoder_State int16_t ini_frame; /* initialization frames counter */ int16_t prev_coder_type; /* coding type of last frame */ int16_t low_rate_mode; /* low-rate mode flag */ +#ifdef FIX_299_ISM_BWS + int16_t last_low_rate_mode; /* previous frame low-rate mode flag */ +#endif /*----------------------------------------------------------------------------------* * ACELP core parameters diff --git a/lib_dec/updt_dec.c b/lib_dec/updt_dec.c index 22d309512a..042375054e 100644 --- a/lib_dec/updt_dec.c +++ b/lib_dec/updt_dec.c @@ -647,6 +647,8 @@ void updt_dec_common( st->last_bits_frame_nominal = st->bits_frame_nominal; } + st->last_low_rate_mode = st->low_rate_mode; + /*-----------------------------------------------------------------* * Increase the counter of initialization frames * Limit the max number of init. frames -- GitLab