From 7a5521ed12e66e3c7ce2fabc5f284418bff5c27a Mon Sep 17 00:00:00 2001 From: "Brown, Stefanie" Date: Thu, 2 Feb 2023 13:34:41 +1100 Subject: [PATCH 01/11] Commit with fixes for #331, HBR low frequency stuttering with HOA inputs --- lib_com/ivas_cov_smooth.c | 130 +++++++++++++++++++++++++++++---- lib_com/ivas_prot.h | 17 +++++ lib_com/ivas_transient_det.c | 46 +++++++++++- lib_com/options.h | 7 +- lib_dec/ivas_dec.c | 4 + lib_dec/ivas_init_dec.c | 18 +++++ lib_dec/ivas_spar_decoder.c | 43 ++++++++--- lib_enc/ivas_enc.c | 7 ++ lib_enc/ivas_enc_cov_handler.c | 11 ++- lib_enc/ivas_init_enc.c | 4 + lib_enc/ivas_spar_encoder.c | 15 +++- 11 files changed, 271 insertions(+), 31 deletions(-) diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 90be8b5385..b39e57d1df 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -39,7 +39,9 @@ #include "wmc_auto.h" #include "prot.h" - +#ifdef SMOOTH_WITH_TRANS_DET +#define BAND_SMOOTH_REST_START_IDX ( 2 ) +#endif /*-----------------------------------------------------------------------------------------* * Function ivas_set_up_cov_smoothing() * @@ -50,27 +52,62 @@ static void ivas_set_up_cov_smoothing( ivas_cov_smooth_state_t *hCovState, ivas_filterbank_t *pFb, const float max_update_rate, - const int16_t min_pool_size ) + const int16_t min_pool_size +#ifdef COV_SMOOTH_TUNING + , + const int16_t nchan_inp /* i : number of input channels */ +#endif +) { int16_t j, k; - for ( j = 0; j < pFb->filterbank_num_bands; j++ ) +#ifdef COV_SMOOTH_TUNING + if ( nchan_inp <= FOA_CHANNELS ) { - float update_factor = 0.0f; - - for ( k = 0; k < pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; k++ ) +#endif + for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { - update_factor += pFb->fb_bin_to_band.pFb_bin_to_band[j][k]; - } + float update_factor; + update_factor = 0.0f; + + for ( k = 0; k < pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; k++ ) + { + update_factor += pFb->fb_bin_to_band.pFb_bin_to_band[j][k]; + } - hCovState->pSmoothing_factor[j] = update_factor / min_pool_size; + hCovState->pSmoothing_factor[j] = update_factor / min_pool_size; + + if ( hCovState->pSmoothing_factor[j] > max_update_rate ) + { + hCovState->pSmoothing_factor[j] = max_update_rate; + } + } - if ( hCovState->pSmoothing_factor[j] > max_update_rate ) +#ifdef COV_SMOOTH_TUNING + } + else + { + for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { - hCovState->pSmoothing_factor[j] = max_update_rate; + float update_factor; + update_factor = 0.0f; + float *p_bin_to_band; + p_bin_to_band = pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j]; + int16_t active_bins; + active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j]; + for ( k = 0; k < active_bins; k++ ) + { + update_factor += p_bin_to_band[k]; + } + hCovState->pSmoothing_factor[j] = update_factor / min_pool_size; + hCovState->pSmoothing_factor[j] *= ( j + 1 ) * 0.75f; + if ( hCovState->pSmoothing_factor[j] > max_update_rate ) + { + hCovState->pSmoothing_factor[j] = max_update_rate; + } } } - +#endif hCovState->prior_bank_idx = -1; return; @@ -115,7 +152,12 @@ ivas_error ivas_spar_covar_smooth_enc_open( } } - ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size ); + ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size +#ifdef COV_SMOOTH_TUNING + , + nchan_inp +#endif + ); *hCovState_out = hCovState; @@ -176,14 +218,66 @@ static void ivas_compute_smooth_cov( const int16_t start_band, const int16_t end_band, const int16_t num_ch, - const int16_t transient_det ) +#ifdef SMOOTH_WITH_TRANS_DET + const int16_t transient_det[2] +#else + const int16_t transient_det +#endif +) { int16_t i, j, k; int16_t prev_idx = hCovState->prior_bank_idx; float factor = 0; +#ifdef SMOOTH_WITH_TRANS_DET + int16_t sm_b; + int16_t non_sm_b_idx; + sm_b = BAND_SMOOTH_REST_START_IDX; +#endif assert( end_band <= pFb->filterbank_num_bands ); +#ifdef SMOOTH_WITH_TRANS_DET + if ( prev_idx == -1 || transient_det[1] == 1 ) + { + for ( i = 0; i < num_ch; i++ ) + { + for ( k = start_band; k < end_band; k++ ) + { + pCov_buf[i][i][k] += ( hCovState->pSmoothing_factor[k] * fac ); + } + } + } + else if ( transient_det[0] == 1 ) + { + non_sm_b_idx = min( sm_b, end_band ); + for ( i = 0; i < num_ch; i++ ) + { + for ( j = 0; j < num_ch; j++ ) + { + if ( i == j ) + { + factor = fac; + } + else + { + factor = 0.0f; + } + + for ( k = start_band; k < non_sm_b_idx; k++ ) + { + pCov_buf[i][j][k] = pPrior_cov_buf[i][j][k] + ( hCovState->pSmoothing_factor[k] * ( pCov_buf[i][j][k] - pPrior_cov_buf[i][j][k] + factor ) ); + } + } + } + for ( i = 0; i < num_ch; i++ ) + { + for ( k = non_sm_b_idx; k < end_band; k++ ) + { + pCov_buf[i][i][k] += ( hCovState->pSmoothing_factor[k] * fac ); + } + } + } +#else if ( prev_idx == -1 || transient_det == 1 ) { for ( i = 0; i < num_ch; i++ ) @@ -194,6 +288,7 @@ static void ivas_compute_smooth_cov( } } } +#endif else if ( prev_idx == 0 ) { for ( i = 0; i < num_ch; i++ ) @@ -234,7 +329,12 @@ void ivas_cov_smooth_process( const int16_t start_band, const int16_t end_band, const int16_t num_ch, - const int16_t transient_det ) +#ifdef SMOOTH_WITH_TRANS_DET + const int16_t transient_det[2] +#else + const int16_t transient_det +#endif +) { int16_t i, j; int16_t num_bands = end_band - start_band; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6f4d27d5e8..77a04783c6 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4171,7 +4171,11 @@ void ivas_enc_cov_handler_process( const int16_t end_band, const int16_t nchan_inp, const int16_t dtx_vad, +#ifdef SMOOTH_WITH_TRANS_DET + const int16_t transient_det[2] +#else const int16_t transient_det +#endif ); ivas_error ivas_spar_covar_smooth_enc_open( @@ -4193,7 +4197,11 @@ void ivas_cov_smooth_process( const int16_t start_band, const int16_t end_band, const int16_t num_ch, +#ifdef SMOOTH_WITH_TRANS_DET + const int16_t transient_det[2] +#else const int16_t transient_det +#endif ); /* Transient detector module */ @@ -4206,11 +4214,20 @@ void ivas_spar_transient_det_close( ivas_trans_det_state_t **hTranDet /* i/o: SPAR TD handle */ ); +#ifdef SMOOTH_WITH_TRANS_DET +void ivas_transient_det_process( + ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ + float *pIn_pcm, /* i : input audio channels */ + const int16_t frame_len, /* i : frame length in samples */ + int16_t transient_det[2] /* o: transient det outputs */ +); +#else int16_t ivas_transient_det_process( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ float *pIn_pcm, /* i : input audio channels */ const int16_t frame_len /* i : frame length in samples */ ); +#endif void ivas_td_decorr_get_ducking_gains( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c index 01a4374f93..20aaf80d73 100644 --- a/lib_com/ivas_transient_det.c +++ b/lib_com/ivas_transient_det.c @@ -211,16 +211,31 @@ void ivas_spar_transient_det_close( * * Transient detection process call *-----------------------------------------------------------------------------------------*/ - +#ifdef SMOOTH_WITH_TRANS_DET +void ivas_transient_det_process( + ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ + float *pIn_pcm, /* i : input audio channels */ + const int16_t frame_len, /* i : frame length in samples */ + int16_t transient_det[2] /* o: transient det outputs */ +) +#else int16_t ivas_transient_det_process( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ float *pIn_pcm, /* i : input audio channels */ const int16_t frame_len /* i : frame length in samples */ ) +#endif { - float mem = hTranDet->in_duck_gain; +#ifdef SMOOTH_WITH_TRANS_DET + float in_duck_gain[L_FRAME48k]; + int16_t num_sf, sf, sf_samp, idx; +#else int16_t trans; +#endif + float mem = hTranDet->in_duck_gain; + +#ifndef SMOOTH_WITH_TRANS_DET ivas_td_decorr_get_ducking_gains( hTranDet, pIn_pcm, NULL, NULL, frame_len, IVAS_TDET_ONLY ); if ( mem - hTranDet->in_duck_gain > IVAS_TDET_PARM_TRANS_THR ) @@ -233,6 +248,30 @@ int16_t ivas_transient_det_process( } return trans; +#else + ivas_td_decorr_get_ducking_gains( hTranDet, pIn_pcm, in_duck_gain, NULL, frame_len, IVAS_TDET_ONLY ); + + transient_det[0] = 0; + transient_det[1] = 0; + if ( mem - hTranDet->in_duck_gain > IVAS_TDET_PARM_TRANS_THR ) + { + transient_det[0] = 1; + } + + num_sf = 16; + sf_samp = frame_len / num_sf; + for ( sf = 1; sf <= num_sf; sf++ ) + { + idx = ( sf_samp * sf ) - 1; + if ( ( mem - in_duck_gain[idx] ) > ( IVAS_TDET_PARM_TRANS_THR * 1.1f ) ) + { + transient_det[1] = 1; + } + mem = in_duck_gain[idx]; + } + // dbgwrite( &transient_det[1], sizeof( int16_t ), 1, 1, "trans_det.raw" ); + return; +#endif } @@ -306,6 +345,9 @@ void ivas_td_decorr_get_ducking_gains( for ( i = 0; i < frame_len; i++ ) { in_duck_gain = ivas_calc_duck_gain( in_duck_gain, in_duck_coeff, e_slow[i], e_fast[i], duck_mult_fac ); +#ifdef SMOOTH_WITH_TRANS_DET + pIn_duck_gains[i] = in_duck_gain; +#endif } hTranDet->in_duck_gain = in_duck_gain; } diff --git a/lib_com/options.h b/lib_com/options.h index 5dddf236ea..8c736258e5 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -167,7 +167,12 @@ #define FIX_317 /* FhG: issue 317 - address sanitizer error in MDCT-Stereo PLC */ - +#define FIX_331_SBA_HBR_HOA_FIXES /* DLB: issue 331 - fix addressing low frequency stuttering with HOA inputs at high bitrates */ +#ifdef FIX_331_SBA_HBR_HOA_FIXES +#define COV_SMOOTH_TUNING +#define SBA_HPF_TUNING +#define SMOOTH_WITH_TRANS_DET +#endif /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index e4a08b0540..47e3afebeb 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -314,7 +314,11 @@ ivas_error ivas_dec( /* HP filtering */ #ifndef DEBUG_SPAR_BYPASS_EVS_CODEC +#ifdef SBA_HPF_TUNING + for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) +#else for ( n = 0; n < nchan_remapped; n++ ) +#endif { hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 763c83dc39..db0deaafba 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -477,10 +477,28 @@ int16_t getNumChanSynthesis( { n = CPE_CHANNELS; } +#ifdef SBA_HPF_TUNING + else if ( st_ivas->ivas_format == SBA_FORMAT ) + { + if ( st_ivas->sba_analysis_order > 1 ) + { + n = 0; + } + else + { + n = st_ivas->nchan_transport; + } + } + else if ( st_ivas->hMCT != NULL ) + { + n = st_ivas->nchan_transport; + } +#else else if ( st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT ) { n = st_ivas->nchan_transport; } +#endif return n; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 2eff5d2cba..65e2d8c3cf 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -794,36 +794,57 @@ void ivas_spar_get_parameters( weight = ivas_spar_get_cldfb_slot_gain( hSpar, hDecoderConfig, ts, &ts0, &ts1, &weight_20ms ); +#ifdef COV_SMOOTH_TUNING + split_band = SPAR_DIRAC_SPLIT_START_BAND; +#else split_band = hSpar->hMdDec->spar_md.num_bands; - +#endif for ( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) { for ( out_ch = 0; out_ch < num_ch_out; out_ch++ ) { +#ifndef COV_SMOOTH_TUNING for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) { +#endif if ( split_band < IVAS_MAX_NUM_BANDS /* 20ms cross-fade for Transport channels in all frequency bands */ && ( 0 == ivas_is_res_channel( out_ch, hSpar->hMdDec->spar_md_cfg.nchan_transport ) ) /* sub-frame processing for missing channels in all frequency bands*/ ) { - if ( hSpar->i_subframe > 3 ) +#ifdef COV_SMOOTH_TUNING + for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) { - par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight ) * hSpar->hMdDec->mixer_mat_prev[ts0][out_ch][in_ch][spar_band] + - weight * hSpar->hMdDec->mixer_mat_prev[ts1][out_ch][in_ch][spar_band]; - } - else - { - par_mat[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; +#endif + if ( hSpar->i_subframe > 3 ) + { + par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight ) * hSpar->hMdDec->mixer_mat_prev[ts0][out_ch][in_ch][spar_band] + + weight * hSpar->hMdDec->mixer_mat_prev[ts1][out_ch][in_ch][spar_band]; + } + else + { + par_mat[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; + } +#ifdef COV_SMOOTH_TUNING } +#endif } else { - /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ - int16_t prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ - par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight_20ms ) * hSpar->hMdDec->mixer_mat_prev[prev_idx][out_ch][in_ch][spar_band] + weight_20ms * hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; +#ifdef COV_SMOOTH_TUNING + for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + { +#endif + /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ + int16_t prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ + par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight_20ms ) * hSpar->hMdDec->mixer_mat_prev[prev_idx][out_ch][in_ch][spar_band] + weight_20ms * hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; +#ifdef COV_SMOOTH_TUNING + } +#endif } +#ifndef COV_SMOOTH_TUNING } +#endif } } diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index e5794d756a..5027ca19d0 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -151,6 +151,13 @@ ivas_error ivas_enc( /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */ for ( i = 0; i < n; i++ ) { +#ifdef SBA_HPF_TUNING + if ( ( ivas_format == SBA_FORMAT ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) + { + hp20( data_f[HOA_keep_ind[i]], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); + } + else +#endif if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) /*TODO: is the HPF needed for LFE channel? */ { hp20( data_f[i], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 97cb1c40de..b70c05e962 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -150,7 +150,12 @@ void ivas_enc_cov_handler_process( const int16_t end_band, const int16_t num_ch, const int16_t dtx_vad, - const int16_t transient_det ) +#ifdef SMOOTH_WITH_TRANS_DET + const int16_t transient_det[2] +#else + const int16_t transient_det +#endif +) { int16_t i, j; int16_t dtx_cov_flag; @@ -213,7 +218,11 @@ void ivas_enc_cov_handler_process( } else { +#ifdef SMOOTH_WITH_TRANS_DET + if ( ( transient_det[0] == 0 ) && ( transient_det[1] == 0 ) ) +#else if ( transient_det == 0 ) +#endif { ivas_cov_smooth_process( hCovEnc->pCov_dtx_state, cov_dtx_real, pFb, start_band, end_band, num_ch, transient_det ); hCovEnc->prior_dtx_present = 1; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index fd92453980..84399f0343 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -184,7 +184,11 @@ int16_t getNumChanAnalysis( n = st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE; if ( st_ivas->hEncoderConfig->ivas_format == SBA_FORMAT ) { +#ifdef SBA_HPF_TUNING + n = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); +#else n = DIRAC_MAX_ANA_CHANS; +#endif } else if ( st_ivas->hEncoderConfig->ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_PARAMMC || st_ivas->mc_mode == MC_MODE_MCMASA ) ) { diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 5e9dd6400c..ab5ef2c962 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -374,7 +374,12 @@ static ivas_error ivas_spar_enc_process( { float pcm_tmp[IVAS_SPAR_MAX_CH][L_FRAME48k * 2]; float *p_pcm_tmp[IVAS_SPAR_MAX_CH]; - int16_t i, j, b, i_ts, input_frame, transient_det, dtx_vad; + int16_t i, j, b, i_ts, input_frame, dtx_vad; +#ifdef SMOOTH_WITH_TRANS_DET + int16_t transient_det[2]; +#else + int16_t transient_det; +#endif int32_t ivas_total_brate, input_Fs; float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; @@ -417,7 +422,15 @@ static ivas_error ivas_spar_enc_process( * Transient detector *-----------------------------------------------------------------------------------------*/ +#ifdef SMOOTH_WITH_TRANS_DET + ivas_transient_det_process( hSpar->hTranDet, data_f[0], input_frame, transient_det ); + if ( sba_order == 1 ) + { + transient_det[1] = transient_det[0]; + } +#else transient_det = ivas_transient_det_process( hSpar->hTranDet, data_f[0], input_frame ); +#endif /* store previous input samples for W in local buffer */ assert( num_del_samples <= IVAS_FB_1MS_48K_SAMP ); -- GitLab From 3b41628705057636efcf12990fa2c96630b89078 Mon Sep 17 00:00:00 2001 From: "Brown, Stefanie" Date: Thu, 2 Feb 2023 15:55:28 +1100 Subject: [PATCH 02/11] Applying CLANG formatting patch --- lib_enc/ivas_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 5027ca19d0..83a6fb6cbd 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -158,7 +158,7 @@ ivas_error ivas_enc( } else #endif - if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) /*TODO: is the HPF needed for LFE channel? */ + if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) /*TODO: is the HPF needed for LFE channel? */ { hp20( data_f[i], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); } -- GitLab From 2880bc367576a916f02f2cfc10affd11bb4ea84b Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Thu, 2 Feb 2023 16:44:11 +0530 Subject: [PATCH 03/11] Fix for SBA BR switching cases crash --- lib_dec/ivas_sba_dec.c | 15 ++++++++-- lib_enc/ivas_sba_enc.c | 65 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index fbdc4f5857..ab7da4b94c 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -606,9 +606,20 @@ ivas_error ivas_sba_dec_reconfigure( *-----------------------------------------------------------------*/ ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); - +#ifndef SBA_BR_SWITCHING_RECONFIG nchan_hp20_old = getNumChanSynthesis( st_ivas ); - +#else + int16_t analysis_order_old; + analysis_order_old = ivas_sba_get_analysis_order( last_ivas_total_brate, st_ivas->sba_order ); + if ( analysis_order_old > 1 ) + { + nchan_hp20_old = 0; + } + else + { + nchan_hp20_old = st_ivas->nchan_transport; + } +#endif nSCE_old = st_ivas->nSCE; nCPE_old = st_ivas->nCPE; nchan_transport_old = st_ivas->nchan_transport; diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 7fd96ae46e..7f94c9a8a3 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -352,7 +352,72 @@ 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 ); +#ifdef SBA_BR_SWITCHING_RECONFIG + int16_t 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; + float **old_mem_hp20_in; + n_old = ivas_sba_get_nchan_metadata( analysis_order_old ); + n = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); + if ( n > n_old ) + { + /* save old mem_hp_20 pointer */ + old_mem_hp20_in = st_ivas->mem_hp20_in; + st_ivas->mem_hp20_in = NULL; + + if ( ( st_ivas->mem_hp20_in = (float **) malloc( n * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); + } + + for ( i = 0; i < n_old; i++ ) + { + st_ivas->mem_hp20_in[i] = old_mem_hp20_in[i]; + old_mem_hp20_in[i] = NULL; + } + /* create additional hp20 memories */ + for ( ; i < n; i++ ) + { + if ( ( st_ivas->mem_hp20_in[i] = (float *) malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); + } + + set_f( st_ivas->mem_hp20_in[i], 0.0f, L_HP20_MEM ); + } + free( old_mem_hp20_in ); + old_mem_hp20_in = NULL; + } + else if ( n < n_old ) + { + /* save old mem_hp_20 pointer */ + old_mem_hp20_in = st_ivas->mem_hp20_in; + st_ivas->mem_hp20_in = NULL; + + if ( ( st_ivas->mem_hp20_in = (float **) malloc( n * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); + } + + for ( i = 0; i < n; i++ ) + { + st_ivas->mem_hp20_in[i] = old_mem_hp20_in[i]; + old_mem_hp20_in[i] = NULL; + } + /* remove superfluous hp20 memories */ + for ( ; i < n_old; i++ ) + { + free( old_mem_hp20_in[i] ); + old_mem_hp20_in[i] = NULL; + } + + free( old_mem_hp20_in ); + old_mem_hp20_in = NULL; + } + } +#endif if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { if ( st_ivas->hSpar == NULL ) -- GitLab From e72d0d4cffb55701649c8cd2afa22203dd546275 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Thu, 2 Feb 2023 18:36:05 +0530 Subject: [PATCH 04/11] Resolving instrumentation error --- lib_enc/ivas_sba_enc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 7f94c9a8a3..6217ffe968 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -341,6 +341,9 @@ ivas_error ivas_sba_enc_reconfigure( DIRAC_ENC_HANDLE hDirAC = st_ivas->hDirAC; SPAR_ENC_HANDLE hSpar; SBA_MODE sba_mode_old; +#endif +#ifdef SBA_BR_SWITCHING_RECONFIG + int16_t analysis_order_old; #endif nchan_transport_old = st_ivas->nchan_transport; nCPE_old = st_ivas->nCPE; @@ -353,7 +356,7 @@ ivas_error ivas_sba_enc_reconfigure( #ifdef SBA_BR_SWITCHING st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); #ifdef SBA_BR_SWITCHING_RECONFIG - int16_t analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); + 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; -- GitLab From 4775d1d8fa410aafcbae34646a55430ad957735e Mon Sep 17 00:00:00 2001 From: "Brown, Stefanie" Date: Fri, 3 Feb 2023 09:54:14 +1100 Subject: [PATCH 05/11] Instrumentation fix in ivas_cov_smooth.c --- lib_com/ivas_cov_smooth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index b39e57d1df..57f74fb70e 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -90,10 +90,10 @@ static void ivas_set_up_cov_smoothing( for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { float update_factor; - update_factor = 0.0f; float *p_bin_to_band; - p_bin_to_band = pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j]; int16_t active_bins; + update_factor = 0.0f; + p_bin_to_band = pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j]; active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j]; for ( k = 0; k < active_bins; k++ ) { -- GitLab From 83b66b7e79033cf388604781434f08b155643fa2 Mon Sep 17 00:00:00 2001 From: "Brown, Stefanie" Date: Fri, 3 Feb 2023 11:28:23 +1100 Subject: [PATCH 06/11] Changing macros for BR SWITCHING fixes to be under the FIX_331* macro --- lib_dec/ivas_sba_dec.c | 2 +- lib_enc/ivas_sba_enc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index ab7da4b94c..aaffc3f4d1 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -606,7 +606,7 @@ ivas_error ivas_sba_dec_reconfigure( *-----------------------------------------------------------------*/ ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); -#ifndef SBA_BR_SWITCHING_RECONFIG +#ifndef FIX_331_SBA_HBR_HOA_FIXES nchan_hp20_old = getNumChanSynthesis( st_ivas ); #else int16_t analysis_order_old; diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 6217ffe968..72eddb3d04 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -355,7 +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 ); -#ifdef SBA_BR_SWITCHING_RECONFIG +#ifdef FIX_331_SBA_HBR_HOA_FIXES 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 ) { -- GitLab From bfae570dfb9be7236fa5d517533f2542b2df8f54 Mon Sep 17 00:00:00 2001 From: "Brown, Stefanie" Date: Fri, 3 Feb 2023 14:57:49 +1100 Subject: [PATCH 07/11] Fix for broken MASA tests --- lib_dec/ivas_dec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 47e3afebeb..e93d84f932 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -315,7 +315,16 @@ ivas_error ivas_dec( /* HP filtering */ #ifndef DEBUG_SPAR_BYPASS_EVS_CODEC #ifdef SBA_HPF_TUNING - for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + int16_t nchan_hp20; + if ( st_ivas->ivas_format == MASA_FORMAT ) + { + nchan_hp20 = nchan_remapped; + } + else + { + nchan_hp20 = getNumChanSynthesis( st_ivas ); + } + for ( n = 0; n < nchan_hp20; n++ ) #else for ( n = 0; n < nchan_remapped; n++ ) #endif -- GitLab From 79cb8c67cb09d88dc4c72c1d81274d81e750a953 Mon Sep 17 00:00:00 2001 From: "Brown, Stefanie" Date: Fri, 3 Feb 2023 17:01:02 +1100 Subject: [PATCH 08/11] Missed changing a BR switching macro to FIX_331* earlier --- lib_enc/ivas_sba_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 72eddb3d04..a74a2a7def 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -342,7 +342,7 @@ ivas_error ivas_sba_enc_reconfigure( SPAR_ENC_HANDLE hSpar; SBA_MODE sba_mode_old; #endif -#ifdef SBA_BR_SWITCHING_RECONFIG +#ifdef FIX_331_SBA_HBR_HOA_FIXES int16_t analysis_order_old; #endif nchan_transport_old = st_ivas->nchan_transport; -- GitLab From 74ccef6f153ae40e48627640fb9d284e48897c76 Mon Sep 17 00:00:00 2001 From: "Brown, Stefanie" Date: Thu, 16 Feb 2023 12:35:41 +1100 Subject: [PATCH 09/11] Splitting SBA_HPF_TUNING into SBA_HPF_TUNING_ENC and SBA_HPF_TUNING_DEC, disabling decoder side macro. --- lib_dec/ivas_dec.c | 2 +- lib_dec/ivas_init_dec.c | 2 +- lib_enc/ivas_enc.c | 2 +- lib_enc/ivas_init_enc.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index e93d84f932..bed60e6434 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -314,7 +314,7 @@ ivas_error ivas_dec( /* HP filtering */ #ifndef DEBUG_SPAR_BYPASS_EVS_CODEC -#ifdef SBA_HPF_TUNING +#ifdef SBA_HPF_TUNING_DEC int16_t nchan_hp20; if ( st_ivas->ivas_format == MASA_FORMAT ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index db0deaafba..ef1894c3dd 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -477,7 +477,7 @@ int16_t getNumChanSynthesis( { n = CPE_CHANNELS; } -#ifdef SBA_HPF_TUNING +#ifdef SBA_HPF_TUNING_DEC else if ( st_ivas->ivas_format == SBA_FORMAT ) { if ( st_ivas->sba_analysis_order > 1 ) diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 83a6fb6cbd..7d783bbf77 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -151,7 +151,7 @@ ivas_error ivas_enc( /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */ for ( i = 0; i < n; i++ ) { -#ifdef SBA_HPF_TUNING +#ifdef SBA_HPF_TUNING_ENC if ( ( ivas_format == SBA_FORMAT ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) { hp20( data_f[HOA_keep_ind[i]], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 84399f0343..b67d21bf8b 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -184,7 +184,7 @@ int16_t getNumChanAnalysis( n = st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE; if ( st_ivas->hEncoderConfig->ivas_format == SBA_FORMAT ) { -#ifdef SBA_HPF_TUNING +#ifdef SBA_HPF_TUNING_ENC n = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); #else n = DIRAC_MAX_ANA_CHANS; -- GitLab From b533f515c2beb75ac20e1bda40747aac7c3664d7 Mon Sep 17 00:00:00 2001 From: "Brown, Stefanie" Date: Thu, 16 Feb 2023 12:36:47 +1100 Subject: [PATCH 10/11] Adding missing options.h for SBA_HPF_TUNING --> ENC/DEC change --- lib_com/options.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8c736258e5..0bdf457ba6 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,7 +170,8 @@ #define FIX_331_SBA_HBR_HOA_FIXES /* DLB: issue 331 - fix addressing low frequency stuttering with HOA inputs at high bitrates */ #ifdef FIX_331_SBA_HBR_HOA_FIXES #define COV_SMOOTH_TUNING -#define SBA_HPF_TUNING +#define SBA_HPF_TUNING_ENC +/*#define SBA_HPF_TUNING_DEC*/ #define SMOOTH_WITH_TRANS_DET #endif /* ################## End DEVELOPMENT switches ######################### */ -- GitLab From 5fe5d9a91f72b79fa7bd4340c9040a4584f1409b Mon Sep 17 00:00:00 2001 From: "Brown, Stefanie" Date: Fri, 17 Feb 2023 11:59:54 +1100 Subject: [PATCH 11/11] Relabelling BR switching fixes for HP20 files as SBA_HPF_TUNING_ENC and SBA_HPF_TUNING_DEC --- lib_dec/ivas_sba_dec.c | 2 +- lib_enc/ivas_sba_enc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index d34e7a35c3..b251bed572 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -597,7 +597,7 @@ ivas_error ivas_sba_dec_reconfigure( *-----------------------------------------------------------------*/ ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); -#ifndef FIX_331_SBA_HBR_HOA_FIXES +#ifndef SBA_HPF_TUNING_DEC nchan_hp20_old = getNumChanSynthesis( st_ivas ); #else int16_t analysis_order_old; diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 32f8357aa0..4786210dd7 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -342,7 +342,7 @@ ivas_error ivas_sba_enc_reconfigure( SPAR_ENC_HANDLE hSpar; SBA_MODE sba_mode_old; #endif -#ifdef FIX_331_SBA_HBR_HOA_FIXES +#ifdef SBA_HPF_TUNING_ENC int16_t analysis_order_old; #endif nchan_transport_old = st_ivas->nchan_transport; @@ -355,7 +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 ); -#ifdef FIX_331_SBA_HBR_HOA_FIXES +#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 ) { -- GitLab