diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 90be8b53853740b72bf8b1c9daa51df03af81de4..57f74fb70ed95ad09f9ab9f5a22ba28f1915015b 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; + float *p_bin_to_band; + 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++ ) + { + 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 562d46a268b088ec0bba1bb06ef638725594b20d..9098ae65212c426d0dd7e7726bcb94d0047e0d55 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4189,7 +4189,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( @@ -4211,7 +4215,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 */ @@ -4224,11 +4232,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 01a4374f93fbcbe981957e4bc3618f28cb7b4e4e..20aaf80d7390dbcb9133f856d90aff0abf262dad 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 f05c268aaaa3d54a2dc52180775a7d8243d0ea58..55cb7e63dd5e7c856602f165d1131bb97803e3fe 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -167,6 +167,14 @@ #define FIX_107_5MS_SUBFRAME_RENDERING /* Issue 107: use 5ms subframes everywhere in parametric binauralizer */ +#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_ENC +/*#define SBA_HPF_TUNING_DEC*/ +#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 384baa0bb26482918c2e122394c771f8658c6294..40b016244b283d430331474c42d2febbdab59d25 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -327,7 +327,20 @@ ivas_error ivas_dec( /* HP filtering */ #ifndef DEBUG_SPAR_BYPASS_EVS_CODEC +#ifdef SBA_HPF_TUNING_DEC + 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 { 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 dd094892e3694f5ef90b20e6fcbc74c4f03344f5..f690129f8c4824b1f1258d77f3a1b79d32bc3d41 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -508,10 +508,28 @@ int16_t getNumChanSynthesis( { n = CPE_CHANNELS; } +#ifdef SBA_HPF_TUNING_DEC + 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_sba_dec.c b/lib_dec/ivas_sba_dec.c index 005aea5555f58070542db46d6fe9ebddcf6a1c8d..b251bed572136b541d412b0b8c848f2f3cc054e8 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -597,9 +597,20 @@ ivas_error ivas_sba_dec_reconfigure( *-----------------------------------------------------------------*/ ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); - +#ifndef SBA_HPF_TUNING_DEC 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_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 035afdfd0ff1a069018833b09a4b6ed4df6b89cb..9f9f8cc1197f0ceee639d53f4be0a82ce50351dd 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -798,36 +798,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 e5794d756ac809dde2be8f0282070d7cfecb4468..7d783bbf77389f13d75fc97377d8c2b5d85fa09c 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -151,7 +151,14 @@ ivas_error ivas_enc( /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */ for ( i = 0; i < n; i++ ) { - if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) /*TODO: is the HPF needed for LFE channel? */ +#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 ); + } + 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 97cb1c40de87854a6dc73e27305b87ec6c16dd9d..b70c05e96205010bdbdf0b759ee87dfaed3aadc4 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 fd92453980a01b1688418cfc0455bf1281b14baa..b67d21bf8bb57a0e7ef1995b5ec3f03438d083a1 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_ENC + 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_sba_enc.c b/lib_enc/ivas_sba_enc.c index e1887ec1241e9147cbf50ce891a7d6b82bdf8ede..4786210dd7f147bc8c8ce7dac03767aa3b2776ab 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_HPF_TUNING_ENC + int16_t analysis_order_old; #endif nchan_transport_old = st_ivas->nchan_transport; nCPE_old = st_ivas->nCPE; @@ -352,7 +355,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_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; + 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 ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 5e9dd6400c868e97217188bd088b9819c0058607..ab5ef2c9620382f367e92ca8c90e8e1b81e75752 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 );