From 691f03e0b88f55d916c2ce46112319bd222afc93 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 7 Dec 2022 17:01:31 +0530 Subject: [PATCH 01/20] Reconfiguration changes -SBA bitrate switching --- lib_com/ivas_sba_config.c | 4 +- lib_com/options.h | 1 + lib_dec/ivas_corecoder_dec_reconfig.c | 8 +- lib_dec/ivas_dirac_dec.c | 4 + lib_dec/ivas_init_dec.c | 4 + lib_dec/ivas_sba_dec.c | 111 +++++++++++++++++++++++- lib_enc/ivas_enc.c | 5 +- lib_enc/ivas_init_enc.c | 2 + lib_enc/ivas_sba_enc.c | 118 +++++++++++++++++++++++++- lib_enc/ivas_spar_encoder.c | 38 +++++++++ lib_enc/ivas_stat_enc.h | 2 + 11 files changed, 291 insertions(+), 6 deletions(-) diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 133bf3886d..bbb44ff074 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -71,7 +71,7 @@ SBA_MODE ivas_sba_mode_select( return sba_mode; } - +#ifndef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING /*-------------------------------------------------------------------* * get_sba_reinit_flag() @@ -118,7 +118,7 @@ int16_t get_sba_reinit_flag( return sba_reinit_flag; } #endif - +#endif /*-------------------------------------------------------------------* * ivas_sba_config() * diff --git a/lib_com/options.h b/lib_com/options.h index 9c39b514da..aa9d4056d9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -153,6 +153,7 @@ #define FIX_MCT_PLC_RECOVERY /* Issue 184: scale the old synthesis part correctly in the first good frame after lost frames in MCT modes - to be activated after previous switch is merged */ #define SBA_BR_SWITCHING_2 /* Issue 114: Changes for sba bit rate switching with reconfigurations*/ #define SBA_BR_SWITCHING /* Issue 114: Changes for sba bit rate switching*/ +#define SBA_BR_SWITCHING_RECONFIG /* Issue 114: Changes for SBA bitrate switching with reconfiguration for bitrates with different transport channels*/ #define FIX_AGC_WINFUNC_MEMORY /* Issue 62: lower agc_com.winFunc memory consumption */ #define FIX_ITD /* Contribution 16: TD renderer ITD improvement and code cleanup */ #define REMOVE_SID_HARM_LEFTOVERS /* Issue 192: remove leftovers from the SID bitrate harmonization */ diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index b8d4e66cf4..2a742c8bb4 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -483,7 +483,13 @@ ivas_error ivas_cldfb_dec_reconfig( } } } - +#ifdef SBA_BR_SWITCHING_RECONFIG + /* CLDFB Interpolation weights */ + if ( st_ivas->sba_mode == SBA_MODE_SPAR && ( numCldfbAnalyses_old != numCldfbAnalyses || numCldfbSyntheses_old != numCldfbSyntheses || nchan_transport_old != st_ivas->nchan_transport ) ) + { + ivas_spar_get_cldfb_gains( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig ); + } +#endif return IVAS_ERR_OK; } #endif diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index dbdf0870e8..caebbd6ea8 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -209,7 +209,11 @@ ivas_error ivas_dirac_dec_config( if ( flag_config == DIRAC_RECONFIGURE && st_ivas->ivas_format == SBA_FORMAT ) { int16_t tmp1, tmp2, tmp3; +#ifdef SBA_BR_SWITCHING_RECONFIG + ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &nchan_transport_old, st_ivas->sba_planar, &tmp1, &tmp2, &tmp3 ); +#else ivas_sba_config( st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->sba_analysis_order, -1, &nchan_transport_old, st_ivas->sba_planar, &tmp1, &tmp2, &tmp3 ); +#endif } /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 9f42ccb99f..a576813372 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -131,6 +131,7 @@ ivas_error ivas_dec_setup( if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) #endif { +#ifndef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING #ifndef SBA_BR_SWITCHING_2 if ( get_sba_reinit_flag( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) @@ -146,13 +147,16 @@ ivas_error ivas_dec_setup( } else { +#endif #endif if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) { return error; } +#ifndef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING } +#endif #endif } else diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 4e96c041bd..207930f958 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -567,10 +567,15 @@ ivas_error ivas_sba_dec_reconfigure( int16_t numCldfbAnalyses_old, numCldfbAnalyses, numCldfbSyntheses, numCldfbSyntheses_old; #endif int16_t sba_dirac_stereo_flag_old; +#ifdef SBA_BR_SWITCHING_RECONFIG + SBA_MODE sba_mode_old; + int32_t ivas_total_brate, last_ivas_total_brate; +#else #ifndef SBA_BR_SWITCHING_2 int32_t ivas_total_brate, last_ivas_total_brate; #else int32_t ivas_total_brate; +#endif #endif DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; @@ -579,8 +584,15 @@ ivas_error ivas_sba_dec_reconfigure( hDecoderConfig = st_ivas->hDecoderConfig; ivas_total_brate = hDecoderConfig->ivas_total_brate; +#ifdef SBA_BR_SWITCHING_RECONFIG + last_ivas_total_brate = st_ivas->last_active_ivas_total_brate; + sba_mode_old = ivas_sba_mode_select( last_ivas_total_brate ); + + st_ivas->sba_mode = sba_mode_old; +#else #ifndef SBA_BR_SWITCHING_2 last_ivas_total_brate = hDecoderConfig->last_ivas_total_brate; +#endif #endif /*-----------------------------------------------------------------* * Set SBA high-level parameters @@ -600,7 +612,9 @@ ivas_error ivas_sba_dec_reconfigure( sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); - +#ifdef SBA_BR_SWITCHING_RECONFIG + st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); +#endif #ifdef SBA_BR_SWITCHING_2 /*-----------------------------------------------------------------* * Allocate, initalize, and configure SBA handles @@ -620,12 +634,78 @@ ivas_error ivas_sba_dec_reconfigure( } else { +#ifdef SBA_BR_SWITCHING_RECONFIG + int16_t i, sba_order_internal, nchan_internal; +#else int16_t sba_order_internal; +#endif DIRAC_DEC_HANDLE hDirAC = st_ivas->hDirAC; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); +#ifdef SBA_BR_SWITCHING_RECONFIG + nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); + if ( hSpar != NULL && nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) ) + { + + // VE: dirty patch -> reconfiguration of SPAR modules should be used instead !! + IVAS_FB_CFG *fb_cfg; + int16_t active_w_mixing; + + /* 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 ) + { + return error; + } + hSpar->hMdDec->td_decorr_flag = 1; + hSpar->hMdDec->table_idx = -1; + + /* TD decorr. */ + ivas_spar_td_decorr_dec_close( &hSpar->hTdDecorr ); + + if ( ( error = ivas_spar_td_decorr_dec_open( &hSpar->hTdDecorr, hDecoderConfig->output_Fs, nchan_internal, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* FB mixer handle */ + ivas_FB_mixer_close( &hSpar->hFbMixer, hDecoderConfig->output_Fs ); + /* set FB config. */ + active_w_mixing = -1; + if ( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, nchan_internal, nchan_internal, active_w_mixing, hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + fb_cfg->pcm_offset = NS2SA( hDecoderConfig->output_Fs, DELAY_FB_1_NS + IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ); + fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order]; + + /* FB mixer handle */ + if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, hDecoderConfig->output_Fs, fb_cfg ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* mixer_mat intitialization */ + for ( i = 0; i < nchan_internal; i++ ) + { + for ( int16_t j = 0; j < nchan_internal; j++ ) + { + for ( int16_t b = 0; b < IVAS_MAX_NUM_BANDS; b++ ) + { + hSpar->hMdDec->mixer_mat[i][j][b] = 0.0f; + for ( int16_t i_ts = 0; i_ts < ( MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); i_ts++ ) + { + hSpar->hMdDec->mixer_mat_prev[i_ts][i][j][b] = 0.0f; + } + } + } + } + hSpar->i_subframe = 0; + } +#endif /* PCA handle */ if ( hSpar != NULL ) { @@ -644,7 +724,17 @@ ivas_error ivas_sba_dec_reconfigure( hSpar->hPCA = NULL; } } +#ifdef SBA_BR_SWITCHING_RECONFIG + if ( hSpar == NULL && st_ivas->sba_mode == SBA_MODE_SPAR ) + { + if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + hSpar = st_ivas->hSpar; + } +#endif st_ivas->sba_dirac_stereo_flag = 0; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); @@ -740,6 +830,25 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } #endif +#ifdef SBA_BR_SWITCHING_RECONFIG + if ( sba_mode_old != st_ivas->sba_mode ) // VE: TBD - possibly merge with the 'else if' branch below + { + if ( st_ivas->hDirAC != NULL ) + { + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE_MODE ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif #ifdef SBA_BR_SWITCHING_2 if ( ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) { diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 61faee23a4..251131e110 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -93,6 +93,7 @@ ivas_error ivas_enc( #ifndef SBA_BR_SWITCHING_2 sba_reinit_flag = 0; #endif +#ifndef SBA_BR_SWITCHING_RECONFIG if ( ivas_format == SBA_FORMAT ) { #ifndef SBA_BR_SWITCHING_2 @@ -110,7 +111,7 @@ ivas_error ivas_enc( } } #endif - +#endif /*----------------------------------------------------------------* * convert 'short' input data to 'float' *----------------------------------------------------------------*/ @@ -220,8 +221,10 @@ ivas_error ivas_enc( #ifndef SBA_BR_SWITCHING_2 if ( ( st_ivas->sba_mode == SBA_MODE_DIRAC ) && ( !sba_reinit_flag ) ) #else +#ifndef SBA_BR_SWITCHING_RECONFIG if ( !st_ivas->sba_reinit_flag ) #endif +#endif #endif { if ( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 8d3f78d154..a06da37805 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -342,8 +342,10 @@ ivas_error ivas_init_encoder( st_ivas->sba_mode = SBA_MODE_NONE; st_ivas->nchan_transport = -1; +#ifndef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING_2 st_ivas->sba_reinit_flag = 0; +#endif #endif /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 04aba97747..b3af97ea9a 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -345,7 +345,9 @@ ivas_error ivas_sba_enc_reconfigure( nchan_transport_old = st_ivas->nchan_transport; nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; - +#ifdef SBA_BR_SWITCHING_RECONFIG + SBA_MODE sba_mode_old = st_ivas->sba_mode; +#endif st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); #ifdef SBA_BR_SWITCHING_2 st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); @@ -382,6 +384,120 @@ ivas_error ivas_sba_enc_reconfigure( hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; } +#endif +#ifdef SBA_BR_SWITCHING_RECONFIG + /* FB mixer handle */ + if ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) + { + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) + { + // VE: TBV whether 'hFbMixer' can be reused + if ( hDirAC->hFbMixer != NULL ) + { + ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs ); + hDirAC->hFbMixer = NULL; + } + + { + // VE: dirty patch -> reconfiguration of SPAR MD, TD_decorr, FbMixer modules should be used instead !! + + IVAS_FB_CFG *fb_cfg; + int16_t nchan_internal, sba_order_internal; + int16_t table_idx, active_w_mixing; + + sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); + + /* Covar. State handle */ + ivas_spar_covar_enc_close( &hSpar->hCovEnc, hSpar->hFbMixer->fb_cfg->num_in_chans ); + + /* MD handle */ + ivas_spar_md_enc_close( &hSpar->hMdEnc ); + + if ( ( error = ivas_spar_md_enc_open( &( hSpar->hMdEnc ), hEncoderConfig, sba_order_internal ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* FB mixer handle */ + ivas_FB_mixer_close( &hSpar->hFbMixer, hEncoderConfig->input_Fs ); + + table_idx = ivas_get_spar_table_idx( ivas_total_brate, sba_order_internal, SPAR_CONFIG_BW, NULL, NULL ); + active_w_mixing = ivas_spar_br_table_consts[table_idx].active_w; + if ( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, nchan_internal, st_ivas->nchan_transport, active_w_mixing, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + fb_cfg->remix_order = remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order]; + + if ( ( error = ivas_FB_mixer_open( &( hSpar->hFbMixer ), hEncoderConfig->input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Covar. State handle */ + if ( ( error = ivas_spar_covar_enc_open( &( hSpar->hCovEnc ), hSpar->hFbMixer->pFb, hEncoderConfig->input_Fs, nchan_internal ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else + { + if ( hDirAC->hFbMixer == NULL ) + { + IVAS_FB_CFG *fb_cfg; + + if ( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_DIRAC, DIRAC_MAX_ANA_CHANS, 0, 0, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Allocate and initialize FB mixer handle */ + if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + + /* initalize delay for SPAR/DirAC delay synchronization */ + if ( ( st_ivas->sba_mode == SBA_MODE_DIRAC ) && ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) ) + { + int16_t n; + + if ( hDirAC->num_samples_synchro_delay == 0 ) + { + hDirAC->num_samples_synchro_delay = NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); + + for ( n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) + { + if ( ( hDirAC->sba_synchro_buffer[n] = (float *) count_malloc( hDirAC->num_samples_synchro_delay * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hDirAC synchro buffer\n" ) ); + } + set_zero( hDirAC->sba_synchro_buffer[n], hDirAC->num_samples_synchro_delay ); + } + for ( ; n < DIRAC_MAX_ANA_CHANS; n++ ) + { + hDirAC->sba_synchro_buffer[n] = NULL; + } + } + } + else + { + for ( int16_t n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) + { + if ( hDirAC->sba_synchro_buffer[n] != NULL ) + { + count_free( hDirAC->sba_synchro_buffer[n] ); + hDirAC->sba_synchro_buffer[n] = NULL; + } + } + hDirAC->num_samples_synchro_delay = 0; + } + } + #endif ivas_dirac_enc_reconfigure( st_ivas ); diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index dc6b5f7c73..8af95a6a57 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -292,6 +292,40 @@ ivas_error ivas_spar_enc( error = IVAS_ERR_OK; hEncoderConfig = st_ivas->hEncoderConfig; +#ifdef SBA_BR_SWITCHING_RECONFIG + // VE2DB: can hFbMixer->ppFilterbank_prior_input be replaced by st->input ? + + /* check last sba_mode */ + if ( ivas_sba_mode_select( st_ivas->hEncoderConfig->last_ivas_total_brate ) == SBA_MODE_DIRAC ) + { + Encoder_State *sts[MCT_MAX_BLOCKS]; + + /* initializations */ + for ( int16_t sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + { + sts[sce_id] = st_ivas->hSCE[sce_id]->hCoreCoder[0]; + } + + for ( int16_t cpe_id = 0, i = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + for ( int16_t ch = 0; ch < CPE_CHANNELS; ch++ ) + { + sts[i] = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]; + i++; + } + } + + /* update FB prior input */ + // VE: last 1ms of 'ppFilterbank_prior_input' is not correct + for ( int16_t i = 0; i < st_ivas->nchan_transport; i++ ) + { + mvr2r( sts[i]->input_buff + NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ), st_ivas->hSpar->hFbMixer->ppFilterbank_prior_input[i] + st_ivas->hSpar->hFbMixer->fb_cfg->prior_input_length - input_frame, input_frame ); + } + + //VE: TBD - update 'st->input_buff' for SparVAD + } +#endif + /* front VAD */ if ( ( error = front_vad_spar( st_ivas->hSpar, data_f[0], hEncoderConfig, input_frame ) ) != IVAS_ERR_OK ) { @@ -548,7 +582,11 @@ static ivas_error ivas_spar_enc_process( { hSpar->hMdEnc->table_idx = table_idx; #ifdef SBA_BR_SWITCHING_2 +#ifndef SBA_BR_SWITCHING_RECONFIG if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate && !st_ivas->sba_reinit_flag ) +#else + if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) +#endif { if ( ( error = ivas_spar_md_enc_init( hSpar->hMdEnc, hEncoderConfig, sba_order ) ) != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 81b89a5edc..3d8b88445f 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1048,8 +1048,10 @@ typedef struct int16_t sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ int16_t codec_mode; /* Mode1 or Mode2 of core codec */ int16_t last_codec_mode; /* previous frame Mode 1 or 2 */ +#ifndef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING_2 int16_t sba_reinit_flag; /*flag indicating whether reinitialisation or reconfiguration function should be used*/ +#endif #endif float **mem_hp20_in; /* input signals HP filter memories */ -- GitLab From 2a68f39b9198fee860bb7ddaaa33efa15e846ee4 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 12 Dec 2022 09:43:38 +0530 Subject: [PATCH 02/20] Undefined the unused functions [x] ivas_sba_enc_reinit(), ivas_sba_dec_reinit(), get_sba_reinit_flag() undefined when the SBA_BR_SWITCHING_RECONFIG macro is enabled --- lib_com/ivas_prot.h | 7 ++++++- lib_dec/ivas_sba_dec.c | 4 ++-- lib_enc/ivas_sba_enc.c | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 500a6c7a9b..d5c936d1c6 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -105,11 +105,14 @@ ivas_error mct_enc_reconfigure( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const uint16_t b_nchan_change /* i : flag indicating different channel count */ ); +#ifndef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING ivas_error ivas_sba_enc_reinit( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); #endif +#endif +#ifndef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING int16_t get_sba_reinit_flag( int32_t ivas_total_bitrate, /* i : Current bitrate */ @@ -119,6 +122,7 @@ int16_t get_sba_reinit_flag( #endif ); #endif +#endif #ifdef SBA_BR_SWITCHING_2 ivas_error ivas_spar_md_enc_init ( @@ -3087,12 +3091,13 @@ void ivas_sba_config( int16_t *nCPE, /* o : number of CPEs */ int16_t *element_mode /* o : element mode of the core coder */ ); +#ifndef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING ivas_error ivas_sba_dec_reinit( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif - +#endif ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 207930f958..6fde66d5a3 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -47,7 +47,7 @@ #endif #include "wmops.h" - +#ifndef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING /*-------------------------------------------------------------------* * ivas_sba_dec_reinit() @@ -544,7 +544,7 @@ ivas_error ivas_sba_dec_reinit( return error; } #endif - +#endif /*-------------------------------------------------------------------* * ivas_sba_dec_decoder() * diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index b3af97ea9a..54e2812f86 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -92,7 +92,7 @@ void ivas_sba_getTCs( return; } - +#ifndef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING /*-------------------------------------------------------------------* * ivas_sba_enc_reinit() @@ -313,7 +313,7 @@ ivas_error ivas_sba_enc_reinit( return error; } #endif - +#endif /*-------------------------------------------------------------------* * ivas_sba_enc_reconfigure() -- GitLab From 05e03673fc6a78423adaf15fa4462097818e2d89 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 12 Dec 2022 10:48:42 +0530 Subject: [PATCH 03/20] Made modificatios in macro definitions [x] SBA_BR_SWITCHING_2 should also be defined if SBA_BR_SWITCHIN_RECONFIG is defined ,as they are dependent macros. --- lib_com/options.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index aa9d4056d9..2ce30a0bc9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -151,9 +151,15 @@ #define FIX_EFAP_MATH /* fix for EFAP: remove angle quantization and a bug in polygon lookup causing incorrect gains. minor tweak for ALLRAD. non-BE for modes using EFAP */ #define FIX_124_DONT_ALLOC_PLCINFO_IN_IVAS /* Issue 124: do not allocate unused plc struct in IVAS modes which is only used in EVS mono */ #define FIX_MCT_PLC_RECOVERY /* Issue 184: scale the old synthesis part correctly in the first good frame after lost frames in MCT modes - to be activated after previous switch is merged */ -#define SBA_BR_SWITCHING_2 /* Issue 114: Changes for sba bit rate switching with reconfigurations*/ +#define SBA_BR_SWITCHING_RECONFIG /* Issue 114: Changes for SBA bitrate switching with reconfiguration for bitrates with different number of transport channels*/ +#ifdef SBA_BR_SWITCHING_RECONFIG +#define SBA_BR_SWITCHING_2 /* Issue 114: Changes for SBA bit rate switching with reconfiguration for bitrates with same number of transport channels*/ +#endif +#ifndef SBA_BR_SWITCHING_2 +#define SBA_BR_SWITCHING_2 /* Issue 114: Changes for SBA bit rate switching with reconfiguration for bitrates with same number of transport channels*/ +#endif #define SBA_BR_SWITCHING /* Issue 114: Changes for sba bit rate switching*/ -#define SBA_BR_SWITCHING_RECONFIG /* Issue 114: Changes for SBA bitrate switching with reconfiguration for bitrates with different transport channels*/ + #define FIX_AGC_WINFUNC_MEMORY /* Issue 62: lower agc_com.winFunc memory consumption */ #define FIX_ITD /* Contribution 16: TD renderer ITD improvement and code cleanup */ #define REMOVE_SID_HARM_LEFTOVERS /* Issue 192: remove leftovers from the SID bitrate harmonization */ -- GitLab From 56c40ab07e7d18364933cad6290090f823deac35 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 14 Dec 2022 11:32:17 +0530 Subject: [PATCH 04/20] Fix for crash in DTX cases with SBA bitrate switch --- lib_com/ivas_prot.h | 3 +++ lib_enc/ivas_core_pre_proc_front.c | 11 ++++++++++- lib_enc/ivas_cpe_enc.c | 7 ++++++- lib_enc/ivas_init_enc.c | 2 ++ lib_enc/ivas_ism_enc.c | 7 ++++++- lib_enc/ivas_sba_enc.c | 4 ++++ lib_enc/ivas_sce_enc.c | 7 ++++++- lib_enc/ivas_stat_enc.h | 2 ++ 8 files changed, 39 insertions(+), 4 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 0ac53db858..7a6f75a051 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -221,6 +221,9 @@ ivas_error pre_proc_front_ivas( const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag /* i : front-VAD DTX flag to overwrite VAD decision*/ ,const int32_t ivas_total_brate /* i : IVAS total bitrate */ +#ifdef SBA_BR_SWITCHING_RECONFIG + ,const int16_t flag_sba_bitrate_switch /* i : SBA bitrate switch flag */ +#endif ); ivas_error pre_proc_ivas( diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 828fdf17a1..7bc46595a2 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -103,6 +103,10 @@ ivas_error pre_proc_front_ivas( const int16_t front_vad_dtx_flag /* i : front-VAD DTX flag to overwrite VAD decision*/ , const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ +#ifdef SBA_BR_SWITCHING_RECONFIG + , + const int16_t flag_sba_bitrate_switch +#endif ) { float *inp_12k8, *new_inp_12k8; /* pointers to current frame and new data */ @@ -450,7 +454,12 @@ ivas_error pre_proc_front_ivas( st->vad_flag = front_vad_flag; st->localVAD = front_vad_flag; } - +#ifdef SBA_BR_SWITCHING_RECONFIG + if ( flag_sba_bitrate_switch ) + { + st->vad_flag = 1; + } +#endif if ( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL ) { *vad_flag_dtx = dtx_hangover_addition( st, st->vad_flag, st->lp_speech - st->lp_noise, 0, vad_hover_flag, NULL, NULL diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 470d597b15..7f48259eae 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -437,7 +437,12 @@ ivas_error ivas_cpe_enc( error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &Etot[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, - ivas_total_brate ); + ivas_total_brate +#ifdef SBA_BR_SWITCHING_RECONFIG + , + st_ivas->flag_sba_bitrate_switch +#endif + ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index a06da37805..2213d8bd72 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -346,6 +346,8 @@ ivas_error ivas_init_encoder( #ifdef SBA_BR_SWITCHING_2 st_ivas->sba_reinit_flag = 0; #endif +#else + st_ivas->flag_sba_bitrate_switch = 0; #endif /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 39d5b42a07..a4c1d51564 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -151,7 +151,12 @@ ivas_error ivas_ism_enc( &Etot[sce_id][0], &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, - st_ivas->hEncoderConfig->ivas_total_brate ); + st_ivas->hEncoderConfig->ivas_total_brate +#ifdef SBA_BR_SWITCHING_RECONFIG + , + 0 +#endif + ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 54e2812f86..adc3be5c26 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -335,6 +335,9 @@ ivas_error ivas_sba_enc_reconfigure( #ifdef SBA_BR_SWITCHING_2 ENCODER_CONFIG_HANDLE hEncoderConfig; hEncoderConfig = st_ivas->hEncoderConfig; +#endif +#ifdef SBA_BR_SWITCHING_RECONFIG + st_ivas->flag_sba_bitrate_switch = 0; #endif if ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) { @@ -347,6 +350,7 @@ ivas_error ivas_sba_enc_reconfigure( nSCE_old = st_ivas->nSCE; #ifdef SBA_BR_SWITCHING_RECONFIG SBA_MODE sba_mode_old = st_ivas->sba_mode; + st_ivas->flag_sba_bitrate_switch = 1; #endif st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); #ifdef SBA_BR_SWITCHING_2 diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 2a74fcf68d..c43aea4a0f 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -186,7 +186,12 @@ ivas_error ivas_sce_enc( &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, - st_ivas->hEncoderConfig->ivas_total_brate ); + st_ivas->hEncoderConfig->ivas_total_brate +#ifdef SBA_BR_SWITCHING_RECONFIG + , + st_ivas->flag_sba_bitrate_switch +#endif + ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 3d8b88445f..c302917ee9 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1052,6 +1052,8 @@ typedef struct #ifdef SBA_BR_SWITCHING_2 int16_t sba_reinit_flag; /*flag indicating whether reinitialisation or reconfiguration function should be used*/ #endif +#else + int16_t flag_sba_bitrate_switch; /*flag indicating whether SBA bitrate switching */ #endif float **mem_hp20_in; /* input signals HP filter memories */ -- GitLab From f1bb6f3f22c327af14f7a44bd3c274aae655f5a1 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Fri, 16 Dec 2022 13:16:22 +0530 Subject: [PATCH 05/20] Combined two switches into one [x] Merged the changes under the switch 'SBA_BR_SWITCHING_2' into 'SBA_BR_SWITCHING' --- lib_com/ivas_cnst.h | 2 +- lib_com/ivas_prot.h | 4 +--- lib_com/ivas_sba_config.c | 13 +------------ lib_com/options.h | 7 +++---- lib_dec/ivas_dec.c | 2 +- lib_dec/ivas_dirac_dec.c | 6 +++--- lib_dec/ivas_init_dec.c | 12 +++++------- lib_dec/ivas_sba_dec.c | 19 +++++++++---------- lib_dec/ivas_stat_dec.h | 2 +- lib_enc/ivas_enc.c | 17 +++-------------- lib_enc/ivas_init_enc.c | 2 +- lib_enc/ivas_sba_enc.c | 8 ++++---- lib_enc/ivas_spar_encoder.c | 8 ++++---- lib_enc/ivas_spar_md_enc.c | 4 ++-- lib_enc/ivas_stat_enc.h | 2 +- 15 files changed, 40 insertions(+), 68 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 95ce270957..3533e5f0e7 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -926,7 +926,7 @@ typedef enum { DIRAC_OPEN, /* initialize to default value */ DIRAC_RECONFIGURE /* HOA3 */ -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING , DIRAC_RECONFIGURE_MODE #endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 7a6f75a051..00723ccffe 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -117,13 +117,11 @@ ivas_error ivas_sba_enc_reinit( int16_t get_sba_reinit_flag( int32_t ivas_total_bitrate, /* i : Current bitrate */ int32_t last_ivas_total_brate /* i : Previous bitrate */ -#ifdef SBA_BR_SWITCHING_2 , int16_t sba_order -#endif ); #endif #endif -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING ivas_error ivas_spar_md_enc_init ( ivas_spar_md_enc_state_t *hMdEnc, /* o : MD encoder handle */ diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index bbb44ff074..b5b8b15f72 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -81,23 +81,15 @@ SBA_MODE ivas_sba_mode_select( int16_t get_sba_reinit_flag( int32_t ivas_total_bitrate, /* i : Current bitrate */ - int32_t last_ivas_total_brate /* i : Previous bitrate */ -#ifdef SBA_BR_SWITCHING_2 - , + int32_t last_ivas_total_brate, /* i : Previous bitrate */ int16_t sba_order -#endif ) { int16_t sba_reinit_flag; sba_reinit_flag = 0; -#ifdef SBA_BR_SWITCHING_2 if ( ivas_total_bitrate != last_ivas_total_brate && ( ivas_total_bitrate > IVAS_SID_5k2 ) ) -#else - if ( ivas_total_bitrate != last_ivas_total_brate && ( last_ivas_total_brate > IVAS_SID_5k2 ) && ( ivas_total_bitrate > IVAS_SID_5k2 ) ) -#endif { -#ifdef SBA_BR_SWITCHING_2 int16_t sba_analysis_order, nchan_transport_old, nchan_transport_new; SBA_MODE last_sba_mode, current_sba_mode; sba_analysis_order = ivas_sba_get_analysis_order( last_ivas_total_brate, sba_order ); @@ -108,11 +100,8 @@ int16_t get_sba_reinit_flag( nchan_transport_new = ivas_get_sba_num_TCs( ivas_total_bitrate, min( sba_analysis_order, IVAS_MAX_SBA_ORDER ) ); if ( ( current_sba_mode != last_sba_mode ) || ( nchan_transport_new != nchan_transport_old ) ) { -#endif sba_reinit_flag = 1; -#ifdef SBA_BR_SWITCHING_2 } -#endif } return sba_reinit_flag; diff --git a/lib_com/options.h b/lib_com/options.h index f80e92ba81..ed898830bc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,12 +148,11 @@ #define FIX_124_DONT_ALLOC_PLCINFO_IN_IVAS /* Issue 124: do not allocate unused plc struct in IVAS modes which is only used in EVS mono */ #define SBA_BR_SWITCHING_RECONFIG /* Issue 114: Changes for SBA bitrate switching with reconfiguration for bitrates with different number of transport channels*/ #ifdef SBA_BR_SWITCHING_RECONFIG -#define SBA_BR_SWITCHING_2 /* Issue 114: Changes for SBA bit rate switching with reconfiguration for bitrates with same number of transport channels*/ +#define SBA_BR_SWITCHING /* Issue 114: Changes for SBA bit rate switching with reconfiguration for bitrates with same number of transport channels*/ #endif -#ifndef SBA_BR_SWITCHING_2 -#define SBA_BR_SWITCHING_2 /* Issue 114: Changes for SBA bit rate switching with reconfiguration for bitrates with same number of transport channels*/ +#ifndef SBA_BR_SWITCHING +#define SBA_BR_SWITCHING /* Issue 114: Changes for SBA bit rate switching with reconfiguration for bitrates with same no:of transport channels and reinitialization for different no:of transport channels */ #endif -#define SBA_BR_SWITCHING /* Issue 114: Changes for sba bit rate switching*/ #define FIX_ITD /* Contribution 16: TD renderer ITD improvement and code cleanup */ #define BRATE_SWITCHING_RENDERING /* Bitrate switching changes related to the renderers */ #define FIX_ISM_DECODER_PRINTOUT /* Issue 229: fix ISM decoder printout */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index c3deb7103f..ef6a8819f9 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -563,7 +563,7 @@ ivas_error ivas_dec( if ( !st_ivas->bfi ) /* do not update if first frame(s) are lost or NO_DATA */ { st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate; -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING st_ivas->last_active_ivas_total_brate = ( ivas_total_brate <= IVAS_SID_5k2 ) ? st_ivas->last_active_ivas_total_brate : ivas_total_brate; #endif } diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 9d92b11867..a21d267e41 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -126,7 +126,7 @@ ivas_error ivas_dirac_dec_open( ivas_error ivas_dirac_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING const DIRAC_CONFIG_FLAG flag_config_inp /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ #else const DIRAC_CONFIG_FLAG flag_config /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ @@ -149,7 +149,7 @@ ivas_error ivas_dirac_dec_config( int32_t output_Fs, ivas_total_brate; ivas_error error; int16_t nchan_transport_orig; -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING DIRAC_CONFIG_FLAG flag_config; flag_config = ( flag_config_inp == DIRAC_RECONFIGURE_MODE ) ? DIRAC_RECONFIGURE : flag_config_inp; @@ -664,7 +664,7 @@ ivas_error ivas_dirac_dec_config( } else if ( flag_config == DIRAC_RECONFIGURE && hDirAC->proto_signal_decorr_on && proto_signal_decorr_on_old ) { -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING if ( nchan_transport != nchan_transport_old || hDirAC->num_outputs_diff != num_outputs_diff_old || flag_config_inp == DIRAC_RECONFIGURE_MODE ) #else if ( ( nchan_transport != nchan_transport_old ) || ( hDirAC->num_outputs_diff != num_outputs_diff_old ) ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a576813372..f7adc20155 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -125,26 +125,24 @@ ivas_error ivas_dec_setup( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); num_bits_read += SBA_ORDER_BITS; -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) #else if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) #endif { #ifndef SBA_BR_SWITCHING_RECONFIG -#ifdef SBA_BR_SWITCHING -#ifndef SBA_BR_SWITCHING_2 - if ( get_sba_reinit_flag( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) -#else +#ifdef SBA_BR_SWITCHING int16_t sba_reinit_flag = get_sba_reinit_flag( ivas_total_brate, st_ivas->last_active_ivas_total_brate, st_ivas->sba_order ); if ( sba_reinit_flag ) -#endif { if ( ( error = ivas_sba_dec_reinit( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } +#endif +#ifdef SBA_BR_SWITCHING else { #endif @@ -637,7 +635,7 @@ ivas_error ivas_init_decoder( ivas_total_brate = hDecoderConfig->ivas_total_brate; hDecoderConfig->last_ivas_total_brate = ivas_total_brate; -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING st_ivas->last_active_ivas_total_brate = ivas_total_brate; #endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 6fde66d5a3..16baeb8c67 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -37,7 +37,7 @@ #include "ivas_cnst.h" #include "prot.h" #include "ivas_prot.h" -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING #include "ivas_rom_com.h" #endif #include "ivas_rom_dec.h" @@ -76,9 +76,8 @@ ivas_error ivas_sba_dec_reinit( ivas_total_brate = hDecoderConfig->ivas_total_brate; hDecoderConfig->last_ivas_total_brate = ivas_total_brate; -#ifdef SBA_BR_SWITCHING_2 st_ivas->last_active_ivas_total_brate = ivas_total_brate; -#endif + /*------------------------------------------------------------------------------------------* * Closing Decoder handles before Reinitialisation *------------------------------------------------------------------------------------------*/ @@ -571,7 +570,7 @@ ivas_error ivas_sba_dec_reconfigure( SBA_MODE sba_mode_old; int32_t ivas_total_brate, last_ivas_total_brate; #else -#ifndef SBA_BR_SWITCHING_2 +#ifndef SBA_BR_SWITCHING int32_t ivas_total_brate, last_ivas_total_brate; #else int32_t ivas_total_brate; @@ -590,7 +589,7 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->sba_mode = sba_mode_old; #else -#ifndef SBA_BR_SWITCHING_2 +#ifndef SBA_BR_SWITCHING last_ivas_total_brate = hDecoderConfig->last_ivas_total_brate; #endif #endif @@ -615,7 +614,7 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef SBA_BR_SWITCHING_RECONFIG st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); #endif -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING /*-----------------------------------------------------------------* * Allocate, initalize, and configure SBA handles *-----------------------------------------------------------------*/ @@ -781,7 +780,7 @@ ivas_error ivas_sba_dec_reconfigure( *-----------------------------------------------------------------*/ /* renderer might have changed */ intern_config_old = st_ivas->intern_config; -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING RENDERER_TYPE old_renderer_type; old_renderer_type = st_ivas->renderer_type; #endif @@ -810,7 +809,7 @@ ivas_error ivas_sba_dec_reconfigure( { ivas_binRenderer_close( &st_ivas->hBinRenderer ); } -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING if ( st_ivas->renderer_type != old_renderer_type ) { #endif @@ -822,7 +821,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING } #endif else if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) ) @@ -849,7 +848,7 @@ ivas_error ivas_sba_dec_reconfigure( } } #endif -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING if ( ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) { if ( st_ivas->hDirAC != NULL ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index de79f876d6..ce72da948d 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1974,7 +1974,7 @@ typedef struct Decoder_Struct #ifdef DEBUGGING int32_t noClipping; /* number of clipped samples */ #endif -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING int32_t last_active_ivas_total_brate; #endif } Decoder_Struct; diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 251131e110..32e1e8b3fa 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -65,10 +65,8 @@ ivas_error ivas_enc( float data_f[MAX_INPUT_CHANNELS][L_FRAME48k]; /* IVAS_fmToDo: buffer can be allocated dynamically based on the number of analysed channels */ int32_t ivas_total_brate; ivas_error error; -#ifndef SBA_BR_SWITCHING_2 -#ifdef SBA_BR_SWITCHING +#ifndef SBA_BR_SWITCHING int16_t sba_reinit_flag; -#endif #endif error = IVAS_ERR_OK; @@ -89,20 +87,15 @@ ivas_error ivas_enc( n_samples_chan = n_samples / nchan_inp; set_s( nb_bits_metadata, 0, MAX_SCE ); -#ifdef SBA_BR_SWITCHING -#ifndef SBA_BR_SWITCHING_2 +#ifndef SBA_BR_SWITCHING sba_reinit_flag = 0; #endif #ifndef SBA_BR_SWITCHING_RECONFIG +#ifdef SBA_BR_SWITCHING if ( ivas_format == SBA_FORMAT ) { -#ifndef SBA_BR_SWITCHING_2 - sba_reinit_flag = get_sba_reinit_flag( ivas_total_brate, st_ivas->hEncoderConfig->last_ivas_total_brate ); - if ( sba_reinit_flag ) -#else st_ivas->sba_reinit_flag = get_sba_reinit_flag( ivas_total_brate, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); if ( st_ivas->sba_reinit_flag ) -#endif { if ( ( error = ivas_sba_enc_reinit( st_ivas ) ) != IVAS_ERR_OK ) { @@ -216,15 +209,11 @@ ivas_error ivas_enc( if ( ivas_format == SBA_FORMAT ) { #ifndef SBA_BR_SWITCHING - if ( st_ivas->sba_mode == SBA_MODE_DIRAC ) -#else -#ifndef SBA_BR_SWITCHING_2 if ( ( st_ivas->sba_mode == SBA_MODE_DIRAC ) && ( !sba_reinit_flag ) ) #else #ifndef SBA_BR_SWITCHING_RECONFIG if ( !st_ivas->sba_reinit_flag ) #endif -#endif #endif { if ( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 2213d8bd72..a121c4aecd 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -343,7 +343,7 @@ ivas_error ivas_init_encoder( st_ivas->nchan_transport = -1; #ifndef SBA_BR_SWITCHING_RECONFIG -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING st_ivas->sba_reinit_flag = 0; #endif #else diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index adc3be5c26..55dc8c1aa0 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -332,7 +332,7 @@ ivas_error ivas_sba_enc_reconfigure( error = IVAS_ERR_OK; ivas_total_brate = st_ivas->hEncoderConfig->ivas_total_brate; -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING ENCODER_CONFIG_HANDLE hEncoderConfig; hEncoderConfig = st_ivas->hEncoderConfig; #endif @@ -341,7 +341,7 @@ ivas_error ivas_sba_enc_reconfigure( #endif if ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) { -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING DIRAC_ENC_HANDLE hDirAC = st_ivas->hDirAC; SPAR_ENC_HANDLE hSpar; #endif @@ -353,7 +353,7 @@ ivas_error ivas_sba_enc_reconfigure( st_ivas->flag_sba_bitrate_switch = 1; #endif st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); if ( st_ivas->sba_mode == SBA_MODE_SPAR ) @@ -505,7 +505,7 @@ ivas_error ivas_sba_enc_reconfigure( #endif ivas_dirac_enc_reconfigure( st_ivas ); -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { mvs2s( hDirAC->dirac_to_spar_md_bands, hSpar->dirac_to_spar_md_bands, DIRAC_MAX_NBANDS ); diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 8af95a6a57..ce222282d8 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -556,7 +556,7 @@ static ivas_error ivas_spar_enc_process( hQMetaData->q_direction->cfg.nbands = orig_dirac_bands; } } -#ifndef SBA_BR_SWITCHING_2 +#ifndef SBA_BR_SWITCHING /*-----------------------------------------------------------------------------------------* * Covariance process *-----------------------------------------------------------------------------------------*/ @@ -581,7 +581,7 @@ static ivas_error ivas_spar_enc_process( if ( hSpar->hMdEnc->table_idx != table_idx ) { hSpar->hMdEnc->table_idx = table_idx; -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING #ifndef SBA_BR_SWITCHING_RECONFIG if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate && !st_ivas->sba_reinit_flag ) #else @@ -597,11 +597,11 @@ static ivas_error ivas_spar_enc_process( { #endif ivas_spar_set_bitrate_config( &hSpar->hMdEnc->spar_md_cfg, table_idx, ( hSpar->hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND ); -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING } #endif } -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING /*-----------------------------------------------------------------------------------------* * Covariance process *-----------------------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 11893eff81..d0657a3339 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -83,7 +83,7 @@ static void ivas_select_next_strat( ivas_strats_t prior_strat, ivas_strats_t cs[ static void ivas_store_prior_coeffs( ivas_spar_md_enc_state_t *hMdEnc, const int16_t num_bands, const int16_t bands_bw, const int16_t strat, const int16_t dtx_vad, const int16_t qsi ); static void ivas_write_spar_md_bitstream( ivas_spar_md_enc_state_t *hMdEnc, const int16_t nB, const int16_t bands_bw, BSTR_ENC_HANDLE hMetaData, const int32_t ivas_total_brate, const int16_t strat, const int16_t qsi, const int16_t planarCP ); -#ifndef SBA_BR_SWITCHING_2 +#ifndef SBA_BR_SWITCHING static ivas_error ivas_spar_md_enc_init( ivas_spar_md_enc_state_t *hMdEnc, const ENCODER_CONFIG_HANDLE hEncoderConfig, const int16_t sba_order ); #endif static void ivas_spar_quant_pred_coeffs_dtx( ivas_spar_md_t *pSpar_md, const float *pValues, const int16_t ndm, int16_t *pIndex, const int16_t dim1, float *pQuant ); @@ -306,7 +306,7 @@ void ivas_spar_md_enc_close( * * SPAR MD encoder initialization *-----------------------------------------------------------------------------------------*/ -#ifndef SBA_BR_SWITCHING_2 +#ifndef SBA_BR_SWITCHING static ivas_error ivas_spar_md_enc_init #else ivas_error ivas_spar_md_enc_init diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index c302917ee9..7716c1d2d7 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1049,7 +1049,7 @@ typedef struct int16_t codec_mode; /* Mode1 or Mode2 of core codec */ int16_t last_codec_mode; /* previous frame Mode 1 or 2 */ #ifndef SBA_BR_SWITCHING_RECONFIG -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING int16_t sba_reinit_flag; /*flag indicating whether reinitialisation or reconfiguration function should be used*/ #endif #else -- GitLab From 5c0f673041464e00b075c9d1e3a040e73dc051ba Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Fri, 16 Dec 2022 15:42:13 +0530 Subject: [PATCH 06/20] Minor modification --- lib_dec/ivas_init_dec.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index f7adc20155..4bac9c557b 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -141,8 +141,6 @@ ivas_error ivas_dec_setup( return error; } } -#endif -#ifdef SBA_BR_SWITCHING else { #endif -- GitLab From 12071b8074786048e66781ef02faa9ca22683d36 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Tue, 20 Dec 2022 13:22:47 +0530 Subject: [PATCH 07/20] Added a check for bitrate when DTX enabled --- lib_enc/ivas_sba_enc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 55dc8c1aa0..7e93dc02a1 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -390,9 +390,13 @@ ivas_error ivas_sba_enc_reconfigure( #endif #ifdef SBA_BR_SWITCHING_RECONFIG - /* FB mixer handle */ if ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) { + if ( hEncoderConfig->Opt_DTX_ON && ( st_ivas->nchan_transport > 2 ) ) + { + return IVAS_ERR_DTX_NOT_SUPPORTED; + } + /* FB mixer handle */ if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { // VE: TBV whether 'hFbMixer' can be reused -- GitLab From 528f05be4ced80923e0729039a3acf7ba5dc6462 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 4 Jan 2023 15:38:50 +0530 Subject: [PATCH 08/20] clang format changes --- lib_com/ivas_prot.h | 4 ++-- lib_com/ivas_sba_config.c | 13 ++----------- lib_dec/ivas_init_dec.c | 2 +- lib_enc/ivas_ism_enc.c | 4 ++-- lib_enc/ivas_sba_enc.c | 7 ++++--- lib_enc/ivas_sce_enc.c | 2 +- 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 837d44b142..6eaa59c73d 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3144,12 +3144,12 @@ ivas_error ivas_sba_enc_reinit( int16_t get_sba_reinit_flag( int32_t ivas_total_bitrate, /* i : Current bitrate */ int32_t last_ivas_total_brate /* i : Previous bitrate */ -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING , const int16_t sba_order #endif ); #endif -#ifdef SBA_BR_SWITCHING_2 +#ifdef SBA_BR_SWITCHING ivas_error ivas_spar_md_enc_init ( ivas_spar_md_enc_state_t *hMdEnc, /* o : MD encoder handle */ diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index abad34aa52..26ae98c954 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -80,18 +80,9 @@ SBA_MODE ivas_sba_mode_select( *-------------------------------------------------------------------*/ int16_t get_sba_reinit_flag( - int32_t ivas_total_bitrate, /* i : Current bitrate */ -<<<<<<< HEAD + int32_t ivas_total_bitrate, /* i : Current bitrate */ int32_t last_ivas_total_brate, /* i : Previous bitrate */ - int16_t sba_order -======= - int32_t last_ivas_total_brate /* i : Previous bitrate */ -#ifdef SBA_BR_SWITCHING_2 - , - const int16_t sba_order -#endif ->>>>>>> main -) + int16_t sba_order ) { int16_t sba_reinit_flag; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 87a3d563a9..cea6a83d59 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -132,7 +132,7 @@ ivas_error ivas_dec_setup( #endif { #ifndef SBA_BR_SWITCHING_RECONFIG -#ifdef SBA_BR_SWITCHING +#ifdef SBA_BR_SWITCHING int16_t sba_reinit_flag = get_sba_reinit_flag( ivas_total_brate, st_ivas->last_active_ivas_total_brate, st_ivas->sba_order ); if ( sba_reinit_flag ) { diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index a13cdbd2cf..752528d365 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -152,8 +152,8 @@ ivas_error ivas_ism_enc( fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format #ifdef SBA_BR_SWITCHING_RECONFIG - , - 0 + , + 0 #endif ); if ( error != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 37ceb5ca11..e02322f319 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -349,10 +349,11 @@ ivas_error ivas_sba_enc_reconfigure( nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; #ifdef SBA_BR_SWITCHING_RECONFIG - SBA_MODE sba_mode_old = st_ivas->sba_mode; + SBA_MODE sba_mode_old; + sba_mode_old = st_ivas->sba_mode; st_ivas->flag_sba_bitrate_switch = 1; #endif - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order(ivas_total_brate, hEncoderConfig->sba_order); + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); #ifdef SBA_BR_SWITCHING st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); @@ -392,7 +393,7 @@ ivas_error ivas_sba_enc_reconfigure( #ifdef SBA_BR_SWITCHING_RECONFIG if ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) { - if ( hEncoderConfig->Opt_DTX_ON && ( st_ivas->nchan_transport > 2 ) ) + if ( hEncoderConfig->Opt_DTX_ON && ( st_ivas->nchan_transport > 2 ) ) { return IVAS_ERR_DTX_NOT_SUPPORTED; } diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 7c630ebe26..44a3b8cbcc 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -185,7 +185,7 @@ ivas_error ivas_sce_enc( &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, - st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format + st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format #ifdef SBA_BR_SWITCHING_RECONFIG , st_ivas->flag_sba_bitrate_switch -- GitLab From 23b7b5e62116366c6dd4f564a6ef9124d6edd035 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 4 Jan 2023 16:03:45 +0530 Subject: [PATCH 09/20] Clang format applied --- lib_enc/ivas_spar_encoder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 6f949fb01c..7d87ec6b61 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -319,7 +319,9 @@ ivas_error ivas_spar_enc( // VE: last 1ms of 'ppFilterbank_prior_input' is not correct for ( int16_t i = 0; i < st_ivas->nchan_transport; i++ ) { - mvr2r( sts[i]->input_buff + NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ), st_ivas->hSpar->hFbMixer->ppFilterbank_prior_input[i] + st_ivas->hSpar->hFbMixer->fb_cfg->prior_input_length - input_frame, input_frame ); + mvr2r( ( sts[i]->input_buff + NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ), + ( st_ivas->hSpar->hFbMixer->ppFilterbank_prior_input[i] + st_ivas->hSpar->hFbMixer->fb_cfg->prior_input_length - input_frame ), + input_frame ); } //VE: TBD - update 'st->input_buff' for SparVAD -- GitLab From 6990b7d8b9cd66909e39359484844258b4e33bd6 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 4 Jan 2023 16:18:05 +0530 Subject: [PATCH 10/20] Resolving clang format error --- lib_enc/ivas_spar_encoder.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 7d87ec6b61..19a87d2cd9 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -321,10 +321,8 @@ ivas_error ivas_spar_enc( { mvr2r( ( sts[i]->input_buff + NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ), ( st_ivas->hSpar->hFbMixer->ppFilterbank_prior_input[i] + st_ivas->hSpar->hFbMixer->fb_cfg->prior_input_length - input_frame ), - input_frame ); + input_frame ); //VE: TBD - update 'st->input_buff' for SparVAD } - - //VE: TBD - update 'st->input_buff' for SparVAD } #endif -- GitLab From f166b20a14db34a4011dd918e307d60a5495ba92 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 4 Jan 2023 16:32:20 +0530 Subject: [PATCH 11/20] Resolving clang error : set 2 --- lib_enc/ivas_spar_encoder.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 19a87d2cd9..8bdfbef0e1 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -320,8 +320,7 @@ ivas_error ivas_spar_enc( for ( int16_t i = 0; i < st_ivas->nchan_transport; i++ ) { mvr2r( ( sts[i]->input_buff + NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ), - ( st_ivas->hSpar->hFbMixer->ppFilterbank_prior_input[i] + st_ivas->hSpar->hFbMixer->fb_cfg->prior_input_length - input_frame ), - input_frame ); //VE: TBD - update 'st->input_buff' for SparVAD + ( st_ivas->hSpar->hFbMixer->ppFilterbank_prior_input[i] + st_ivas->hSpar->hFbMixer->fb_cfg->prior_input_length - input_frame ), input_frame ); } } #endif -- GitLab From 7e0aa8250971d926fa8b396ebce337bf2cd1c4c2 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 4 Jan 2023 20:07:18 +0530 Subject: [PATCH 12/20] Resolving memory sanitizer error --- lib_enc/ivas_sba_enc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index e02322f319..ab4ebad853 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -427,7 +427,8 @@ ivas_error ivas_sba_enc_reconfigure( { return error; } - + /*Initialization*/ + hSpar->hMdEnc->table_idx = -1; /* FB mixer handle */ ivas_FB_mixer_close( &hSpar->hFbMixer, hEncoderConfig->input_Fs ); -- GitLab From 8a7e01530738a67c8a198ccb96691d64c5d19c7d Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Thu, 5 Jan 2023 11:09:10 +0530 Subject: [PATCH 13/20] Resolving memory sanitizer error :set 2 --- lib_dec/ivas_corecoder_dec_reconfig.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 0c8fbe2b0d..792d4cbd24 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -296,7 +296,10 @@ ivas_error ivas_corecoder_dec_reconfig( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->use_itd = 0; st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->reverse_dmx = 0; st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->smooth_ratio = 1.f; - +#ifdef SBA_BR_SWITCHING_RECONFIG + st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->IGFStereoMode[0] = -1; + st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->IGFStereoMode[1] = -1; +#endif for ( n = 0; n < CPE_CHANNELS; n++ ) { /* reset mct_chan_mode */ -- GitLab From 82228af2c19f7ac4570996d9627e0d419baf2ab7 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Fri, 6 Jan 2023 18:35:27 +0530 Subject: [PATCH 14/20] Address review comments:set 1 --- lib_com/ivas_prot.h | 34 ++---------------------------- lib_com/options.h | 7 ++---- lib_enc/ivas_core_pre_proc_front.c | 13 +----------- lib_enc/ivas_cpe_enc.c | 7 +----- lib_enc/ivas_front_vad.c | 3 ++- lib_enc/ivas_init_enc.c | 2 -- lib_enc/ivas_ism_enc.c | 7 +----- lib_enc/ivas_sba_enc.c | 6 +----- lib_enc/ivas_sce_enc.c | 7 +----- lib_enc/ivas_stat_enc.h | 2 -- 10 files changed, 11 insertions(+), 77 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6eaa59c73d..ad30acb039 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -226,9 +226,6 @@ ivas_error pre_proc_front_ivas( const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t ivas_format /* i : IVAS format */ -#ifdef SBA_BR_SWITCHING_RECONFIG - , const int16_t flag_sba_bitrate_switch /* i : SBA bitrate switch flag */ -#endif ); ivas_error pre_proc_ivas( @@ -3130,44 +3127,17 @@ void ivas_sba_config( int16_t *nCPE, /* o : number of CPEs */ int16_t *element_mode /* o : element mode of the core coder */ ); -#ifndef SBA_BR_SWITCHING_RECONFIG - -ivas_error ivas_sba_enc_reconfigure( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -#ifdef SBA_BR_SWITCHING -ivas_error ivas_sba_enc_reinit( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); -int16_t get_sba_reinit_flag( - int32_t ivas_total_bitrate, /* i : Current bitrate */ - int32_t last_ivas_total_brate /* i : Previous bitrate */ -#ifdef SBA_BR_SWITCHING - , const int16_t sba_order -#endif -); -#endif -#ifdef SBA_BR_SWITCHING -ivas_error ivas_spar_md_enc_init -( - ivas_spar_md_enc_state_t *hMdEnc, /* o : MD encoder handle */ - const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ -); -#endif -#endif ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); - +#ifndef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING ivas_error ivas_sba_dec_reinit( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif - +#endif void ivas_init_dec_get_num_cldfb_instances( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ diff --git a/lib_com/options.h b/lib_com/options.h index c528ef68ce..dd94e750ee 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,12 +141,9 @@ #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define SBA_BR_SWITCHING_RECONFIG /* Issue 114: Changes for SBA bitrate switching with reconfiguration for bitrates with different number of transport channels*/ -#ifdef SBA_BR_SWITCHING_RECONFIG #define SBA_BR_SWITCHING /* Issue 114: Changes for SBA bit rate switching with reconfiguration for bitrates with same number of transport channels*/ -#endif -#ifndef SBA_BR_SWITCHING -#define SBA_BR_SWITCHING /* Issue 114: Changes for SBA bit rate switching with reconfiguration for bitrates with same no:of transport channels and reinitialization for different no:of transport channels */ +#ifdef SBA_BR_SWITCHING +#define SBA_BR_SWITCHING_RECONFIG /* Issue 114: Changes for SBA bitrate switching with reconfiguration for bitrates with different number of transport channels*/ #endif #define BRATE_SWITCHING_RENDERING /* Bitrate switching changes related to the renderers */ #define FIX_I59_DELAY_ROUNDING /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */ diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 7887748e2d..e7741a10da 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -108,12 +108,7 @@ ivas_error pre_proc_front_ivas( const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ const int32_t ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX */ - const int16_t ivas_format -#ifdef SBA_BR_SWITCHING_RECONFIG - , - const int16_t flag_sba_bitrate_switch -#endif -) + const int16_t ivas_format ) { float *inp_12k8, *new_inp_12k8; /* pointers to current frame and new data */ float *wsp; /* weighted input signal buffer */ @@ -461,12 +456,6 @@ ivas_error pre_proc_front_ivas( st->vad_flag = front_vad_flag; st->localVAD = front_vad_flag; } -#ifdef SBA_BR_SWITCHING_RECONFIG - if ( flag_sba_bitrate_switch ) - { - st->vad_flag = 1; - } -#endif if ( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL ) { *vad_flag_dtx = dtx_hangover_addition( st, st->vad_flag, st->lp_speech - st->lp_noise, 0, vad_hover_flag, NULL, NULL, NULL ); diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index e524bae615..1ab8a5084c 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -433,12 +433,7 @@ ivas_error ivas_cpe_enc( &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, - ivas_total_brate, st_ivas->hEncoderConfig->ivas_format -#ifdef SBA_BR_SWITCHING_RECONFIG - , - st_ivas->flag_sba_bitrate_switch -#endif - ); + ivas_total_brate, st_ivas->hEncoderConfig->ivas_format ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index c95f0bc47a..9bb9230077 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -397,7 +397,8 @@ ivas_error front_vad_spar( hFrontVad = hSpar->hFrontVad; st = hSpar->hCoreCoderVAD; - if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_total_brate <= SBA_DTX_BITRATE_THRESHOLD ) + if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_total_brate <= SBA_DTX_BITRATE_THRESHOLD && + hEncoderConfig->ivas_total_brate == hEncoderConfig->last_ivas_total_brate ) { /*------------------------------------------------------------------* * Initialization diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 3a5b4fdd72..6f2d8e377c 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -346,8 +346,6 @@ ivas_error ivas_init_encoder( #ifdef SBA_BR_SWITCHING st_ivas->sba_reinit_flag = 0; #endif -#else - st_ivas->flag_sba_bitrate_switch = 0; #endif /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 752528d365..1849d2da03 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -150,12 +150,7 @@ ivas_error ivas_ism_enc( &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, - st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format -#ifdef SBA_BR_SWITCHING_RECONFIG - , - 0 -#endif - ); + st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index ab4ebad853..380429f2cf 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -332,10 +332,6 @@ ivas_error ivas_sba_enc_reconfigure( error = IVAS_ERR_OK; - -#ifdef SBA_BR_SWITCHING_RECONFIG - st_ivas->flag_sba_bitrate_switch = 0; -#endif hEncoderConfig = st_ivas->hEncoderConfig; ivas_total_brate = hEncoderConfig->ivas_total_brate; @@ -351,7 +347,6 @@ ivas_error ivas_sba_enc_reconfigure( #ifdef SBA_BR_SWITCHING_RECONFIG SBA_MODE sba_mode_old; sba_mode_old = st_ivas->sba_mode; - st_ivas->flag_sba_bitrate_switch = 1; #endif st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); #ifdef SBA_BR_SWITCHING @@ -391,6 +386,7 @@ ivas_error ivas_sba_enc_reconfigure( #endif #ifdef SBA_BR_SWITCHING_RECONFIG + /*TODO : Verify if full SPAR close and open can be used instead of submodules close and open */ if ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) { if ( hEncoderConfig->Opt_DTX_ON && ( st_ivas->nchan_transport > 2 ) ) diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 44a3b8cbcc..a67c527081 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -185,12 +185,7 @@ ivas_error ivas_sce_enc( &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, - st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format -#ifdef SBA_BR_SWITCHING_RECONFIG - , - st_ivas->flag_sba_bitrate_switch -#endif - ); + st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 832cf555f4..11dd51104d 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1042,8 +1042,6 @@ typedef struct #ifdef SBA_BR_SWITCHING int16_t sba_reinit_flag; /*flag indicating whether reinitialisation or reconfiguration function should be used*/ #endif -#else - int16_t flag_sba_bitrate_switch; /*flag indicating whether SBA bitrate switching */ #endif float **mem_hp20_in; /* input signals HP filter memories */ -- GitLab From 17ea12b3a39f364c2fc84f93fe6cff13caa81c25 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 9 Jan 2023 12:06:28 +0530 Subject: [PATCH 15/20] Moved a change to under the switch --- lib_enc/ivas_front_vad.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 9bb9230077..b97146313c 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -396,9 +396,12 @@ ivas_error front_vad_spar( hFrontVad = hSpar->hFrontVad; st = hSpar->hCoreCoderVAD; - +#ifdef SBA_BR_SWITCHING_RECONFIG if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_total_brate <= SBA_DTX_BITRATE_THRESHOLD && hEncoderConfig->ivas_total_brate == hEncoderConfig->last_ivas_total_brate ) +#else + if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_total_brate <= SBA_DTX_BITRATE_THRESHOLD ) +#endif { /*------------------------------------------------------------------* * Initialization -- GitLab From 17f92b46b867c026a66145e685f0b0d1a146ad77 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 9 Jan 2023 19:56:43 +0530 Subject: [PATCH 16/20] Address review comments : set 2 --- lib_dec/ivas_sba_dec.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index bd3bbaeb14..72d1cf647e 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -726,21 +726,24 @@ ivas_error ivas_sba_dec_reconfigure( hDirAC = st_ivas->hDirAC; } - +#ifndef SBA_BR_SWITCHING_RECONFIG if ( hDirAC != NULL ) +#else + if ( ( hDirAC != NULL ) + && ( sba_mode_old == st_ivas->sba_mode ) ) +#endif { ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE_MODE ); - +#ifndef SBA_BR_SWITCHING_RECONFIG mvs2s( hDirAC->dirac_to_spar_md_bands, hSpar->dirac_to_spar_md_bands, DIRAC_MAX_NBANDS ); hSpar->enc_param_start_band = hDirAC->hConfig->enc_param_start_band; +#endif } - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK ) { return error; } } - if ( st_ivas->nchan_transport == 1 ) { st_ivas->element_mode_init = IVAS_SCE; @@ -808,24 +811,27 @@ ivas_error ivas_sba_dec_reconfigure( } #endif #ifdef SBA_BR_SWITCHING_RECONFIG - if ( sba_mode_old != st_ivas->sba_mode ) // VE: TBD - possibly merge with the 'else if' branch below + if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC || ( sba_mode_old != st_ivas->sba_mode ) ) { + DIRAC_CONFIG_FLAG flag_config; + + flag_config = DIRAC_OPEN; if ( st_ivas->hDirAC != NULL ) { - if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE_MODE ) ) != IVAS_ERR_OK ) + flag_config = DIRAC_RECONFIGURE; + if ( sba_mode_old != st_ivas->sba_mode && st_ivas->sba_mode != SBA_MODE_SPAR ) { - return error; + flag_config = DIRAC_RECONFIGURE_MODE; } } - else + + if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } -#endif +#else #ifdef SBA_BR_SWITCHING if ( ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) { @@ -844,6 +850,9 @@ ivas_error ivas_sba_dec_reconfigure( } } } +#endif +#endif +#ifdef SBA_BR_SWITCHING else if ( st_ivas->renderer_type == RENDERER_DISABLE || ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR ) ) { if ( st_ivas->hDirAC != NULL ) -- GitLab From d8ef287624de6b29341831cdcf6a5291f9b5655f Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 9 Jan 2023 20:15:52 +0530 Subject: [PATCH 17/20] Resolving pipeline errors --- lib_dec/ivas_sba_dec.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 72d1cf647e..c7f14a0a80 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -729,8 +729,7 @@ ivas_error ivas_sba_dec_reconfigure( #ifndef SBA_BR_SWITCHING_RECONFIG if ( hDirAC != NULL ) #else - if ( ( hDirAC != NULL ) - && ( sba_mode_old == st_ivas->sba_mode ) ) + if ( ( hDirAC != NULL ) && ( sba_mode_old == st_ivas->sba_mode ) ) #endif { ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE_MODE ); @@ -811,7 +810,7 @@ ivas_error ivas_sba_dec_reconfigure( } #endif #ifdef SBA_BR_SWITCHING_RECONFIG - if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC || ( sba_mode_old != st_ivas->sba_mode ) ) + if ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) || ( sba_mode_old != st_ivas->sba_mode ) ) { DIRAC_CONFIG_FLAG flag_config; @@ -829,7 +828,6 @@ ivas_error ivas_sba_dec_reconfigure( { return error; } - } #else #ifdef SBA_BR_SWITCHING -- GitLab From bf5cda2b53fce3ad25ef66139dbe8010c1e8ec6d Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 9 Jan 2023 20:26:02 +0530 Subject: [PATCH 18/20] Resolving pipeline warnings --- lib_dec/ivas_sba_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index c7f14a0a80..89e72ee9f4 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -810,7 +810,7 @@ ivas_error ivas_sba_dec_reconfigure( } #endif #ifdef SBA_BR_SWITCHING_RECONFIG - if ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) || ( sba_mode_old != st_ivas->sba_mode ) ) + if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) ) { DIRAC_CONFIG_FLAG flag_config; -- GitLab From f26cc865bc4c0e7cb4327b9597ef04efc595c02f Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Tue, 10 Jan 2023 17:51:10 +0530 Subject: [PATCH 19/20] Fix for DTX with SBA BR switching crash --- lib_enc/ivas_front_vad.c | 6 +----- lib_enc/ivas_sba_enc.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index b97146313c..c95f0bc47a 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -396,12 +396,8 @@ ivas_error front_vad_spar( hFrontVad = hSpar->hFrontVad; st = hSpar->hCoreCoderVAD; -#ifdef SBA_BR_SWITCHING_RECONFIG - if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_total_brate <= SBA_DTX_BITRATE_THRESHOLD && - hEncoderConfig->ivas_total_brate == hEncoderConfig->last_ivas_total_brate ) -#else + if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_total_brate <= SBA_DTX_BITRATE_THRESHOLD ) -#endif { /*------------------------------------------------------------------* * Initialization diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 380429f2cf..d1fc5b11e5 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -523,6 +523,27 @@ ivas_error ivas_sba_enc_reconfigure( #else ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old ); #endif + +#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; -- GitLab From 3527c98c75e7955abc285a604db31eec2deb7da5 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 11 Jan 2023 11:48:26 +0530 Subject: [PATCH 20/20] Removed a condition check --- lib_enc/ivas_sba_enc.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index d1fc5b11e5..71ad626a4a 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -389,10 +389,6 @@ ivas_error ivas_sba_enc_reconfigure( /*TODO : Verify if full SPAR close and open can be used instead of submodules close and open */ if ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) { - if ( hEncoderConfig->Opt_DTX_ON && ( st_ivas->nchan_transport > 2 ) ) - { - return IVAS_ERR_DTX_NOT_SUPPORTED; - } /* FB mixer handle */ if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { -- GitLab