From dfe0767bb8e524a8b75cfb85c4907e80780622ea Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Fri, 3 Feb 2023 12:13:43 +0530 Subject: [PATCH 01/21] Cleanup for SBA reconfig functions [x] Added cleanup changes for both encoder and decoder reconfig functions --- lib_com/ivas_prot.h | 14 +++ lib_com/options.h | 1 + lib_dec/ivas_init_dec.c | 8 ++ lib_dec/ivas_sba_dec.c | 71 +++++++++++- lib_dec/ivas_spar_decoder.c | 124 ++++++++++++-------- lib_enc/ivas_init_enc.c | 8 ++ lib_enc/ivas_sba_enc.c | 125 ++++++++++++++------ lib_enc/ivas_spar_encoder.c | 219 +++++++++++++++++++++--------------- 8 files changed, 399 insertions(+), 171 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6f4d27d5e8..89a548d6e1 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3811,12 +3811,18 @@ void FdCngDecodeDiracMDCTStereoSID( ivas_error ivas_spar_enc_open( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ,const int16_t spar_reconfig_flag +#endif ); void ivas_spar_enc_close( SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder handle */ const int32_t input_Fs, /* i : input sampling rate */ const int16_t nchan_inp /* i : number of input channels */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ,const int16_t spar_reconfig_flag +#endif ); ivas_error ivas_spar_enc( @@ -3829,11 +3835,19 @@ ivas_error ivas_spar_enc( ivas_error ivas_spar_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + , + const int16_t spar_reconfig_flag +#endif ); void ivas_spar_dec_close( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs /* i : output sampling rate */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + , + const int16_t spar_reconfig_flag +#endif ); ivas_error ivas_spar_dec( diff --git a/lib_com/options.h b/lib_com/options.h index 5dddf236ea..1cef4a5d83 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,6 +145,7 @@ #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*/ #define SBA_BR_SWITCHING_COMPLEXITY_FIX /* VA: fix complexity overhead */ +#define SBA_BR_SWITCHING_CLEAN_UP #endif #define FIX_I59_DELAY_ROUNDING /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */ #define FIX_FIX_I59 /* Issue 59: small fix concerning LFE delay rounding */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 763c83dc39..f4cb9de752 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -813,7 +813,11 @@ ivas_error ivas_init_decoder( { if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1673,7 +1677,11 @@ void ivas_destroy_dec( /* Spar handle */ if ( st_ivas->hSpar != NULL ) { +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs, 0 ); +#else ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs ); +#endif st_ivas->hSpar = NULL; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index fbdc4f5857..1ea5cc1a92 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -625,7 +625,11 @@ ivas_error ivas_sba_dec_reconfigure( if ( st_ivas->sba_mode != SBA_MODE_SPAR ) { +#ifndef SBA_BR_SWITCHING_CLEAN_UP ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs ); +#else + ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs, 0 ); +#endif st_ivas->hSpar = NULL; 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, -1 ) ) != IVAS_ERR_OK ) @@ -637,20 +641,24 @@ ivas_error ivas_sba_dec_reconfigure( } else { +#ifdef SBA_BR_SWITCHING_CLEAN_UP + int16_t sba_order_internal, nchan_internal; +#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; +#endif 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 ); +#ifndef SBA_BR_SWITCHING_CLEAN_UP 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; @@ -708,7 +716,47 @@ ivas_error ivas_sba_dec_reconfigure( } hSpar->i_subframe = 0; } +#else + if ( hSpar != NULL ) + { + if ( hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 ) + { + if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" ); + } + + ivas_pca_dec_init( hSpar->hPCA ); + } + else if ( hSpar->hPCA != NULL ) + { + free( st_ivas->hSpar->hPCA ); + hSpar->hPCA = NULL; + } + if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) ) + { + + ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs, 1 ); + + if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); + } + else + { + if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + } + hSpar = st_ivas->hSpar; + st_ivas->sba_dirac_stereo_flag = 0; +#endif #endif +#ifndef SBA_BR_SWITCHING_CLEAN_UP /* PCA handle */ if ( hSpar != NULL ) { @@ -768,6 +816,7 @@ ivas_error ivas_sba_dec_reconfigure( { return error; } +#endif } if ( st_ivas->nchan_transport == 1 ) { @@ -849,6 +898,25 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } #ifdef SBA_BR_SWITCHING_RECONFIG +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) || ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) + { + DIRAC_CONFIG_FLAG flag_config; + flag_config = DIRAC_OPEN; + if ( st_ivas->hDirAC != NULL ) + { + flag_config = DIRAC_RECONFIGURE_MODE; + if ( ( sba_mode_old == st_ivas->sba_mode ) && ( st_ivas->sba_mode != SBA_MODE_SPAR ) ) + { + flag_config = DIRAC_RECONFIGURE; + } + } + if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else 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; @@ -868,6 +936,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } +#endif #else #ifdef SBA_BR_SWITCHING if ( ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 2eff5d2cba..119c4b1bc9 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -61,6 +61,10 @@ static void ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 ); ivas_error ivas_spar_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + , + const int16_t spar_reconfig_flag +#endif ) { SPAR_DEC_HANDLE hSpar; @@ -73,13 +77,19 @@ ivas_error ivas_spar_dec_open( error = IVAS_ERR_OK; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); num_channels_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); - - /* SPAR decoder handle */ - if ( ( hSpar = (SPAR_DEC_HANDLE) malloc( sizeof( SPAR_DEC_DATA ) ) ) == NULL ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + hSpar = st_ivas->hSpar; + if ( !spar_reconfig_flag ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder" ); +#endif + /* SPAR decoder handle */ + if ( ( hSpar = (SPAR_DEC_HANDLE) malloc( sizeof( SPAR_DEC_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder" ); + } +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - +#endif output_Fs = st_ivas->hDecoderConfig->output_Fs; /* TD decorr. */ @@ -110,25 +120,30 @@ ivas_error ivas_spar_dec_open( { return error; } - - /* AGC handle */ - if ( ( error = ivas_spar_agc_dec_open( &hSpar->hAgcDec, output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* PCA handle */ - hSpar->hPCA = NULL; - if ( st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { - if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) +#endif + /* AGC handle */ + if ( ( error = ivas_spar_agc_dec_open( &hSpar->hAgcDec, output_Fs ) ) != IVAS_ERR_OK ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" ); + return error; } - ivas_pca_dec_init( hSpar->hPCA ); - } + /* PCA handle */ + hSpar->hPCA = NULL; + if ( st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 ) + { + if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" ); + } + ivas_pca_dec_init( hSpar->hPCA ); + } +#ifdef SBA_BR_SWITCHING_CLEAN_UP + } +#endif /* mixer_mat intitialization */ for ( i = 0; i < num_channels_internal; i++ ) { @@ -145,30 +160,35 @@ ivas_error ivas_spar_dec_open( } } hSpar->i_subframe = 0; - - /*-----------------------------------------------------------------* +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) + { +#endif + /*-----------------------------------------------------------------* * Configuration - set SPAR high-level parameters *-----------------------------------------------------------------*/ - ivas_spar_config( st_ivas->hDecoderConfig->ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); - - switch ( sba_order_internal ) - { - case 1: - st_ivas->transport_config = AUDIO_CONFIG_FOA; - break; - case 2: - st_ivas->transport_config = AUDIO_CONFIG_HOA2; - break; - case 3: - st_ivas->transport_config = AUDIO_CONFIG_HOA3; - break; - } + ivas_spar_config( st_ivas->hDecoderConfig->ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); - ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config ); + switch ( sba_order_internal ) + { + case 1: + st_ivas->transport_config = AUDIO_CONFIG_FOA; + break; + case 2: + st_ivas->transport_config = AUDIO_CONFIG_HOA2; + break; + case 3: + st_ivas->transport_config = AUDIO_CONFIG_HOA3; + break; + } - st_ivas->hSpar = hSpar; + ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config ); + st_ivas->hSpar = hSpar; +#ifdef SBA_BR_SWITCHING_CLEAN_UP + } +#endif return error; } @@ -182,6 +202,10 @@ ivas_error ivas_spar_dec_open( void ivas_spar_dec_close( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs /* i : output sampling rate */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + , + const int16_t spar_reconfig_flag +#endif ) { if ( hSpar != NULL ) @@ -194,19 +218,25 @@ void ivas_spar_dec_close( /* FB mixer handle */ ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs ); +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) + { +#endif + /* AGC */ + ivas_spar_agc_dec_close( &hSpar->hAgcDec ); - /* AGC */ - ivas_spar_agc_dec_close( &hSpar->hAgcDec ); + /* PCA */ + if ( hSpar->hPCA != NULL ) + { + free( hSpar->hPCA ); + hSpar->hPCA = NULL; + } - /* PCA */ - if ( hSpar->hPCA != NULL ) - { - free( hSpar->hPCA ); - hSpar->hPCA = NULL; + free( hSpar ); + hSpar = NULL; +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - - free( hSpar ); - hSpar = NULL; +#endif } return; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index fd92453980..b6a1712a69 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -448,7 +448,11 @@ ivas_error ivas_init_encoder( if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_spar_enc_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_spar_enc_open( st_ivas ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -939,7 +943,11 @@ void ivas_destroy_enc( /* SPAR handle */ if ( st_ivas->hSpar != NULL ) { +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ivas_spar_enc_close( st_ivas->hSpar, st_ivas->hEncoderConfig->input_Fs, nchan_inp, 0 ); +#else ivas_spar_enc_close( st_ivas->hSpar, st_ivas->hEncoderConfig->input_Fs, nchan_inp ); +#endif st_ivas->hSpar = NULL; } diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 7fd96ae46e..a0b59ac2b0 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -348,16 +348,22 @@ ivas_error ivas_sba_enc_reconfigure( #ifdef SBA_BR_SWITCHING_RECONFIG sba_mode_old = st_ivas->sba_mode; #endif - +#ifdef SBA_BR_SWITCHING_CLEAN_UP + int16_t spar_reconfig_flag; + spar_reconfig_flag = 0; +#endif 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 ); - if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { if ( st_ivas->hSpar == NULL ) { +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_spar_enc_open( st_ivas ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -367,10 +373,26 @@ ivas_error ivas_sba_enc_reconfigure( ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); +#ifdef SBA_BR_SWITCHING_CLEAN_UP + for ( int16_t n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) + { + if ( hDirAC->sba_synchro_buffer[n] != NULL ) + { + free( hDirAC->sba_synchro_buffer[n] ); + hDirAC->sba_synchro_buffer[n] = NULL; + } + } + hDirAC->num_samples_synchro_delay = 0; +#endif } else { +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ivas_spar_enc_close( st_ivas->hSpar, hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); + +#else ivas_spar_enc_close( st_ivas->hSpar, hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp ); +#endif st_ivas->hSpar = NULL; } @@ -403,7 +425,7 @@ ivas_error ivas_sba_enc_reconfigure( if ( sba_mode_old == SBA_MODE_SPAR ) { // VE: dirty patch -> reconfiguration of SPAR MD, TD_decorr, FbMixer modules should be used instead !! - +#ifndef SBA_BR_SWITCHING_CLEAN_UP IVAS_FB_CFG *fb_cfg; int16_t nchan_internal, sba_order_internal; int16_t table_idx, active_w_mixing; @@ -444,6 +466,18 @@ ivas_error ivas_sba_enc_reconfigure( { return error; } +#else + spar_reconfig_flag = 1; + ivas_spar_enc_close( st_ivas->hSpar, hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); + + if ( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ) != IVAS_ERR_OK ) + { + return error; + } + + // VE: TBV - populate 'hSpar->hFrontVad' with 'hCoreCoder[0]' instead of resetting it to init-state? + +#endif } } else @@ -463,11 +497,6 @@ ivas_error ivas_sba_enc_reconfigure( 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 ) @@ -488,57 +517,83 @@ ivas_error ivas_sba_enc_reconfigure( } } } - else + } +#ifndef SBA_BR_SWITCHING_CLEAN_UP + /* 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 ) { - for ( int16_t n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) + 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] != NULL ) + if ( ( hDirAC->sba_synchro_buffer[n] = (float *) malloc( hDirAC->num_samples_synchro_delay * sizeof( float ) ) ) == NULL ) { - free( hDirAC->sba_synchro_buffer[n] ); - hDirAC->sba_synchro_buffer[n] = 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 ) + { + free( hDirAC->sba_synchro_buffer[n] ); + hDirAC->sba_synchro_buffer[n] = NULL; } - hDirAC->num_samples_synchro_delay = 0; } + hDirAC->num_samples_synchro_delay = 0; } + } +#endif #endif - ivas_dirac_enc_reconfigure( st_ivas ); + ivas_dirac_enc_reconfigure( st_ivas ); #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 ); - hSpar->enc_param_start_band = hDirAC->hConfig->enc_param_start_band; - } + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) + { + 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 - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * Allocate, initalize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ - 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 ); + 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 ( st_ivas->hEncoderConfig->Opt_DTX_ON ) + { + if ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) { - 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++ ) { - for ( int16_t sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - st_ivas->hSCE[sce_id]->hCoreCoder[0]->ini_frame = 1; - } + 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 cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + for ( int16_t n = 0; n < CPE_CHANNELS; n++ ) { - for ( int16_t n = 0; n < CPE_CHANNELS; n++ ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->ini_frame = 1; - } + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->ini_frame = 1; } } } -#endif } +#endif +} - return error; +return error; } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 5e9dd6400c..b90cb748e9 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -59,6 +59,10 @@ static ivas_error ivas_spar_enc_process( Encoder_Struct *st_ivas, const ENCODER_ ivas_error ivas_spar_enc_open( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + , + const int16_t spar_reconfig_flag +#endif ) { SPAR_ENC_HANDLE hSpar; @@ -71,13 +75,22 @@ ivas_error ivas_spar_enc_open( hEncoderConfig = st_ivas->hEncoderConfig; error = IVAS_ERR_OK; - - /* SPAR encoder handle */ - if ( ( hSpar = (SPAR_ENC_HANDLE) malloc( sizeof( SPAR_ENC_DATA ) ) ) == NULL ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR encoder" ); +#endif + /* SPAR encoder handle */ + if ( ( hSpar = (SPAR_ENC_HANDLE) malloc( sizeof( SPAR_ENC_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR encoder" ); + } +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - + else + { + hSpar = st_ivas->hSpar; + } +#endif input_Fs = hEncoderConfig->input_Fs; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); nchan_inp = ivas_sba_get_nchan_metadata( sba_order_internal ); @@ -112,49 +125,58 @@ ivas_error ivas_spar_enc_open( { return error; } - - /* Transient Detector handle */ - if ( ( error = ivas_spar_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + /* initialization */ + hSpar->hMdEnc->table_idx = -1; +#endif +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { - return error; - } +#endif + /* Transient Detector handle */ + if ( ( error = ivas_spar_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } - /* AGC handle */ + /* AGC handle */ #ifdef DEBUG_AGC_ENCODER_CMD_OPTION - hSpar->AGC_Enable = ivas_agc_enc_get_flag( hEncoderConfig->Opt_AGC_ON, nchan_transport ); + hSpar->AGC_Enable = ivas_agc_enc_get_flag( hEncoderConfig->Opt_AGC_ON, nchan_transport ); #else hSpar->AGC_Enable = ivas_agc_enc_get_flag( nchan_transport ); #endif - hSpar->hAgcEnc = NULL; - if ( hSpar->AGC_Enable ) - { - if ( ( error = ivas_spar_agc_enc_open( &hSpar->hAgcEnc, input_Fs, nchan_inp ) ) != IVAS_ERR_OK ) + hSpar->hAgcEnc = NULL; + if ( hSpar->AGC_Enable ) { - return error; + if ( ( error = ivas_spar_agc_enc_open( &hSpar->hAgcEnc, input_Fs, nchan_inp ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - /* PCA handle */ - hSpar->hPCA = NULL; - if ( hEncoderConfig->Opt_PCA_ON ) - { - if ( ( hSpar->hPCA = (PCA_ENC_STATE *) malloc( sizeof( PCA_ENC_STATE ) ) ) == NULL ) + /* PCA handle */ + hSpar->hPCA = NULL; + if ( hEncoderConfig->Opt_PCA_ON ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR PCA encoder" ); + if ( ( hSpar->hPCA = (PCA_ENC_STATE *) malloc( sizeof( PCA_ENC_STATE ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR PCA encoder" ); + } + ivas_pca_enc_init( hSpar->hPCA ); } - ivas_pca_enc_init( hSpar->hPCA ); - } - - /* initialization */ - hSpar->hMdEnc->table_idx = -1; - - /*-----------------------------------------------------------------* - * Configuration - set SPAR high-level parameters - *-----------------------------------------------------------------*/ - - ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), - &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 ); +#ifndef SBA_BR_SWITCHING_CLEAN_UP + /* initialization */ + hSpar->hMdEnc->table_idx = -1; +#endif + /*-----------------------------------------------------------------* + * Configuration - set SPAR high-level parameters + *-----------------------------------------------------------------*/ + ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), + &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 ); +#ifdef SBA_BR_SWITCHING_CLEAN_UP + } +#endif if ( st_ivas->nchan_transport == 1 ) { hEncoderConfig->element_mode_init = IVAS_SCE; @@ -167,45 +189,50 @@ ivas_error ivas_spar_enc_open( /*-----------------------------------------------------------------* * Allocate and initialize Front-VAD handle *-----------------------------------------------------------------*/ - - hSpar->front_vad_flag = 0; - hSpar->front_vad_dtx_flag = 0; - hSpar->force_front_vad = 0; - - if ( hEncoderConfig->Opt_DTX_ON ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { - if ( ( error = front_vad_create( &( hSpar->hFrontVad ), hEncoderConfig ) ) != IVAS_ERR_OK ) - { - return error; - } +#endif + hSpar->front_vad_flag = 0; + hSpar->front_vad_dtx_flag = 0; + hSpar->force_front_vad = 0; - if ( ( hSpar->hCoreCoderVAD = (ENC_CORE_HANDLE) malloc( sizeof( Encoder_State ) ) ) == NULL ) + if ( hEncoderConfig->Opt_DTX_ON ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CoreCoder structure\n" ) ); - } + if ( ( error = front_vad_create( &( hSpar->hFrontVad ), hEncoderConfig ) ) != IVAS_ERR_OK ) + { + return error; + } - copy_encoder_config( st_ivas, hSpar->hCoreCoderVAD, 1 ); + if ( ( hSpar->hCoreCoderVAD = (ENC_CORE_HANDLE) malloc( sizeof( Encoder_State ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CoreCoder structure\n" ) ); + } + + copy_encoder_config( st_ivas, hSpar->hCoreCoderVAD, 1 ); - hSpar->hCoreCoderVAD->total_brate = hEncoderConfig->ivas_total_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ - hSpar->hCoreCoderVAD->mct_chan_mode = MCT_CHAN_MODE_IGNORE; + hSpar->hCoreCoderVAD->total_brate = hEncoderConfig->ivas_total_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + hSpar->hCoreCoderVAD->mct_chan_mode = MCT_CHAN_MODE_IGNORE; - if ( ( error = init_encoder( hSpar->hCoreCoderVAD, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1 ) ) != IVAS_ERR_OK ) + if ( ( error = init_encoder( hSpar->hCoreCoderVAD, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else { - return error; + hSpar->hCoreCoderVAD = NULL; + hSpar->hFrontVad = NULL; } - } - else - { - hSpar->hCoreCoderVAD = NULL; - hSpar->hFrontVad = NULL; - } - - /*-----------------------------------------------------------------* - * Final assignment - *-----------------------------------------------------------------*/ - st_ivas->hSpar = hSpar; + /*-----------------------------------------------------------------* + * Final assignment + *-----------------------------------------------------------------*/ + st_ivas->hSpar = hSpar; +#ifdef SBA_BR_SWITCHING_CLEAN_UP + } +#endif return error; } @@ -220,25 +247,35 @@ void ivas_spar_enc_close( SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder handle */ const int32_t input_Fs, /* i : input sampling rate */ const int16_t nchan_inp /* i : number of input channels */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + , + const int16_t spar_reconfig_flag +#endif ) { int16_t num_chans; if ( hSpar != NULL ) { - /* core-coder-VAD handle */ - if ( hSpar->hCoreCoderVAD != NULL ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { - destroy_core_enc( hSpar->hCoreCoderVAD ); - hSpar->hCoreCoderVAD = NULL; - } +#endif + /* core-coder-VAD handle */ + if ( hSpar->hCoreCoderVAD != NULL ) + { + destroy_core_enc( hSpar->hCoreCoderVAD ); + hSpar->hCoreCoderVAD = NULL; + } - /* front-VAD handle */ - if ( hSpar->hFrontVad != NULL ) - { - front_vad_destroy( &hSpar->hFrontVad ); - hSpar->hFrontVad = NULL; + /* front-VAD handle */ + if ( hSpar->hFrontVad != NULL ) + { + front_vad_destroy( &hSpar->hFrontVad ); + hSpar->hFrontVad = NULL; + } +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - +#endif num_chans = hSpar->hFbMixer->fb_cfg->num_in_chans; assert( num_chans <= nchan_inp ); @@ -250,22 +287,28 @@ void ivas_spar_enc_close( /* FB mixer handle */ ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs ); +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) + { +#endif + /* Trans Det handle */ + ivas_spar_transient_det_close( &hSpar->hTranDet ); - /* Trans Det handle */ - ivas_spar_transient_det_close( &hSpar->hTranDet ); + /* AGC */ + ivas_spar_agc_enc_close( &hSpar->hAgcEnc ); - /* AGC */ - ivas_spar_agc_enc_close( &hSpar->hAgcEnc ); + /* PCA */ + if ( hSpar->hPCA != NULL ) + { + free( hSpar->hPCA ); + hSpar->hPCA = NULL; + } - /* PCA */ - if ( hSpar->hPCA != NULL ) - { - free( hSpar->hPCA ); - hSpar->hPCA = NULL; + free( hSpar ); + hSpar = NULL; +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - - free( hSpar ); - hSpar = NULL; +#endif } return; -- GitLab From 58a57c208c5910f6e7b5f7dd830db738fb1a0aed Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 6 Feb 2023 15:16:10 +0530 Subject: [PATCH 02/21] Minor modifications [x] Added missing braces in the undefined part of the clean up code [x] Proper indendation added to the encoder reconfiguration function --- lib_com/options.h | 2 +- lib_enc/ivas_sba_enc.c | 99 ++++++++++++++++++------------------- lib_enc/ivas_spar_encoder.c | 8 +-- 3 files changed, 52 insertions(+), 57 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1cef4a5d83..b3491e38c3 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,7 +145,7 @@ #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*/ #define SBA_BR_SWITCHING_COMPLEXITY_FIX /* VA: fix complexity overhead */ -#define SBA_BR_SWITCHING_CLEAN_UP +#define SBA_BR_SWITCHING_CLEAN_UP /*Issue 114: Clean up changes for the SBA reconfiguation functions*/ #endif #define FIX_I59_DELAY_ROUNDING /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */ #define FIX_FIX_I59 /* Issue 59: small fix concerning LFE delay rounding */ diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index a0b59ac2b0..7bde5c3445 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -517,83 +517,82 @@ ivas_error ivas_sba_enc_reconfigure( } } } - } #ifndef SBA_BR_SWITCHING_CLEAN_UP - /* 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 ) + /* 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 ) ) ) { - hDirAC->num_samples_synchro_delay = NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); + int16_t n; - for ( n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) + if ( hDirAC->num_samples_synchro_delay == 0 ) { - if ( ( hDirAC->sba_synchro_buffer[n] = (float *) malloc( hDirAC->num_samples_synchro_delay * sizeof( float ) ) ) == NULL ) + hDirAC->num_samples_synchro_delay = NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); + + for ( n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hDirAC synchro buffer\n" ) ); + if ( ( hDirAC->sba_synchro_buffer[n] = (float *) 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; } - 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++ ) + else { - if ( hDirAC->sba_synchro_buffer[n] != NULL ) + for ( int16_t n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) { - free( hDirAC->sba_synchro_buffer[n] ); - hDirAC->sba_synchro_buffer[n] = NULL; + if ( hDirAC->sba_synchro_buffer[n] != NULL ) + { + free( hDirAC->sba_synchro_buffer[n] ); + hDirAC->sba_synchro_buffer[n] = NULL; + } } + hDirAC->num_samples_synchro_delay = 0; } - hDirAC->num_samples_synchro_delay = 0; - } - } + #endif #endif - ivas_dirac_enc_reconfigure( st_ivas ); + } + ivas_dirac_enc_reconfigure( st_ivas ); #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 ); - hSpar->enc_param_start_band = hDirAC->hConfig->enc_param_start_band; - } + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) + { + 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 - /*-----------------------------------------------------------------* - * Allocate, initalize, and configure SCE/CPE/MCT handles - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * Allocate, initalize, and configure SCE/CPE/MCT handles + *-----------------------------------------------------------------*/ - 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 ); + 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 ) ) + if ( st_ivas->hEncoderConfig->Opt_DTX_ON ) { - for ( int16_t sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + if ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) { - st_ivas->hSCE[sce_id]->hCoreCoder[0]->ini_frame = 1; - } + 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++ ) + for ( int16_t cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->ini_frame = 1; + for ( int16_t n = 0; n < CPE_CHANNELS; n++ ) + { + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->ini_frame = 1; + } } } } - } #endif -} - -return error; + } + return error; } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index b90cb748e9..4b818ac160 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -76,6 +76,7 @@ ivas_error ivas_spar_enc_open( hEncoderConfig = st_ivas->hEncoderConfig; error = IVAS_ERR_OK; #ifdef SBA_BR_SWITCHING_CLEAN_UP + hSpar = st_ivas->hSpar; if ( !spar_reconfig_flag ) { #endif @@ -86,10 +87,6 @@ ivas_error ivas_spar_enc_open( } #ifdef SBA_BR_SWITCHING_CLEAN_UP } - else - { - hSpar = st_ivas->hSpar; - } #endif input_Fs = hEncoderConfig->input_Fs; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); @@ -128,8 +125,7 @@ ivas_error ivas_spar_enc_open( #ifdef SBA_BR_SWITCHING_CLEAN_UP /* initialization */ hSpar->hMdEnc->table_idx = -1; -#endif -#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { #endif -- GitLab From 110840888ce49f7f93a0fa0468256424cddc9a5d Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Tue, 14 Feb 2023 14:03:16 +0530 Subject: [PATCH 03/21] Added fb_mixer optimisation --- lib_com/ivas_fb_mixer.c | 215 ++++++++++++++++++++++------------- lib_com/ivas_prot.h | 8 ++ lib_dec/ivas_spar_decoder.c | 8 ++ lib_enc/ivas_dirac_enc.c | 8 ++ lib_enc/ivas_ism_param_enc.c | 8 ++ lib_enc/ivas_mc_param_enc.c | 9 +- lib_enc/ivas_mcmasa_enc.c | 18 ++- lib_enc/ivas_sba_enc.c | 8 ++ lib_enc/ivas_spar_encoder.c | 10 +- 9 files changed, 207 insertions(+), 85 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 5787470e0f..517d91b39c 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -52,7 +52,11 @@ static void ivas_get_ld_fb_resp( float **ppIdeal_FRs_re, float **ppIdeal_FRs_im, static int16_t ivas_fb_mixer_get_band_diff_non48k( const int32_t sampling_rate, const float delay_ms ); static const float *ivas_get_cheby_ramp( const int16_t delay ); static void ivas_get_hanning_win( const int16_t len, float *pH_win ); +#ifdef SBA_BR_SWITCHING_CLEAN_UP +static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate, const int16_t spar_reconfig_flag ); +#else static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate ); +#endif static ivas_error ivas_fb_mixer_get_window( const int16_t fade_len, const int32_t sampling_rate, const float **pWindow ); @@ -175,6 +179,10 @@ ivas_error ivas_FB_mixer_open( IVAS_FB_MIXER_HANDLE *hFbMixer_out, /* i/o: FB mixer handle */ const int32_t sampling_rate, /* i : sampling rate */ IVAS_FB_CFG *fb_cfg /* i : FB config. handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + , + const int16_t spar_reconfig_flag +#endif ) { IVAS_FB_MIXER_HANDLE hFbMixer; @@ -185,24 +193,30 @@ ivas_error ivas_FB_mixer_open( error = IVAS_ERR_OK; frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC ); - - - if ( ( hFbMixer = (IVAS_FB_MIXER_HANDLE) malloc( sizeof( IVAS_FB_MIXER_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } - - if ( fb_cfg->num_out_chans > 0 ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + hFbMixer = *hFbMixer_out; + if ( !spar_reconfig_flag ) { - if ( ( hFbMixer->pFb = (ivas_filterbank_t *) malloc( sizeof( ivas_filterbank_t ) ) ) == NULL ) +#endif + if ( ( hFbMixer = (IVAS_FB_MIXER_HANDLE) malloc( sizeof( IVAS_FB_MIXER_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); } + + if ( fb_cfg->num_out_chans > 0 ) + { + if ( ( hFbMixer->pFb = (ivas_filterbank_t *) malloc( sizeof( ivas_filterbank_t ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); + } + } + else + { + hFbMixer->pFb = NULL; + } +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - else - { - hFbMixer->pFb = NULL; - } +#endif if ( fb_cfg->active_w_mixing == -1 ) { num_chs_alloc = 0; @@ -274,59 +288,67 @@ ivas_error ivas_FB_mixer_open( } } } - - if ( fb_cfg->num_out_chans > 0 ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { - const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs; +#endif + if ( fb_cfg->num_out_chans > 0 ) + { + const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs; - num_bands = ivas_get_num_bands( sampling_rate ); + num_bands = ivas_get_num_bands( sampling_rate ); - ivas_get_active_bins( &pActive_bins_per_band, &pActive_bins_per_band_abs, &pStart_offset, &pStart_offset_abs, sampling_rate ); + ivas_get_active_bins( &pActive_bins_per_band, &pActive_bins_per_band_abs, &pStart_offset, &pStart_offset_abs, sampling_rate ); - if ( fb_cfg->active_w_mixing != -1 ) - { - for ( i = 0; i < num_bands; i++ ) + if ( fb_cfg->active_w_mixing != -1 ) { - if ( ( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] = (float *) malloc( sizeof( float ) * pActive_bins_per_band_abs[i] ) ) == NULL ) + for ( i = 0; i < num_bands; i++ ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); + if ( ( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] = (float *) malloc( sizeof( float ) * pActive_bins_per_band_abs[i] ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); + } } } - } - if ( sampling_rate != 48000 ) - { - int16_t num_diff_bands, start_diff_band_non48k; + if ( sampling_rate != 48000 ) + { + int16_t num_diff_bands, start_diff_band_non48k; - num_diff_bands = MAX_NUM_BANDS_DIFF_NON48K; - start_diff_band_non48k = num_bands - num_diff_bands; + num_diff_bands = MAX_NUM_BANDS_DIFF_NON48K; + start_diff_band_non48k = num_bands - num_diff_bands; - hFbMixer->num_diff_bands = num_diff_bands; + hFbMixer->num_diff_bands = num_diff_bands; - for ( j = start_diff_band_non48k; j < num_bands; j++ ) - { - if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL ) + for ( j = start_diff_band_non48k; j < num_bands; j++ ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); - } + if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); + } - if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); + if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); + } } } } - } - else - { + else + { - /* ignore all the deeper filter bank stuff for now */ - hFbMixer->num_diff_bands = 0; + /* ignore all the deeper filter bank stuff for now */ + hFbMixer->num_diff_bands = 0; + } +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - +#endif hFbMixer->fb_cfg = fb_cfg; - +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate, spar_reconfig_flag ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -346,6 +368,10 @@ ivas_error ivas_FB_mixer_open( void ivas_FB_mixer_close( IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ const int32_t sampling_rate /* i : sampling rate in Hz */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + , + const int16_t spar_reconfig_flag +#endif ) { IVAS_FB_MIXER_HANDLE hFbMixer; @@ -404,50 +430,67 @@ void ivas_FB_mixer_close( free( hFbMixer->prior_mixer[0][0] ); hFbMixer->prior_mixer[0][0] = NULL; } - - if ( fb_cfg->num_out_chans > 0 ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { - num_bands = hFbMixer->pFb->filterbank_num_bands; - - if ( fb_cfg->active_w_mixing != -1 ) +#endif + if ( fb_cfg->num_out_chans > 0 ) { - for ( i = 0; i < num_bands; i++ ) + num_bands = hFbMixer->pFb->filterbank_num_bands; + + if ( fb_cfg->active_w_mixing != -1 ) { - free( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] ); - hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] = NULL; + for ( i = 0; i < num_bands; i++ ) + { + free( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] ); + hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] = NULL; + } } - } - - if ( sampling_rate != 48000 ) - { - int16_t start_diff_band_non48k; - start_diff_band_non48k = num_bands - hFbMixer->num_diff_bands; - for ( j = start_diff_band_non48k; j < num_bands; j++ ) + if ( sampling_rate != 48000 ) { - free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] ); - hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] = NULL; + int16_t start_diff_band_non48k; + start_diff_band_non48k = num_bands - hFbMixer->num_diff_bands; + + for ( j = start_diff_band_non48k; j < num_bands; j++ ) + { + free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] ); + hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] = NULL; - free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] ); - hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] = NULL; + free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] ); + hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] = NULL; + } } } +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - - if ( hFbMixer->pFb != NULL ) +#endif +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { - free( hFbMixer->pFb ); - hFbMixer->pFb = NULL; +#endif + if ( hFbMixer->pFb != NULL ) + { + free( hFbMixer->pFb ); + hFbMixer->pFb = NULL; + } +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - +#endif if ( hFbMixer->fb_cfg != NULL ) { free( hFbMixer->fb_cfg ); hFbMixer->fb_cfg = NULL; } - - free( hFbMixer ); - hFbMixer = NULL; +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) + { +#endif + free( hFbMixer ); + hFbMixer = NULL; +#ifdef SBA_BR_SWITCHING_CLEAN_UP + } +#endif } return; @@ -1014,7 +1057,12 @@ static void ivas_get_active_bins( static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, - const int32_t sampling_rate ) + const int32_t sampling_rate +#ifdef SBA_BR_SWITCHING_CLEAN_UP + , + const int16_t spar_reconfig_flag +#endif +) { int16_t i, j; const float *pAll_fb_fr[2]; @@ -1053,17 +1101,22 @@ static ivas_error ivas_filterbank_setup( hFbMixer->cross_fade_end_offset = pCfg->fade_len + pCfg->pcm_offset; hFbMixer->cross_fade_start_offset = hFbMixer->cross_fade_end_offset - pCfg->fade_len; hFbMixer->ana_window_offset = pCfg->fb_latency + pCfg->pcm_offset; - - if ( ( error = ivas_fb_mixer_get_window( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window ) ) ) != IVAS_ERR_OK ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { - return error; - } +#endif + if ( ( error = ivas_fb_mixer_get_window( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window ) ) ) != IVAS_ERR_OK ) + { + return error; + } - if ( ( error = ivas_fb_mixer_get_window( pCfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade ) ) ) != IVAS_ERR_OK ) - { - return error; + if ( ( error = ivas_fb_mixer_get_window( pCfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade ) ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - +#endif if ( pCfg->num_out_chans > 0 ) { ivas_filterbank_t *pFb = hFbMixer->pFb; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 89a548d6e1..774fad4b74 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5316,11 +5316,19 @@ ivas_error ivas_FB_mixer_open( IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ const int32_t sampling_rate, /* i : sampling rate */ IVAS_FB_CFG *fb_cfg /* i : FB config. handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + , + const int16_t spar_reconfig_flag +#endif ); void ivas_FB_mixer_close( IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ const int32_t sampling_rate /* i : sampling rate in Hz */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + , + const int16_t spar_reconfig_flag +#endif ); void ivas_fb_mixer_pcm_ingest( diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 119c4b1bc9..464df9285d 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -116,7 +116,11 @@ ivas_error ivas_spar_dec_open( fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order]; /* FB mixer handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, output_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, output_Fs, fb_cfg ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -217,7 +221,11 @@ void ivas_spar_dec_close( ivas_spar_td_decorr_dec_close( &hSpar->hTdDecorr ); /* FB mixer handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs, spar_reconfig_flag ); +#else ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs ); +#endif #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 92c2f80fad..fceb67d583 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -104,7 +104,11 @@ ivas_error ivas_dirac_enc_open( return error; } /* Allocate and initialize FB mixer handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -238,7 +242,11 @@ void ivas_dirac_enc_close( if ( hDirAC->hFbMixer != NULL ) { +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs, 0 ); +#else ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs ); +#endif } for ( i = 0; i < DIRAC_MAX_ANA_CHANS; i++ ) diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 98054cf51e..40f78939b9 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -281,7 +281,11 @@ ivas_error ivas_param_ism_enc_open( } /* Allocate and initialize FB mixer handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -322,7 +326,11 @@ void ivas_param_ism_enc_close( const int32_t input_Fs /* i : input sampling_rate */ ) { +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs, 0 ); +#else ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs ); +#endif if ( hDirAC->hParamIsm != NULL ) { diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 5de51576e9..3921b3173a 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -146,7 +146,11 @@ ivas_error ivas_param_mc_enc_open( } /* Allocate and initialize FB mixer handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_FB_mixer_open( &( hParamMC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_FB_mixer_open( &( hParamMC->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -366,8 +370,11 @@ void ivas_param_mc_enc_close( const int32_t sampling_rate ) { ivas_param_mc_metadata_close( &hParamMC->hMetadataPMC ); - +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ivas_FB_mixer_close( &hParamMC->hFbMixer, sampling_rate, 0 ); +#else ivas_FB_mixer_close( &hParamMC->hFbMixer, sampling_rate ); +#endif free( hParamMC ); diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index e456cb3b70..1b0c9d8c31 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -195,7 +195,11 @@ ivas_error ivas_mcmasa_enc_open( } /* Allocate and initialize FB mixer handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -217,8 +221,11 @@ ivas_error ivas_mcmasa_enc_open( { return error; } - +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixerLfe ), input_Fs, fb_cfgLfe, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixerLfe ), input_Fs, fb_cfgLfe ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -465,12 +472,19 @@ void ivas_mcmasa_enc_close( free( hMcMasa->lfeAnaRingBuffer[i] ); } } - +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ivas_FB_mixer_close( &hMcMasa->hFbMixer, input_Fs, 0 ); +#else ivas_FB_mixer_close( &hMcMasa->hFbMixer, input_Fs ); +#endif if ( !hMcMasa->separateChannelEnabled ) { +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ivas_FB_mixer_close( &hMcMasa->hFbMixerLfe, input_Fs, 0 ); +#else ivas_FB_mixer_close( &hMcMasa->hFbMixerLfe, input_Fs ); +#endif } /* intensity 3-dim */ diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 7bde5c3445..ee46e7d955 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -418,7 +418,11 @@ ivas_error ivas_sba_enc_reconfigure( // VE: TBV whether 'hFbMixer' can be reused if ( hDirAC->hFbMixer != NULL ) { +#ifndef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs ); +#else + ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, 0 ); +#endif hDirAC->hFbMixer = NULL; } @@ -492,7 +496,11 @@ ivas_error ivas_sba_enc_reconfigure( } /* Allocate and initialize FB mixer handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 4b818ac160..80bc9da9df 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -111,8 +111,12 @@ ivas_error ivas_spar_enc_open( ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, nchan_inp, nchan_transport, active_w_mixing, input_Fs ); fb_cfg->remix_order = remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order]; - /* FB mixer handle */ +/* FB mixer handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( ( error = ivas_FB_mixer_open( &( hSpar->hFbMixer ), input_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_FB_mixer_open( &( hSpar->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -282,7 +286,11 @@ void ivas_spar_enc_close( ivas_spar_covar_enc_close( &hSpar->hCovEnc, num_chans ); /* FB mixer handle */ +#ifdef SBA_BR_SWITCHING_CLEAN_UP + ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs, spar_reconfig_flag ); +#else ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs ); +#endif #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -- GitLab From e6a63766ac62fc392c39a0ac3c5612bee974459f Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Tue, 14 Feb 2023 16:56:51 +0530 Subject: [PATCH 04/21] Fb_mixer optimisation changes : set 2 --- lib_com/ivas_fb_mixer.c | 131 +++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 62 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 517d91b39c..2f3ae8d981 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -1126,87 +1126,94 @@ static ivas_error ivas_filterbank_setup( pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; pFb->fb_bin_to_band.pFb_active_bins_per_band = pAll_bins_per_band_abs; pFb->fb_bin_to_band.pFb_start_bin_per_band = pAll_bins_start_offset_abs; +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) + { +#endif + /* Initialization for short stride Parameter calculation and SPAR CLDFB reconstruction */ + pFb->fb_bin_to_band.num_cldfb_bands = ( int16_t )( sampling_rate * INV_CLDFB_BANDWIDTH + 0.5f ); + /*pFb->fb_bin_to_band.cldfb_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX );*/ /* equals num_cldfb_bands*/ + pFb->fb_bin_to_band.short_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / 4 ); - /* Initialization for short stride Parameter calculation and SPAR CLDFB reconstruction */ - pFb->fb_bin_to_band.num_cldfb_bands = (int16_t) ( sampling_rate * INV_CLDFB_BANDWIDTH + 0.5f ); - /*pFb->fb_bin_to_band.cldfb_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX );*/ /* equals num_cldfb_bands*/ - pFb->fb_bin_to_band.short_stride = (int16_t) ( ( sampling_rate / FRAMES_PER_SEC ) / 4 ); - set_f( pFb->fb_bin_to_band.p_short_stride_bin_to_band, 0.0f, 2 * MDFT_FB_BANDS_240 ); - set_s( pFb->fb_bin_to_band.p_cldfb_map_to_spar_band, 0, CLDFB_NO_CHANNELS_MAX ); - set_s( pFb->fb_bin_to_band.p_spar_start_bands, 0, CLDFB_NO_CHANNELS_MAX ); + set_f( pFb->fb_bin_to_band.p_short_stride_bin_to_band, 0.0f, 2 * MDFT_FB_BANDS_240 ); + set_s( pFb->fb_bin_to_band.p_cldfb_map_to_spar_band, 0, CLDFB_NO_CHANNELS_MAX ); + set_s( pFb->fb_bin_to_band.p_spar_start_bands, 0, CLDFB_NO_CHANNELS_MAX ); - for ( j = 0; j < IVAS_MAX_NUM_FB_BANDS; j++ ) - { - pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j] = 0; /* aka num_active_bins per SPAR band */ - pFb->fb_bin_to_band.p_short_stride_start_bin_per_band[j] = 0; /* first considered bin index per SPAR band */ - pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j] = NULL; - for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + for ( j = 0; j < IVAS_MAX_NUM_FB_BANDS; j++ ) { - pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band[i][j] = 0.0f; + pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j] = 0; /* aka num_active_bins per SPAR band */ + pFb->fb_bin_to_band.p_short_stride_start_bin_per_band[j] = 0; /* first considered bin index per SPAR band */ + pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j] = NULL; + for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band[i][j] = 0.0f; + } } - } - if ( sampling_rate == 48000 ) - { - for ( j = 0; j < pFb->filterbank_num_bands; j++ ) + if ( sampling_rate == 48000 ) { - pFb->fb_consts.ppFilterbank_FRs[0][j] = &pAll_fb_fr[0][offset]; - pFb->fb_consts.ppFilterbank_FRs[1][j] = &pAll_fb_fr[1][offset]; - offset += pFb->fb_consts.pFilterbank_bins_per_band[j]; + for ( j = 0; j < pFb->filterbank_num_bands; j++ ) + { + pFb->fb_consts.ppFilterbank_FRs[0][j] = &pAll_fb_fr[0][offset]; + pFb->fb_consts.ppFilterbank_FRs[1][j] = &pAll_fb_fr[1][offset]; + offset += pFb->fb_consts.pFilterbank_bins_per_band[j]; + } + + ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); } + else + { + float *ppFilterbank_FRs_re_temp[MAX_NUM_BANDS_DIFF_NON48K]; + float *ppFilterbank_FRs_im_temp[MAX_NUM_BANDS_DIFF_NON48K]; + int16_t active_bins_temp[MAX_NUM_BANDS_DIFF_NON48K]; + int16_t start_offset_temp[MAX_NUM_BANDS_DIFF_NON48K]; + int16_t num_diff_bands, start_diff_band_non48k; - ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); - } - else - { - float *ppFilterbank_FRs_re_temp[MAX_NUM_BANDS_DIFF_NON48K]; - float *ppFilterbank_FRs_im_temp[MAX_NUM_BANDS_DIFF_NON48K]; - int16_t active_bins_temp[MAX_NUM_BANDS_DIFF_NON48K]; - int16_t start_offset_temp[MAX_NUM_BANDS_DIFF_NON48K]; - int16_t num_diff_bands, start_diff_band_non48k; + num_diff_bands = MAX_NUM_BANDS_DIFF_NON48K; + start_diff_band_non48k = pFb->filterbank_num_bands - num_diff_bands; - num_diff_bands = MAX_NUM_BANDS_DIFF_NON48K; - start_diff_band_non48k = pFb->filterbank_num_bands - num_diff_bands; + pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band; + pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; - pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band; - pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; + for ( j = 0; j < pFb->filterbank_num_bands; j++ ) + { + int16_t num_active_bins = pFb->fb_consts.pFilterbank_bins_per_band[j]; - for ( j = 0; j < pFb->filterbank_num_bands; j++ ) - { - int16_t num_active_bins = pFb->fb_consts.pFilterbank_bins_per_band[j]; + if ( j < start_diff_band_non48k ) + { + pFb->fb_consts.ppFilterbank_FRs[0][j] = &pAll_fb_fr[0][offset]; + pFb->fb_consts.ppFilterbank_FRs[1][j] = &pAll_fb_fr[1][offset]; + } + else + { + mvr2r( &pAll_fb_fr[0][offset], pFb->fb_consts.ppFilterbank_FRs_non48k[0][j], num_active_bins ); + mvr2r( &pAll_fb_fr[1][offset], pFb->fb_consts.ppFilterbank_FRs_non48k[1][j], num_active_bins ); + } - if ( j < start_diff_band_non48k ) - { - pFb->fb_consts.ppFilterbank_FRs[0][j] = &pAll_fb_fr[0][offset]; - pFb->fb_consts.ppFilterbank_FRs[1][j] = &pAll_fb_fr[1][offset]; + offset += pAll_bins_per_band_48k[j]; } - else + + for ( j = start_diff_band_non48k; j < pFb->filterbank_num_bands; j++ ) { - mvr2r( &pAll_fb_fr[0][offset], pFb->fb_consts.ppFilterbank_FRs_non48k[0][j], num_active_bins ); - mvr2r( &pAll_fb_fr[1][offset], pFb->fb_consts.ppFilterbank_FRs_non48k[1][j], num_active_bins ); + ppFilterbank_FRs_re_temp[j - start_diff_band_non48k] = pFb->fb_consts.ppFilterbank_FRs_non48k[0][j]; + ppFilterbank_FRs_im_temp[j - start_diff_band_non48k] = pFb->fb_consts.ppFilterbank_FRs_non48k[1][j]; + active_bins_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_per_band[j]; + start_offset_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_start_offset[j]; } - offset += pAll_bins_per_band_48k[j]; - } + ivas_get_ld_fb_resp( ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, + active_bins_temp, start_offset_temp, num_diff_bands, pCfg->fb_latency, sampling_rate ); - for ( j = start_diff_band_non48k; j < pFb->filterbank_num_bands; j++ ) - { - ppFilterbank_FRs_re_temp[j - start_diff_band_non48k] = pFb->fb_consts.ppFilterbank_FRs_non48k[0][j]; - ppFilterbank_FRs_im_temp[j - start_diff_band_non48k] = pFb->fb_consts.ppFilterbank_FRs_non48k[1][j]; - active_bins_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_per_band[j]; - start_offset_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_start_offset[j]; - } - - ivas_get_ld_fb_resp( ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, - active_bins_temp, start_offset_temp, num_diff_bands, pCfg->fb_latency, sampling_rate ); + for ( j = start_diff_band_non48k; j < pFb->filterbank_num_bands; j++ ) + { + pFb->fb_consts.ppFilterbank_FRs[0][j] = (const float *) pFb->fb_consts.ppFilterbank_FRs_non48k[0][j]; + pFb->fb_consts.ppFilterbank_FRs[1][j] = (const float *) pFb->fb_consts.ppFilterbank_FRs_non48k[1][j]; + } - for ( j = start_diff_band_non48k; j < pFb->filterbank_num_bands; j++ ) - { - pFb->fb_consts.ppFilterbank_FRs[0][j] = (const float *) pFb->fb_consts.ppFilterbank_FRs_non48k[0][j]; - pFb->fb_consts.ppFilterbank_FRs[1][j] = (const float *) pFb->fb_consts.ppFilterbank_FRs_non48k[1][j]; + ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); } - - ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); +#ifdef SBA_BR_SWITCHING_CLEAN_UP } +#endif } return error; -- GitLab From e7b3fc0ab2d694ed376dee6f438b59456e776be9 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Tue, 14 Feb 2023 18:03:38 +0530 Subject: [PATCH 05/21] fb_mixer optimisation changes : set 3 --- lib_com/ivas_fb_mixer.c | 75 +++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 2f3ae8d981..3eb11ec384 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -193,6 +193,7 @@ ivas_error ivas_FB_mixer_open( error = IVAS_ERR_OK; frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC ); + #ifdef SBA_BR_SWITCHING_CLEAN_UP hFbMixer = *hFbMixer_out; if ( !spar_reconfig_flag ) @@ -464,8 +465,7 @@ void ivas_FB_mixer_close( } #ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif -#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { #endif @@ -1079,32 +1079,32 @@ static ivas_error ivas_filterbank_setup( set_s( hFbMixer->first_frame, 1, pCfg->num_out_chans ); set_s( hFbMixer->first_frame + pCfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - pCfg->num_out_chans ); - - if ( pCfg->num_out_chans > 0 ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { - hFbMixer->pFb->filterbank_num_bands = ivas_get_num_bands( sampling_rate ); +#endif + if ( pCfg->num_out_chans > 0 ) + { + hFbMixer->pFb->filterbank_num_bands = ivas_get_num_bands( sampling_rate ); - ivas_get_active_bins( &pAll_bins_per_band, &pAll_bins_per_band_abs, &pAll_bins_start_offset, &pAll_bins_start_offset_abs, sampling_rate ); + ivas_get_active_bins( &pAll_bins_per_band, &pAll_bins_per_band_abs, &pAll_bins_start_offset, &pAll_bins_start_offset_abs, sampling_rate ); - if ( pCfg->fb_latency == NS2SA( sampling_rate, DELAY_FB_1_NS ) ) - { - pAll_fb_fr[0] = ivas_fb_fr_12band_1ms_re; - pAll_fb_fr[1] = ivas_fb_fr_12band_1ms_im; - pAll_bins_per_band_48k = ivas_fb_bins_per_band_12band_1ms[0]; - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong FB in ivas_filterbank_setup()!" ); + if ( pCfg->fb_latency == NS2SA( sampling_rate, DELAY_FB_1_NS ) ) + { + pAll_fb_fr[0] = ivas_fb_fr_12band_1ms_re; + pAll_fb_fr[1] = ivas_fb_fr_12band_1ms_im; + pAll_bins_per_band_48k = ivas_fb_bins_per_band_12band_1ms[0]; + } + else + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong FB in ivas_filterbank_setup()!" ); + } } - } - hFbMixer->cross_fade_end_offset = pCfg->fade_len + pCfg->pcm_offset; - hFbMixer->cross_fade_start_offset = hFbMixer->cross_fade_end_offset - pCfg->fade_len; - hFbMixer->ana_window_offset = pCfg->fb_latency + pCfg->pcm_offset; -#ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( !spar_reconfig_flag ) - { -#endif + hFbMixer->cross_fade_end_offset = pCfg->fade_len + pCfg->pcm_offset; + hFbMixer->cross_fade_start_offset = hFbMixer->cross_fade_end_offset - pCfg->fade_len; + hFbMixer->ana_window_offset = pCfg->fb_latency + pCfg->pcm_offset; + if ( ( error = ivas_fb_mixer_get_window( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window ) ) ) != IVAS_ERR_OK ) { return error; @@ -1114,22 +1114,16 @@ static ivas_error ivas_filterbank_setup( { return error; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP - } -#endif - if ( pCfg->num_out_chans > 0 ) - { - ivas_filterbank_t *pFb = hFbMixer->pFb; - int16_t offset = 0; - - pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band; - pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; - pFb->fb_bin_to_band.pFb_active_bins_per_band = pAll_bins_per_band_abs; - pFb->fb_bin_to_band.pFb_start_bin_per_band = pAll_bins_start_offset_abs; -#ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( !spar_reconfig_flag ) + if ( pCfg->num_out_chans > 0 ) { -#endif + ivas_filterbank_t *pFb = hFbMixer->pFb; + int16_t offset = 0; + + pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band; + pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; + pFb->fb_bin_to_band.pFb_active_bins_per_band = pAll_bins_per_band_abs; + pFb->fb_bin_to_band.pFb_start_bin_per_band = pAll_bins_start_offset_abs; + /* Initialization for short stride Parameter calculation and SPAR CLDFB reconstruction */ pFb->fb_bin_to_band.num_cldfb_bands = ( int16_t )( sampling_rate * INV_CLDFB_BANDWIDTH + 0.5f ); /*pFb->fb_bin_to_band.cldfb_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX );*/ /* equals num_cldfb_bands*/ @@ -1211,11 +1205,10 @@ static ivas_error ivas_filterbank_setup( ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - +#endif return error; } -- GitLab From 8408a13a9c069db408cf60099e4b880ee80f200c Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Tue, 28 Feb 2023 19:08:59 +0530 Subject: [PATCH 06/21] Address review comments:set 1 --- lib_com/ivas_fb_mixer.c | 229 +++++++++++++++++------------------- lib_dec/ivas_sba_dec.c | 13 +- lib_dec/ivas_spar_decoder.c | 95 +++++++-------- lib_enc/ivas_spar_encoder.c | 97 ++++++++------- 4 files changed, 195 insertions(+), 239 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 3eb11ec384..fa2f9af7fe 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -52,11 +52,7 @@ static void ivas_get_ld_fb_resp( float **ppIdeal_FRs_re, float **ppIdeal_FRs_im, static int16_t ivas_fb_mixer_get_band_diff_non48k( const int32_t sampling_rate, const float delay_ms ); static const float *ivas_get_cheby_ramp( const int16_t delay ); static void ivas_get_hanning_win( const int16_t len, float *pH_win ); -#ifdef SBA_BR_SWITCHING_CLEAN_UP -static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate, const int16_t spar_reconfig_flag ); -#else static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate ); -#endif static ivas_error ivas_fb_mixer_get_window( const int16_t fade_len, const int32_t sampling_rate, const float **pWindow ); @@ -346,14 +342,18 @@ ivas_error ivas_FB_mixer_open( #endif hFbMixer->fb_cfg = fb_cfg; #ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate, spar_reconfig_flag ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK ) -#endif + set_s( hFbMixer->first_frame, 1, hFbMixer->fb_cfg->num_out_chans ); + set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - hFbMixer->fb_cfg->num_out_chans ); + if ( !spar_reconfig_flag ) { - return error; +#endif + if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - +#endif *hFbMixer_out = hFbMixer; return error; @@ -463,12 +463,6 @@ void ivas_FB_mixer_close( } } } -#ifdef SBA_BR_SWITCHING_CLEAN_UP - } - - if ( !spar_reconfig_flag ) - { -#endif if ( hFbMixer->pFb != NULL ) { free( hFbMixer->pFb ); @@ -1058,10 +1052,6 @@ static void ivas_get_active_bins( static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate -#ifdef SBA_BR_SWITCHING_CLEAN_UP - , - const int16_t spar_reconfig_flag -#endif ) { int16_t i, j; @@ -1075,140 +1065,133 @@ static ivas_error ivas_filterbank_setup( IVAS_FB_CFG *pCfg = hFbMixer->fb_cfg; error = IVAS_ERR_OK; - +#ifndef SBA_BR_SWITCHING_CLEAN_UP set_s( hFbMixer->first_frame, 1, pCfg->num_out_chans ); set_s( hFbMixer->first_frame + pCfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - pCfg->num_out_chans ); - -#ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( !spar_reconfig_flag ) - { #endif - if ( pCfg->num_out_chans > 0 ) - { - hFbMixer->pFb->filterbank_num_bands = ivas_get_num_bands( sampling_rate ); - - ivas_get_active_bins( &pAll_bins_per_band, &pAll_bins_per_band_abs, &pAll_bins_start_offset, &pAll_bins_start_offset_abs, sampling_rate ); - - if ( pCfg->fb_latency == NS2SA( sampling_rate, DELAY_FB_1_NS ) ) - { - pAll_fb_fr[0] = ivas_fb_fr_12band_1ms_re; - pAll_fb_fr[1] = ivas_fb_fr_12band_1ms_im; - pAll_bins_per_band_48k = ivas_fb_bins_per_band_12band_1ms[0]; - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong FB in ivas_filterbank_setup()!" ); - } - } + if ( pCfg->num_out_chans > 0 ) + { + hFbMixer->pFb->filterbank_num_bands = ivas_get_num_bands( sampling_rate ); - hFbMixer->cross_fade_end_offset = pCfg->fade_len + pCfg->pcm_offset; - hFbMixer->cross_fade_start_offset = hFbMixer->cross_fade_end_offset - pCfg->fade_len; - hFbMixer->ana_window_offset = pCfg->fb_latency + pCfg->pcm_offset; + ivas_get_active_bins( &pAll_bins_per_band, &pAll_bins_per_band_abs, &pAll_bins_start_offset, &pAll_bins_start_offset_abs, sampling_rate ); - if ( ( error = ivas_fb_mixer_get_window( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window ) ) ) != IVAS_ERR_OK ) + if ( pCfg->fb_latency == NS2SA( sampling_rate, DELAY_FB_1_NS ) ) { - return error; + pAll_fb_fr[0] = ivas_fb_fr_12band_1ms_re; + pAll_fb_fr[1] = ivas_fb_fr_12band_1ms_im; + pAll_bins_per_band_48k = ivas_fb_bins_per_band_12band_1ms[0]; } - - if ( ( error = ivas_fb_mixer_get_window( pCfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade ) ) ) != IVAS_ERR_OK ) + else { - return error; + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong FB in ivas_filterbank_setup()!" ); } - if ( pCfg->num_out_chans > 0 ) - { - ivas_filterbank_t *pFb = hFbMixer->pFb; - int16_t offset = 0; + } - pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band; - pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; - pFb->fb_bin_to_band.pFb_active_bins_per_band = pAll_bins_per_band_abs; - pFb->fb_bin_to_band.pFb_start_bin_per_band = pAll_bins_start_offset_abs; + hFbMixer->cross_fade_end_offset = pCfg->fade_len + pCfg->pcm_offset; + hFbMixer->cross_fade_start_offset = hFbMixer->cross_fade_end_offset - pCfg->fade_len; + hFbMixer->ana_window_offset = pCfg->fb_latency + pCfg->pcm_offset; + + if ( ( error = ivas_fb_mixer_get_window( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_fb_mixer_get_window( pCfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade ) ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( pCfg->num_out_chans > 0 ) + { + ivas_filterbank_t *pFb = hFbMixer->pFb; + int16_t offset = 0; + + pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band; + pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; + pFb->fb_bin_to_band.pFb_active_bins_per_band = pAll_bins_per_band_abs; + pFb->fb_bin_to_band.pFb_start_bin_per_band = pAll_bins_start_offset_abs; - /* Initialization for short stride Parameter calculation and SPAR CLDFB reconstruction */ - pFb->fb_bin_to_band.num_cldfb_bands = ( int16_t )( sampling_rate * INV_CLDFB_BANDWIDTH + 0.5f ); - /*pFb->fb_bin_to_band.cldfb_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX );*/ /* equals num_cldfb_bands*/ - pFb->fb_bin_to_band.short_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / 4 ); + /* Initialization for short stride Parameter calculation and SPAR CLDFB reconstruction */ + pFb->fb_bin_to_band.num_cldfb_bands = ( int16_t )( sampling_rate * INV_CLDFB_BANDWIDTH + 0.5f ); + /*pFb->fb_bin_to_band.cldfb_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX );*/ /* equals num_cldfb_bands*/ + pFb->fb_bin_to_band.short_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / 4 ); - set_f( pFb->fb_bin_to_band.p_short_stride_bin_to_band, 0.0f, 2 * MDFT_FB_BANDS_240 ); - set_s( pFb->fb_bin_to_band.p_cldfb_map_to_spar_band, 0, CLDFB_NO_CHANNELS_MAX ); - set_s( pFb->fb_bin_to_band.p_spar_start_bands, 0, CLDFB_NO_CHANNELS_MAX ); + set_f( pFb->fb_bin_to_band.p_short_stride_bin_to_band, 0.0f, 2 * MDFT_FB_BANDS_240 ); + set_s( pFb->fb_bin_to_band.p_cldfb_map_to_spar_band, 0, CLDFB_NO_CHANNELS_MAX ); + set_s( pFb->fb_bin_to_band.p_spar_start_bands, 0, CLDFB_NO_CHANNELS_MAX ); - for ( j = 0; j < IVAS_MAX_NUM_FB_BANDS; j++ ) + for ( j = 0; j < IVAS_MAX_NUM_FB_BANDS; j++ ) + { + pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j] = 0; /* aka num_active_bins per SPAR band */ + pFb->fb_bin_to_band.p_short_stride_start_bin_per_band[j] = 0; /* first considered bin index per SPAR band */ + pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j] = NULL; + for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { - pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j] = 0; /* aka num_active_bins per SPAR band */ - pFb->fb_bin_to_band.p_short_stride_start_bin_per_band[j] = 0; /* first considered bin index per SPAR band */ - pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j] = NULL; - for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band[i][j] = 0.0f; - } + pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band[i][j] = 0.0f; } - if ( sampling_rate == 48000 ) + } + if ( sampling_rate == 48000 ) + { + for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { - for ( j = 0; j < pFb->filterbank_num_bands; j++ ) - { - pFb->fb_consts.ppFilterbank_FRs[0][j] = &pAll_fb_fr[0][offset]; - pFb->fb_consts.ppFilterbank_FRs[1][j] = &pAll_fb_fr[1][offset]; - offset += pFb->fb_consts.pFilterbank_bins_per_band[j]; - } - - ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); + pFb->fb_consts.ppFilterbank_FRs[0][j] = &pAll_fb_fr[0][offset]; + pFb->fb_consts.ppFilterbank_FRs[1][j] = &pAll_fb_fr[1][offset]; + offset += pFb->fb_consts.pFilterbank_bins_per_band[j]; } - else - { - float *ppFilterbank_FRs_re_temp[MAX_NUM_BANDS_DIFF_NON48K]; - float *ppFilterbank_FRs_im_temp[MAX_NUM_BANDS_DIFF_NON48K]; - int16_t active_bins_temp[MAX_NUM_BANDS_DIFF_NON48K]; - int16_t start_offset_temp[MAX_NUM_BANDS_DIFF_NON48K]; - int16_t num_diff_bands, start_diff_band_non48k; - num_diff_bands = MAX_NUM_BANDS_DIFF_NON48K; - start_diff_band_non48k = pFb->filterbank_num_bands - num_diff_bands; + ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); + } + else + { + float *ppFilterbank_FRs_re_temp[MAX_NUM_BANDS_DIFF_NON48K]; + float *ppFilterbank_FRs_im_temp[MAX_NUM_BANDS_DIFF_NON48K]; + int16_t active_bins_temp[MAX_NUM_BANDS_DIFF_NON48K]; + int16_t start_offset_temp[MAX_NUM_BANDS_DIFF_NON48K]; + int16_t num_diff_bands, start_diff_band_non48k; - pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band; - pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; + num_diff_bands = MAX_NUM_BANDS_DIFF_NON48K; + start_diff_band_non48k = pFb->filterbank_num_bands - num_diff_bands; - for ( j = 0; j < pFb->filterbank_num_bands; j++ ) - { - int16_t num_active_bins = pFb->fb_consts.pFilterbank_bins_per_band[j]; + pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band; + pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset; - if ( j < start_diff_band_non48k ) - { - pFb->fb_consts.ppFilterbank_FRs[0][j] = &pAll_fb_fr[0][offset]; - pFb->fb_consts.ppFilterbank_FRs[1][j] = &pAll_fb_fr[1][offset]; - } - else - { - mvr2r( &pAll_fb_fr[0][offset], pFb->fb_consts.ppFilterbank_FRs_non48k[0][j], num_active_bins ); - mvr2r( &pAll_fb_fr[1][offset], pFb->fb_consts.ppFilterbank_FRs_non48k[1][j], num_active_bins ); - } + for ( j = 0; j < pFb->filterbank_num_bands; j++ ) + { + int16_t num_active_bins = pFb->fb_consts.pFilterbank_bins_per_band[j]; - offset += pAll_bins_per_band_48k[j]; + if ( j < start_diff_band_non48k ) + { + pFb->fb_consts.ppFilterbank_FRs[0][j] = &pAll_fb_fr[0][offset]; + pFb->fb_consts.ppFilterbank_FRs[1][j] = &pAll_fb_fr[1][offset]; } - - for ( j = start_diff_band_non48k; j < pFb->filterbank_num_bands; j++ ) + else { - ppFilterbank_FRs_re_temp[j - start_diff_band_non48k] = pFb->fb_consts.ppFilterbank_FRs_non48k[0][j]; - ppFilterbank_FRs_im_temp[j - start_diff_band_non48k] = pFb->fb_consts.ppFilterbank_FRs_non48k[1][j]; - active_bins_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_per_band[j]; - start_offset_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_start_offset[j]; + mvr2r( &pAll_fb_fr[0][offset], pFb->fb_consts.ppFilterbank_FRs_non48k[0][j], num_active_bins ); + mvr2r( &pAll_fb_fr[1][offset], pFb->fb_consts.ppFilterbank_FRs_non48k[1][j], num_active_bins ); } - ivas_get_ld_fb_resp( ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, - active_bins_temp, start_offset_temp, num_diff_bands, pCfg->fb_latency, sampling_rate ); + offset += pAll_bins_per_band_48k[j]; + } - for ( j = start_diff_band_non48k; j < pFb->filterbank_num_bands; j++ ) - { - pFb->fb_consts.ppFilterbank_FRs[0][j] = (const float *) pFb->fb_consts.ppFilterbank_FRs_non48k[0][j]; - pFb->fb_consts.ppFilterbank_FRs[1][j] = (const float *) pFb->fb_consts.ppFilterbank_FRs_non48k[1][j]; - } + for ( j = start_diff_band_non48k; j < pFb->filterbank_num_bands; j++ ) + { + ppFilterbank_FRs_re_temp[j - start_diff_band_non48k] = pFb->fb_consts.ppFilterbank_FRs_non48k[0][j]; + ppFilterbank_FRs_im_temp[j - start_diff_band_non48k] = pFb->fb_consts.ppFilterbank_FRs_non48k[1][j]; + active_bins_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_per_band[j]; + start_offset_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_start_offset[j]; + } - ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); + ivas_get_ld_fb_resp( ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, + active_bins_temp, start_offset_temp, num_diff_bands, pCfg->fb_latency, sampling_rate ); + + for ( j = start_diff_band_non48k; j < pFb->filterbank_num_bands; j++ ) + { + pFb->fb_consts.ppFilterbank_FRs[0][j] = (const float *) pFb->fb_consts.ppFilterbank_FRs_non48k[0][j]; + pFb->fb_consts.ppFilterbank_FRs[1][j] = (const float *) pFb->fb_consts.ppFilterbank_FRs_non48k[1][j]; } + + ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 1ea5cc1a92..87888b627a 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -719,16 +719,8 @@ ivas_error ivas_sba_dec_reconfigure( #else if ( hSpar != NULL ) { - if ( hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 ) - { - if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" ); - } - - ivas_pca_dec_init( hSpar->hPCA ); - } - else if ( hSpar->hPCA != NULL ) + if ( ( hSpar->hPCA != NULL ) + && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE) || (sba_order_internal != 1 ) ) ) { free( st_ivas->hSpar->hPCA ); hSpar->hPCA = NULL; @@ -972,7 +964,6 @@ ivas_error ivas_sba_dec_reconfigure( vbap_free_data( &( st_ivas->hVBAPdata ) ); } } - if ( st_ivas->hDirAC != NULL && st_ivas->sba_mode == SBA_MODE_SPAR ) { mvs2s( st_ivas->hDirAC->dirac_to_spar_md_bands, st_ivas->hSpar->dirac_to_spar_md_bands, DIRAC_MAX_NBANDS ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 464df9285d..2cf540d20d 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -124,30 +124,23 @@ ivas_error ivas_spar_dec_open( { return error; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( !spar_reconfig_flag ) + /* AGC handle */ + if ( ( error = ivas_spar_agc_dec_open( &hSpar->hAgcDec, output_Fs ) ) != IVAS_ERR_OK ) { -#endif - /* AGC handle */ - if ( ( error = ivas_spar_agc_dec_open( &hSpar->hAgcDec, output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; + } - /* PCA handle */ - hSpar->hPCA = NULL; - if ( st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 ) + /* PCA handle */ + hSpar->hPCA = NULL; + if ( st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 ) + { + if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) { - if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" ); - } - - ivas_pca_dec_init( hSpar->hPCA ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" ); } -#ifdef SBA_BR_SWITCHING_CLEAN_UP + + ivas_pca_dec_init( hSpar->hPCA ); } -#endif /* mixer_mat intitialization */ for ( i = 0; i < num_channels_internal; i++ ) { @@ -164,35 +157,29 @@ ivas_error ivas_spar_dec_open( } } hSpar->i_subframe = 0; -#ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( !spar_reconfig_flag ) - { -#endif - /*-----------------------------------------------------------------* - * Configuration - set SPAR high-level parameters - *-----------------------------------------------------------------*/ - ivas_spar_config( st_ivas->hDecoderConfig->ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); + /*-----------------------------------------------------------------* + * Configuration - set SPAR high-level parameters + *-----------------------------------------------------------------*/ - switch ( sba_order_internal ) - { - case 1: - st_ivas->transport_config = AUDIO_CONFIG_FOA; - break; - case 2: - st_ivas->transport_config = AUDIO_CONFIG_HOA2; - break; - case 3: - st_ivas->transport_config = AUDIO_CONFIG_HOA3; - break; - } - - ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config ); + ivas_spar_config( st_ivas->hDecoderConfig->ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); - st_ivas->hSpar = hSpar; -#ifdef SBA_BR_SWITCHING_CLEAN_UP + switch ( sba_order_internal ) + { + case 1: + st_ivas->transport_config = AUDIO_CONFIG_FOA; + break; + case 2: + st_ivas->transport_config = AUDIO_CONFIG_HOA2; + break; + case 3: + st_ivas->transport_config = AUDIO_CONFIG_HOA3; + break; } -#endif + + ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config ); + + st_ivas->hSpar = hSpar; return error; } @@ -226,20 +213,20 @@ void ivas_spar_dec_close( #else ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs ); #endif + + /* AGC */ + ivas_spar_agc_dec_close( &hSpar->hAgcDec ); + + /* PCA */ + if ( hSpar->hPCA != NULL ) + { + free( hSpar->hPCA ); + hSpar->hPCA = NULL; + } #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { #endif - /* AGC */ - ivas_spar_agc_dec_close( &hSpar->hAgcDec ); - - /* PCA */ - if ( hSpar->hPCA != NULL ) - { - free( hSpar->hPCA ); - hSpar->hPCA = NULL; - } - free( hSpar ); hSpar = NULL; #ifdef SBA_BR_SWITCHING_CLEAN_UP diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 80bc9da9df..2ad33ef525 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -126,57 +126,51 @@ ivas_error ivas_spar_enc_open( { return error; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP - /* initialization */ - hSpar->hMdEnc->table_idx = -1; - if ( !spar_reconfig_flag ) + /* Transient Detector handle */ + if ( ( error = ivas_spar_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK ) { -#endif - /* Transient Detector handle */ - if ( ( error = ivas_spar_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; + } + + /* initialization */ + hSpar->hMdEnc->table_idx = -1; /* AGC handle */ #ifdef DEBUG_AGC_ENCODER_CMD_OPTION - hSpar->AGC_Enable = ivas_agc_enc_get_flag( hEncoderConfig->Opt_AGC_ON, nchan_transport ); + hSpar->AGC_Enable = ivas_agc_enc_get_flag( hEncoderConfig->Opt_AGC_ON, nchan_transport ); #else hSpar->AGC_Enable = ivas_agc_enc_get_flag( nchan_transport ); #endif - hSpar->hAgcEnc = NULL; - if ( hSpar->AGC_Enable ) + hSpar->hAgcEnc = NULL; + if ( hSpar->AGC_Enable ) + { + if ( ( error = ivas_spar_agc_enc_open( &hSpar->hAgcEnc, input_Fs, nchan_inp ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_spar_agc_enc_open( &hSpar->hAgcEnc, input_Fs, nchan_inp ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - /* PCA handle */ - hSpar->hPCA = NULL; - if ( hEncoderConfig->Opt_PCA_ON ) + } + + /* PCA handle */ + hSpar->hPCA = NULL; + if ( hEncoderConfig->Opt_PCA_ON ) + { + if ( ( hSpar->hPCA = (PCA_ENC_STATE *) malloc( sizeof( PCA_ENC_STATE ) ) ) == NULL ) { - if ( ( hSpar->hPCA = (PCA_ENC_STATE *) malloc( sizeof( PCA_ENC_STATE ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR PCA encoder" ); - } - ivas_pca_enc_init( hSpar->hPCA ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR PCA encoder" ); } -#ifndef SBA_BR_SWITCHING_CLEAN_UP - /* initialization */ - hSpar->hMdEnc->table_idx = -1; -#endif - /*-----------------------------------------------------------------* - * Configuration - set SPAR high-level parameters - *-----------------------------------------------------------------*/ - - ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), - &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 ); -#ifdef SBA_BR_SWITCHING_CLEAN_UP + ivas_pca_enc_init( hSpar->hPCA ); } -#endif + + /* initialization */ + hSpar->hMdEnc->table_idx = -1; + + /*-----------------------------------------------------------------* + * Configuration - set SPAR high-level parameters + *-----------------------------------------------------------------*/ + ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), + &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 ); if ( st_ivas->nchan_transport == 1 ) { hEncoderConfig->element_mode_init = IVAS_SCE; @@ -229,10 +223,11 @@ ivas_error ivas_spar_enc_open( * Final assignment *-----------------------------------------------------------------*/ - st_ivas->hSpar = hSpar; + #ifdef SBA_BR_SWITCHING_CLEAN_UP } #endif + st_ivas->hSpar = hSpar; return error; } @@ -291,23 +286,23 @@ void ivas_spar_enc_close( #else ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs ); #endif + + /* Trans Det handle */ + ivas_spar_transient_det_close( &hSpar->hTranDet ); + + /* AGC */ + ivas_spar_agc_enc_close( &hSpar->hAgcEnc ); + + /* PCA */ + if ( hSpar->hPCA != NULL ) + { + free( hSpar->hPCA ); + hSpar->hPCA = NULL; + } #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { #endif - /* Trans Det handle */ - ivas_spar_transient_det_close( &hSpar->hTranDet ); - - /* AGC */ - ivas_spar_agc_enc_close( &hSpar->hAgcEnc ); - - /* PCA */ - if ( hSpar->hPCA != NULL ) - { - free( hSpar->hPCA ); - hSpar->hPCA = NULL; - } - free( hSpar ); hSpar = NULL; #ifdef SBA_BR_SWITCHING_CLEAN_UP -- GitLab From 6e18482381e693225057d91e1b2505ae1b01dda5 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 1 Mar 2023 11:38:07 +0530 Subject: [PATCH 07/21] Reverting one change --- lib_enc/ivas_spar_encoder.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 2ad33ef525..557748be0b 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -126,13 +126,18 @@ ivas_error ivas_spar_enc_open( { return error; } - - /* Transient Detector handle */ - if ( ( error = ivas_spar_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK ) +#ifdef SBA_BR_SWITCHING_CLEAN_UP + if ( !spar_reconfig_flag ) { - return error; +#endif + /* Transient Detector handle */ + if ( ( error = ivas_spar_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef SBA_BR_SWITCHING_CLEAN_UP } - +#endif /* initialization */ hSpar->hMdEnc->table_idx = -1; @@ -286,10 +291,10 @@ void ivas_spar_enc_close( #else ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs ); #endif - +#ifndef SBA_BR_SWITCHING_CLEAN_UP /* Trans Det handle */ ivas_spar_transient_det_close( &hSpar->hTranDet ); - +#endif /* AGC */ ivas_spar_agc_enc_close( &hSpar->hAgcEnc ); @@ -302,6 +307,8 @@ void ivas_spar_enc_close( #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { + /* Trans Det handle */ + ivas_spar_transient_det_close( &hSpar->hTranDet ); #endif free( hSpar ); hSpar = NULL; -- GitLab From 8d2db8e97133b168c5aab59f1faca435e8377dc9 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 1 Mar 2023 16:54:56 +0530 Subject: [PATCH 08/21] Address review comments:set 2 --- lib_dec/ivas_sba_dec.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 87888b627a..a548cd0bef 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -891,7 +891,8 @@ ivas_error ivas_sba_dec_reconfigure( } #ifdef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) || ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) + if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( sba_mode_old != st_ivas->sba_mode ) || ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) + && (( (hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) { DIRAC_CONFIG_FLAG flag_config; flag_config = DIRAC_OPEN; @@ -908,6 +909,29 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } + if ( ( ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) && ( ( sba_mode_old != st_ivas->sba_mode ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) ) + { + /* if ( st_ivas->hDirAC != NULL && st_ivas->sba_mode == SBA_MODE_SPAR ) + { + mvs2s( st_ivas->hDirAC->dirac_to_spar_md_bands, st_ivas->hSpar->dirac_to_spar_md_bands, DIRAC_MAX_NBANDS ); + st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; + }*/ + if ( st_ivas->hDirAC != NULL ) + { + ivas_dirac_dec_close( st_ivas->hDirAC ); + st_ivas->hDirAC = NULL; + } + 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; + } + int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; + + st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); + + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); + } #else if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) ) { @@ -951,6 +975,7 @@ 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 d1f57ac896c64e99f9c69cb718bdd8aaf70aab97 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 6 Mar 2023 12:03:11 +0530 Subject: [PATCH 09/21] Added a fix for an error while testing : set 1 --- lib_dec/ivas_sba_dec.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index a548cd0bef..617bbfb64c 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -792,6 +792,7 @@ ivas_error ivas_sba_dec_reconfigure( hDirAC = st_ivas->hDirAC; } + #ifndef SBA_BR_SWITCHING_RECONFIG if ( hDirAC != NULL ) #else @@ -891,7 +892,7 @@ ivas_error ivas_sba_dec_reconfigure( } #ifdef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( sba_mode_old != st_ivas->sba_mode ) || ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) + if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( sba_mode_old != st_ivas->sba_mode ) || ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) && (( (hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) { DIRAC_CONFIG_FLAG flag_config; @@ -909,21 +910,19 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } - if ( ( ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) && ( ( sba_mode_old != st_ivas->sba_mode ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) ) + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { - /* if ( st_ivas->hDirAC != NULL && st_ivas->sba_mode == SBA_MODE_SPAR ) + 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 ) { - mvs2s( st_ivas->hDirAC->dirac_to_spar_md_bands, st_ivas->hSpar->dirac_to_spar_md_bands, DIRAC_MAX_NBANDS ); - st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; - }*/ + return error; + } + } + if ( ( ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) && ( ( sba_mode_old != st_ivas->sba_mode ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) ) + { if ( st_ivas->hDirAC != NULL ) { ivas_dirac_dec_close( st_ivas->hDirAC ); st_ivas->hDirAC = NULL; - } - 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; } int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; -- GitLab From ff365e2f14f405b98353d7858a98b42437da9ada Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 6 Mar 2023 12:55:39 +0530 Subject: [PATCH 10/21] Added new test cases for AGC for SBA BR switching --- tests/conftest.py | 15 +++++++++++++++ tests/test_sba_bs_enc.py | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 9896c4908f..ef5f46ffc9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -450,7 +450,22 @@ def test_vector_path(request) -> str: path = str(path.resolve()) return path + +@pytest.fixture(scope="session") +def br_switch_file_path(request) -> str: + """ + Return base directory of test vector files. + """ + if request.config.option.test_vector_path: + return request.config.option.test_vector_path + here = Path(__file__).parent.resolve() + + path = here.joinpath("../scripts/switchPaths") + + path = str(path.resolve()) + + return path @pytest.fixture(scope="session") def reference_path(request) -> str: diff --git a/tests/test_sba_bs_enc.py b/tests/test_sba_bs_enc.py index 2b659432c2..411f8089bb 100644 --- a/tests/test_sba_bs_enc.py +++ b/tests/test_sba_bs_enc.py @@ -53,7 +53,7 @@ dtx_set = ['0', '1'] dict_fsample_bw = {'48': '3', '32': '2', '16': '1'} dict_bw_idx = {'FB': '3', 'SWB': '2', 'WB': '1'} dict_bw_tag = {'SWB': '_ForceSWB', 'WB': '_ForceWB'} -ivas_br_FOA = ['32000', '64000', '96000', '160000', '256000', '384000', '512000'] +ivas_br_FOA = ['32000','64000', '96000', '160000', '256000', '384000', '512000','sw_24k4_256k.bin'] ivas_br_HOA2 = ['256000', '384000', '512000'] ivas_br_HOA3 = ['256000', '384000', '512000'] @@ -111,6 +111,7 @@ def test_bypass_enc( ref_encoder_path, reference_path, dut_base_path, + None, tag, fs, ivas_br, @@ -155,6 +156,7 @@ def test_sba_enc_system( dut_base_path, ref_encoder_path, ref_decoder_path, + br_switch_file_path, update_ref, keep_files, ivas_br, @@ -166,7 +168,9 @@ def test_sba_enc_system( if dtx == '1' and ivas_br not in ['32000', '64000']: # skip high bitrates for DTX until DTX issue is resolved pytest.skip() - + if ivas_br == 'sw_24k4_256k.bin' and agc != 1: + pytest.skip() + tag = tag + fs + 'c' max_bw = "FB" bypass = -1 @@ -185,6 +189,7 @@ def test_sba_enc_system( ref_encoder_path, reference_path, dut_base_path, + br_switch_file_path, tag, fs, ivas_br, @@ -250,6 +255,7 @@ def test_spar_hoa2_enc_system( ref_encoder_path, reference_path, dut_base_path, + None, tag, fs, ivas_br, @@ -314,6 +320,7 @@ def test_spar_hoa3_enc_system( ref_encoder_path, reference_path, dut_base_path, + None, tag, fs, ivas_br, @@ -368,7 +375,8 @@ def test_sba_enc_BWforce_system( if dtx == '1' and ivas_br not in ['32000', '64000']: # skip high bitrates for DTX until DTX issue is resolved pytest.skip() - + if ivas_br == 'sw_24k4_256k.bin': + pytest.skip() fs = sample_rate_bw_idx[0] bw = sample_rate_bw_idx[1] tag = tag + fs + 'c' @@ -384,6 +392,7 @@ def test_sba_enc_BWforce_system( ref_encoder_path, reference_path, dut_base_path, + None, tag, fs, ivas_br, @@ -422,6 +431,7 @@ def sba_enc( ref_encoder_path, reference_path, dut_base_path, + br_switch_file_path, tag, sampling_rate, ivas_br, @@ -450,6 +460,8 @@ def sba_enc( tag = tag + dict_bw_tag[ivas_max_bw] tag_out = f"{tag}_ivasbr{ivas_br[:-3]}k_DTX{dtx}" + if ivas_br == 'sw_24k4_256k.bin': + ivas_br = f"{br_switch_file_path}/sw_24k4_256k.bin" short_tag_ext = "" if agc != -1: short_tag_ext += f'_AGC{agc}' -- GitLab From 843414cb202b59a50a723de9e2df40da6af0bd12 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 6 Mar 2023 13:23:36 +0530 Subject: [PATCH 11/21] Clang formatting added --- lib_com/ivas_fb_mixer.c | 13 +++++++------ lib_dec/ivas_sba_dec.c | 12 +++++------- lib_dec/ivas_spar_decoder.c | 8 +++++--- lib_enc/ivas_sba_enc.c | 6 ++++-- lib_enc/ivas_spar_encoder.c | 24 +++++++++++++----------- 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index fa2f9af7fe..62f16bbb94 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -1051,8 +1051,7 @@ static void ivas_get_active_bins( static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, - const int32_t sampling_rate -) + const int32_t sampling_rate ) { int16_t i, j; const float *pAll_fb_fr[2]; @@ -1069,6 +1068,7 @@ static ivas_error ivas_filterbank_setup( set_s( hFbMixer->first_frame, 1, pCfg->num_out_chans ); set_s( hFbMixer->first_frame + pCfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - pCfg->num_out_chans ); #endif + if ( pCfg->num_out_chans > 0 ) { hFbMixer->pFb->filterbank_num_bands = ivas_get_num_bands( sampling_rate ); @@ -1100,6 +1100,7 @@ static ivas_error ivas_filterbank_setup( { return error; } + if ( pCfg->num_out_chans > 0 ) { ivas_filterbank_t *pFb = hFbMixer->pFb; @@ -1111,10 +1112,9 @@ static ivas_error ivas_filterbank_setup( pFb->fb_bin_to_band.pFb_start_bin_per_band = pAll_bins_start_offset_abs; /* Initialization for short stride Parameter calculation and SPAR CLDFB reconstruction */ - pFb->fb_bin_to_band.num_cldfb_bands = ( int16_t )( sampling_rate * INV_CLDFB_BANDWIDTH + 0.5f ); + pFb->fb_bin_to_band.num_cldfb_bands = (int16_t) ( sampling_rate * INV_CLDFB_BANDWIDTH + 0.5f ); /*pFb->fb_bin_to_band.cldfb_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX );*/ /* equals num_cldfb_bands*/ - pFb->fb_bin_to_band.short_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / 4 ); - + pFb->fb_bin_to_band.short_stride = (int16_t) ( ( sampling_rate / FRAMES_PER_SEC ) / 4 ); set_f( pFb->fb_bin_to_band.p_short_stride_bin_to_band, 0.0f, 2 * MDFT_FB_BANDS_240 ); set_s( pFb->fb_bin_to_band.p_cldfb_map_to_spar_band, 0, CLDFB_NO_CHANNELS_MAX ); set_s( pFb->fb_bin_to_band.p_spar_start_bands, 0, CLDFB_NO_CHANNELS_MAX ); @@ -1181,7 +1181,7 @@ static ivas_error ivas_filterbank_setup( } ivas_get_ld_fb_resp( ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, ppFilterbank_FRs_re_temp, ppFilterbank_FRs_im_temp, - active_bins_temp, start_offset_temp, num_diff_bands, pCfg->fb_latency, sampling_rate ); + active_bins_temp, start_offset_temp, num_diff_bands, pCfg->fb_latency, sampling_rate ); for ( j = start_diff_band_non48k; j < pFb->filterbank_num_bands; j++ ) { @@ -1192,6 +1192,7 @@ static ivas_error ivas_filterbank_setup( ivas_calculate_abs_fr( pFb, sampling_rate, pCfg->active_w_mixing ); } } + return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 617bbfb64c..9cfb32414a 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -659,6 +659,7 @@ ivas_error ivas_sba_dec_reconfigure( #ifndef SBA_BR_SWITCHING_CLEAN_UP 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; @@ -719,8 +720,7 @@ ivas_error ivas_sba_dec_reconfigure( #else if ( hSpar != NULL ) { - if ( ( hSpar->hPCA != NULL ) - && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE) || (sba_order_internal != 1 ) ) ) + if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( sba_order_internal != 1 ) ) ) { free( st_ivas->hSpar->hPCA ); hSpar->hPCA = NULL; @@ -792,7 +792,6 @@ ivas_error ivas_sba_dec_reconfigure( hDirAC = st_ivas->hDirAC; } - #ifndef SBA_BR_SWITCHING_RECONFIG if ( hDirAC != NULL ) #else @@ -892,8 +891,7 @@ ivas_error ivas_sba_dec_reconfigure( } #ifdef SBA_BR_SWITCHING_RECONFIG #ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( sba_mode_old != st_ivas->sba_mode ) || ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) - && (( (hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) + if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( sba_mode_old != st_ivas->sba_mode ) || ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) && ( ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) { DIRAC_CONFIG_FLAG flag_config; flag_config = DIRAC_OPEN; @@ -917,7 +915,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } - if ( ( ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) && ( ( sba_mode_old != st_ivas->sba_mode ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) ) + if ( ( ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) && ( ( sba_mode_old != st_ivas->sba_mode ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) ) { if ( st_ivas->hDirAC != NULL ) { @@ -974,7 +972,6 @@ 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 ) @@ -988,6 +985,7 @@ ivas_error ivas_sba_dec_reconfigure( vbap_free_data( &( st_ivas->hVBAPdata ) ); } } + if ( st_ivas->hDirAC != NULL && st_ivas->sba_mode == SBA_MODE_SPAR ) { mvs2s( st_ivas->hDirAC->dirac_to_spar_md_bands, st_ivas->hSpar->dirac_to_spar_md_bands, DIRAC_MAX_NBANDS ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 2cf540d20d..af5d1531d2 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -141,6 +141,7 @@ ivas_error ivas_spar_dec_open( ivas_pca_dec_init( hSpar->hPCA ); } + /* mixer_mat intitialization */ for ( i = 0; i < num_channels_internal; i++ ) { @@ -158,9 +159,9 @@ ivas_error ivas_spar_dec_open( } hSpar->i_subframe = 0; - /*-----------------------------------------------------------------* - * Configuration - set SPAR high-level parameters - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * Configuration - set SPAR high-level parameters + *-----------------------------------------------------------------*/ ivas_spar_config( st_ivas->hDecoderConfig->ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); @@ -180,6 +181,7 @@ ivas_error ivas_spar_dec_open( ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config ); st_ivas->hSpar = hSpar; + return error; } diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index ee46e7d955..526af9d513 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -355,6 +355,7 @@ ivas_error ivas_sba_enc_reconfigure( 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 ); + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { if ( st_ivas->hSpar == NULL ) @@ -576,8 +577,8 @@ ivas_error ivas_sba_enc_reconfigure( } #endif /*-----------------------------------------------------------------* - * Allocate, initalize, and configure SCE/CPE/MCT handles - *-----------------------------------------------------------------*/ + * Allocate, initalize, and configure SCE/CPE/MCT handles + *-----------------------------------------------------------------*/ 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 ); @@ -602,5 +603,6 @@ ivas_error ivas_sba_enc_reconfigure( } #endif } + return error; } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 557748be0b..34b83b29a2 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -141,7 +141,7 @@ ivas_error ivas_spar_enc_open( /* initialization */ hSpar->hMdEnc->table_idx = -1; - /* AGC handle */ + /* AGC handle */ #ifdef DEBUG_AGC_ENCODER_CMD_OPTION hSpar->AGC_Enable = ivas_agc_enc_get_flag( hEncoderConfig->Opt_AGC_ON, nchan_transport ); #else @@ -156,7 +156,6 @@ ivas_error ivas_spar_enc_open( return error; } } - /* PCA handle */ hSpar->hPCA = NULL; if ( hEncoderConfig->Opt_PCA_ON ) @@ -172,10 +171,12 @@ ivas_error ivas_spar_enc_open( hSpar->hMdEnc->table_idx = -1; /*-----------------------------------------------------------------* - * Configuration - set SPAR high-level parameters - *-----------------------------------------------------------------*/ + * Configuration - set SPAR high-level parameters + *-----------------------------------------------------------------*/ + ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), - &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 ); + &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 ); + if ( st_ivas->nchan_transport == 1 ) { hEncoderConfig->element_mode_init = IVAS_SCE; @@ -224,15 +225,17 @@ ivas_error ivas_spar_enc_open( hSpar->hFrontVad = NULL; } - /*-----------------------------------------------------------------* - * Final assignment - *-----------------------------------------------------------------*/ - #ifdef SBA_BR_SWITCHING_CLEAN_UP } #endif + + /*-----------------------------------------------------------------* + * Final assignment + *-----------------------------------------------------------------*/ + st_ivas->hSpar = hSpar; + return error; } @@ -290,8 +293,7 @@ void ivas_spar_enc_close( ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs, spar_reconfig_flag ); #else ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs ); -#endif -#ifndef SBA_BR_SWITCHING_CLEAN_UP + /* Trans Det handle */ ivas_spar_transient_det_close( &hSpar->hTranDet ); #endif -- GitLab From 31e89e335d81b1cc13dfef345ac029d481ab4b37 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 6 Mar 2023 18:59:01 +0530 Subject: [PATCH 12/21] Resolving build warnings : set 1 --- lib_dec/ivas_sba_dec.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 9c2a0fb476..9c70347af5 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -64,7 +64,9 @@ ivas_error ivas_sba_dec_reconfigure( int32_t ivas_total_brate, last_ivas_total_brate; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; - +#ifdef SBA_BR_SWITCHING_CLEAN_UP + int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; +#endif error = IVAS_ERR_OK; hDecoderConfig = st_ivas->hDecoderConfig; @@ -73,7 +75,7 @@ ivas_error ivas_sba_dec_reconfigure( sba_mode_old = ivas_sba_mode_select( last_ivas_total_brate ); st_ivas->sba_mode = sba_mode_old; - + /*-----------------------------------------------------------------* * Set SBA high-level parameters * Save old SBA high-level parameters @@ -133,9 +135,9 @@ ivas_error ivas_sba_dec_reconfigure( SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); - nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); + #ifndef SBA_BR_SWITCHING_CLEAN_UP - + 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 !! @@ -376,7 +378,7 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_dec_close( st_ivas->hDirAC ); st_ivas->hDirAC = NULL; } - int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; + st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); -- GitLab From 8f2cd9672ea3066a4cd8beb5607d3bd749a8ee3b Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 6 Mar 2023 19:39:44 +0530 Subject: [PATCH 13/21] Resolving pipeline warnings : set 2 --- lib_dec/ivas_sba_dec.c | 2 +- lib_enc/ivas_spar_encoder.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 9c70347af5..fbb69d487a 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -127,7 +127,7 @@ ivas_error ivas_sba_dec_reconfigure( else { #ifdef SBA_BR_SWITCHING_CLEAN_UP - int16_t sba_order_internal, nchan_internal; + int16_t sba_order_internal; #else int16_t i, sba_order_internal, nchan_internal; DIRAC_DEC_HANDLE hDirAC = st_ivas->hDirAC; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 956ea3fae8..79cb801361 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -220,11 +220,15 @@ ivas_error ivas_spar_enc_open( if ( ( error = init_encoder( hSpar->hCoreCoderVAD, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1 ) ) != IVAS_ERR_OK ) #endif { - hSpar->hCoreCoderVAD = NULL; - hSpar->hFrontVad = NULL; + return error; } } + else + { + hSpar->hCoreCoderVAD = NULL; + hSpar->hFrontVad = NULL; + } #ifdef SBA_BR_SWITCHING_CLEAN_UP } #endif -- GitLab From d4ed5521972c0a902a30a293bd36d7c22c883a8c Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 8 Mar 2023 08:52:25 +0530 Subject: [PATCH 14/21] Resolving clang format error --- lib_dec/ivas_sba_dec.c | 8 ++++---- lib_enc/ivas_spar_encoder.c | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index fbb69d487a..5e603cfe9d 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -75,7 +75,7 @@ ivas_error ivas_sba_dec_reconfigure( sba_mode_old = ivas_sba_mode_select( last_ivas_total_brate ); st_ivas->sba_mode = sba_mode_old; - + /*-----------------------------------------------------------------* * Set SBA high-level parameters * Save old SBA high-level parameters @@ -135,7 +135,7 @@ ivas_error ivas_sba_dec_reconfigure( SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); - + #ifndef SBA_BR_SWITCHING_CLEAN_UP 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 ) ) @@ -378,11 +378,11 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_dec_close( st_ivas->hDirAC ); st_ivas->hDirAC = NULL; } - + st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } #else diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 79cb801361..786bd29a96 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -217,17 +217,16 @@ ivas_error ivas_spar_enc_open( #ifdef PARAM_ISM_DTX_CNG if ( ( error = init_encoder( hSpar->hCoreCoderVAD, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) #else - if ( ( error = init_encoder( hSpar->hCoreCoderVAD, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1 ) ) != IVAS_ERR_OK ) + if ( ( error = init_encoder( hSpar->hCoreCoderVAD, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1 ) ) != IVAS_ERR_OK ) #endif { return error; } - } else { - hSpar->hCoreCoderVAD = NULL; - hSpar->hFrontVad = NULL; + hSpar->hCoreCoderVAD = NULL; + hSpar->hFrontVad = NULL; } #ifdef SBA_BR_SWITCHING_CLEAN_UP } -- GitLab From 9271b6d97bdd2d07cb78d3b69e9de9e35a827fca Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 8 Mar 2023 09:00:58 +0530 Subject: [PATCH 15/21] Resolving pipeline warning :set 3 --- 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 5e603cfe9d..b8c9782ffb 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -347,7 +347,7 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } #ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( sba_mode_old != st_ivas->sba_mode ) || ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) && ( ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) + if ( ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( sba_mode_old != st_ivas->sba_mode ) || ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) ) && ( ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) { DIRAC_CONFIG_FLAG flag_config; flag_config = DIRAC_OPEN; -- GitLab From b540aca6e75d6c458fc213d741f6bc25e5803936 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 8 Mar 2023 09:35:05 +0530 Subject: [PATCH 16/21] Resolve pipeline error : set 4 --- 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 b8c9782ffb..c89f7aca17 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -347,7 +347,7 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } #ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( sba_mode_old != st_ivas->sba_mode ) || ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) ) && ( ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) + if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) || ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) { DIRAC_CONFIG_FLAG flag_config; flag_config = DIRAC_OPEN; -- GitLab From 268ccc5cc5694a6dc1fdd5066d777d56bdc9aa65 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Wed, 8 Mar 2023 09:43:05 +0530 Subject: [PATCH 17/21] Added clang formatting for the changes added --- 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 c89f7aca17..ea5e2656eb 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -347,7 +347,7 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } #ifdef SBA_BR_SWITCHING_CLEAN_UP - if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) || ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) + if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) || ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) { DIRAC_CONFIG_FLAG flag_config; flag_config = DIRAC_OPEN; -- GitLab From 105938cc681fe183f967cc0814f0d99d918bd289 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 9 Mar 2023 08:36:34 +0100 Subject: [PATCH 18/21] editorial improvements --- lib_com/ivas_fb_mixer.c | 22 ++++++++++++++++------ lib_com/ivas_prot.h | 12 ++++++------ lib_dec/ivas_sba_dec.c | 11 +++++++++-- lib_dec/ivas_spar_decoder.c | 14 +++++++++----- lib_enc/ivas_mc_param_enc.c | 1 + lib_enc/ivas_mcmasa_enc.c | 2 ++ lib_enc/ivas_sba_enc.c | 22 ++++++++++++---------- lib_enc/ivas_spar_encoder.c | 21 +++++++++++++++------ 8 files changed, 70 insertions(+), 35 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 62f16bbb94..2116032627 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -177,7 +177,7 @@ ivas_error ivas_FB_mixer_open( IVAS_FB_CFG *fb_cfg /* i : FB config. handle */ #ifdef SBA_BR_SWITCHING_CLEAN_UP , - const int16_t spar_reconfig_flag + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ) { @@ -192,6 +192,7 @@ ivas_error ivas_FB_mixer_open( #ifdef SBA_BR_SWITCHING_CLEAN_UP hFbMixer = *hFbMixer_out; + if ( !spar_reconfig_flag ) { #endif @@ -214,6 +215,7 @@ ivas_error ivas_FB_mixer_open( #ifdef SBA_BR_SWITCHING_CLEAN_UP } #endif + if ( fb_cfg->active_w_mixing == -1 ) { num_chs_alloc = 0; @@ -258,6 +260,7 @@ ivas_error ivas_FB_mixer_open( { num_chs_alloc = fb_cfg->num_in_chans; } + for ( i = 0; i < num_chs_alloc; i++ ) { if ( ( hFbMixer->ppFilterbank_prior_input[i] = (float *) malloc( sizeof( float ) * fb_cfg->prior_input_length ) ) == NULL ) @@ -285,6 +288,7 @@ ivas_error ivas_FB_mixer_open( } } } + #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { @@ -340,10 +344,12 @@ ivas_error ivas_FB_mixer_open( #ifdef SBA_BR_SWITCHING_CLEAN_UP } #endif + hFbMixer->fb_cfg = fb_cfg; #ifdef SBA_BR_SWITCHING_CLEAN_UP set_s( hFbMixer->first_frame, 1, hFbMixer->fb_cfg->num_out_chans ); set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - hFbMixer->fb_cfg->num_out_chans ); + if ( !spar_reconfig_flag ) { #endif @@ -354,6 +360,7 @@ ivas_error ivas_FB_mixer_open( #ifdef SBA_BR_SWITCHING_CLEAN_UP } #endif + *hFbMixer_out = hFbMixer; return error; @@ -367,11 +374,11 @@ ivas_error ivas_FB_mixer_open( *------------------------------------------------------------------------*/ void ivas_FB_mixer_close( - IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ - const int32_t sampling_rate /* i : sampling rate in Hz */ + IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ + const int32_t sampling_rate /* i : sampling rate in Hz */ #ifdef SBA_BR_SWITCHING_CLEAN_UP , - const int16_t spar_reconfig_flag + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ) { @@ -431,6 +438,7 @@ void ivas_FB_mixer_close( free( hFbMixer->prior_mixer[0][0] ); hFbMixer->prior_mixer[0][0] = NULL; } + #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { @@ -471,11 +479,13 @@ void ivas_FB_mixer_close( #ifdef SBA_BR_SWITCHING_CLEAN_UP } #endif + if ( hFbMixer->fb_cfg != NULL ) { free( hFbMixer->fb_cfg ); hFbMixer->fb_cfg = NULL; } + #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { @@ -847,8 +857,8 @@ static int16_t ivas_calculate_abs_fr( float short_stride_nrg = 0.0f; float cldfb_nrg = 0.0f; int16_t short_stride = pFb->fb_bin_to_band.short_stride; - const int16_t num_bins_per_short_stride_bin = ( const int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); - const int16_t num_bins_per_cldfb_band = ( const int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); + const int16_t num_bins_per_short_stride_bin = (const int16_t) ( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); + const int16_t num_bins_per_cldfb_band = (const int16_t) ( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); float short_stride_max_per_spar_band = 1e-9f; /*loop over all stored Filter Bank Response MDFT coefficients*/ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 361cc8e0a5..9d58810857 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3750,7 +3750,7 @@ void FdCngDecodeDiracMDCTStereoSID( ivas_error ivas_spar_enc_open( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ #ifdef SBA_BR_SWITCHING_CLEAN_UP - ,const int16_t spar_reconfig_flag + ,const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ); @@ -3759,7 +3759,7 @@ void ivas_spar_enc_close( const int32_t input_Fs, /* i : input sampling rate */ const int16_t nchan_inp /* i : number of input channels */ #ifdef SBA_BR_SWITCHING_CLEAN_UP - ,const int16_t spar_reconfig_flag + ,const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ); @@ -3775,7 +3775,7 @@ ivas_error ivas_spar_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ #ifdef SBA_BR_SWITCHING_CLEAN_UP , - const int16_t spar_reconfig_flag + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ); @@ -3784,7 +3784,7 @@ void ivas_spar_dec_close( const int32_t output_Fs /* i : output sampling rate */ #ifdef SBA_BR_SWITCHING_CLEAN_UP , - const int16_t spar_reconfig_flag + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ); @@ -4939,7 +4939,7 @@ ivas_error ivas_FB_mixer_open( IVAS_FB_CFG *fb_cfg /* i : FB config. handle */ #ifdef SBA_BR_SWITCHING_CLEAN_UP , - const int16_t spar_reconfig_flag + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ); @@ -4948,7 +4948,7 @@ void ivas_FB_mixer_close( const int32_t sampling_rate /* i : sampling rate in Hz */ #ifdef SBA_BR_SWITCHING_CLEAN_UP , - const int16_t spar_reconfig_flag + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index ea5e2656eb..18a54132c7 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -62,11 +62,13 @@ ivas_error ivas_sba_dec_reconfigure( int16_t sba_dirac_stereo_flag_old; SBA_MODE sba_mode_old; int32_t ivas_total_brate, last_ivas_total_brate; + RENDERER_TYPE old_renderer_type; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; #ifdef SBA_BR_SWITCHING_CLEAN_UP int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; #endif + error = IVAS_ERR_OK; hDecoderConfig = st_ivas->hDecoderConfig; @@ -205,6 +207,7 @@ ivas_error ivas_sba_dec_reconfigure( free( st_ivas->hSpar->hPCA ); hSpar->hPCA = NULL; } + if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) ) { @@ -224,6 +227,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } + hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = 0; #endif @@ -298,7 +302,6 @@ ivas_error ivas_sba_dec_reconfigure( /* renderer might have changed */ intern_config_old = st_ivas->intern_config; - RENDERER_TYPE old_renderer_type; old_renderer_type = st_ivas->renderer_type; ivas_renderer_select( st_ivas ); @@ -346,10 +349,12 @@ ivas_error ivas_sba_dec_reconfigure( { ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } + #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) || ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) { DIRAC_CONFIG_FLAG flag_config; + flag_config = DIRAC_OPEN; if ( st_ivas->hDirAC != NULL ) { @@ -359,11 +364,13 @@ ivas_error ivas_sba_dec_reconfigure( flag_config = DIRAC_RECONFIGURE; } } + if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK ) { return error; } } + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { 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 ) @@ -371,6 +378,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } + if ( ( ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) && ( ( sba_mode_old != st_ivas->sba_mode ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) ) { if ( st_ivas->hDirAC != NULL ) @@ -379,7 +387,6 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->hDirAC = NULL; } - st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 43a7bbeb8c..7515300681 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -61,10 +61,10 @@ static void ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 ); *------------------------------------------------------------------------*/ ivas_error ivas_spar_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ #ifdef SBA_BR_SWITCHING_CLEAN_UP , - const int16_t spar_reconfig_flag + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ) { @@ -80,6 +80,7 @@ ivas_error ivas_spar_dec_open( num_channels_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); #ifdef SBA_BR_SWITCHING_CLEAN_UP hSpar = st_ivas->hSpar; + if ( !spar_reconfig_flag ) { #endif @@ -91,6 +92,7 @@ ivas_error ivas_spar_dec_open( #ifdef SBA_BR_SWITCHING_CLEAN_UP } #endif + output_Fs = st_ivas->hDecoderConfig->output_Fs; /* TD decorr. */ @@ -125,6 +127,7 @@ ivas_error ivas_spar_dec_open( { return error; } + /* AGC handle */ if ( ( error = ivas_spar_agc_dec_open( &hSpar->hAgcDec, output_Fs ) ) != IVAS_ERR_OK ) { @@ -194,11 +197,11 @@ ivas_error ivas_spar_dec_open( *------------------------------------------------------------------------*/ void ivas_spar_dec_close( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - const int32_t output_Fs /* i : output sampling rate */ + SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ + const int32_t output_Fs /* i : output sampling rate */ #ifdef SBA_BR_SWITCHING_CLEAN_UP , - const int16_t spar_reconfig_flag + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ) { @@ -226,6 +229,7 @@ void ivas_spar_dec_close( free( hSpar->hPCA ); hSpar->hPCA = NULL; } + #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 0726f5ec68..9b1241f234 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -368,6 +368,7 @@ void ivas_param_mc_enc_close( const int32_t sampling_rate ) { ivas_param_mc_metadata_close( &hParamMC->hMetadataPMC ); + #ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hParamMC->hFbMixer, sampling_rate, 0 ); #else diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 02399be40a..7cae277f9a 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -220,6 +220,7 @@ ivas_error ivas_mcmasa_enc_open( { return error; } + #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixerLfe ), input_Fs, fb_cfgLfe, 0 ) ) != IVAS_ERR_OK ) #else @@ -469,6 +470,7 @@ void ivas_mcmasa_enc_close( free( hMcMasa->lfeAnaRingBuffer[i] ); } } + #ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hMcMasa->hFbMixer, input_Fs, 0 ); #else diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 0dec59f6e2..85afc96e77 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -106,13 +106,12 @@ ivas_error ivas_sba_enc_reconfigure( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) { - int16_t nSCE_old, nCPE_old, nchan_transport_old; + int16_t n, nSCE_old, nCPE_old, nchan_transport_old; int32_t ivas_total_brate; ivas_error error; ENCODER_CONFIG_HANDLE hEncoderConfig; error = IVAS_ERR_OK; - hEncoderConfig = st_ivas->hEncoderConfig; ivas_total_brate = hEncoderConfig->ivas_total_brate; @@ -124,23 +123,25 @@ ivas_error ivas_sba_enc_reconfigure( #ifdef SBA_HPF_TUNING_ENC int16_t analysis_order_old; #endif +#ifdef SBA_BR_SWITCHING_CLEAN_UP + int16_t spar_reconfig_flag; + spar_reconfig_flag = 0; +#endif nchan_transport_old = st_ivas->nchan_transport; nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; sba_mode_old = st_ivas->sba_mode; -#ifdef SBA_BR_SWITCHING_CLEAN_UP - int16_t spar_reconfig_flag; - spar_reconfig_flag = 0; -#endif + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); #ifdef SBA_HPF_TUNING_ENC analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); + if ( analysis_order_old != st_ivas->sba_analysis_order ) { - int16_t n, i, n_old; + int16_t i, n_old; float **old_mem_hp20_in; n_old = ivas_sba_get_nchan_metadata( analysis_order_old ); @@ -223,8 +224,9 @@ ivas_error ivas_sba_enc_reconfigure( ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + #ifdef SBA_BR_SWITCHING_CLEAN_UP - for ( int16_t n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) + for ( n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) { if ( hDirAC->sba_synchro_buffer[n] != NULL ) { @@ -328,7 +330,6 @@ ivas_error ivas_sba_enc_reconfigure( } // VE: TBV - populate 'hSpar->hFrontVad' with 'hCoreCoder[0]' instead of resetting it to init-state? - #endif } } @@ -353,7 +354,6 @@ ivas_error ivas_sba_enc_reconfigure( return error; } } - int16_t n; if ( hDirAC->num_samples_synchro_delay == 0 ) { @@ -413,6 +413,7 @@ ivas_error ivas_sba_enc_reconfigure( #endif } + ivas_dirac_enc_reconfigure( st_ivas ); if ( st_ivas->sba_mode == SBA_MODE_SPAR ) @@ -420,6 +421,7 @@ ivas_error ivas_sba_enc_reconfigure( 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; } + /*-----------------------------------------------------------------* * Allocate, initalize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 786bd29a96..b156c524d2 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -58,10 +58,10 @@ static ivas_error ivas_spar_enc_process( Encoder_Struct *st_ivas, const ENCODER_ *------------------------------------------------------------------------*/ ivas_error ivas_spar_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ #ifdef SBA_BR_SWITCHING_CLEAN_UP , - const int16_t spar_reconfig_flag + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ) { @@ -77,6 +77,7 @@ ivas_error ivas_spar_enc_open( error = IVAS_ERR_OK; #ifdef SBA_BR_SWITCHING_CLEAN_UP hSpar = st_ivas->hSpar; + if ( !spar_reconfig_flag ) { #endif @@ -88,6 +89,7 @@ ivas_error ivas_spar_enc_open( #ifdef SBA_BR_SWITCHING_CLEAN_UP } #endif + input_Fs = hEncoderConfig->input_Fs; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); nchan_inp = ivas_sba_get_nchan_metadata( sba_order_internal ); @@ -126,6 +128,7 @@ ivas_error ivas_spar_enc_open( { return error; } + #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { @@ -138,6 +141,7 @@ ivas_error ivas_spar_enc_open( #ifdef SBA_BR_SWITCHING_CLEAN_UP } #endif + /* initialization */ hSpar->hMdEnc->table_idx = -1; @@ -189,6 +193,7 @@ ivas_error ivas_spar_enc_open( /*-----------------------------------------------------------------* * Allocate and initialize Front-VAD handle *-----------------------------------------------------------------*/ + #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { @@ -249,16 +254,17 @@ ivas_error ivas_spar_enc_open( *------------------------------------------------------------------------*/ void ivas_spar_enc_close( - SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder handle */ - const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp /* i : number of input channels */ + SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder handle */ + const int32_t input_Fs, /* i : input sampling rate */ + const int16_t nchan_inp /* i : number of input channels */ #ifdef SBA_BR_SWITCHING_CLEAN_UP , - const int16_t spar_reconfig_flag + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ #endif ) { int16_t num_chans; + if ( hSpar != NULL ) { #ifdef SBA_BR_SWITCHING_CLEAN_UP @@ -281,6 +287,7 @@ void ivas_spar_enc_close( #ifdef SBA_BR_SWITCHING_CLEAN_UP } #endif + num_chans = hSpar->hFbMixer->fb_cfg->num_in_chans; assert( num_chans <= nchan_inp ); @@ -299,6 +306,7 @@ void ivas_spar_enc_close( /* Trans Det handle */ ivas_transient_det_close( &hSpar->hTranDet ); #endif + /* AGC */ ivas_spar_agc_enc_close( &hSpar->hAgcEnc ); @@ -308,6 +316,7 @@ void ivas_spar_enc_close( free( hSpar->hPCA ); hSpar->hPCA = NULL; } + #ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -- GitLab From dd65968e163b12850597bccd5459994eeba8e8b6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 9 Mar 2023 12:46:49 +0100 Subject: [PATCH 19/21] - fix compilation warning when SBA_BR_SWITCHING_CLEAN_UP is disabled - clean out remaining ToDo comments --- lib_enc/ivas_sba_enc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 85afc96e77..8513745435 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -106,7 +106,10 @@ ivas_error ivas_sba_enc_reconfigure( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) { - int16_t n, nSCE_old, nCPE_old, nchan_transport_old; +#ifdef SBA_BR_SWITCHING_CLEAN_UP + int16_t n; +#endif + int16_t nSCE_old, nCPE_old, nchan_transport_old; int32_t ivas_total_brate; ivas_error error; ENCODER_CONFIG_HANDLE hEncoderConfig; @@ -218,8 +221,6 @@ ivas_error ivas_sba_enc_reconfigure( { return error; } - - // VE: TBV - populate 'hSpar->hFrontVad' with 'hCoreCoder[0]' instead of resetting it to init-state? } ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), @@ -259,13 +260,11 @@ ivas_error ivas_sba_enc_reconfigure( hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; } - /*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 ) ) { /* FB mixer handle */ if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { - // VE: TBV whether 'hFbMixer' can be reused if ( hDirAC->hFbMixer != NULL ) { #ifndef SBA_BR_SWITCHING_CLEAN_UP @@ -278,7 +277,6 @@ ivas_error ivas_sba_enc_reconfigure( if ( sba_mode_old == SBA_MODE_SPAR ) { - // VE: dirty patch -> reconfiguration of SPAR MD, TD_decorr, FbMixer modules should be used instead !! #ifndef SBA_BR_SWITCHING_CLEAN_UP IVAS_FB_CFG *fb_cfg; int16_t nchan_internal, sba_order_internal; @@ -328,8 +326,6 @@ ivas_error ivas_sba_enc_reconfigure( { return error; } - - // VE: TBV - populate 'hSpar->hFrontVad' with 'hCoreCoder[0]' instead of resetting it to init-state? #endif } } -- GitLab From 4ec0b4493247fa575a35312ca7d429d5aa905a32 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 9 Mar 2023 12:47:51 +0100 Subject: [PATCH 20/21] clang format --- lib_com/ivas_fb_mixer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 2116032627..a141b761d3 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -857,8 +857,8 @@ static int16_t ivas_calculate_abs_fr( float short_stride_nrg = 0.0f; float cldfb_nrg = 0.0f; int16_t short_stride = pFb->fb_bin_to_band.short_stride; - const int16_t num_bins_per_short_stride_bin = (const int16_t) ( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); - const int16_t num_bins_per_cldfb_band = (const int16_t) ( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); + const int16_t num_bins_per_short_stride_bin = ( const int16_t ) ( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); + const int16_t num_bins_per_cldfb_band = ( const int16_t ) ( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); float short_stride_max_per_spar_band = 1e-9f; /*loop over all stored Filter Bank Response MDFT coefficients*/ -- GitLab From 37e426f053028396d28cab44c240a348999a5186 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 9 Mar 2023 12:54:05 +0100 Subject: [PATCH 21/21] clang format --- lib_com/ivas_fb_mixer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index a141b761d3..c3389288de 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -857,8 +857,8 @@ static int16_t ivas_calculate_abs_fr( float short_stride_nrg = 0.0f; float cldfb_nrg = 0.0f; int16_t short_stride = pFb->fb_bin_to_band.short_stride; - const int16_t num_bins_per_short_stride_bin = ( const int16_t ) ( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); - const int16_t num_bins_per_cldfb_band = ( const int16_t ) ( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); + const int16_t num_bins_per_short_stride_bin = ( const int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); + const int16_t num_bins_per_cldfb_band = ( const int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); float short_stride_max_per_spar_band = 1e-9f; /*loop over all stored Filter Bank Response MDFT coefficients*/ -- GitLab