From f63c4d02e90491a20af9848610d0f08f2d38c741 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Dec 2022 18:02:59 +0100 Subject: [PATCH 1/3] Issue 265: fix use-of-uninitialized-value in MC bitrate switching; under FIX_265_MC_BRATE_SWITCHING --- lib_com/options.h | 2 +- lib_dec/ivas_corecoder_dec_reconfig.c | 6 ++++++ lib_dec/ivas_stereo_switching_dec.c | 8 ++++++++ lib_enc/ivas_stereo_switching_enc.c | 14 ++++++++++---- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5bf0435c0c..871157993c 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -157,7 +157,7 @@ #define SIMPLIFY_TD_BWE_RESET /* Issue 250: Resolve "TB-BWE state memories reset simplification" */ #define REMOVE_ETOT_PROPAGATION /* Issue 251: Do not propagate Etot parameter */ #define MC_JBM /* FhG: extend JBM beyond mono for running IVAS in VoIP mode (contribution 19) */ - +#define FIX_265_MC_BRATE_SWITCHING /* Issue 265: fix use-of-uninitialized-value in MC bitrate switching */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 04dc4cccfc..8b29d9c785 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -244,6 +244,12 @@ ivas_error ivas_corecoder_dec_reconfig( for ( ; cpe_id < st_ivas->nCPE; cpe_id++ ) { #ifdef MC_BITRATE_SWITCHING +#ifdef FIX_265_MC_BRATE_SWITCHING + if ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hOutSetup.separateChannelEnabled ) + { + st_ivas->element_mode_init = IVAS_CPE_MDCT; + } +#endif if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) #else if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index b04cae97a9..569818760a 100755 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -40,6 +40,9 @@ #include "prot.h" #include "ivas_prot.h" #include "ivas_rom_com.h" +#ifdef FIX_265_MC_BRATE_SWITCHING +#include "assert.h" +#endif #include "wmc_auto.h" #include @@ -354,6 +357,11 @@ ivas_error stereo_memory_dec( error = IVAS_ERR_OK; +#ifdef FIX_265_MC_BRATE_SWITCHING + assert( hCPE->last_element_mode > IVAS_CPE_DFT ); +#endif + + hCPE->hCoreCoder[0]->element_mode = hCPE->element_mode; hCPE->hCoreCoder[1]->element_mode = hCPE->element_mode; diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 75c62cfba9..5352e8f4fb 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -32,16 +32,18 @@ #include #include "options.h" -#ifdef DEBUGGING -#include "debug.h" -#endif #include "cnst.h" #include "rom_com.h" #include "prot.h" #include "ivas_prot.h" #include "ivas_rom_com.h" +#ifdef FIX_265_MC_BRATE_SWITCHING +#include "assert.h" +#endif #include "wmc_auto.h" - +#ifdef DEBUGGING +#include "debug.h" +#endif /*-------------------------------------------------------------------* * Function allocate_CoreCoder_enc() @@ -231,6 +233,10 @@ ivas_error stereo_memory_enc( error = IVAS_ERR_OK; +#ifdef FIX_265_MC_BRATE_SWITCHING + assert( hCPE->last_element_mode > IVAS_CPE_DFT ); +#endif + /*--------------------------------------------------------------* * save parameters from structures that will be freed *---------------------------------------------------------------*/ -- GitLab From 17aff08398f1f2388e67d1ef6dd8442207d4b8b1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Dec 2022 18:05:21 +0100 Subject: [PATCH 2/3] add explanation print-out --- lib_dec/ivas_stereo_switching_dec.c | 2 +- lib_enc/ivas_stereo_switching_enc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 569818760a..4ba5c69598 100755 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -358,7 +358,7 @@ ivas_error stereo_memory_dec( error = IVAS_ERR_OK; #ifdef FIX_265_MC_BRATE_SWITCHING - assert( hCPE->last_element_mode > IVAS_CPE_DFT ); + assert( hCPE->last_element_mode > IVAS_CPE_DFT && "Switching from SCE to CPE is not a valid configuration!" ); #endif diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 5352e8f4fb..6caff93cde 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -234,7 +234,7 @@ ivas_error stereo_memory_enc( error = IVAS_ERR_OK; #ifdef FIX_265_MC_BRATE_SWITCHING - assert( hCPE->last_element_mode > IVAS_CPE_DFT ); + assert( hCPE->last_element_mode > IVAS_CPE_DFT && "Switching from SCE to CPE is not a valid configuration!" ); #endif /*--------------------------------------------------------------* -- GitLab From 07244161d1a061ae488d1461bfd2322329d7b17c Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 23 Dec 2022 18:20:26 +0100 Subject: [PATCH 3/3] correct the assert condition --- lib_dec/ivas_stereo_switching_dec.c | 2 +- lib_enc/ivas_stereo_switching_enc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 4ba5c69598..165d7dc896 100755 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -358,7 +358,7 @@ ivas_error stereo_memory_dec( error = IVAS_ERR_OK; #ifdef FIX_265_MC_BRATE_SWITCHING - assert( hCPE->last_element_mode > IVAS_CPE_DFT && "Switching from SCE to CPE is not a valid configuration!" ); + assert( hCPE->last_element_mode >= IVAS_CPE_DFT && "Switching from SCE to CPE is not a valid configuration!" ); #endif diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 6caff93cde..8f39a1f15d 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -234,7 +234,7 @@ ivas_error stereo_memory_enc( error = IVAS_ERR_OK; #ifdef FIX_265_MC_BRATE_SWITCHING - assert( hCPE->last_element_mode > IVAS_CPE_DFT && "Switching from SCE to CPE is not a valid configuration!" ); + assert( hCPE->last_element_mode >= IVAS_CPE_DFT && "Switching from SCE to CPE is not a valid configuration!" ); #endif /*--------------------------------------------------------------* -- GitLab