diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6f4d27d5e8123c075c32130532cea576ccd91fec..f84e162c45d7585002c4e14f84409c1010af0a5e 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4089,6 +4089,9 @@ ivas_error ivas_spar_md_dec_open( const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ const int16_t num_channels, /* i : number of internal channels */ const int16_t sba_order /* i : SBA order */ +#ifdef SBA_BR_SWITCHING_RECONFIG + ,const int16_t sid_format +#endif ); void ivas_spar_md_dec_close( diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 763c83dc39f6b38cfed95fb8fbb7ea5c55a19754..4d0e3e322bf6fabca83c9665450b6e2dc351475d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -267,6 +267,37 @@ ivas_error ivas_dec_setup( st_ivas->element_mode_init = IVAS_CPE_MDCT; break; } +#ifdef SBA_BR_SWITCHING_RECONFIG + if ( ( st_ivas->ini_frame > 0 ) && ( st_ivas->ivas_format == SBA_FORMAT ) ) + { + int16_t nchan_transport_old, nchan_transport; + SBA_MODE sba_mode_old; + int32_t last_ivas_total_brate; + last_ivas_total_brate = st_ivas->last_active_ivas_total_brate; + sba_mode_old = ivas_sba_mode_select( last_ivas_total_brate ); + nchan_transport_old = st_ivas->nchan_transport; + nchan_transport = ( st_ivas->sid_format == SID_SBA_2TC ) ? 2 : 1; + + if ( ( nchan_transport_old != nchan_transport ) || ( sba_mode_old != st_ivas->sba_mode ) ) + { + /*Setting the default bitrate for the reconfig function*/ + if ( st_ivas->sid_format == SID_SBA_2TC ) + { + st_ivas->hDecoderConfig->ivas_total_brate = IVAS_48k; + } + else + { + st_ivas->hDecoderConfig->ivas_total_brate = ( st_ivas->sba_mode == SBA_MODE_SPAR ) ? IVAS_24k4 : IVAS_13k2; + } + if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + st_ivas->last_active_ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; + } + } +#endif } /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index fbdc4f5857aa8476838224c607da1be53f5c43ae..d48664be32d9702a5dcabc0a72ce094c78d42063 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -658,7 +658,7 @@ ivas_error ivas_sba_dec_reconfigure( /* MD handle */ ivas_spar_md_dec_close( &hSpar->hMdDec ); - if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, nchan_internal, sba_order_internal ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, nchan_internal, sba_order_internal, st_ivas->sid_format ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 2eff5d2cba546e108ba612ba10ee95802fd6c4b0..035afdfd0ff1a069018833b09a4b6ed4df6b89cb 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -89,7 +89,11 @@ ivas_error ivas_spar_dec_open( } /* MD handle */ +#ifdef SBA_BR_SWITCHING_RECONFIG + if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 6c978384e868914b9bae36893497f0498ba08d03..a9df2ff34b8120cb873a6402356a7b5043efcf61 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -253,6 +253,10 @@ ivas_error ivas_spar_md_dec_open( const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ const int16_t num_channels, /* i : number of internal channels */ const int16_t sba_order /* i : SBA order */ +#ifdef SBA_BR_SWITCHING_RECONFIG + , + const int16_t sid_format +#endif ) { ivas_spar_md_dec_state_t *hMdDec; @@ -271,7 +275,12 @@ ivas_error ivas_spar_md_dec_open( } hMdDec->table_idx = 0; /* just to initialize state variables*/ - +#ifdef SBA_BR_SWITCHING_RECONFIG + if ( ( hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 ) && ( sid_format == SID_SBA_2TC ) ) + { + hMdDec->table_idx = ivas_get_spar_table_idx( IVAS_48k, sba_order, SPAR_CONFIG_BW, NULL, NULL ); + } +#endif if ( ( error = ivas_spar_md_dec_init( hMdDec, hDecoderConfig, num_channels, sba_order ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c index ffe6645688e56e1b34965d47db4ca5b28097396b..80520d4c38d37b99a347b7262506eee0c39eb7ed 100644 --- a/lib_enc/amr_wb_enc.c +++ b/lib_enc/amr_wb_enc.c @@ -310,9 +310,7 @@ void amr_wb_enc( { st->fd_cng_reset_flag = 0; } - dtx( st, -1, vad_flag_dtx, inp ); - /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation * Long-term energies and relative frame energy updates diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index 3aa78adb65f2898027e9b789b40e2d4075caa0cc..c99a8faf286fdd9f87c0acfd9ecb2a66dcee6162 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -90,7 +90,6 @@ void dtx( DTX_ENC_HANDLE hDtxEnc = st->hDtxEnc; int16_t last_br_cng_flag, last_br_flag, br_dtx_flag; - if ( st->dtx_sce_sba != 0 ) { last_br_cng_flag = 1; diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 9aec652f05ef45fc9faf8af15cd505ebce4bace0..17d91a31d5fbdb6abb3347f077b3ddf2d6ec8f44 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -446,6 +446,9 @@ ivas_error ivas_cpe_enc( if ( sts[0]->core_brate == SID_2k40 || sts[0]->core_brate == FRAME_NO_DATA ) { sts[0]->core_brate = -1; +#ifdef SBA_BR_SWITCHING_RECONFIG + sts[0]->total_brate = hCPE->element_brate; +#endif } } diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 7fd96ae46e544189213b62382466037473094778..e1887ec1241e9147cbf50ce891a7d6b82bdf8ede 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -517,27 +517,6 @@ ivas_error ivas_sba_enc_reconfigure( *-----------------------------------------------------------------*/ ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, ivas_total_brate / st_ivas->nchan_transport, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS, MC_MODE_NONE ); - -#ifdef SBA_BR_SWITCHING_RECONFIG - if ( st_ivas->hEncoderConfig->Opt_DTX_ON ) - { - if ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) - { - for ( int16_t sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - st_ivas->hSCE[sce_id]->hCoreCoder[0]->ini_frame = 1; - } - - for ( int16_t cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - for ( int16_t n = 0; n < CPE_CHANNELS; n++ ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->ini_frame = 1; - } - } - } - } -#endif } return error; diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index 1723855916a75479e15cd0f3c13b2b9e193aec7c..300cb79787d08451ccd6734198d38938badce4ed 100644 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -252,7 +252,6 @@ void pre_proc( /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled *-----------------------------------------------------------------*/ - dtx( st, -1, vad_flag_dtx, inp_12k8 ); /*----------------------------------------------------------------*