From 939dfcc7558cde458e7c2c6ec37ecf13b4023dac Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Oct 2022 12:56:33 +0200 Subject: [PATCH 1/7] harmonize 'nchan' terminology --- lib_com/ivas_cov_smooth.c | 22 +- lib_com/ivas_fb_mixer.c | 84 ++++---- lib_com/ivas_prot.h | 30 +-- lib_com/ivas_spar_com.c | 158 +++++++------- lib_com/ivas_stat_com.h | 6 +- lib_dec/ivas_dirac_dec.c | 30 +-- lib_dec/ivas_dirac_decorr_dec.c | 34 +-- lib_dec/ivas_dirac_output_synthesis_cov.c | 30 +-- lib_dec/ivas_dirac_output_synthesis_dec.c | 30 +-- lib_dec/ivas_init_dec.c | 8 +- lib_dec/ivas_ism_param_dec.c | 4 +- lib_dec/ivas_limiter.c | 26 +-- lib_dec/ivas_mc_param_dec.c | 3 +- lib_dec/ivas_out_setup_conversion.c | 14 +- lib_dec/ivas_rom_dec.c | 2 +- lib_dec/ivas_sba_rendering.c | 36 ++-- lib_dec/ivas_spar_decoder.c | 67 +++--- lib_dec/ivas_spar_md_dec.c | 192 ++++++++--------- lib_dec/ivas_stat_dec.h | 36 ++-- lib_dec/ivas_td_decorr.c | 22 +- lib_dec/jbm_pcmdsp_apa.c | 48 ++--- lib_dec/jbm_pcmdsp_apa.h | 4 +- lib_enc/ivas_enc_cov_handler.c | 40 ++-- lib_enc/ivas_mc_param_enc.c | 100 ++++----- lib_enc/ivas_spar_encoder.c | 19 +- lib_enc/ivas_spar_md_enc.c | 196 +++++++++--------- lib_enc/ivas_stat_enc.h | 2 +- .../unit_tests/crend/ivas_crend_utest_utils.c | 24 +-- 28 files changed, 632 insertions(+), 635 deletions(-) diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 4584303293..49a833843c 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -180,7 +180,7 @@ static void ivas_compute_smooth_cov( const int16_t end_band #ifdef SBA_SPAR_HARM , - const int16_t num_ch, + const int16_t nchan, const int16_t transient_det #endif ) @@ -188,7 +188,7 @@ static void ivas_compute_smooth_cov( int16_t i, j, k; int16_t prev_idx = hCovState->prior_bank_idx; #ifndef SBA_SPAR_HARM - int16_t num_ch = pIn_buf->num_ch; + int16_t nchan = pIn_buf->nchan; #endif float factor = 0; @@ -200,7 +200,7 @@ static void ivas_compute_smooth_cov( if ( prev_idx == -1 || pIn_buf->reset_cov == 1 ) #endif { - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { for ( k = start_band; k < end_band; k++ ) { @@ -210,9 +210,9 @@ static void ivas_compute_smooth_cov( } else if ( prev_idx == 0 ) { - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( i == j ) { @@ -253,26 +253,26 @@ void ivas_cov_smooth_process( const int16_t end_band #ifdef SBA_SPAR_HARM , - const int16_t num_ch, + const int16_t nchan, const int16_t transient_det #endif ) { int16_t i, j; #ifndef SBA_SPAR_HARM - int16_t num_ch = pIn_buf->num_ch; + int16_t nchan = pIn_buf->nchan; #endif int16_t num_bands = end_band - start_band; #ifdef SBA_SPAR_HARM - ivas_compute_smooth_cov( hCovState, pFb, cov_real, hCovState->pPrior_cov_real, 1e-20f, start_band, end_band, num_ch, transient_det ); + ivas_compute_smooth_cov( hCovState, pFb, cov_real, hCovState->pPrior_cov_real, 1e-20f, start_band, end_band, nchan, transient_det ); #else - ivas_compute_smooth_cov( hCovState, pFb, pIn_buf->cov_real, hCovState->pPrior_cov_real, 1e-20f, start_band, end_band, num_ch, transient_det ); + ivas_compute_smooth_cov( hCovState, pFb, pIn_buf->cov_real, hCovState->pPrior_cov_real, 1e-20f, start_band, end_band, nchan, transient_det ); #endif - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { #ifdef SBA_SPAR_HARM mvr2r( &cov_real[i][j][start_band], &hCovState->pPrior_cov_real[i][j][start_band], num_bands ); diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 53ad90d01f..8419fea31f 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -102,8 +102,8 @@ ivas_error ivas_fb_set_cfg( IVAS_FB_CFG **pFb_cfg_out, /* o : FB config. handle */ const int16_t ivas_format, /* i : IVAS format */ const SBA_MODE sba_mode, /* i : SBA mode */ - const int16_t num_in_chans, /* i : number of FB input channels */ - const int16_t num_out_chans, /* i : number of FB output channels*/ + const int16_t nchan_inp, /* i : number of FB input channels */ + const int16_t nchan_out, /* i : number of FB output channels*/ const int16_t active_w_mixing, /* i : active_w_mixing flag */ const int32_t sampling_rate /* i : sampling rate */ ) @@ -115,8 +115,8 @@ ivas_error ivas_fb_set_cfg( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer config" ); } - pFb_cfg->num_in_chans = num_in_chans; - pFb_cfg->num_out_chans = num_out_chans; + pFb_cfg->nchan_inp = nchan_inp; + pFb_cfg->nchan_out = nchan_out; pFb_cfg->pcm_offset = 0; /* note: in SPAR decoder, this parameter is overwritten later */ pFb_cfg->active_w_mixing = active_w_mixing; @@ -179,7 +179,7 @@ ivas_error ivas_FB_mixer_open( { IVAS_FB_MIXER_HANDLE hFbMixer; int16_t i, j, frame_len, num_bands; - int16_t num_chs_alloc; + int16_t nchan_alloc; ivas_error error; error = IVAS_ERR_OK; @@ -198,20 +198,20 @@ ivas_error ivas_FB_mixer_open( if ( fb_cfg->active_w_mixing == -1 ) { - num_chs_alloc = 0; + nchan_alloc = 0; } else if ( fb_cfg->active_w_mixing ) { - num_chs_alloc = fb_cfg->num_in_chans; + nchan_alloc = fb_cfg->nchan_inp; } else { - num_chs_alloc = fb_cfg->num_out_chans; + nchan_alloc = fb_cfg->nchan_out; } - for ( i = 0; i < num_chs_alloc; i++ ) + for ( i = 0; i < nchan_alloc; i++ ) { - if ( fb_cfg->num_out_chans == 0 ) + if ( fb_cfg->nchan_out == 0 ) { hFbMixer->ppFilterbank_inFR_re[i] = NULL; hFbMixer->ppFilterbank_inFR_im[i] = NULL; @@ -234,13 +234,13 @@ ivas_error ivas_FB_mixer_open( if ( fb_cfg->active_w_mixing == -1 ) { - num_chs_alloc = 0; + nchan_alloc = 0; } else { - num_chs_alloc = fb_cfg->num_in_chans; + nchan_alloc = fb_cfg->nchan_inp; } - for ( i = 0; i < num_chs_alloc; i++ ) + for ( i = 0; i < nchan_alloc; i++ ) { if ( ( hFbMixer->ppFilterbank_prior_input[i] = (float *) count_malloc( sizeof( float ) * fb_cfg->prior_input_length ) ) == NULL ) { @@ -249,17 +249,17 @@ ivas_error ivas_FB_mixer_open( set_f( hFbMixer->ppFilterbank_prior_input[i], 0, fb_cfg->prior_input_length ); } - if ( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) ) + if ( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->nchan_out > 0 ) ) { float *pTemp_mem; - if ( ( pTemp_mem = (float *) count_malloc( sizeof( float ) * fb_cfg->num_out_chans * fb_cfg->num_in_chans * IVAS_MAX_NUM_BANDS ) ) == NULL ) + if ( ( pTemp_mem = (float *) count_malloc( sizeof( float ) * fb_cfg->nchan_out * fb_cfg->nchan_inp * IVAS_MAX_NUM_BANDS ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer" ); } - for ( i = 0; i < fb_cfg->num_out_chans; i++ ) + for ( i = 0; i < fb_cfg->nchan_out; i++ ) { - for ( j = 0; j < fb_cfg->num_in_chans; j++ ) + for ( j = 0; j < fb_cfg->nchan_inp; j++ ) { hFbMixer->prior_mixer[i][j] = pTemp_mem; pTemp_mem += IVAS_MAX_NUM_BANDS; @@ -268,7 +268,7 @@ ivas_error ivas_FB_mixer_open( } } - if ( fb_cfg->num_out_chans > 0 ) + if ( fb_cfg->nchan_out > 0 ) { const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs; @@ -372,18 +372,18 @@ void ivas_FB_mixer_close( } else if ( fb_cfg->active_w_mixing ) { - num_chs_alloc = fb_cfg->num_in_chans; + num_chs_alloc = fb_cfg->nchan_inp; } else { - num_chs_alloc = fb_cfg->num_out_chans; + num_chs_alloc = fb_cfg->nchan_out; } if ( hFbMixer != NULL ) { for ( i = 0; i < num_chs_alloc; i++ ) { - if ( fb_cfg->num_out_chans > 0 ) + if ( fb_cfg->nchan_out > 0 ) { j = fb_cfg->remix_order[i]; @@ -401,7 +401,7 @@ void ivas_FB_mixer_close( } else { - num_chs_alloc = fb_cfg->num_in_chans; + num_chs_alloc = fb_cfg->nchan_inp; } for ( i = 0; i < num_chs_alloc; i++ ) { @@ -409,13 +409,13 @@ void ivas_FB_mixer_close( hFbMixer->ppFilterbank_prior_input[i] = NULL; } - if ( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) ) + if ( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->nchan_out > 0 ) ) { count_free( hFbMixer->prior_mixer[0][0] ); hFbMixer->prior_mixer[0][0] = NULL; } - if ( fb_cfg->num_out_chans > 0 ) + if ( fb_cfg->nchan_out > 0 ) { num_bands = hFbMixer->pFb->filterbank_num_bands; @@ -483,14 +483,14 @@ void ivas_fb_mixer_pcm_ingest( if ( fb_cfg->active_w_mixing ) { - num_chs_ingest = fb_cfg->num_in_chans; + num_chs_ingest = fb_cfg->nchan_inp; } else { - num_chs_ingest = fb_cfg->num_out_chans; + num_chs_ingest = fb_cfg->nchan_out; } - for ( i = 0; i < fb_cfg->num_in_chans; i++ ) + for ( i = 0; i < fb_cfg->nchan_inp; i++ ) { mvr2r( &hFbMixer->ppFilterbank_prior_input[i][fb_cfg->prior_input_length - frame_len], ppOut_pcm[i], frame_len ); mvr2r( pcm_in[i], &ppOut_pcm[i][frame_len], frame_len ); @@ -519,7 +519,7 @@ void ivas_fb_mixer_update_prior_input( { int16_t i; - for ( i = 0; i < hFbMixer->fb_cfg->num_in_chans; i++ ) + for ( i = 0; i < hFbMixer->fb_cfg->nchan_inp; i++ ) { mvr2r( &hFbMixer->ppFilterbank_prior_input[i][length], hFbMixer->ppFilterbank_prior_input[i], hFbMixer->fb_cfg->prior_input_length - length ); mvr2r( pcm_in[i], &hFbMixer->ppFilterbank_prior_input[i][hFbMixer->fb_cfg->prior_input_length - length], length ); @@ -556,7 +556,7 @@ void ivas_fb_mixer_get_windowed_fr( rev_offset = (int16_t) ( 2 * mdft_len - hFbMixer->ana_window_offset ); set_zero( fr_in_block, offset ); - for ( ch_idx = 0; ch_idx < hFbMixer->fb_cfg->num_in_chans; ch_idx++ ) + for ( ch_idx = 0; ch_idx < hFbMixer->fb_cfg->nchan_inp; ch_idx++ ) { mvr2r( &hFbMixer->ppFilterbank_prior_input[ch_idx][offset + hFbMixer->fb_cfg->windowed_fr_offset], &fr_in_block[offset], n_old_samples - offset ); mvr2r( pcm_in[ch_idx], &fr_in_block[n_old_samples], n_new_samples ); @@ -657,7 +657,7 @@ void ivas_fb_mixer_process( pMdft_out[0] = Mdft_out_0; pMdft_out[1] = Mdft_out_1; - for ( ch = ( hFbMixer->fb_cfg->active_w_mixing == 0 ); ch < hFbMixer->fb_cfg->num_out_chans; ch++ ) + for ( ch = ( hFbMixer->fb_cfg->active_w_mixing == 0 ); ch < hFbMixer->fb_cfg->nchan_out; ch++ ) { /* Run a loop of 2 to calculate current frame's filterbank output and prev frame's output */ for ( hist = 0; hist < 2; hist++ ) @@ -665,7 +665,7 @@ void ivas_fb_mixer_process( set_zero( pOut_fr_re, frame_len ); set_zero( pOut_fr_im, frame_len ); - for ( j = 0; j < hFbMixer->fb_cfg->num_in_chans; j++ ) + for ( j = 0; j < hFbMixer->fb_cfg->nchan_inp; j++ ) { if ( in_out_mixer_map[ch][j] != 0 ) { @@ -739,9 +739,9 @@ void ivas_fb_mixer_get_in_out_mapping( { if ( fb_cfg->active_w_mixing ) { - for ( i = 0; i < fb_cfg->num_out_chans; i++ ) + for ( i = 0; i < fb_cfg->nchan_out; i++ ) { - for ( j = 0; j < fb_cfg->num_in_chans; j++ ) + for ( j = 0; j < fb_cfg->nchan_inp; j++ ) { in_out_mixer_map[i][j] = 1; } @@ -750,7 +750,7 @@ void ivas_fb_mixer_get_in_out_mapping( else { in_out_mixer_map[0][0] = 1; /* W depends on only W input*/ - for ( i = 1; i < fb_cfg->num_out_chans; i++ ) + for ( i = 1; i < fb_cfg->nchan_out; i++ ) { in_out_mixer_map[i][0] = 1; in_out_mixer_map[i][order[i]] = 1; @@ -768,7 +768,7 @@ void ivas_fb_mixer_get_in_out_mapping( if ( nchan_transport == 1 ) { /* no cross predicitons in 1 ch dmx*/ - for ( i = nchan_transport; i < fb_cfg->num_out_chans; i++ ) + for ( i = nchan_transport; i < fb_cfg->nchan_out; i++ ) { in_out_mixer_map[order[i]][0] = 1; in_out_mixer_map[order[i]][i] = 1; @@ -777,7 +777,7 @@ void ivas_fb_mixer_get_in_out_mapping( else { /* handle the cross predictions and decorrelation*/ - for ( i = nchan_transport; i < fb_cfg->num_out_chans; i++ ) + for ( i = nchan_transport; i < fb_cfg->nchan_out; i++ ) { for ( j = 0; j < nchan_transport; j++ ) { @@ -820,8 +820,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*/ @@ -1038,11 +1038,11 @@ static ivas_error ivas_filterbank_setup( error = IVAS_ERR_OK; - 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 ); + set_s( hFbMixer->first_frame, 1, pCfg->nchan_out ); + set_s( hFbMixer->first_frame + pCfg->nchan_out, 0, IVAS_SPAR_MAX_CH - pCfg->nchan_out ); - if ( pCfg->num_out_chans > 0 ) + if ( pCfg->nchan_out > 0 ) { hFbMixer->pFb->filterbank_num_bands = ivas_get_num_bands( sampling_rate ); @@ -1078,7 +1078,7 @@ static ivas_error ivas_filterbank_setup( return error; } - if ( pCfg->num_out_chans > 0 ) + if ( pCfg->nchan_out > 0 ) { ivas_filterbank_t *pFb = hFbMixer->pFb; int16_t offset = 0; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 84450e89a0..7e280a082f 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -654,7 +654,7 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( /*! r: limiter struct handle */ IVAS_LIMITER_HANDLE ivas_limiter_open( - const int16_t num_channels, /* i : number of I/O channels */ + const int16_t nchan, /* i : number of I/O channels */ const int32_t sampling_rate /* i : sampling rate for processing */ ); @@ -666,7 +666,7 @@ void ivas_limiter_dec ( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], /* i/o: input/output buffer */ - const int16_t num_channels, /* i : number of channels to be processed */ + const int16_t nchan, /* i : number of channels to be processed */ const int16_t output_frame, /* i : number of samples per channel in the buffer */ const int16_t BER_detect /* i : BER detect flag */ ); @@ -3115,7 +3115,7 @@ void ivas_sba_getTCs( ivas_error ivas_sba_linear_renderer( float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nchan_in, /* i : number of input ambisonics channels */ + const int16_t nchan_inp, /* i : number of input ambisonics channels */ const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */ const float hoa_dec_mtx[] /* i : HOA decoding mtx */ @@ -3311,7 +3311,7 @@ void computeDiffuseness( ); void ivas_dirac_dec_onset_detection_open( - const int16_t num_channels, + const int16_t nchan, const int16_t num_freq_bands, const int16_t max_band_decorr, DIRAC_ONSET_DETECTION_PARAMS *ph_dirac_onset_detection_params, @@ -3340,7 +3340,7 @@ void ivas_dirac_dec_decorr_open( void ivas_dirac_dec_decorr_process( const int16_t num_freq_bands, - int16_t num_channels, + int16_t nchan, const int16_t num_protos_diff, const DIRAC_SYNTHESIS_CONFIG synthesisConf, const int16_t nchan_transport, /* i : number of transport channels */ @@ -3635,14 +3635,14 @@ void ivas_dirac_dec_output_synthesis_cov_open( const int16_t interp_length, /* i : length for interpolating the mixing matrices in time slots */ const int16_t num_param_bands, /* i : number of parameter bands */ const int16_t num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ - const int16_t nchan_in, /* i : number of input (transport) channels */ + const int16_t nchan_inp, /* i : number of input (transport) channels */ const int16_t nchan_out, /* i : number of output channels */ const float *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ ); void ivas_dirac_dec_output_synthesis_cov_init( DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: pointer to the state of the covariance synthesis */ - const int16_t nchan_in, /* i : number of input (tranport) channels */ + const int16_t nchan_inp, /* i : number of input (tranport) channels */ const int16_t nchan_out, /* i : number of output channels */ const int16_t n_param_bands, /* i : number of total parameter bands */ const int16_t n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ @@ -3659,7 +3659,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) */ float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (imaginary part) */ PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ - const int16_t nchan_in, /* i : number of input channels */ + const int16_t nchan_inp, /* i : number of input channels */ const int16_t idx_slot /* i : index of the slot to be added to the input covariance */ ); @@ -3934,7 +3934,7 @@ void ivas_compute_spar_params( const int16_t start_band, const int16_t end_band, const int16_t dtx_vad, - const int16_t num_ch, + const int16_t nchan, const int16_t bands_bw, const int16_t active_w, ivas_spar_md_com_cfg *hSparCfg, @@ -3959,7 +3959,7 @@ void ivas_calc_c_p_coeffs( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t i_ts, float ***mixer_mat, - const int16_t num_ch, + const int16_t nchan, const int16_t num_dmx, const int16_t band_idx, const int16_t dtx_vad, @@ -3985,7 +3985,7 @@ void ivas_get_spar_md_from_dirac( ivas_error ivas_spar_md_dec_open( ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels /* i : number of internal channels */ + const int16_t nchan /* i : number of internal channels */ ); void ivas_spar_md_dec_close( @@ -4005,7 +4005,7 @@ void ivas_spar_get_parameters( ivas_error ivas_spar_md_dec_init( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels /* i : number of internal channels */ + const int16_t nchan /* i : number of internal channels */ ); void ivas_spar_md_dec_process( @@ -4102,7 +4102,7 @@ void ivas_cov_smooth_process( const int16_t end_band #ifdef SBA_SPAR_HARM , - const int16_t num_ch, + const int16_t nchan, const int16_t transient_det #endif ); @@ -5158,8 +5158,8 @@ ivas_error ivas_fb_set_cfg( IVAS_FB_CFG **pFb_cfg_out, /* o : FB config. handle */ const int16_t ivas_format, /* i : IVAS format */ const SBA_MODE sba_mode, /* i : SBA mode */ - const int16_t num_in_chans, /* i : number of FB input channels */ - const int16_t num_out_chans, /* i : number of FB output channels */ + const int16_t nchan_inp, /* i : number of FB input channels */ + const int16_t nchan_out, /* i : number of FB output channels */ const int16_t active_w_mixing, /* i : active_w_mixing flag */ const int32_t sampling_Fs /* i : sampling rate */ ); diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index a93326ec9c..b9abd5f778 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -80,9 +80,9 @@ static void ivas_get_pred_coeffs( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SP static void ivas_reorder_array( float in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS], const int16_t in_chans, const int16_t order[IVAS_SPAR_MAX_CH], float ***mixer_mat, const int16_t start_band, const int16_t end_band ); -static void ivas_get_Wscaling_factor( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], float ***mixer_mat, const int16_t start_band, const int16_t end_band, const int16_t dtx_vad, const int16_t num_ch, const int16_t *pNum_dmx, const int16_t bands_bw, const int16_t active_w, float *pWscale ); +static void ivas_get_Wscaling_factor( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], float ***mixer_mat, const int16_t start_band, const int16_t end_band, const int16_t dtx_vad, const int16_t nchan, const int16_t *pNum_dmx, const int16_t bands_bw, const int16_t active_w, float *pWscale ); -static void ivas_calc_post_pred_per_band( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float ***mixer_mat, const int16_t num_ch, const int16_t num_dmx, const int16_t band_idx, float postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH] ); +static void ivas_calc_post_pred_per_band( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float ***mixer_mat, const int16_t nchan, const int16_t num_dmx, const int16_t band_idx, float postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH] ); static int16_t ivas_is_mat_inv( float in_re[MAX_MAT_DIM][MAX_MAT_DIM], const int16_t dim ); @@ -641,7 +641,7 @@ static void ivas_get_Wscaling_factor( const int16_t start_band, const int16_t end_band, const int16_t dtx_vad, - const int16_t num_ch, + const int16_t nchan, const int16_t *pNum_dmx, const int16_t bands_bw, const int16_t active_w, @@ -668,11 +668,11 @@ static void ivas_get_Wscaling_factor( { float Gw_sq, g_sq = 0; - ivas_calc_post_pred_per_band( cov_real, mixer_mat, num_ch, pNum_dmx[b * bands_bw], b, postpred_cov_re ); + ivas_calc_post_pred_per_band( cov_real, mixer_mat, nchan, pNum_dmx[b * bands_bw], b, postpred_cov_re ); Gw_sq = cov_real[0][0][b] / max( postpred_cov_re[0][0], IVAS_FLT_EPS ); - for ( ch = 0; ch < num_ch - 1; ch++ ) + for ( ch = 0; ch < nchan - 1; ch++ ) { IVAS_CALCULATE_SQ_ABS_N( pred_coeffs_re[ch][b], abs_val ); @@ -864,7 +864,7 @@ static void ivas_reorder_array( static void ivas_calc_post_pred_per_band( float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float ***mixer_mat, - const int16_t num_ch, + const int16_t nchan, const int16_t num_dmx, const int16_t band_idx, float postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH] ) @@ -875,29 +875,29 @@ static void ivas_calc_post_pred_per_band( float tmp_re; // NOTE: What is this doing? - if ( num_dmx != num_ch ) + if ( num_dmx != nchan ) { - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { dmx_mat_conj[i][j] = mixer_mat[j][i][band_idx]; } } } - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - set_zero( postpred_cov_re[i], num_ch ); + set_zero( postpred_cov_re[i], nchan ); } - /* num_ch x num_ch mult */ - for ( i = 0; i < num_ch; i++ ) + /* nchan x nchan mult */ + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { temp_mat[i][j] = 0; - for ( k = 0; k < num_ch; k++ ) + for ( k = 0; k < nchan; k++ ) { IVAS_RMULT_FLOAT( cov_real[i][k][band_idx], dmx_mat_conj[k][j], tmp_re ); temp_mat[i][j] += tmp_re; @@ -905,12 +905,12 @@ static void ivas_calc_post_pred_per_band( } } - /* num_ch x num_ch mult */ - for ( i = 0; i < num_ch; i++ ) + /* nchan x nchan mult */ + for ( i = 0; i < nchan; i++ ) { - for ( j = i; j < num_ch; j++ ) + for ( j = i; j < nchan; j++ ) { - for ( k = 0; k < num_ch; k++ ) + for ( k = 0; k < nchan; k++ ) { IVAS_RMULT_FLOAT( mixer_mat[i][k][band_idx], temp_mat[k][j], tmp_re ); @@ -919,7 +919,7 @@ static void ivas_calc_post_pred_per_band( } } - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { for ( j = 0; j < i; j++ ) { @@ -928,9 +928,9 @@ static void ivas_calc_post_pred_per_band( } #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n Postpred cov: (band %d)\n", band_idx); - for (i = 0; i < num_ch; i++) + for (i = 0; i < nchan; i++) { - for (j = 0; j < num_ch; j++) + for (j = 0; j < nchan; j++) { fprintf(stderr, "%f, ", postpred_cov_re[i][j]); } @@ -953,7 +953,7 @@ static void ivas_calc_p_coeffs_per_band( ivas_spar_md_t *pSparMd, const int16_t i_ts, float postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], - const int16_t num_ch, + const int16_t nchan, const int16_t dtx_vad, const int16_t num_dmx, const int16_t band_idx ) @@ -970,7 +970,7 @@ static void ivas_calc_p_coeffs_per_band( b_ts_idx = band_idx + i_ts * IVAS_MAX_NUM_BANDS; - if ( num_dmx != num_ch ) + if ( num_dmx != nchan ) { set_zero( pSparMd->band_coeffs[b_ts_idx].P_re, IVAS_SPAR_MAX_CH - 1 ); for ( i = 0; i < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; i++ ) @@ -978,9 +978,9 @@ static void ivas_calc_p_coeffs_per_band( set_zero( recon_uu_re[i], IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ); } - for ( i = num_dmx; i < num_ch; i++ ) + for ( i = num_dmx; i < nchan; i++ ) { - for ( j = num_dmx; j < num_ch; j++ ) + for ( j = num_dmx; j < nchan; j++ ) { cov_uu_re[i - num_dmx][j - num_dmx] = postpred_cov_re[i][j]; } @@ -1043,7 +1043,7 @@ static void ivas_calc_p_coeffs_per_band( /* Step 1: Multiply C * cov_dd * C' */ float re1[3], re; - for ( i = 0; i < num_ch - num_dmx; i++ ) + for ( i = 0; i < nchan - num_dmx; i++ ) { set_f( re1, 0, 3 ); for ( m = 0; m < num_dmx - 1; m++ ) @@ -1054,7 +1054,7 @@ static void ivas_calc_p_coeffs_per_band( re1[m] += re; } } - for ( j = 0; j < num_ch - num_dmx; j++ ) + for ( j = 0; j < nchan - num_dmx; j++ ) { for ( m = 0; m < num_dmx - 1; m++ ) { @@ -1065,9 +1065,9 @@ static void ivas_calc_p_coeffs_per_band( } /* Step 2: cov_uu - recon_uu */ - for ( i = 0; i < num_ch - num_dmx; i++ ) + for ( i = 0; i < nchan - num_dmx; i++ ) { - for ( j = 0; j < num_ch - num_dmx; j++ ) + for ( j = 0; j < nchan - num_dmx; j++ ) { cov_uu_re[i][j] -= recon_uu_re[i][j]; } @@ -1084,7 +1084,7 @@ static void ivas_calc_p_coeffs_per_band( trace = 0.0f; - for ( i = num_dmx; i < num_ch; i++ ) + for ( i = num_dmx; i < nchan; i++ ) { float tmp_out; IVAS_CALCULATE_RABS( cov_uu_re[i - num_dmx][i - num_dmx], tmp_out ); @@ -1096,9 +1096,9 @@ static void ivas_calc_p_coeffs_per_band( factor = 1 / factor; /* normalise Hermitian (except for rounding) cov_uu */ - for ( i = num_dmx; i < num_ch; i++ ) + for ( i = num_dmx; i < nchan; i++ ) { - for ( j = num_dmx; j < num_ch; j++ ) + for ( j = num_dmx; j < nchan; j++ ) { if ( i == j ) { @@ -1114,16 +1114,16 @@ static void ivas_calc_p_coeffs_per_band( } /* take sqrt of max of diags and zero */ - for ( i = num_dmx; i < num_ch; i++ ) + for ( i = num_dmx; i < nchan; i++ ) { cov_uu_re[i - num_dmx][i - num_dmx] = sqrtf( max( 0.0f, cov_uu_re[i - num_dmx][i - num_dmx] ) ); /* cov_uu_im[i - num_dmx][i - num_dmx] = 0; */ } /* save into MD struct */ - for ( i = num_dmx; i < num_ch; i++ ) + for ( i = num_dmx; i < nchan; i++ ) { - for ( j = num_dmx; j < num_ch; j++ ) + for ( j = num_dmx; j < nchan; j++ ) { if ( i == j ) { @@ -1147,7 +1147,7 @@ static void ivas_calc_c_coeffs_per_band( ivas_spar_md_t *pSparMd, const int16_t i_ts, float postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], - const int16_t num_ch, + const int16_t nchan, const int16_t num_dmx, const int16_t band_idx, const int16_t dtx_vad ) @@ -1171,7 +1171,7 @@ static void ivas_calc_c_coeffs_per_band( return; } - for ( i = num_dmx; i < num_ch; i++ ) + for ( i = num_dmx; i < nchan; i++ ) { for ( j = 1; j < num_dmx; j++ ) { @@ -1213,7 +1213,7 @@ static void ivas_calc_c_coeffs_per_band( else { ivas_calc_mat_inv( cov_dd_re, num_dmx - 1, cov_dd_re_inv ); - for ( i = 0; i < num_ch - num_dmx; i++ ) + for ( i = 0; i < nchan - num_dmx; i++ ) { for ( j = 0; j < num_dmx - 1; j++ ) { @@ -1243,7 +1243,7 @@ void ivas_calc_c_p_coeffs( float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t i_ts, float ***mixer_mat, - const int16_t num_ch, + const int16_t nchan, const int16_t num_dmx, const int16_t band_idx, const int16_t dtx_vad, @@ -1253,18 +1253,18 @@ void ivas_calc_c_p_coeffs( int16_t i, j; float postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - if ( num_dmx != num_ch ) + if ( num_dmx != nchan ) { - ivas_calc_post_pred_per_band( cov_real, mixer_mat, num_ch, num_dmx, band_idx, postpred_cov_re ); + ivas_calc_post_pred_per_band( cov_real, mixer_mat, nchan, num_dmx, band_idx, postpred_cov_re ); if ( num_dmx != 1 ) { - ivas_calc_c_coeffs_per_band( pSparMd, i_ts, postpred_cov_re, num_ch, num_dmx, band_idx, dtx_vad ); + ivas_calc_c_coeffs_per_band( pSparMd, i_ts, postpred_cov_re, nchan, num_dmx, band_idx, dtx_vad ); } if ( planarCP ) { - for ( i = 0; i < num_ch - num_dmx; i++ ) + for ( i = 0; i < nchan - num_dmx; i++ ) { if ( !keep_planar[i] ) { @@ -1278,12 +1278,12 @@ void ivas_calc_c_p_coeffs( if ( compute_p_flag == 1 ) { - ivas_calc_p_coeffs_per_band( pSparMd, i_ts, postpred_cov_re, num_ch, dtx_vad, num_dmx, band_idx ); + ivas_calc_p_coeffs_per_band( pSparMd, i_ts, postpred_cov_re, nchan, dtx_vad, num_dmx, band_idx ); } if ( planarCP ) { - for ( i = num_dmx; i < num_ch; i++ ) + for ( i = num_dmx; i < nchan; i++ ) { if ( !keep_planar[i - num_dmx] ) { @@ -1533,7 +1533,7 @@ void ivas_compute_spar_params( const int16_t start_band, const int16_t end_band, const int16_t dtx_vad, - const int16_t num_ch, + const int16_t nchan, const int16_t bands_bw, const int16_t active_w, ivas_spar_md_com_cfg *hSparCfg, @@ -1544,12 +1544,12 @@ void ivas_compute_spar_params( float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; int16_t b, i, ndm; - ivas_get_pred_coeffs( cov_real, pred_coeffs_re, dm_fv_re, num_ch, start_band, end_band, active_w, dtx_vad, from_dirac ); + ivas_get_pred_coeffs( cov_real, pred_coeffs_re, dm_fv_re, nchan, start_band, end_band, active_w, dtx_vad, from_dirac ); #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n Prediction Coefficients:\n"); - for (i = 0; i < num_ch - 1; i++) + for (i = 0; i < nchan - 1; i++) { for (j = start_band; j < end_band; j++) { @@ -1559,14 +1559,14 @@ void ivas_compute_spar_params( } fprintf(stderr, "\n\n"); */ #endif - ivas_create_fullr_dmx_mat( pred_coeffs_re, dm_fv_re, mixer_mat, num_ch, start_band, end_band, active_w, hSparCfg ); + ivas_create_fullr_dmx_mat( pred_coeffs_re, dm_fv_re, mixer_mat, nchan, start_band, end_band, active_w, hSparCfg ); #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n 1st DMX matrix (band 0):\n"); - for (i = 0; i < num_ch; i++) + for (i = 0; i < nchan; i++) { - for (j = 0; j < num_ch; j++) + for (j = 0; j < nchan; j++) { fprintf(stderr, "%f, ", mixer_mat[i][j][0]); } @@ -1575,18 +1575,18 @@ void ivas_compute_spar_params( fprintf(stderr, "\n\n");*/ #endif - ivas_get_Wscaling_factor( cov_real, pred_coeffs_re, mixer_mat, start_band, end_band, dtx_vad, num_ch, + ivas_get_Wscaling_factor( cov_real, pred_coeffs_re, mixer_mat, start_band, end_band, dtx_vad, nchan, hSparCfg->num_dmx_chans_per_band, bands_bw, active_w, pWscale ); for ( b = start_band; b < end_band; b++ ) { float onebyscale = 1.0f / pWscale[b]; - for ( i = 0; i < num_ch - 1; i++ ) + for ( i = 0; i < nchan - 1; i++ ) { hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re[i] = pred_coeffs_re[i][b] * onebyscale; } - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { mixer_mat[0][i][b] *= pWscale[b]; } @@ -1596,20 +1596,20 @@ void ivas_compute_spar_params( { ndm = hSparCfg->num_dmx_chans_per_band[b * bands_bw]; - if ( ndm != num_ch ) + if ( ndm != nchan ) { - ivas_calc_c_p_coeffs( hSparMd, cov_real, i_ts, mixer_mat, num_ch, ndm, b, dtx_vad, 1, 0 ); + ivas_calc_c_p_coeffs( hSparMd, cov_real, i_ts, mixer_mat, nchan, ndm, b, dtx_vad, 1, 0 ); #ifdef SPAR_HOA_DBG /* if (b == 0) */ { fprintf( stdout, "\n\nUnquantised C, P coeffs -- band %d:\n", b ); - for ( int16_t ii = 0; ii < num_ch; ii++ ) + for ( int16_t ii = 0; ii < nchan; ii++ ) { fprintf( stdout, "%f |", hSparMd->band_coeffs[b].pred_re[ii] ); - if ( ii < num_ch - ndm ) + if ( ii < nchan - ndm ) { for ( int16_t jj = 0; jj < ndm - 1; jj++ ) { @@ -1649,7 +1649,7 @@ void ivas_get_spar_md_from_dirac( const int16_t dtx_vad, float Wscale_d[IVAS_MAX_NUM_BANDS] ) { - int16_t num_ch, band, i, j; + int16_t nchan, band, i, j; int16_t block, ch; float response_avg[MAX_OUTPUT_CHANNELS]; float response[MAX_PARAM_SPATIAL_SUBFRAMES][MAX_OUTPUT_CHANNELS]; @@ -1667,7 +1667,7 @@ void ivas_get_spar_md_from_dirac( remix_order = remix_order_set[hSpar_md_cfg->remix_unmix_order]; - num_ch = 2 * order + 2; + nchan = 2 * order + 2; hoa2_ch = 6; foa_ch = FOA_CHANNELS; diff_norm_order1 = 3.0f; @@ -1696,18 +1696,18 @@ void ivas_get_spar_md_from_dirac( P_norm[0] *= diff_norm_order1 / min( diff_norm_order1, max( 0, foa_ch - ndm ) ); P_norm[1] = 0.0f; - for ( ; i < max( 0, min( num_ch, hoa2_ch ) - ndm ); i++ ) + for ( ; i < max( 0, min( nchan, hoa2_ch ) - ndm ); i++ ) { P_norm[1] += hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i]; } - P_norm[1] *= diff_norm_order2 / min( diff_norm_order2, max( 0, min( num_ch, hoa2_ch ) - ndm ) ); + P_norm[1] *= diff_norm_order2 / min( diff_norm_order2, max( 0, min( nchan, hoa2_ch ) - ndm ) ); P_norm[2] = 0.0f; - for ( ; i < num_ch - ndm; i++ ) + for ( ; i < nchan - ndm; i++ ) { P_norm[2] += hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i]; } - P_norm[2] *= diff_norm_order3 / min( diff_norm_order3, max( 0, num_ch - ndm ) ); + P_norm[2] *= diff_norm_order3 / min( diff_norm_order3, max( 0, nchan - ndm ) ); for ( i = 0; i < max( 0, foa_ch - ndm ); i++ ) { @@ -1715,13 +1715,13 @@ void ivas_get_spar_md_from_dirac( P_dir_fact[idx] = hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i]; P_dir_fact[idx] = P_dir_fact[idx] / max( IVAS_FLT_EPS, P_norm[0] ); } - for ( ; i < max( 0, min( num_ch, hoa2_ch ) - ndm ); i++ ) + for ( ; i < max( 0, min( nchan, hoa2_ch ) - ndm ); i++ ) { idx = remix_order[i + ndm] - ndm; P_dir_fact[idx] = hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i]; P_dir_fact[idx] = P_dir_fact[idx] / max( IVAS_FLT_EPS, P_norm[1] ); } - for ( ; i < num_ch - ndm; i++ ) + for ( ; i < nchan - ndm; i++ ) { idx = remix_order[i + ndm] - ndm; P_dir_fact[idx] = hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i]; @@ -1807,15 +1807,15 @@ void ivas_get_spar_md_from_dirac( } } - for ( i = FOA_CHANNELS + 1; i < num_ch; i++ ) + for ( i = FOA_CHANNELS + 1; i < nchan; i++ ) { response_avg[i] = response_avg[HOA_keep_ind[i]]; } en_ratio_fac = ( 1.0f - diffuseness[band] ); - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( i == j ) { @@ -1874,9 +1874,9 @@ void ivas_get_spar_md_from_dirac( } } - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { pCov_real[i][j] = cov_real_dirac[i][j]; } @@ -1892,9 +1892,9 @@ void ivas_get_spar_md_from_dirac( fid = fopen( "cov_real_dirac.txt", "wt" ); } - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = start_band; k < end_band; k++ ) { @@ -1907,7 +1907,7 @@ void ivas_get_spar_md_from_dirac( #endif ivas_compute_spar_params( pCov_real, dm_fv_re, i_ts, ppMixer_mat, start_band, end_band, dtx_vad, - num_ch, 1, hSpar_md_cfg->active_w, hSpar_md_cfg, hSpar_md, Wscale, 1 ); + nchan, 1, hSpar_md_cfg->active_w, hSpar_md_cfg, hSpar_md, Wscale, 1 ); if ( mixer_mat != NULL ) { @@ -1917,15 +1917,15 @@ void ivas_get_spar_md_from_dirac( for ( i = 0; i < ndm; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { mixer_mat[i][j][band + i_ts * IVAS_MAX_NUM_BANDS] = ppMixer_mat[i][j][band]; } } - for ( i = ndm; i < num_ch; i++ ) + for ( i = ndm; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { mixer_mat[i][j][band + i_ts * IVAS_MAX_NUM_BANDS] = 0.0f; } @@ -1933,7 +1933,7 @@ void ivas_get_spar_md_from_dirac( if ( ( ndm == 1 ) && ( Wscale_d != NULL ) ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { mixer_mat[0][j][band + i_ts * IVAS_MAX_NUM_BANDS] *= Wscale_d[band]; } diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 4b2c342f4f..859baaedce 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -355,7 +355,7 @@ typedef struct ivas_cov_smooth_cfg_t typedef struct ivas_cov_smooth_in_buf_t { float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - int16_t num_ch; + int16_t nchan; int16_t reset_cov; } ivas_cov_smooth_in_buf_t; @@ -670,8 +670,8 @@ typedef struct ivas_trans_det_state_t typedef struct ivas_fb_mixer_cfg_t { int16_t fb_latency; - int16_t num_in_chans; - int16_t num_out_chans; + int16_t nchan_inp; + int16_t nchan_out; int16_t pcm_offset; int16_t fade_len; /* this sets the stride length; no delay is introduced */ int16_t prior_input_length; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ec9a712065..116288299d 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -56,7 +56,7 @@ static void ivas_dirac_free_mem( DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem ); static void initDiffuseResponses( float *diffuse_response_function, - const int16_t num_channels, + const int16_t nchan, AUDIO_CONFIG output_config, IVAS_OUTPUT_SETUP hOutSetup, const int16_t ambisonics_order, @@ -2522,7 +2522,7 @@ void ivas_dirac_dec_get_frequency_axis( static void initDiffuseResponses( float *diffuse_response_function, - const int16_t num_channels, + const int16_t nchan, AUDIO_CONFIG output_config, IVAS_OUTPUT_SETUP hOutSetup, const int16_t ambisonics_order, @@ -2543,7 +2543,7 @@ static void initDiffuseResponses( /* set diffuse response function */ if ( ivas_format == MC_FORMAT && ( transport_config == AUDIO_CONFIG_5_1 || transport_config == AUDIO_CONFIG_7_1 ) && output_config == AUDIO_CONFIG_5_1_4 ) { - num_horizontal_speakers = num_channels - NUM_ELEVATED_SPEAKERS; + num_horizontal_speakers = nchan - NUM_ELEVATED_SPEAKERS; mvr2r( diffuse_response_CICP6, diffuse_response_function, num_horizontal_speakers ); set_zero( &diffuse_response_function[num_horizontal_speakers], NUM_ELEVATED_SPEAKERS ); @@ -2551,30 +2551,30 @@ static void initDiffuseResponses( } else if ( ivas_format == MC_FORMAT && ( transport_config == AUDIO_CONFIG_5_1 || transport_config == AUDIO_CONFIG_7_1 ) && output_config == AUDIO_CONFIG_7_1_4 ) { - num_horizontal_speakers = num_channels - NUM_ELEVATED_SPEAKERS; + num_horizontal_speakers = nchan - NUM_ELEVATED_SPEAKERS; set_f( diffuse_response_function, sqrtf( 1.f / ( (float) num_horizontal_speakers ) ), num_horizontal_speakers ); set_zero( &diffuse_response_function[num_horizontal_speakers], NUM_ELEVATED_SPEAKERS ); *num_ele_spk_no_diffuse_rendering = NUM_ELEVATED_SPEAKERS; } - else if ( ( ivas_format == MASA_FORMAT || ivas_format == MC_FORMAT ) && output_config == AUDIO_CONFIG_5_1 && num_channels == 5 ) + else if ( ( ivas_format == MASA_FORMAT || ivas_format == MC_FORMAT ) && output_config == AUDIO_CONFIG_5_1 && nchan == 5 ) { - mvr2r( diffuse_response_CICP6, diffuse_response_function, num_channels ); + mvr2r( diffuse_response_CICP6, diffuse_response_function, nchan ); } - else if ( ( ivas_format == MASA_FORMAT || ivas_format == MC_FORMAT ) && output_config == AUDIO_CONFIG_5_1_2 && num_channels == 7 ) + else if ( ( ivas_format == MASA_FORMAT || ivas_format == MC_FORMAT ) && output_config == AUDIO_CONFIG_5_1_2 && nchan == 7 ) { - mvr2r( diffuse_response_CICP14, diffuse_response_function, num_channels ); + mvr2r( diffuse_response_CICP14, diffuse_response_function, nchan ); } - else if ( ( ivas_format == MASA_FORMAT || ivas_format == MC_FORMAT ) && ( output_config == AUDIO_CONFIG_5_1_4 ) && ( num_channels == 9 ) ) + else if ( ( ivas_format == MASA_FORMAT || ivas_format == MC_FORMAT ) && ( output_config == AUDIO_CONFIG_5_1_4 ) && ( nchan == 9 ) ) { - mvr2r( diffuse_response_CICP16, diffuse_response_function, num_channels ); + mvr2r( diffuse_response_CICP16, diffuse_response_function, nchan ); } else if ( ( ivas_format == MASA_FORMAT || ivas_format == MC_FORMAT ) && ( output_config == AUDIO_CONFIG_LS_CUSTOM ) ) { if ( transport_config == AUDIO_CONFIG_5_1 || transport_config == AUDIO_CONFIG_7_1 ) { /* Detect loudspeakers with elevation */ - for ( i = 0, num_horizontal_speakers = 0; i < num_channels; i++ ) + for ( i = 0, num_horizontal_speakers = 0; i < nchan; i++ ) { if ( fabsf( hOutSetup.ls_elevation[i] ) <= 5.f ) { @@ -2590,7 +2590,7 @@ static void initDiffuseResponses( /* Diffuse only to horizontal plane if enough loudspeakers */ if ( num_horizontal_speakers > 2 ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { diffuse_response_function[i] *= sqrtf( 1.f / (float) num_horizontal_speakers ); } @@ -2598,17 +2598,17 @@ static void initDiffuseResponses( else { *num_ele_spk_no_diffuse_rendering = 0; - set_f( diffuse_response_function, sqrtf( 1.f / (float) num_channels ), num_channels ); + set_f( diffuse_response_function, sqrtf( 1.f / (float) nchan ), nchan ); } } else { - set_f( diffuse_response_function, sqrtf( 1.f / (float) num_channels ), num_channels ); + set_f( diffuse_response_function, sqrtf( 1.f / (float) nchan ), nchan ); } } else { - set_f( diffuse_response_function, sqrtf( 1.f / (float) num_channels ), num_channels ); + set_f( diffuse_response_function, sqrtf( 1.f / (float) nchan ), nchan ); } } else diff --git a/lib_dec/ivas_dirac_decorr_dec.c b/lib_dec/ivas_dirac_decorr_dec.c index 437bdf8a64..c74d5d29ab 100644 --- a/lib_dec/ivas_dirac_decorr_dec.c +++ b/lib_dec/ivas_dirac_decorr_dec.c @@ -292,7 +292,7 @@ void ivas_dirac_dec_decorr_open( void ivas_dirac_dec_decorr_process( const int16_t num_freq_bands, - int16_t num_channels, + int16_t nchan, const int16_t num_protos_diff, const DIRAC_SYNTHESIS_CONFIG synthesisConf, const int16_t nchan_transport, /* i : number of transport channels*/ @@ -355,7 +355,7 @@ void ivas_dirac_dec_decorr_process( if ( synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - num_channels -= nchan_transport; + nchan -= nchan_transport; } @@ -380,8 +380,8 @@ void ivas_dirac_dec_decorr_process( ivas_dirac_dec_onset_detection_process( aux_buffer, onset_filter, num_protos_diff, h_freq_domain_decorr_ap_params->h_onset_detection_power_params, h_freq_domain_decorr_ap_state->h_onset_detection_power_state ); - /* Apply decorrelator if num_channels is greater than 0 */ - if ( num_channels > 0 ) + /* Apply decorrelator if nchan is greater than 0 */ + if ( nchan > 0 ) { /* remove onsets from prototype frame */ for ( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) @@ -403,7 +403,7 @@ void ivas_dirac_dec_decorr_process( phase_coeff_imag = h_freq_domain_decorr_ap_params->phase_coeff_imag; incr_aux = 2 * ( num_freq_bands - max_band_decorr ); - for ( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + for ( ch_idx = 0; ch_idx < nchan; ++ch_idx ) { /* final phase rotation */ for ( k = 0; k < max_band_decorr; k++ ) @@ -419,9 +419,9 @@ void ivas_dirac_dec_decorr_process( decorr_buffer_len = h_freq_domain_decorr_ap_params->filter_length[0] + h_freq_domain_decorr_ap_params->pre_delay[0] - 1; for ( time_idx = 0; time_idx < ( decorr_buffer_len - 1 ); time_idx++ ) { - mvr2r( &h_freq_domain_decorr_ap_state->decorr_buffer[2 * ( time_idx + 1 ) * max_band_decorr * num_channels], &h_freq_domain_decorr_ap_state->decorr_buffer[2 * (time_idx) *max_band_decorr * num_channels], 2 * max_band_decorr * num_channels ); + mvr2r( &h_freq_domain_decorr_ap_state->decorr_buffer[2 * ( time_idx + 1 ) * max_band_decorr * nchan], &h_freq_domain_decorr_ap_state->decorr_buffer[2 * (time_idx) *max_band_decorr * nchan], 2 * max_band_decorr * nchan ); } - set_zero( &h_freq_domain_decorr_ap_state->decorr_buffer[2 * ( decorr_buffer_len - 1 ) * max_band_decorr * num_channels], 2 * max_band_decorr * num_channels ); + set_zero( &h_freq_domain_decorr_ap_state->decorr_buffer[2 * ( decorr_buffer_len - 1 ) * max_band_decorr * nchan], 2 * max_band_decorr * nchan ); /* calculate all pass */ for ( split_bands_idx = 0; split_bands_idx < h_freq_domain_decorr_ap_params->num_split_frequency_bands; split_bands_idx++ ) @@ -431,15 +431,15 @@ void ivas_dirac_dec_decorr_process( num_bands = k_2 - k_1; filter_length = h_freq_domain_decorr_ap_params->filter_length[split_bands_idx]; pre_delay = h_freq_domain_decorr_ap_params->pre_delay[split_bands_idx]; - decorr_buffer_step = num_channels * max_band_decorr; + decorr_buffer_step = nchan * max_band_decorr; for ( k = 0; k < num_bands; ++k ) { band_idx = k_1 + k; - for ( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + for ( ch_idx = 0; ch_idx < nchan; ++ch_idx ) { - idx_filter = band_idx * ( h_freq_domain_decorr_ap_params->filter_length[0] * num_channels ) + ch_idx * h_freq_domain_decorr_ap_params->filter_length[0]; + idx_filter = band_idx * ( h_freq_domain_decorr_ap_params->filter_length[0] * nchan ) + ch_idx * h_freq_domain_decorr_ap_params->filter_length[0]; filter_coeff_num_real = &h_freq_domain_decorr_ap_params->filter_coeff_num_real[idx_filter]; filter_coeff_den_real = &h_freq_domain_decorr_ap_params->filter_coeff_den_real[idx_filter]; decorr_buffer_start_ptr = &h_freq_domain_decorr_ap_state->decorr_buffer[2 * ( ch_idx * max_band_decorr + band_idx )]; @@ -486,18 +486,18 @@ void ivas_dirac_dec_decorr_process( /* calculate the power of the decorrelated signal */ - for ( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + for ( ch_idx = 0; ch_idx < nchan; ++ch_idx ) { v_mult( &frame_dec_f[2 * ch_idx * num_freq_bands], &frame_dec_f[2 * ch_idx * num_freq_bands], &aux_buffer[2 * ch_idx * max_band_decorr], 2 * max_band_decorr ); v_add_inc( &aux_buffer[2 * ch_idx * max_band_decorr], 2, &aux_buffer[2 * ch_idx * max_band_decorr + 1], 2, &aux_buffer[ch_idx * max_band_decorr], 1, max_band_decorr ); } /* smooth energies */ - v_multc( aux_buffer, 1.0f - DIRAC_DUCK_ALPHA, aux_buffer, num_channels * max_band_decorr ); + v_multc( aux_buffer, 1.0f - DIRAC_DUCK_ALPHA, aux_buffer, nchan * max_band_decorr ); - v_multc( h_freq_domain_decorr_ap_state->reverb_energy_smooth, DIRAC_DUCK_ALPHA, h_freq_domain_decorr_ap_state->reverb_energy_smooth, num_channels * max_band_decorr ); + v_multc( h_freq_domain_decorr_ap_state->reverb_energy_smooth, DIRAC_DUCK_ALPHA, h_freq_domain_decorr_ap_state->reverb_energy_smooth, nchan * max_band_decorr ); - v_add( aux_buffer, h_freq_domain_decorr_ap_state->reverb_energy_smooth, h_freq_domain_decorr_ap_state->reverb_energy_smooth, num_channels * max_band_decorr ); + v_add( aux_buffer, h_freq_domain_decorr_ap_state->reverb_energy_smooth, h_freq_domain_decorr_ap_state->reverb_energy_smooth, nchan * max_band_decorr ); v_multc( direct_energy, 1.0f - DIRAC_DUCK_ALPHA, direct_energy, num_protos_dir * max_band_decorr ); @@ -505,7 +505,7 @@ void ivas_dirac_dec_decorr_process( v_add( direct_energy, h_freq_domain_decorr_ap_state->direct_energy_smooth, h_freq_domain_decorr_ap_state->direct_energy_smooth, num_protos_dir * max_band_decorr ); - for ( ch_idx = 0; ch_idx < num_channels; ch_idx++ ) + for ( ch_idx = 0; ch_idx < nchan; ch_idx++ ) { float *frame_dec_f_ptr = &frame_dec_f[ch_idx * 2 * num_freq_bands]; int16_t cur_proto_index = proto_index_dir[ch_idx] * max_band_decorr; @@ -545,7 +545,7 @@ void ivas_dirac_dec_decorr_process( if ( h_freq_domain_decorr_ap_params->add_back_onsets_on == 1 ) { - for ( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + for ( ch_idx = 0; ch_idx < nchan; ++ch_idx ) { offset = proto_index_dir[ch_idx] * num_freq_bands; @@ -560,7 +560,7 @@ void ivas_dirac_dec_decorr_process( } /* avoid decorrelation above maximum frequency -> set to zero the remaining frequencies*/ - for ( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + for ( ch_idx = 0; ch_idx < nchan; ++ch_idx ) { /* calc output indices */ idx_in_out = 2 * ( ch_idx * num_freq_bands + h_freq_domain_decorr_ap_params->max_band_decorr ); diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index decca34452..a26a469522 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -65,7 +65,7 @@ void ivas_dirac_dec_output_synthesis_cov_open( const int16_t interp_length, /* i : length for interpolating the mixing matrices in time slots */ const int16_t num_param_bands, /* i : number of parameter bands */ const int16_t num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ - const int16_t nchan_in, /* i : number of input (transport) channels */ + const int16_t nchan_inp, /* i : number of input (transport) channels */ const int16_t nchan_out, /* i : number of output channels */ const float *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ ) @@ -80,18 +80,18 @@ void ivas_dirac_dec_output_synthesis_cov_open( /* buffer length and interpolator */ h_dirac_output_synthesis_params->alpha_synthesis = NULL; - h_dirac_output_synthesis_params->proto_matrix = (float *) count_malloc( nchan_out * nchan_in * sizeof( float ) ); + h_dirac_output_synthesis_params->proto_matrix = (float *) count_malloc( nchan_out * nchan_inp * sizeof( float ) ); /* cov buffers */ for ( idx = 0; idx < num_param_bands; idx++ ) { - h_dirac_output_synthesis_state->cx_old[idx] = (float *) count_malloc( nchan_in * nchan_in * sizeof( float ) ); + h_dirac_output_synthesis_state->cx_old[idx] = (float *) count_malloc( nchan_inp * nchan_inp * sizeof( float ) ); h_dirac_output_synthesis_state->cy_old[idx] = (float *) count_malloc( nchan_out * nchan_out * sizeof( float ) ); - h_dirac_output_synthesis_state->mixing_matrix_old[idx] = (float *) count_malloc( nchan_out * nchan_in * sizeof( float ) ); - set_zero( h_dirac_output_synthesis_state->cx_old[idx], nchan_in * nchan_in ); + h_dirac_output_synthesis_state->mixing_matrix_old[idx] = (float *) count_malloc( nchan_out * nchan_inp * sizeof( float ) ); + set_zero( h_dirac_output_synthesis_state->cx_old[idx], nchan_inp * nchan_inp ); set_zero( h_dirac_output_synthesis_state->cy_old[idx], nchan_out * nchan_out ); - set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_in ); + set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_inp ); } for ( ; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -120,7 +120,7 @@ void ivas_dirac_dec_output_synthesis_cov_open( h_dirac_output_synthesis_params->interpolator[idx - 1] = (float) idx / (float) interp_length; } - mvr2r( proto_matrix, h_dirac_output_synthesis_params->proto_matrix, nchan_in * nchan_out ); + mvr2r( proto_matrix, h_dirac_output_synthesis_params->proto_matrix, nchan_inp * nchan_out ); return; } @@ -134,7 +134,7 @@ void ivas_dirac_dec_output_synthesis_cov_open( void ivas_dirac_dec_output_synthesis_cov_init( DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: pointer to the state of the covariance synthesis */ - const int16_t nchan_in, /* i : number of input (tranport) channels */ + const int16_t nchan_inp, /* i : number of input (tranport) channels */ const int16_t nchan_out, /* i : number of output channels */ const int16_t n_param_bands, /* i : number of total parameter bands */ const int16_t n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ @@ -146,9 +146,9 @@ void ivas_dirac_dec_output_synthesis_cov_init( /* initialize buffers */ for ( idx = 0; idx < n_param_bands; idx++ ) { - set_zero( h_dirac_output_synthesis_state->cx_old[idx], nchan_in * nchan_in ); + set_zero( h_dirac_output_synthesis_state->cx_old[idx], nchan_inp * nchan_inp ); set_zero( h_dirac_output_synthesis_state->cy_old[idx], nchan_out * nchan_out ); - set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_in ); + set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_inp ); } for ( idx = 0; idx < n_param_bands_res; idx++ ) @@ -243,7 +243,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) */ float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (imaginary part) */ PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ - const int16_t nchan_in, /* i : number of input channels */ + const int16_t nchan_inp, /* i : number of input channels */ const int16_t idx_slot /* i : index of the slot to be added to the input covariance */ ) { @@ -268,18 +268,18 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( for ( band_idx = 0; band_idx < num_bands; band_idx++ ) { int16_t band = brange[0] + band_idx; - for ( ch_idx = 0; ch_idx < nchan_in; ch_idx++ ) + for ( ch_idx = 0; ch_idx < nchan_inp; ch_idx++ ) { real_in_buffer[band_idx + num_bands * ch_idx] = RealBuffer[ch_idx][idx_slot][band]; imag_in_buffer[band_idx + num_bands * ch_idx] = ImagBuffer[ch_idx][idx_slot][band]; } } - cmplx_matrix_square( real_in_buffer, imag_in_buffer, num_bands, nchan_in, real_buffer, imag_buffer ); + cmplx_matrix_square( real_in_buffer, imag_in_buffer, num_bands, nchan_inp, real_buffer, imag_buffer ); - v_add( cx[param_band], real_buffer, cx[param_band], nchan_in * nchan_in ); + v_add( cx[param_band], real_buffer, cx[param_band], nchan_inp * nchan_inp ); - v_add( cx_imag[param_band], imag_buffer, cx_imag[param_band], nchan_in * nchan_in ); + v_add( cx_imag[param_band], imag_buffer, cx_imag[param_band], nchan_inp * nchan_inp ); } return; diff --git a/lib_dec/ivas_dirac_output_synthesis_dec.c b/lib_dec/ivas_dirac_output_synthesis_dec.c index 79c04f824b..3cf09b8182 100644 --- a/lib_dec/ivas_dirac_output_synthesis_dec.c +++ b/lib_dec/ivas_dirac_output_synthesis_dec.c @@ -61,15 +61,15 @@ * Local function prototypes *------------------------------------------------------------------------*/ -static void computeTargetPSDs_direct( const int16_t num_channels, const int16_t num_freq_bands, const float *direct_power_factor, const float *reference_power, const float *direct_responses, const float *direct_responses_square, float *cy_auto_dir_smooth, float *cy_cross_dir_smooth ); +static void computeTargetPSDs_direct( const int16_t nchan, const int16_t num_freq_bands, const float *direct_power_factor, const float *reference_power, const float *direct_responses, const float *direct_responses_square, float *cy_auto_dir_smooth, float *cy_cross_dir_smooth ); -static void computeTargetPSDs_direct_subframe( const int16_t num_channels, const int16_t num_freq_bands, const float *direct_power_factor, const float *reference_power, const float *direct_responses, const float *direct_responses_square, float *cy_auto_dir_smooth, float *cy_cross_dir_smooth ); +static void computeTargetPSDs_direct_subframe( const int16_t nchan, const int16_t num_freq_bands, const float *direct_power_factor, const float *reference_power, const float *direct_responses, const float *direct_responses_square, float *cy_auto_dir_smooth, float *cy_cross_dir_smooth ); -static void computeTargetPSDs_diffuse( const int16_t num_channels, const int16_t num_freq_bands, const int16_t start_band, const float *diffuse_power_factor, const float *reference_power, const float *diffuse_responses_square, float *cy_auto_diff_smooth ); +static void computeTargetPSDs_diffuse( const int16_t nchan, const int16_t num_freq_bands, const int16_t start_band, const float *diffuse_power_factor, const float *reference_power, const float *diffuse_responses_square, float *cy_auto_diff_smooth ); -static void computeTargetPSDs_diffuse_subframe( const int16_t num_channels, const int16_t num_freq_bands, const int16_t start_band, const float *diffuse_power_factor, const float *reference_power, const float *diffuse_responses_square, float *cy_auto_diff_smooth ); +static void computeTargetPSDs_diffuse_subframe( const int16_t nchan, const int16_t num_freq_bands, const int16_t start_band, const float *diffuse_power_factor, const float *reference_power, const float *diffuse_responses_square, float *cy_auto_diff_smooth ); -static void computeTargetPSDs_diffuse_with_onsets( const int16_t num_channels, const int16_t num_freq_bands, const int16_t num_decorr_freq_bands, const int16_t *proto_frame_diff_index, const float *diffuse_power_factor, const float *reference_power, const float *diffuse_responses_square, const float *onset_filter, float *cy_auto_diff_smooth ); +static void computeTargetPSDs_diffuse_with_onsets( const int16_t nchan, const int16_t num_freq_bands, const int16_t num_decorr_freq_bands, const int16_t *proto_frame_diff_index, const float *diffuse_power_factor, const float *reference_power, const float *diffuse_responses_square, const float *onset_filter, float *cy_auto_diff_smooth ); static void computeAlphaSynthesis( float *alpha_synthesis, const int16_t averaging_length_ms, const float maxAlpha, int16_t *numAlphas, const int16_t slot_size, const int16_t num_freq_bands, const float *frequency_axis, const int32_t output_Fs ); @@ -1812,7 +1812,7 @@ void ivas_lfe_synth_with_filters( *------------------------------------------------------------------------*/ static void computeTargetPSDs_direct( - const int16_t num_channels, + const int16_t nchan, const int16_t num_freq_bands, const float *direct_power_factor, const float *reference_power, @@ -1831,7 +1831,7 @@ static void computeTargetPSDs_direct( v_mult( direct_power_factor, reference_power, direct_power, num_freq_bands ); /* compute target auto and cross PSDs of current frame (smoothed) */ - for ( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + for ( ch_idx = 0; ch_idx < nchan; ++ch_idx ) { cur_idx = ch_idx * num_freq_bands; @@ -1847,7 +1847,7 @@ static void computeTargetPSDs_direct( static void computeTargetPSDs_direct_subframe( - const int16_t num_channels, + const int16_t nchan, const int16_t num_freq_bands, const float *direct_power_factor, const float *reference_power, @@ -1865,7 +1865,7 @@ static void computeTargetPSDs_direct_subframe( v_mult( direct_power_factor, reference_power, direct_power, num_freq_bands ); /* compute target auto and cross PSDs of current frame (smoothed) */ - for ( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + for ( ch_idx = 0; ch_idx < nchan; ++ch_idx ) { cur_idx = ch_idx * num_freq_bands; @@ -1878,7 +1878,7 @@ static void computeTargetPSDs_direct_subframe( static void computeTargetPSDs_diffuse( - const int16_t num_channels, + const int16_t nchan, const int16_t num_freq_bands, const int16_t start_band, const float *diffuse_power_factor, @@ -1896,7 +1896,7 @@ static void computeTargetPSDs_diffuse( v_mult( diffuse_power_factor, reference_power, diffuse_power, num_freq_bands ); /* compute target auto and cross PSDs of current frame (smoothed) */ - for ( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + for ( ch_idx = 0; ch_idx < nchan; ++ch_idx ) { cur_idx = ch_idx * num_freq_bands; v_multc( &diffuse_power[start_band], diffuse_responses_square[ch_idx], aux_buffer_res, num_freq_bands - start_band ); @@ -1908,7 +1908,7 @@ static void computeTargetPSDs_diffuse( static void computeTargetPSDs_diffuse_subframe( - const int16_t num_channels, + const int16_t nchan, const int16_t num_freq_bands, const int16_t start_band, const float *diffuse_power_factor, @@ -1923,7 +1923,7 @@ static void computeTargetPSDs_diffuse_subframe( v_mult( diffuse_power_factor, reference_power, diffuse_power, num_freq_bands ); /* compute target auto and cross PSDs of current frame (smoothed) */ - for ( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + for ( ch_idx = 0; ch_idx < nchan; ++ch_idx ) { cur_idx = ch_idx * num_freq_bands; @@ -1935,7 +1935,7 @@ static void computeTargetPSDs_diffuse_subframe( static void computeTargetPSDs_diffuse_with_onsets( - const int16_t num_channels, + const int16_t nchan, const int16_t num_freq_bands, const int16_t num_decorr_freq_bands, const int16_t *proto_frame_diff_index, @@ -1955,7 +1955,7 @@ static void computeTargetPSDs_diffuse_with_onsets( v_mult( diffuse_power_factor, reference_power, diffuse_power, num_decorr_freq_bands ); /* compute target auto and cross PSDs of current frame (smoothed) */ - for ( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + for ( ch_idx = 0; ch_idx < nchan; ++ch_idx ) { diffuse_response_p4 = diffuse_responses_square[ch_idx] * diffuse_responses_square[ch_idx]; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index e3849dfbe0..2984ada3de 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1753,7 +1753,7 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_DIRAC: if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { - *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; + *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->nchan_inp; if ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) { @@ -1761,7 +1761,7 @@ void ivas_init_dec_get_num_cldfb_instances( } else if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) { - *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; + *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->nchan_out; } else { @@ -1811,7 +1811,7 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_BINAURAL_FASTCONV_ROOM: if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { - *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; + *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->nchan_inp; if ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) { @@ -1819,7 +1819,7 @@ void ivas_init_dec_get_num_cldfb_instances( } else if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) { - *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; + *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->nchan_out; } else { diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index c6c1f99c9c..460efb7e22 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -351,7 +351,7 @@ static ivas_error ivas_param_ism_rendering_init( static void ivas_param_ism_update_mixing_matrix( DIRAC_DEC_HANDLE hDirAC, float mixing_matrix[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX], - const int16_t nchan_in, + const int16_t nchan_inp, const int16_t nchan_out ) { int16_t inchIdx, outchIdx, bin_idx, band_idx; @@ -364,7 +364,7 @@ static void ivas_param_ism_update_mixing_matrix( for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) { - for ( inchIdx = 0; inchIdx < nchan_in; inchIdx++ ) + for ( inchIdx = 0; inchIdx < nchan_inp; inchIdx++ ) { for ( outchIdx = 0; outchIdx < nchan_out; outchIdx++ ) { diff --git a/lib_dec/ivas_limiter.c b/lib_dec/ivas_limiter.c index e483318be8..d3dcd8027f 100644 --- a/lib_dec/ivas_limiter.c +++ b/lib_dec/ivas_limiter.c @@ -125,7 +125,7 @@ IVAS_LIMITER_HANDLE ivas_limiter_open( hLimiter = count_malloc( sizeof( IVAS_LIMITER ) ); hLimiter->max_num_channels = max_num_channels; - hLimiter->num_channels = max_num_channels; + hLimiter->nchan = max_num_channels; hLimiter->channel_ptrs = count_malloc( max_num_channels * sizeof( float * ) ); hLimiter->sampling_rate = sampling_rate; hLimiter->gain = 1.f; @@ -176,11 +176,11 @@ void ivas_limiter_close( *-------------------------------------------------------------------*/ void ivas_limiter_dec( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], /* i/o: input/output buffer */ - const int16_t num_channels, /* i : number of channels to be processed */ - const int16_t output_frame, /* i : number of samples per channel in the buffer */ - const int16_t BER_detect /* i : BER detect flag */ + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], /* i/o: input/output buffer */ + const int16_t nchan, /* i : number of channels to be processed */ + const int16_t output_frame, /* i : number of samples per channel in the buffer */ + const int16_t BER_detect /* i : BER detect flag */ ) { int16_t c; @@ -193,11 +193,11 @@ void ivas_limiter_dec( } /* Update number of channels and prepare pointers to the beginning of each of them */ - assert( num_channels <= hLimiter->max_num_channels && "Number of channels must be lower than the maximum set during limiter initialization!" ); - hLimiter->num_channels = min( num_channels, hLimiter->max_num_channels ); + assert( nchan <= hLimiter->max_num_channels && "Number of channels must be lower than the maximum set during limiter initialization!" ); + hLimiter->nchan = min( nchan, hLimiter->max_num_channels ); channels = hLimiter->channel_ptrs; - for ( c = 0; c < num_channels; ++c ) + for ( c = 0; c < nchan; ++c ) { channels[c] = output[c]; } @@ -231,7 +231,7 @@ void limiter_process( float releaseHeuristic; int16_t apply_limiting, apply_strong_limiting; float **output; - int16_t num_channels; + int16_t nchan; int32_t sampling_rate; /* return early if given nonsensical values */ @@ -245,7 +245,7 @@ void limiter_process( gain = hLimiter->gain; output = hLimiter->channel_ptrs; - num_channels = hLimiter->num_channels; + nchan = hLimiter->nchan; sampling_rate = hLimiter->sampling_rate; attack_constant = hLimiter->attack_constant; @@ -257,7 +257,7 @@ void limiter_process( for ( i = 0; i < output_frame; i++ ) { - for ( c = 0; c < num_channels; c++ ) + for ( c = 0; c < nchan; c++ ) { tmp = fabsf( output[c][i] ); if ( tmp > max_val ) @@ -364,7 +364,7 @@ void limiter_process( gain = release_constant * ( gain - frame_gain ) + frame_gain; } - for ( c = 0; c < num_channels; c++ ) + for ( c = 0; c < nchan; c++ ) { sample = &output[c][i]; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 29e2ce4002..a6889137f6 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -60,8 +60,7 @@ * Local function prototypes *-----------------------------------------------------------------------*/ -static void ivas_param_mc_dec_init( PARAM_MC_DEC_HANDLE hParamMC, const int16_t nchan_in, const int16_t nchan_out ); - +static void ivas_param_mc_dec_init( PARAM_MC_DEC_HANDLE hParamMC, const int16_t nchan_inp, const int16_t nchan_out ); static void param_mc_protoSignalComputation( float RealBuffer[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], float *proto_frame_f, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const int16_t slot_index, const int16_t num_freq_bands ); diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 9ed27e56c3..2a02fb56e9 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -147,7 +147,7 @@ static void get_custom_ls_conversion_matrix( { int16_t ch_in, ch_in_woLFE; int16_t ch_out, ch_out_woLFE; - int16_t nchan_in, nchan_out; + int16_t nchan_inp, nchan_out; int16_t lfe_in_idx, lfe_out_idx; float dmxCoeff_LFE; @@ -156,7 +156,7 @@ static void get_custom_ls_conversion_matrix( lfe_in_idx = -1; lfe_out_idx = -1; - nchan_in = hTransSetup.nchan_out_woLFE + hTransSetup.num_lfe; + nchan_inp = hTransSetup.nchan_out_woLFE + hTransSetup.num_lfe; nchan_out = hLsSetupCustom->num_spk + hLsSetupCustom->num_lfe; /* The below code will need to be restructured in case additional LFEs must be supported */ @@ -171,7 +171,7 @@ static void get_custom_ls_conversion_matrix( dmxCoeff_LFE = 1.f / hTransSetup.nchan_out_woLFE; - for ( ch_in = 0, ch_in_woLFE = 0; ch_in < nchan_in; ch_in++, ch_in_woLFE++ ) + for ( ch_in = 0, ch_in_woLFE = 0; ch_in < nchan_inp; ch_in++, ch_in_woLFE++ ) { if ( lfe_in_idx == ch_in ) { @@ -218,7 +218,7 @@ static ivas_error get_ls_conversion_matrix( { int16_t i, k; int16_t ch_in, ch_out; - int16_t nchan_in, nchan_out; + int16_t nchan_inp, nchan_out; int16_t index; float value; const LS_CONVERSION_MATRIX *conversion_matrix; @@ -228,7 +228,7 @@ static ivas_error get_ls_conversion_matrix( conversion_matrix = NULL; - nchan_in = audioCfg2channels( input_config ); + nchan_inp = audioCfg2channels( input_config ); nchan_out = audioCfg2channels( output_config ); /* Search the table for a mapping */ @@ -239,7 +239,7 @@ static ivas_error get_ls_conversion_matrix( /* Special handling for MONO and STEREO downmix */ if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) { - for ( ch_in = 0, k = 0; ch_in < nchan_in; ch_in++, k++ ) + for ( ch_in = 0, k = 0; ch_in < nchan_inp; ch_in++, k++ ) { /* Skip two rows in the matrix for 5.1.x formats */ if ( ch_in == 6 && ( input_config == AUDIO_CONFIG_5_1_2 || input_config == AUDIO_CONFIG_5_1_4 ) ) @@ -268,7 +268,7 @@ static ivas_error get_ls_conversion_matrix( /* If a mapping is defined with a NULL matrix, 1:1 upmix of input channels */ if ( conversion_matrix == NULL ) { - for ( k = 0; k < nchan_in; k++ ) + for ( k = 0; k < nchan_inp; k++ ) { hLsSetUpConversion->dmxMtx[k][k] = 1.0f; } diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 39918776e6..421ec619d3 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -516,7 +516,7 @@ const int16_t sba_map_tc[8] = * LS Renderer ROM tables *----------------------------------------------------------------------------------*/ - /* All matrices are stored with dimensions nchan_in x nchan_out */ + /* All matrices are stored with dimensions nchan_inp x nchan_out */ /* Downmix matrices */ const float ls_conversion_cicpX_mono[12][1] = { diff --git a/lib_dec/ivas_sba_rendering.c b/lib_dec/ivas_sba_rendering.c index 92e50de535..1efde66cf5 100644 --- a/lib_dec/ivas_sba_rendering.c +++ b/lib_dec/ivas_sba_rendering.c @@ -47,7 +47,7 @@ * Local function prototypes *-----------------------------------------------------------------------*/ -static void ivas_sba_mtx_mult( float output_f[][L_FRAME48k], const int16_t output_frame, const int16_t nchan_in, const IVAS_OUTPUT_SETUP output_setup, const float *mtx_hoa_decoder ); +static void ivas_sba_mtx_mult( float output_f[][L_FRAME48k], const int16_t output_frame, const int16_t nchan_inp, const IVAS_OUTPUT_SETUP output_setup, const float *mtx_hoa_decoder ); /*-------------------------------------------------------------------* @@ -59,7 +59,7 @@ static void ivas_sba_mtx_mult( float output_f[][L_FRAME48k], const int16_t outpu ivas_error ivas_sba_linear_renderer( float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nchan_in, /* i : number of input ambisonics channels */ + const int16_t nchan_inp, /* i : number of input ambisonics channels */ const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */ const float hoa_dec_mtx[] /* i : HOA decoding mtx */ @@ -73,13 +73,13 @@ ivas_error ivas_sba_linear_renderer( error = IVAS_ERR_OK; /* Number of channels of HOA depends of transport format which is mixed order xH1V*/ - nchan_hoa = nchan_in; + nchan_hoa = nchan_inp; - if ( nchan_in == 6 ) /*2H1V*/ + if ( nchan_inp == 6 ) /*2H1V*/ { nchan_hoa = 9; } - else if ( nchan_in == 8 ) /*3H1V*/ + else if ( nchan_inp == 8 ) /*3H1V*/ { nchan_hoa = 16; } @@ -88,7 +88,7 @@ ivas_error ivas_sba_linear_renderer( { case AUDIO_CONFIG_MONO: /* If stereo DMX, MONO = W = Cardioids L + R*/ - if ( nchan_in == 2 ) + if ( nchan_inp == 2 ) { for ( i = 0; i < output_frame; i++ ) { @@ -98,10 +98,10 @@ ivas_error ivas_sba_linear_renderer( /* else: do nothing, MONO = W*/ break; case AUDIO_CONFIG_STEREO: - assert( ( nchan_in >= 2 ) && "Number of input channels must be at least 2 (for W and Y)!\n" ); + assert( ( nchan_inp >= 2 ) && "Number of input channels must be at least 2 (for W and Y)!\n" ); /* Compute L and R cardioids from SB format except if stereo DMX is transmitted already in this format*/ - if ( nchan_in > 2 ) + if ( nchan_inp > 2 ) { /*Build L/R cardioids*/ for ( i = 0; i < output_frame; i++ ) @@ -145,7 +145,7 @@ ivas_error ivas_sba_linear_renderer( static void ivas_sba_mtx_mult( float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nchan_in, /* i : Number of ambisonic channels */ + const int16_t nchan_inp, /* i : Number of ambisonic channels */ const IVAS_OUTPUT_SETUP output_setup, /* i : Output configuration */ const float *mtx_hoa_decoder /* i : HOA decoding mtx */ ) @@ -155,14 +155,14 @@ static void ivas_sba_mtx_mult( float input_f[16]; const float *hoa_decoder; - assert( ( nchan_in >= FOA_CHANNELS ) && "Number of input channels must be at least 4 (FOA)!\n" ); + assert( ( nchan_inp >= FOA_CHANNELS ) && "Number of input channels must be at least 4 (FOA)!\n" ); for ( i = 0; i < output_frame; i++ ) { /* init*/ idx_lfe = 0; hoa_decoder = &mtx_hoa_decoder[0]; - for ( k = 0; k < nchan_in; k++ ) + for ( k = 0; k < nchan_inp; k++ ) { input_f[k] = output_f[k][i]; } @@ -183,7 +183,7 @@ static void ivas_sba_mtx_mult( { /*HOA decoding*/ output_f[ch_idx][i] = input_f[0] * hoa_decoder[0]; - for ( k = 1; k < nchan_in; k++ ) + for ( k = 1; k < nchan_inp; k++ ) { output_f[ch_idx][i] += input_f[k] * hoa_decoder[k]; } @@ -320,7 +320,7 @@ void ivas_sba_prototype_renderer( DECODER_CONFIG_HANDLE hDecoderConfig; int16_t num_spar_bands, spar_band; int16_t b, ts; - int16_t num_cldfb_bands, numch_in, numch_out; + int16_t num_cldfb_bands, nchan_inp, nchan_out; int16_t cldfb_band; int16_t out_ch, in_ch; int16_t firstSlot, slotEnd, firstInCh, inChEnd, firstOutCh, outChEnd; @@ -336,8 +336,8 @@ void ivas_sba_prototype_renderer( slotEnd = ( firstSubframe + nSubframes ) * ( CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ); num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands; - numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; - numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; + nchan_inp = hSpar->hFbMixer->fb_cfg->nchan_inp; + nchan_out = hSpar->hFbMixer->fb_cfg->nchan_out; if ( st_ivas->nchan_transport == 1 ) { @@ -358,7 +358,7 @@ void ivas_sba_prototype_renderer( for ( ts = firstSlot; ts < slotEnd; ts++ ) { /* determine SPAR parameters for this time slot */ - ivas_spar_get_parameters( hSpar, hDecoderConfig, ts, numch_out, numch_in, num_spar_bands, mixer_mat ); + ivas_spar_get_parameters( hSpar, hDecoderConfig, ts, nchan_out, nchan_inp, num_spar_bands, mixer_mat ); for ( cldfb_band = 0; cldfb_band < num_cldfb_bands; cldfb_band++ ) { @@ -413,9 +413,9 @@ void ivas_sba_prototype_renderer( mvr2r( hSpar->hMdDec->mixer_mat_prev[3][0][0], hSpar->hMdDec->mixer_mat_prev[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); mvr2r( hSpar->hMdDec->mixer_mat_prev[4][0][0], hSpar->hMdDec->mixer_mat_prev[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - for ( out_ch = 0; out_ch < numch_out; out_ch++ ) + for ( out_ch = 0; out_ch < nchan_out; out_ch++ ) { - for ( in_ch = 0; in_ch < numch_in; in_ch++ ) + for ( in_ch = 0; in_ch < nchan_inp; in_ch++ ) { for ( b = 0; b < num_spar_bands; b++ ) { diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index c7a3fcff20..8da866f194 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -65,14 +65,14 @@ ivas_error ivas_spar_dec_open( { SPAR_DEC_HANDLE hSpar; ivas_error error; - int16_t sba_order_internal, num_channels_internal; + int16_t sba_order_internal, nchan_internal; IVAS_FB_CFG *fb_cfg; int16_t i, j, b, active_w_mixing; int32_t output_Fs; 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 ); + nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); /* SPAR decoder handle */ if ( ( hSpar = (SPAR_DEC_HANDLE) count_malloc( sizeof( SPAR_DEC_DATA ) ) ) == NULL ) @@ -83,13 +83,13 @@ ivas_error ivas_spar_dec_open( output_Fs = st_ivas->hDecoderConfig->output_Fs; /* TD decorr. */ - if ( ( error = ivas_spar_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_channels_internal, 1 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, nchan_internal, 1 ) ) != IVAS_ERR_OK ) { return error; } /* MD handle */ - if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, nchan_internal ) ) != IVAS_ERR_OK ) { return error; } @@ -98,7 +98,7 @@ ivas_error ivas_spar_dec_open( /* set FB config. */ active_w_mixing = -1; - if ( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, num_channels_internal, num_channels_internal, active_w_mixing, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, nchan_internal, nchan_internal, active_w_mixing, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -130,9 +130,9 @@ ivas_error ivas_spar_dec_open( } /* mixer_mat intitialization */ - for ( i = 0; i < num_channels_internal; i++ ) + for ( i = 0; i < nchan_internal; i++ ) { - for ( j = 0; j < num_channels_internal; j++ ) + for ( j = 0; j < nchan_internal; j++ ) { for ( b = 0; b < IVAS_MAX_NUM_BANDS; b++ ) { @@ -622,7 +622,7 @@ static void ivas_spar_dec_MD( Decoder_State *st0 /* i/o: decoder state structure - for bitstream handling*/ ) { - int16_t num_channels, table_idx, num_bands_out, bfi, sba_order; + int16_t nchan, table_idx, num_bands_out, bfi, sba_order; int32_t ivas_total_brate; DECODER_CONFIG_HANDLE hDecoderConfig = st_ivas->hDecoderConfig; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; @@ -636,7 +636,7 @@ static void ivas_spar_dec_MD( sba_order = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); bfi = st_ivas->bfi; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - num_channels = ivas_sba_get_nchan_metadata( sba_order ); + nchan = ivas_sba_get_nchan_metadata( sba_order ); num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; if ( ivas_total_brate > FRAME_NO_DATA && !bfi ) @@ -652,7 +652,7 @@ static void ivas_spar_dec_MD( hSpar->hMdDec->table_idx = table_idx; hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking; - ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels ); + ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, nchan ); } } @@ -884,14 +884,13 @@ void ivas_spar_dec_upmixer( const int16_t output_frame /* i : output frame length */ ) { - int16_t cldfb_band, num_cldfb_bands, numch_in, numch_out; + int16_t nchan_inp, nchan_out, nchan_transport, nchan_ingest; + int16_t cldfb_band, num_cldfb_bands; float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX]; float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX]; int16_t i, b, ts, out_ch, in_ch; - int16_t num_spar_bands, spar_band, nchan_transport; - int16_t num_in_ingest, num_bands_out, split_band; + int16_t num_spar_bands, spar_band, num_bands_out, split_band; float Pcm_tmp[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - int16_t numch_out_dirac; float *pPcm_tmp[MAX_OUTPUT_CHANNELS]; float mixer_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; int16_t b_skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; @@ -906,8 +905,8 @@ void ivas_spar_dec_upmixer( nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands; - numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; - numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; + nchan_inp = hSpar->hFbMixer->fb_cfg->nchan_inp; + nchan_out = hSpar->hFbMixer->fb_cfg->nchan_out; #ifdef DEBUG_SPAR_BYPASS_EVS_CODEC /* by-pass core-coder */ @@ -963,11 +962,11 @@ void ivas_spar_dec_upmixer( if ( hSpar->hMdDec->td_decorr_flag ) { - num_in_ingest = nchan_internal; + nchan_ingest = nchan_internal; } else { - num_in_ingest = nchan_transport; + nchan_ingest = nchan_transport; } for ( i = 0; i < nchan_internal; i++ ) @@ -979,15 +978,15 @@ void ivas_spar_dec_upmixer( * PCA decoder *---------------------------------------------------------------------*/ #ifdef DEBUG_SBA_AUDIO_DUMP - hSpar->pca_ingest_channels = num_in_ingest; + hSpar->pca_ingest_channels = nchan_ingest; #endif if ( hSpar->hPCA != NULL ) { - ivas_pca_dec( hSpar->hPCA, output_frame, num_in_ingest, hDecoderConfig->ivas_total_brate, hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output ); + ivas_pca_dec( hSpar->hPCA, output_frame, nchan_ingest, hDecoderConfig->ivas_total_brate, hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output ); #ifdef DEBUG_SBA_AUDIO_DUMP /* Dump audio signal after ivas_pca_dec */ - ivas_spar_dump_signal_wav( output_frame, NULL, output, num_in_ingest, spar_foa_dec_wav[2], "ivas_pca_dec()" ); + ivas_spar_dump_signal_wav( output_frame, NULL, output, nchan_ingest, spar_foa_dec_wav[2], "ivas_pca_dec()" ); #endif } @@ -1005,11 +1004,11 @@ void ivas_spar_dec_upmixer( mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], output[nchan_internal - 1 - i], output_frame ); } - hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest; + hSpar->hFbMixer->fb_cfg->nchan_inp = nchan_inp; // VE2DB: this is the same for the else branch below -> call it only once? } else { - hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest; + hSpar->hFbMixer->fb_cfg->nchan_inp = nchan_inp; } /*---------------------------------------------------------------------* @@ -1031,7 +1030,7 @@ void ivas_spar_dec_upmixer( } else { - for ( in_ch = 0; in_ch < numch_in; in_ch++ ) + for ( in_ch = 0; in_ch < nchan_inp; in_ch++ ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { @@ -1056,14 +1055,12 @@ void ivas_spar_dec_upmixer( /* apply parameters */ /* determine if we can skip certain data */ - ivas_spar_get_skip_mat( hSpar, numch_out, numch_in, num_spar_bands, b_skip_mat ); /* this can be precomputed based on bitrate and format*/ - - numch_out_dirac = st_ivas->hDecoderConfig->nchan_out; + ivas_spar_get_skip_mat( hSpar, nchan_out, nchan_inp, num_spar_bands, b_skip_mat ); /* this can be precomputed based on bitrate and format*/ for ( int16_t i_sf = 0; i_sf < MAX_PARAM_SPATIAL_SUBFRAMES; i_sf++ ) { /* CLDFB analysis of incoming frame */ - for ( in_ch = 0; in_ch < numch_in; in_ch++ ) + for ( in_ch = 0; in_ch < nchan_inp; in_ch++ ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { @@ -1079,7 +1076,7 @@ void ivas_spar_dec_upmixer( for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { /* determine SPAR parameters for this time slots */ - ivas_spar_get_parameters( hSpar, st_ivas->hDecoderConfig, ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES, numch_out, numch_in, num_spar_bands, mixer_mat ); + ivas_spar_get_parameters( hSpar, st_ivas->hDecoderConfig, ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES, nchan_out, nchan_inp, num_spar_bands, mixer_mat ); for ( cldfb_band = 0; cldfb_band < num_cldfb_bands; cldfb_band++ ) { @@ -1088,12 +1085,12 @@ void ivas_spar_dec_upmixer( float cldfb_par; ivas_fb_bin_to_band_data_t *bin2band = &hSpar->hFbMixer->pFb->fb_bin_to_band; - for ( out_ch = 0; out_ch < numch_out; out_ch++ ) + for ( out_ch = 0; out_ch < nchan_out; out_ch++ ) { out_re[out_ch] = 0.0f; out_im[out_ch] = 0.0f; - for ( in_ch = 0; in_ch < numch_in; in_ch++ ) + for ( in_ch = 0; in_ch < nchan_inp; in_ch++ ) { if ( b_skip_mat[out_ch][in_ch] ) { @@ -1120,7 +1117,7 @@ void ivas_spar_dec_upmixer( } /*update CLDFB data with the parameter-modified data*/ - for ( out_ch = 0; out_ch < numch_out; out_ch++ ) + for ( out_ch = 0; out_ch < nchan_out; out_ch++ ) { cldfb_in_ts_re[out_ch][ts][cldfb_band] = out_re[out_ch]; cldfb_in_ts_im[out_ch][ts][cldfb_band] = out_im[out_ch]; @@ -1176,7 +1173,7 @@ void ivas_spar_dec_upmixer( else { /* CLDFB to time synthesis (overwrite mixer output) */ - for ( out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) + for ( out_ch = 0; out_ch < st_ivas->hDecoderConfig->nchan_out; out_ch++ ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { @@ -1207,9 +1204,9 @@ void ivas_spar_dec_upmixer( mvr2r( hSpar->hMdDec->mixer_mat_prev[3][0][0], hSpar->hMdDec->mixer_mat_prev[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); mvr2r( hSpar->hMdDec->mixer_mat_prev[4][0][0], hSpar->hMdDec->mixer_mat_prev[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - for ( out_ch = 0; out_ch < numch_out; out_ch++ ) + for ( out_ch = 0; out_ch < nchan_out; out_ch++ ) { - for ( in_ch = 0; in_ch < numch_in; in_ch++ ) + for ( in_ch = 0; in_ch < nchan_inp; in_ch++ ) { for ( b = 0; b < num_spar_bands; b++ ) { diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 7f01f64c0f..a9307ddb82 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -73,7 +73,7 @@ static void ivas_fill_band_coeffs_idx( ivas_band_coeffs_ind_t *pBands_idx, const static void ivas_get_band_idx_from_differential( ivas_spar_md_t *pSpar_md, const int16_t q_levels[2], const int16_t one_sided, const int16_t nB, const ivas_coeffs_type_t coeff_type ); -static void ivas_mat_col_rearrange( float in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t order[IVAS_SPAR_MAX_CH], const int16_t i_ts, float ***mixer_mat, const int16_t bands, const int16_t num_ch ); +static void ivas_mat_col_rearrange( float in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t order[IVAS_SPAR_MAX_CH], const int16_t i_ts, float ***mixer_mat, const int16_t bands, const int16_t nchan ); static void ivas_spar_dec_compute_ramp_down_post_matrix( ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands, const int16_t bfi ); @@ -94,7 +94,7 @@ static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder static ivas_error ivas_spar_md_dec_matrix_open( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels /* i : number of internal channels */ + const int16_t nchan /* i : number of internal channels */ ) { int16_t i, j; @@ -103,17 +103,17 @@ static ivas_error ivas_spar_md_dec_matrix_open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for band_coeffs in SPAR MD" ); } - if ( ( hMdDec->mixer_mat = (float ***) count_malloc( num_channels * sizeof( float ** ) ) ) == NULL ) + if ( ( hMdDec->mixer_mat = (float ***) count_malloc( nchan * sizeof( float ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - if ( ( hMdDec->mixer_mat[i] = (float **) count_malloc( num_channels * sizeof( float * ) ) ) == NULL ) + if ( ( hMdDec->mixer_mat[i] = (float **) count_malloc( nchan * sizeof( float * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( ( hMdDec->mixer_mat[i][j] = (float *) count_malloc( MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS * sizeof( float ) ) ) == NULL ) { @@ -122,17 +122,17 @@ static ivas_error ivas_spar_md_dec_matrix_open( } } - if ( ( hMdDec->spar_coeffs.C_re = (float ***) count_malloc( num_channels * sizeof( float ** ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs.C_re = (float ***) count_malloc( nchan * sizeof( float ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - if ( ( hMdDec->spar_coeffs.C_re[i] = (float **) count_malloc( num_channels * sizeof( float * ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs.C_re[i] = (float **) count_malloc( nchan * sizeof( float * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( ( hMdDec->spar_coeffs.C_re[i][j] = (float *) count_malloc( MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS * sizeof( float ) ) ) == NULL ) { @@ -141,17 +141,17 @@ static ivas_error ivas_spar_md_dec_matrix_open( } } - if ( ( hMdDec->spar_coeffs.P_re = (float ***) count_malloc( num_channels * sizeof( float ** ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs.P_re = (float ***) count_malloc( nchan * sizeof( float ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - if ( ( hMdDec->spar_coeffs.P_re[i] = (float **) count_malloc( num_channels * sizeof( float * ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs.P_re[i] = (float **) count_malloc( nchan * sizeof( float * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( ( hMdDec->spar_coeffs.P_re[i][j] = (float *) count_malloc( MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS * sizeof( float ) ) ) == NULL ) { @@ -160,17 +160,17 @@ static ivas_error ivas_spar_md_dec_matrix_open( } } - if ( ( hMdDec->spar_coeffs_prev.C_re = (float ***) count_malloc( num_channels * sizeof( float ** ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs_prev.C_re = (float ***) count_malloc( nchan * sizeof( float ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - if ( ( hMdDec->spar_coeffs_prev.C_re[i] = (float **) count_malloc( num_channels * sizeof( float * ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs_prev.C_re[i] = (float **) count_malloc( nchan * sizeof( float * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( ( hMdDec->spar_coeffs_prev.C_re[i][j] = (float *) count_malloc( IVAS_MAX_NUM_BANDS * sizeof( float ) ) ) == NULL ) { @@ -179,17 +179,17 @@ static ivas_error ivas_spar_md_dec_matrix_open( } } - if ( ( hMdDec->spar_coeffs_prev.P_re = (float ***) count_malloc( num_channels * sizeof( float ** ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs_prev.P_re = (float ***) count_malloc( nchan * sizeof( float ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - if ( ( hMdDec->spar_coeffs_prev.P_re[i] = (float **) count_malloc( num_channels * sizeof( float * ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs_prev.P_re[i] = (float **) count_malloc( nchan * sizeof( float * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( ( hMdDec->spar_coeffs_prev.P_re[i][j] = (float *) count_malloc( IVAS_MAX_NUM_BANDS * sizeof( float ) ) ) == NULL ) { @@ -198,17 +198,17 @@ static ivas_error ivas_spar_md_dec_matrix_open( } } - if ( ( hMdDec->spar_coeffs_tar.C_re = (float ***) count_malloc( num_channels * sizeof( float ** ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs_tar.C_re = (float ***) count_malloc( nchan * sizeof( float ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - if ( ( hMdDec->spar_coeffs_tar.C_re[i] = (float **) count_malloc( num_channels * sizeof( float * ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs_tar.C_re[i] = (float **) count_malloc( nchan * sizeof( float * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( ( hMdDec->spar_coeffs_tar.C_re[i][j] = (float *) count_malloc( IVAS_MAX_NUM_BANDS * sizeof( float ) ) ) == NULL ) { @@ -217,17 +217,17 @@ static ivas_error ivas_spar_md_dec_matrix_open( } } - if ( ( hMdDec->spar_coeffs_tar.P_re = (float ***) count_malloc( num_channels * sizeof( float ** ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs_tar.P_re = (float ***) count_malloc( nchan * sizeof( float ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - if ( ( hMdDec->spar_coeffs_tar.P_re[i] = (float **) count_malloc( num_channels * sizeof( float * ) ) ) == NULL ) + if ( ( hMdDec->spar_coeffs_tar.P_re[i] = (float **) count_malloc( nchan * sizeof( float * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( ( hMdDec->spar_coeffs_tar.P_re[i][j] = (float *) count_malloc( IVAS_MAX_NUM_BANDS * sizeof( float ) ) ) == NULL ) { @@ -249,7 +249,7 @@ static ivas_error ivas_spar_md_dec_matrix_open( ivas_error ivas_spar_md_dec_open( ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels /* i : number of internal channels */ + const int16_t nchan /* i : number of internal channels */ ) { ivas_spar_md_dec_state_t *hMdDec; @@ -262,14 +262,14 @@ ivas_error ivas_spar_md_dec_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD decoder" ); } - if ( ( error = ivas_spar_md_dec_matrix_open( hMdDec, num_channels ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_matrix_open( hMdDec, nchan ) ) != IVAS_ERR_OK ) { return error; } hMdDec->table_idx = 0; /* just to initialize state variables*/ - if ( ( error = ivas_spar_md_dec_init( hMdDec, hDecoderConfig, num_channels ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_init( hMdDec, hDecoderConfig, nchan ) ) != IVAS_ERR_OK ) { return error; } @@ -288,7 +288,7 @@ ivas_error ivas_spar_md_dec_open( static void ivas_spar_md_dec_matrix_close( ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels /* i : number of internal channels */ + const int16_t nchan /* i : number of internal channels */ ) { int16_t i, j; @@ -300,9 +300,9 @@ static void ivas_spar_md_dec_matrix_close( } if ( hMdDecoder->mixer_mat != NULL ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { count_free( hMdDecoder->mixer_mat[i][j] ); } @@ -313,9 +313,9 @@ static void ivas_spar_md_dec_matrix_close( if ( hMdDecoder->spar_coeffs.C_re != NULL ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { count_free( hMdDecoder->spar_coeffs.C_re[i][j] ); } @@ -326,9 +326,9 @@ static void ivas_spar_md_dec_matrix_close( if ( hMdDecoder->spar_coeffs.P_re != NULL ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { count_free( hMdDecoder->spar_coeffs.P_re[i][j] ); } @@ -339,9 +339,9 @@ static void ivas_spar_md_dec_matrix_close( if ( hMdDecoder->spar_coeffs_prev.C_re != NULL ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { count_free( hMdDecoder->spar_coeffs_prev.C_re[i][j] ); } @@ -352,9 +352,9 @@ static void ivas_spar_md_dec_matrix_close( if ( hMdDecoder->spar_coeffs_prev.P_re != NULL ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { count_free( hMdDecoder->spar_coeffs_prev.P_re[i][j] ); } @@ -365,9 +365,9 @@ static void ivas_spar_md_dec_matrix_close( if ( hMdDecoder->spar_coeffs_tar.C_re != NULL ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { count_free( hMdDecoder->spar_coeffs_tar.C_re[i][j] ); } @@ -378,9 +378,9 @@ static void ivas_spar_md_dec_matrix_close( if ( hMdDecoder->spar_coeffs_tar.P_re != NULL ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { count_free( hMdDecoder->spar_coeffs_tar.P_re[i][j] ); } @@ -404,12 +404,12 @@ void ivas_spar_md_dec_close( ) { ivas_spar_md_dec_state_t *hMdDecoder; - int16_t num_channels; + int16_t nchan; hMdDecoder = *hMdDec; - num_channels = hMdDecoder->spar_md_cfg.num_umx_chs; + nchan = hMdDecoder->spar_md_cfg.num_umx_chs; - ivas_spar_md_dec_matrix_close( hMdDecoder, num_channels ); + ivas_spar_md_dec_matrix_close( hMdDecoder, nchan ); if ( *hMdDec != NULL ) { @@ -430,7 +430,7 @@ void ivas_spar_md_dec_close( ivas_error ivas_spar_md_dec_init( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels /* i : number of internal channels */ + const int16_t nchan /* i : number of internal channels */ ) { int16_t i, j, k; @@ -471,9 +471,9 @@ ivas_error ivas_spar_md_dec_init( hMdDec->spar_plc_num_lost_frames = 0; hMdDec->spar_plc_enable_fadeout_flag = 1; - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -482,9 +482,9 @@ ivas_error ivas_spar_md_dec_init( } } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -493,9 +493,9 @@ ivas_error ivas_spar_md_dec_init( } } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -504,9 +504,9 @@ ivas_error ivas_spar_md_dec_init( } } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -622,17 +622,17 @@ void ivas_spar_md_dec_process( char f_name[100]; int16_t num_bands = nB; int16_t num_subframes = 1, num_block_groups = 1, num_elements = 1, byte_size = sizeof( float ); - int16_t num_ch = 2 * sba_order + 2; + int16_t nchan = 2 * sba_order + 2; for ( b = 0; b < num_bands; b++ ) { sprintf( f_name, "spar_band_pred_coeffs_dec.bin" ); ( b == 0 && frame == 0 ) ? dbgwrite( &num_bands, sizeof( num_bands ), 1, 1, f_name ) : false; - num_elements = num_ch - 1; + num_elements = nchan - 1; ( b == 0 && frame == 0 ) ? dbgwrite( &num_elements, sizeof( num_elements ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_subframes, sizeof( num_subframes ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_block_groups, sizeof( num_block_groups ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &byte_size, sizeof( byte_size ), 1, 1, f_name ) : false; - for ( j = 0; j < num_ch - 1; j++ ) + for ( j = 0; j < nchan - 1; j++ ) { dbgwrite( &hMdDec->spar_md.band_coeffs[b].pred_re[j], sizeof( float ), 1, 1, f_name ); } @@ -652,12 +652,12 @@ void ivas_spar_md_dec_process( } sprintf( f_name, "spar_band_P_coeffs_dec.bin" ); ( b == 0 && frame == 0 ) ? dbgwrite( &num_bands, sizeof( num_bands ), 1, 1, f_name ) : false; - num_elements = num_ch - 1; + num_elements = nchan - 1; ( b == 0 && frame == 0 ) ? dbgwrite( &num_elements, sizeof( num_elements ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_subframes, sizeof( num_subframes ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_block_groups, sizeof( num_block_groups ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &byte_size, sizeof( byte_size ), 1, 1, f_name ) : false; - for ( j = 0; j < num_ch - 1; j++ ) + for ( j = 0; j < nchan - 1; j++ ) { dbgwrite( &hMdDec->spar_md.band_coeffs[b].P_re[j], sizeof( float ), 1, 1, f_name ); } @@ -826,13 +826,13 @@ void ivas_spar_setup_md_smoothing( ) { /* copy the coeffs */ - int16_t num_channels, i, j, k; + int16_t nchan, i, j, k; - num_channels = hMdDec->spar_md_cfg.num_umx_chs; + nchan = hMdDec->spar_md_cfg.num_umx_chs; - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -841,9 +841,9 @@ void ivas_spar_setup_md_smoothing( } } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -852,9 +852,9 @@ void ivas_spar_setup_md_smoothing( } } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -863,9 +863,9 @@ void ivas_spar_setup_md_smoothing( } } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -889,13 +889,13 @@ void ivas_spar_setup_md_smoothing( void ivas_spar_update_md_hist( ivas_spar_md_dec_state_t *hMdDec ) { - int16_t num_channels, i, j, k; + int16_t nchan, i, j, k; - num_channels = hMdDec->spar_md_cfg.num_umx_chs; + nchan = hMdDec->spar_md_cfg.num_umx_chs; - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -904,9 +904,9 @@ void ivas_spar_update_md_hist( } } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -915,9 +915,9 @@ void ivas_spar_update_md_hist( } } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -926,9 +926,9 @@ void ivas_spar_update_md_hist( } } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -1316,15 +1316,15 @@ static void ivas_mat_col_rearrange( const int16_t i_ts, float ***mixer_mat, const int16_t bands, - const int16_t num_ch ) + const int16_t nchan ) { int16_t i, j, idx; - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { idx = order[i]; - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { mixer_mat[j][i][bands + i_ts * IVAS_MAX_NUM_BANDS] = in_re[j][idx]; } @@ -2097,9 +2097,9 @@ static void ivas_spar_md_fill_invalid_bands( int16_t valid_band_idx[IVAS_MAX_NUM_BANDS], idx = -1; int16_t last_valid_band_idx[IVAS_MAX_NUM_BANDS]; float w = 0; - int16_t num_channels; + int16_t nchan; - num_channels = ivas_sba_get_nchan_metadata( sba_order ); + nchan = ivas_sba_get_nchan_metadata( sba_order ); set_s( valid_band_idx, 0, IVAS_MAX_NUM_BANDS ); set_s( last_valid_band_idx, 0, IVAS_MAX_NUM_BANDS ); @@ -2155,9 +2155,9 @@ static void ivas_spar_md_fill_invalid_bands( w = ( (float) ( b - id0 ) ) / ( id1 - id0 ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { pSpar_coeffs->C_re[i][j][b] = ( 1 - w ) * pSpar_coeffs->C_re[i][j][id0] + w * pSpar_coeffs->C_re[i][j][id1]; pSpar_coeffs->P_re[i][j][b] = ( 1 - w ) * pSpar_coeffs->P_re[i][j][id0] + w * pSpar_coeffs->P_re[i][j][id1]; @@ -2168,9 +2168,9 @@ static void ivas_spar_md_fill_invalid_bands( { if ( valid_bands[b] == 0 ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { pSpar_coeffs->C_re[i][j][b] = pSpar_coeffs_prev->C_re[i][j][b]; pSpar_coeffs->P_re[i][j][b] = pSpar_coeffs_prev->P_re[i][j][b]; @@ -2182,9 +2182,9 @@ static void ivas_spar_md_fill_invalid_bands( if ( valid_bands[b] == 0 ) { int16_t i_ts; - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( i_ts = 1; i_ts < MAX_PARAM_SPATIAL_SUBFRAMES; i_ts++ ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 9f36670a7d..9bfe233e8e 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -511,37 +511,37 @@ typedef struct dirac_output_synthesis_params_structure typedef struct dirac_output_synthesis_state_structure { /* only pointer to local buffers */ - float *direct_responses; /* direct responses for DOA of current frame. Size: num_freq_bands*num_channels. */ + float *direct_responses; /* direct responses for DOA of current frame. Size: num_freq_bands*nchan. */ float *direct_responses_square; - float *diffuse_responses_square; /* squared diffuse responses. Size: num_channels. */ + float *diffuse_responses_square; /* squared diffuse responses. Size: nchan. */ /* only pointer to local buffers */ float *direct_power_factor; float *diffuse_power_factor; - float *proto_power_smooth; /* Smoothed power of the prototype signals. Size: num_freq_bands*num_channels. */ - float *proto_power_smooth_prev; /* Smoothed power of the prototype signals of the previous synthesis block. Size: num_freq_bands*num_channels. */ + float *proto_power_smooth; /* Smoothed power of the prototype signals. Size: num_freq_bands*nchan. */ + float *proto_power_smooth_prev; /* Smoothed power of the prototype signals of the previous synthesis block. Size: num_freq_bands*nchan. */ float *proto_power_diff_smooth; float *proto_power_diff_smooth_prev; /* only pointer to local buffers */ - float *proto_direct_buffer_f; /* Buffer for direct sound prototype signals. Size: 2*num_freq_bands*num_channels*buffer_length (complex interleaved). */ - float *proto_diffuse_buffer_f; /* Buffer for diffuse sound prototype signals. Size: 2*num_freq_bands*num_channels*buffer_length (complex interleaved). */ + float *proto_direct_buffer_f; /* Buffer for direct sound prototype signals. Size: 2*num_freq_bands*nchan*buffer_length (complex interleaved). */ + float *proto_diffuse_buffer_f; /* Buffer for diffuse sound prototype signals. Size: 2*num_freq_bands*nchan*buffer_length (complex interleaved). */ /* Output gain memories */ float *gains_dir_prev; /* Direct sound gains of current synthesis block. Size: num_freq_bands*num_channel. */ float *gains_diff_prev; /* Diffuse sound gains of previous synthesis block. Size: num_freq_bands*num_channel. */ /* only pointer to local buffers */ - float *cy_auto_dir_smooth; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ - float *cy_cross_dir_smooth; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ - float *cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ + float *cy_auto_dir_smooth; /* Target auto PSD of direct sound. Size: num_freq_bands*nchan. */ + float *cy_cross_dir_smooth; /* Target cross PSD of direct sound. Size: num_freq_bands*nchan. */ + float *cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*nchan. */ /* PSD memories */ - float *cy_auto_dir_smooth_prev; /* Target auto PSD of direct sound of previous synthesis block. Size: num_freq_bands*num_channels. */ - float *cy_cross_dir_smooth_prev; /* Target cross PSD of direct sound of previous synthesis block. Size: num_freq_bands*num_channels. */ - float *cy_auto_diff_smooth_prev; /* Target auto PSD of diffuse sound of previous synthesis block. Size: num_freq_bands*num_channels. */ + float *cy_auto_dir_smooth_prev; /* Target auto PSD of direct sound of previous synthesis block. Size: num_freq_bands*nchan. */ + float *cy_cross_dir_smooth_prev; /* Target cross PSD of direct sound of previous synthesis block. Size: num_freq_bands*nchan. */ + float *cy_auto_diff_smooth_prev; /* Target auto PSD of diffuse sound of previous synthesis block. Size: num_freq_bands*nchan. */ const float *onset_filter; @@ -559,14 +559,14 @@ typedef struct dirac_output_synthesis_cov_state_structure float *diffuse_power_factor; /* only pointer to local buffers */ - float *direct_responses; /* direct responses for DOA of current frame. Size: num_freq_bands*num_channels. */ + float *direct_responses; /* direct responses for DOA of current frame. Size: num_freq_bands*nchan. */ float *direct_responses_square; - float *diffuse_responses_square; /* squared diffuse responses. Size: num_channels. */ + float *diffuse_responses_square; /* squared diffuse responses. Size: nchan. */ /* only pointer to local buffers */ - float *proto_direct_buffer_f; /* Buffer for direct sound prototype signals. Size: 2*num_freq_bands*num_channels*buffer_length (complex interleaved). */ - float *proto_diffuse_buffer_f; /* Buffer for diffuse sound prototype signals. Size: 2*num_freq_bands*num_channels*buffer_length (complex interleaved). */ - float *proto_power; /* Smoothed power of the prototype signals. Size: num_freq_bands*num_channels. */ + float *proto_direct_buffer_f; /* Buffer for direct sound prototype signals. Size: 2*num_freq_bands*nchan*buffer_length (complex interleaved). */ + float *proto_diffuse_buffer_f; /* Buffer for diffuse sound prototype signals. Size: 2*num_freq_bands*nchan*buffer_length (complex interleaved). */ + float *proto_power; /* Smoothed power of the prototype signals. Size: num_freq_bands*nchan. */ float *proto_power_diff; float *cx_old[CLDFB_NO_CHANNELS_MAX]; @@ -1881,7 +1881,7 @@ typedef struct ivas_lfe_dec_data_structure typedef struct { int16_t max_num_channels; - int16_t num_channels; + int16_t nchan; float **channel_ptrs; int32_t sampling_rate; float gain; diff --git a/lib_dec/ivas_td_decorr.c b/lib_dec/ivas_td_decorr.c index 29b748e4c7..e1daf78e60 100644 --- a/lib_dec/ivas_td_decorr.c +++ b/lib_dec/ivas_td_decorr.c @@ -91,8 +91,8 @@ const float ivas_three_pow_frac[IVAS_MAX_DECORR_APD_SECTIONS] = { * Local functions declaration *------------------------------------------------------------------------------------------*/ -static int16_t ivas_get_APD_filt_orders( const int16_t num_out_chans, const int32_t output_Fs, int16_t *APD_filt_orders ); -static ivas_error ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, const int16_t num_out_chans, const int16_t ducking_flag ); +static int16_t ivas_get_APD_filt_orders( const int16_t nchan, const int32_t output_Fs, int16_t *APD_filt_orders ); +static ivas_error ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, const int16_t nchan, const int16_t ducking_flag ); /*------------------------------------------------------------------------- @@ -109,11 +109,11 @@ ivas_error ivas_spar_td_decorr_dec_open( ) { int16_t i, j, len; - int16_t num_out_chans; + int16_t nchan; ivas_td_decorr_state_t *hCovState; ivas_error error; - num_out_chans = nchan_internal - 1; + nchan = nchan_internal - 1; error = IVAS_ERR_OK; @@ -128,9 +128,9 @@ ivas_error ivas_spar_td_decorr_dec_open( } set_f( hCovState->look_ahead_buf, 0, (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) ); - hCovState->num_apd_sections = ivas_get_APD_filt_orders( num_out_chans, output_Fs, hCovState->APD_filt_state[0].order ); + hCovState->num_apd_sections = ivas_get_APD_filt_orders( nchan, output_Fs, hCovState->APD_filt_state[0].order ); - for ( j = 0; j < num_out_chans; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( i = 0; i < hCovState->num_apd_sections; i++ ) { @@ -145,7 +145,7 @@ ivas_error ivas_spar_td_decorr_dec_open( } } - ivas_td_decorr_init( hCovState, num_out_chans, ducking_flag ); + ivas_td_decorr_init( hCovState, nchan, ducking_flag ); if ( ducking_flag ) { @@ -213,7 +213,7 @@ void ivas_spar_td_decorr_dec_close( *-----------------------------------------------------------------------------------------*/ static int16_t ivas_get_APD_filt_orders( - const int16_t num_out_chans, + const int16_t nchan, const int32_t output_Fs, int16_t *APD_filt_orders ) { @@ -221,7 +221,7 @@ static int16_t ivas_get_APD_filt_orders( int16_t num_apd_sections = 0; float sum_R, R[IVAS_MAX_DECORR_APD_SECTIONS]; - switch ( num_out_chans ) + switch ( nchan ) { case IVAS_TD_DECORR_OUT_1CH: case IVAS_TD_DECORR_OUT_2CH: @@ -277,13 +277,13 @@ static int16_t ivas_get_APD_filt_orders( static ivas_error ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, - const int16_t num_out_chans, + const int16_t nchan, const int16_t ducking_flag ) { int16_t i, j; hTdDecorr->ducking_flag = ducking_flag; - hTdDecorr->num_apd_outputs = num_out_chans; + hTdDecorr->num_apd_outputs = nchan; for ( i = 0; i < hTdDecorr->num_apd_outputs; i++ ) { diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index 3968e38974..659738feb9 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -110,7 +110,7 @@ struct apa_state_t uint16_t bad_frame_count; /* # frames before quality threshold is lowered */ uint16_t good_frame_count; /* # scaled frames */ - uint16_t num_channels; /* number of input/output channels */ + uint16_t nchan; /* number of input/output channels */ }; @@ -186,7 +186,7 @@ void apa_reset( ps->last_pitch = 0; ps->bad_frame_count = 0; ps->good_frame_count = 0; - ps->num_channels = 0; + ps->nchan = 0; return; } @@ -196,7 +196,7 @@ void apa_reset( bool apa_set_rate( apa_state_t *ps, const int32_t output_Fs, - const int16_t num_channels ) + const int16_t nchan ) { /* make sure pointer is valid */ if ( ps == NULL ) @@ -217,7 +217,7 @@ bool apa_set_rate( ps->rate = (uint16_t) output_Fs; /* set number of channels */ - ps->num_channels = num_channels; + ps->nchan = nchan; /* * several other parameters depend on the sampling rate @@ -232,7 +232,7 @@ bool apa_set_rate( /* in the order of a pitch, set to 160 samples at 16 kHz */ /* used for windowing and as the correlation length, i.e., */ /* the size of the template segment. */ - ps->l_seg = ( ps->rate / 100 ) * ps->num_channels; + ps->l_seg = ( ps->rate / 100 ) * ps->nchan; /* init Hann window */ /* Note: l_win < APA_BUF is required, which is assured */ @@ -244,17 +244,17 @@ bool apa_set_rate( /* set frame size */ /* set to 320 samples at 16 kHz */ - ps->l_frm = ( ps->rate / FRAMES_PER_SEC ) * ps->num_channels; + ps->l_frm = ( ps->rate / FRAMES_PER_SEC ) * ps->nchan; /* set minimum pitch */ /* set to 40 samples at 16 kHz */ /* (defines min change in number of samples, i.e., abs(l_in-l_out) >= p_min) */ - ps->p_min = ( ps->rate / 400 ) * ps->num_channels; + ps->p_min = ( ps->rate / 400 ) * ps->nchan; /* set search length */ /* must cover one pitch, set to 200 samples at 16 kHz */ /* (the resulting maximum pitch is then p_min+l_search = 240 samples at 16 kHz) */ - ps->l_search = ( ps->rate / 80 ) * ps->num_channels; + ps->l_search = ( ps->rate / 80 ) * ps->nchan; return 0; } @@ -669,18 +669,18 @@ static void get_scaling_quality( uint16_t i = 0; - for ( i = 0; i < ps->num_channels; i++ ) + for ( i = 0; i < ps->nchan; i++ ) { float energy; offset = 0; - pitch_cn = normalized_cross_correlation_self( signal, pitch + offset, offset, corr_len, ps->num_channels * 2, &pitch_energy ); + pitch_cn = normalized_cross_correlation_self( signal, pitch + offset, offset, corr_len, ps->nchan * 2, &pitch_energy ); if ( pitch_cn > 0.0f ) { /* calculate correlation for double pitch */ if ( 2 * pitch + offset + corr_len <= s_len ) { - double_pitch_cn = normalized_cross_correlation_self( signal, 2 * pitch + offset, offset, corr_len, ps->num_channels * 2, &double_pitch_energy ); + double_pitch_cn = normalized_cross_correlation_self( signal, 2 * pitch + offset, offset, corr_len, ps->nchan * 2, &double_pitch_energy ); } else { @@ -690,7 +690,7 @@ static void get_scaling_quality( /* calculate correlation for three/half pitch */ if ( ( 3 * pitch ) / 2 + offset + corr_len <= s_len ) { - three_halves_pitch_cn = normalized_cross_correlation_self( signal, ( 3 * pitch ) / 2 + offset, offset, corr_len, ps->num_channels * 2, &three_halves_pitch_energy ); + three_halves_pitch_cn = normalized_cross_correlation_self( signal, ( 3 * pitch ) / 2 + offset, offset, corr_len, ps->nchan * 2, &three_halves_pitch_energy ); } else { @@ -700,7 +700,7 @@ static void get_scaling_quality( /* calculate correlation for half pitch */ if ( pitch / 2 + offset + corr_len <= s_len ) { - half_pitch_cn = normalized_cross_correlation_self( signal, pitch / 2 + offset, offset, corr_len, ps->num_channels * 2, &half_pitch_energy ); + half_pitch_cn = normalized_cross_correlation_self( signal, pitch / 2 + offset, offset, corr_len, ps->nchan * 2, &half_pitch_energy ); } else { @@ -820,13 +820,13 @@ static bool logarithmic_search( coeff_max = -FLT_MAX; /* will always be overwritten with result of first correlation */ for ( i = s_start; i < s_start + inlen; i += css ) { - if ( ( wss == 1 ) && ( ps->num_channels == 1 ) ) + if ( ( wss == 1 ) && ( ps->nchan == 1 ) ) { coeff = cross_correlation_self( signal, i + offset, fixed_pos + offset, corr_len ); } else { - coeff = cross_correlation_subsampled_self( signal, i + offset, fixed_pos + offset, corr_len, wss * ps->num_channels ); + coeff = cross_correlation_subsampled_self( signal, i + offset, fixed_pos + offset, corr_len, wss * ps->nchan ); } /* update max corr */ @@ -929,10 +929,10 @@ static bool find_synch( /* pass last pitch to search function as prediction value */ *synch_pos = ps->last_pitch; - logarithmic_search( ps, in, s_start, s_len, offset, fixed_pos, corr_len, ps->wss, ps->css * ps->num_channels, synch_pos ); + logarithmic_search( ps, in, s_start, s_len, offset, fixed_pos, corr_len, ps->wss, ps->css * ps->nchan, synch_pos ); /* assert synch_pos is cleanly divisible by number of channels */ - assert( *synch_pos % ps->num_channels == 0 ); + assert( *synch_pos % ps->nchan == 0 ); *quality = 0; get_scaling_quality( ps, in, l_in, offset, corr_len, (uint16_t) abs( fixed_pos - *synch_pos ), energy, quality ); @@ -1035,7 +1035,7 @@ static bool shrink_frm( frm_in += l_frm; /* set search range */ - s_start = ( ps->p_min / ps->num_channels ) * ps->num_channels; + s_start = ( ps->p_min / ps->nchan ) * ps->nchan; s_end = s_start + ps->l_search; if ( ( s_end + l_seg ) >= l_frm ) { @@ -1055,7 +1055,7 @@ static bool shrink_frm( else { /* set to last valid element (i.e. element[len - 1] but note for stereo last element is last pair of samples) */ - xtract = s_end - ps->num_channels; + xtract = s_end - ps->nchan; } } else @@ -1065,7 +1065,7 @@ static bool shrink_frm( } /* assert synch_pos is cleanly divisible by number of channels */ - assert( xtract % ps->num_channels == 0 ); + assert( xtract % ps->nchan == 0 ); /* set frame overlappable - reset if necessary */ over = 1; @@ -1104,7 +1104,7 @@ static bool shrink_frm( { return 1; } - overlapAdd( frm_in, frm_in + xtract, frm_out, l_seg, ps->num_channels, ps->win + ps->l_halfwin, ps->win ); + overlapAdd( frm_in, frm_in + xtract, frm_out, l_seg, ps->nchan, ps->win + ps->l_halfwin, ps->win ); } else { @@ -1256,7 +1256,7 @@ static bool extend_frm( /* maximum scaling */ energy = -65; quality = 5; - xtract[n] = s_start + ps->num_channels; + xtract[n] = s_start + ps->nchan; } else { @@ -1264,7 +1264,7 @@ static bool extend_frm( findSynchResult = find_synch( ps, frm_in, 2 * l_frm, s_start, s_end - s_start, sync_start, l_seg, l_frm, &energy, &quality, &xtract[n] ); } /* assert synch_pos is cleanly divisible by number of channels */ - assert( xtract[n] % ps->num_channels == 0 ); + assert( xtract[n] % ps->nchan == 0 ); /* test for sufficient quality */ if ( quality < ( ps->targetQuality - ( ps->bad_frame_count * 0.1f ) + ( ps->good_frame_count * 0.2f ) ) ) @@ -1313,7 +1313,7 @@ static bool extend_frm( fadeOut = frm_in + l_frm + xtract[n - 1] + l_seg; fadeIn = frm_in + l_frm + xtract[n]; out = frm_out + ( n - 2 ) * l_seg; - overlapAdd( fadeOut, fadeIn, out, l_seg, ps->num_channels, ps->win + ps->l_halfwin, ps->win ); + overlapAdd( fadeOut, fadeIn, out, l_seg, ps->nchan, ps->win + ps->l_halfwin, ps->win ); } else { diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index 5cf4e7d8b6..5297c799b9 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -101,9 +101,9 @@ void apa_reset( apa_state_t *s ); * Will also set a number of other state variables that depend on the sampling rate. * @param[in,out] ps state * @param[in] output_Fs sample rate [Hz] - * @param[in] num_channels number of channels + * @param[in] nchan number of channels * @return 0 on success, 1 on failure */ -bool apa_set_rate( apa_state_t *ps, const int32_t output_Fs, const int16_t num_channels ); +bool apa_set_rate( apa_state_t *ps, const int32_t output_Fs, const int16_t nchan ); /*! Set scaling. * The scale is given in % and will be valid until changed again. diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 907b8c5908..c49154e4a6 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -156,7 +156,7 @@ void ivas_enc_cov_handler_process( const int16_t end_band #ifdef SBA_SPAR_HARM , - const int16_t num_ch, + const int16_t nchan, const int16_t dtx_vad, const int16_t transient_det #endif @@ -169,15 +169,15 @@ void ivas_enc_cov_handler_process( dtx_cov_flag = ( dtx_vad == 1 ) ? 0 : 1; #else ivas_cov_smooth_in_buf_t pCov_in_buf; - int16_t num_ch = pIn_buf->num_ch; + int16_t nchan = pIn_buf->nchan; - pCov_in_buf.num_ch = num_ch; + pCov_in_buf.nchan = nchan; #endif #ifdef SBA_SPAR_HARM - ivas_band_cov( ppIn_FR_real, ppIn_FR_imag, num_ch, hCovEnc->num_bins, + ivas_band_cov( ppIn_FR_real, ppIn_FR_imag, nchan, hCovEnc->num_bins, #else - ivas_band_cov( pIn_buf->ppIn_FR_real, pIn_buf->ppIn_FR_imag, pIn_buf->num_ch, hCovEnc->num_bins, + ivas_band_cov( pIn_buf->ppIn_FR_real, pIn_buf->ppIn_FR_imag, pIn_buf->nchan, hCovEnc->num_bins, #endif pFb->fb_bin_to_band.short_stride, pFb->fb_bin_to_band.pp_short_stride_bin_to_band, @@ -196,9 +196,9 @@ void ivas_enc_cov_handler_process( fid = fopen( "cov_real.txt", "wt" ); } - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = start_band; k < end_band; k++ ) { @@ -209,9 +209,9 @@ void ivas_enc_cov_handler_process( fprintf( fid, "\n" ); } #endif - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { #ifndef SBA_SPAR_HARM pCov_in_buf.cov_real[i][j] = cov_real[i][j]; @@ -221,7 +221,7 @@ void ivas_enc_cov_handler_process( } #ifdef SBA_SPAR_HARM - ivas_cov_smooth_process( hCovEnc->pCov_state, cov_real, pFb, start_band, end_band, num_ch, transient_det ); + ivas_cov_smooth_process( hCovEnc->pCov_state, cov_real, pFb, start_band, end_band, nchan, transient_det ); #else ivas_cov_smooth_process( hCovEnc->pCov_state, &pCov_in_buf, pFb, start_band, end_band ); #endif @@ -232,9 +232,9 @@ void ivas_enc_cov_handler_process( if ( pIn_buf->dtx_cov_flag == 0 ) #endif { - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { #ifdef SBA_SPAR_HARM mvr2r( cov_real[i][j], hCovEnc->pCov_dtx_state->pPrior_cov_real[i][j], pFb->filterbank_num_bands ); @@ -257,11 +257,11 @@ void ivas_enc_cov_handler_process( #endif { #ifdef SBA_SPAR_HARM - ivas_cov_smooth_process( hCovEnc->pCov_dtx_state, cov_dtx_real, pFb, start_band, end_band, num_ch, transient_det ); + ivas_cov_smooth_process( hCovEnc->pCov_dtx_state, cov_dtx_real, pFb, start_band, end_band, nchan, transient_det ); #else - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { pCov_in_buf.cov_real[i][j] = cov_dtx_real[i][j]; } @@ -277,11 +277,11 @@ void ivas_enc_cov_handler_process( if ( hCovEnc->prior_dtx_present == 0 ) { #ifdef SBA_SPAR_HARM - ivas_cov_smooth_process( hCovEnc->pCov_dtx_state, cov_dtx_real, pFb, start_band, end_band, num_ch, transient_det ); + ivas_cov_smooth_process( hCovEnc->pCov_dtx_state, cov_dtx_real, pFb, start_band, end_band, nchan, transient_det ); #else - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { pCov_in_buf.cov_real[i][j] = cov_dtx_real[i][j]; } @@ -294,9 +294,9 @@ void ivas_enc_cov_handler_process( } else { - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { mvr2r( hCovEnc->pCov_dtx_state->pPrior_cov_real[i][j], cov_dtx_real[i][j], pFb->filterbank_num_bands ); } diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index af7a48a80b..844a3c19bf 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -53,19 +53,19 @@ * Local function prototypes *------------------------------------------------------------------------*/ -static void ivas_param_mc_dmx( PARAM_MC_ENC_HANDLE hParamMC, float data_f[][L_FRAME48k], float data_dmx[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); +static void ivas_param_mc_dmx( PARAM_MC_ENC_HANDLE hParamMC, float data_f[][L_FRAME48k], float data_dmx[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_inp, const int16_t nchan_transport ); -static void ivas_param_mc_param_est_enc( PARAM_MC_ENC_HANDLE hParamMC, float input_frame_t[][L_FRAME48k], float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); +static void ivas_param_mc_param_est_enc( PARAM_MC_ENC_HANDLE hParamMC, float input_frame_t[][L_FRAME48k], float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t input_frame, const int16_t nchan_inp, const int16_t nchan_transport ); static void ivas_param_mc_parameter_quantizer( const float *x, const int16_t L, const int16_t sz_quantizer, const float *quantizer, int16_t *quant_idx, float *y ); static void ivas_param_mc_transient_detection( PARAM_MC_ENC_HANDLE hParamMC, TRAN_DET_HANDLE hTranDet, int16_t *bAttackPresent, int16_t *attackIdx ); -static void ivas_param_mc_enc_find_icc_map( PARAM_MC_ENC_HANDLE hParamMC, float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float ILD_q[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_SZ_ILD_MAP], const int16_t nchan_input, const int16_t nchan_transport ); +static void ivas_param_mc_enc_find_icc_map( PARAM_MC_ENC_HANDLE hParamMC, float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float ILD_q[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_SZ_ILD_MAP], const int16_t nchan_inp, const int16_t nchan_transport ); -static void ivas_param_mc_quantize_iccs( PARAM_MC_ENC_HANDLE hParamMC, float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], const int16_t freq_idx, const int16_t nchan_input, int16_t *ICC_idx_out ); +static void ivas_param_mc_quantize_iccs( PARAM_MC_ENC_HANDLE hParamMC, float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], const int16_t freq_idx, const int16_t nchan_inp, int16_t *ICC_idx_out ); -static void ivas_param_mc_quantize_ilds( PARAM_MC_ENC_HANDLE hParamMC, float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t freq_idx, const int16_t nchan_input, const int16_t nchan_transport, int16_t *ILD_idx_out, float ILD_q[PARAM_MC_SZ_ILD_MAP] ); +static void ivas_param_mc_quantize_ilds( PARAM_MC_ENC_HANDLE hParamMC, float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t freq_idx, const int16_t nchan_inp, const int16_t nchan_transport, int16_t *ILD_idx_out, float ILD_q[PARAM_MC_SZ_ILD_MAP] ); static void ivas_param_mc_write_bs( const PARAM_MC_ENC_HANDLE hParamMC, int16_t *ILD_idx, int16_t *ICC_idx, uint16_t bit_buffer[PARAM_MC_MAX_BITS], int16_t *bit_pos ); @@ -430,7 +430,7 @@ static void ivas_param_mc_dmx( float data_f[][L_FRAME48k], /* i : Input frame */ float data_dmx[][L_FRAME48k], /* o : Down mixed frame */ const int16_t input_frame, /* i : Input frame length */ - const int16_t nchan_input, /* i : number of input channels */ + const int16_t nchan_inp, /* i : number of input channels */ const int16_t nchan_transport /* i : number of transport channels */ ) { @@ -448,7 +448,7 @@ static void ivas_param_mc_dmx( { float *dmx_sample = &data_dmx[idx[dmx_ch]][i]; *dmx_sample = 0.0f; - for ( inp_ch = 0; inp_ch < nchan_input; inp_ch++ ) + for ( inp_ch = 0; inp_ch < nchan_inp; inp_ch++ ) { ( *dmx_sample ) += data_f[idx[inp_ch]][i] * ( *( p_dmx_fac++ ) ); } @@ -472,7 +472,7 @@ static void ivas_param_mc_param_est_enc( float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame */ float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame */ const int16_t input_frame, /* i : Input frame length */ - const int16_t nchan_input, /* i : number of input channels */ + const int16_t nchan_inp, /* i : number of input channels */ const int16_t nchan_transport /* i : number of transport channels */ ) { @@ -525,7 +525,7 @@ static void ivas_param_mc_param_est_enc( } /* Copy current frame to memory for delay compensation */ - for ( i = 0; i < nchan_input; i++ ) + for ( i = 0; i < nchan_inp; i++ ) { idx_ls = map_ls[i]; pcm_in[i] = &input_frame_t[idx_ls][0]; @@ -536,7 +536,7 @@ static void ivas_param_mc_param_est_enc( for ( ts = 0; ts < start_ts; ts++ ) { ivas_fb_mixer_update_prior_input( hParamMC->hFbMixer, pcm_in, l_ts ); - for ( i = 0; i < nchan_input; i++ ) + for ( i = 0; i < nchan_inp; i++ ) { pcm_in[i] += l_ts; } @@ -546,7 +546,7 @@ static void ivas_param_mc_param_est_enc( { ivas_fb_mixer_get_windowed_fr( hParamMC->hFbMixer, pcm_in, p_slot_frame_f_real, p_slot_frame_f_imag, l_ts, 2 * l_ts ); ivas_fb_mixer_update_prior_input( hParamMC->hFbMixer, pcm_in, l_ts ); - for ( i = 0; i < nchan_input; i++ ) + for ( i = 0; i < nchan_inp; i++ ) { pcm_in[i] += l_ts; } @@ -566,7 +566,7 @@ static void ivas_param_mc_param_est_enc( { dmx_real[ch_idx1] = 0.0f; dmx_imag[ch_idx1] = 0.0f; - for ( inp_ch = 0; inp_ch < nchan_input; inp_ch++ ) + for ( inp_ch = 0; inp_ch < nchan_inp; inp_ch++ ) { dmx_real[ch_idx1] += slot_frame_f_real[inp_ch][cur_cldfb_band] * ( *p_dmx_fac ); dmx_imag[ch_idx1] += slot_frame_f_imag[inp_ch][cur_cldfb_band] * ( *p_dmx_fac ); @@ -591,9 +591,9 @@ static void ivas_param_mc_param_est_enc( } /* Cy for input channels */ - for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) + for ( ch_idx1 = 0; ch_idx1 < nchan_inp; ++ch_idx1 ) { - for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) + for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_inp; ++ch_idx2 ) { a = slot_frame_f_real[ch_idx1][cur_cldfb_band]; b = slot_frame_f_imag[ch_idx1][cur_cldfb_band]; @@ -624,7 +624,7 @@ static void ivas_param_mc_param_est_enc( dmx_real[ch_idx1] = 0.0f; dmx_imag[ch_idx1] = 0.0f; - for ( inp_ch = 0; inp_ch < nchan_input; inp_ch++ ) + for ( inp_ch = 0; inp_ch < nchan_inp; inp_ch++ ) { dmx_real[ch_idx1] += slot_frame_f_real[inp_ch][cur_cldfb_band] * ( *p_dmx_fac ); dmx_imag[ch_idx1] += slot_frame_f_imag[inp_ch][cur_cldfb_band] * ( *p_dmx_fac ); @@ -648,9 +648,9 @@ static void ivas_param_mc_param_est_enc( } /* Cy for input channels */ - for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) + for ( ch_idx1 = 0; ch_idx1 < nchan_inp; ++ch_idx1 ) { - for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) + for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_inp; ++ch_idx2 ) { a = slot_frame_f_real[ch_idx1][cur_cldfb_band]; b = slot_frame_f_imag[ch_idx1][cur_cldfb_band]; @@ -671,7 +671,7 @@ static void ivas_param_mc_param_est_enc( { for ( cur_param_band = PARAM_MC_MAX_BAND_LFE; cur_param_band < hParamMC->max_param_band_abs_cov; cur_param_band++ ) { - for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) + for ( ch_idx1 = 0; ch_idx1 < nchan_inp; ++ch_idx1 ) { Cy_sum[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_sum[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; @@ -682,7 +682,7 @@ static void ivas_param_mc_param_est_enc( for ( ; cur_param_band < num_parameter_bands; cur_param_band++ ) { - for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) + for ( ch_idx1 = 0; ch_idx1 < nchan_inp; ++ch_idx1 ) { Cy_sum[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_sum[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; @@ -704,9 +704,9 @@ static void ivas_param_mc_param_est_enc( } } - for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) + for ( ch_idx1 = 0; ch_idx1 < nchan_inp; ++ch_idx1 ) { - for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) + for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_inp; ++ch_idx2 ) { Cy_sum[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_sum[cur_param_band][ch_idx1][ch_idx2]; Cy_sum_imag[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_sum_imag[cur_param_band][ch_idx1][ch_idx2]; @@ -726,9 +726,9 @@ static void ivas_param_mc_param_est_enc( } } - for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) + for ( ch_idx1 = 0; ch_idx1 < nchan_inp; ++ch_idx1 ) { - for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) + for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_inp; ++ch_idx2 ) { Cy_sum[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_sum[cur_param_band][ch_idx1][ch_idx2]; } @@ -756,9 +756,9 @@ static void ivas_param_mc_param_est_enc( } /* Cy for transport channels */ - for ( ch_idx1 = 0; ch_idx1 < nchan_input; ch_idx1++ ) + for ( ch_idx1 = 0; ch_idx1 < nchan_inp; ch_idx1++ ) { - for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ch_idx2++ ) + for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_inp; ch_idx2++ ) { real_part = Cy_sum[cur_param_band][ch_idx1][ch_idx2]; imag_part = Cy_sum_imag[cur_param_band][ch_idx1][ch_idx2]; @@ -794,7 +794,7 @@ static void ivas_param_mc_enc_find_icc_map( float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* i : Covariance matrix for the downmixed frame */ float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix for the original frame */ float ILD_q[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_SZ_ILD_MAP], /* i : quantized ILDs */ - const int16_t nchan_input, /* i : number of input channels */ + const int16_t nchan_inp, /* i : number of input channels */ const int16_t nchan_transport /* i : number of transport channels */ ) { @@ -824,7 +824,7 @@ static void ivas_param_mc_enc_find_icc_map( icc_map_size_wo_lfe = hParamMC->hMetadataPMC.icc_mapping_conf->icc_map_size_wo_lfe; icc_map_size = hParamMC->hMetadataPMC.icc_mapping_conf->icc_map_size_lfe; - set_zero( Cy_band, nchan_input * nchan_input ); + set_zero( Cy_band, nchan_inp * nchan_inp ); /* Estimate the target covariance like in the decoder using the * already available qunantised ICLDs */ @@ -842,18 +842,18 @@ static void ivas_param_mc_enc_find_icc_map( } /* get estimated Cy from Cx and proto matrix */ - matrix_product( hParamMC->dmx_factors, nchan_input, nchan_transport, 0, + matrix_product( hParamMC->dmx_factors, nchan_inp, nchan_transport, 0, Cx_band, nchan_transport, nchan_transport, 0, mat_mult_buffer1 ); - matrix_product( mat_mult_buffer1, nchan_input, nchan_transport, 0, - hParamMC->dmx_factors, nchan_input, nchan_transport, 1, + matrix_product( mat_mult_buffer1, nchan_inp, nchan_transport, 0, + hParamMC->dmx_factors, nchan_inp, nchan_transport, 1, Cproto_band ); set_zero( Nrqq, MAX_OUTPUT_CHANNELS ); /*get back Nrg*/ - for ( k = 0; k < nchan_input; k++ ) + for ( k = 0; k < nchan_inp; k++ ) { float ref_ener = 0.0f; int16_t ref_channel_cnt; @@ -868,51 +868,51 @@ static void ivas_param_mc_enc_find_icc_map( } /* apply quantized ICLDs in the estimated covariance */ - for ( k = 0; k < nchan_input; k++ ) + for ( k = 0; k < nchan_inp; k++ ) { - a[k] = sqrtf( Nrqq[k] ) / ( sqrtf( Cproto_band[k + nchan_input * k] ) + EPSILON ); - v_multc( Cproto_band + k * nchan_input, a[k], Cproto_band + k * nchan_input, nchan_input ); + a[k] = sqrtf( Nrqq[k] ) / ( sqrtf( Cproto_band[k + nchan_inp * k] ) + EPSILON ); + v_multc( Cproto_band + k * nchan_inp, a[k], Cproto_band + k * nchan_inp, nchan_inp ); } - for ( k = 0; k < nchan_input; k++ ) + for ( k = 0; k < nchan_inp; k++ ) { int16_t l; float *Cyp = Cproto_band + k; float ap = a[k]; - for ( l = 0; l < nchan_input; l++ ) + for ( l = 0; l < nchan_inp; l++ ) { ( *Cyp ) *= ap; - Cyp += nchan_input; + Cyp += nchan_inp; } } /* transfer Cy_sum band to columnwise matrix */ - for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) + for ( ch_idx1 = 0; ch_idx1 < nchan_inp; ++ch_idx1 ) { - for ( ch_idx2 = 0; ch_idx2 < nchan_input; ++ch_idx2 ) + for ( ch_idx2 = 0; ch_idx2 < nchan_inp; ++ch_idx2 ) { Cy_band[ch_idx1 + nchan_transport * ch_idx2] = Cy_sum[cur_param_band][ch_idx1][ch_idx2]; } } /* apply quantized ICLDs on the input covariance */ - for ( k = 0; k < nchan_input; k++ ) + for ( k = 0; k < nchan_inp; k++ ) { - a[k] = sqrtf( Nrqq[k] ) / ( sqrtf( Cy_band[k + nchan_input * k] ) + EPSILON ); - v_multc( Cy_band + k * nchan_input, a[k], Cy_band + k * nchan_input, nchan_input ); + a[k] = sqrtf( Nrqq[k] ) / ( sqrtf( Cy_band[k + nchan_inp * k] ) + EPSILON ); + v_multc( Cy_band + k * nchan_inp, a[k], Cy_band + k * nchan_inp, nchan_inp ); } - for ( k = 0; k < nchan_input; k++ ) + for ( k = 0; k < nchan_inp; k++ ) { int16_t l; float *Cyp = Cy_band + k; float ap = a[k]; - for ( l = 0; l < nchan_input; l++ ) + for ( l = 0; l < nchan_inp; l++ ) { ( *Cyp ) *= ap; - Cyp += nchan_input; + Cyp += nchan_inp; } } @@ -921,7 +921,7 @@ static void ivas_param_mc_enc_find_icc_map( { int16_t idx0 = hParamMC->hMetadataPMC.icc_map_full[0][map_idx]; int16_t idx1 = hParamMC->hMetadataPMC.icc_map_full[1][map_idx]; - mapped_error[map_idx] += fabsf( Cproto_band[idx0 + idx1 * nchan_input] - Cy_band[idx0 + idx1 * nchan_input] ); + mapped_error[map_idx] += fabsf( Cproto_band[idx0 + idx1 * nchan_inp] - Cy_band[idx0 + idx1 * nchan_inp] ); } } } @@ -1018,7 +1018,7 @@ static void ivas_param_mc_quantize_ilds( float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix of the input */ float Cx[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* i : Covariance matrix of the dmx */ const int16_t freq_idx, /* i : frequency index being processed */ - const int16_t nchan_input, /* i : number of input channels */ + const int16_t nchan_inp, /* i : number of input channels */ const int16_t nchan_transport, /* i : number of transport channels */ int16_t *ILD_idx_out, /* o : ILD indices */ float ILD_q[PARAM_MC_SZ_ILD_MAP] /* o : Quanzited ILD matrix */ @@ -1040,7 +1040,7 @@ static void ivas_param_mc_quantize_ilds( set_zero( Nrg, MAX_CICP_CHANNELS ); set_zero( ILD, PARAM_MC_SZ_ILD_MAP ); - Ny = nchan_input; + Ny = nchan_inp; h_ild_mapping = hParamMC->hMetadataPMC.ild_mapping_conf; ild_map_size = hParamMC->hMetadataPMC.ild_mapping_conf->ild_map_size_lfe; @@ -1159,7 +1159,7 @@ static void ivas_param_mc_quantize_iccs( PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix of the input */ const int16_t freq_idx, /* i : frequency index being processed */ - const int16_t nchan_input, /* i : number of input channels */ + const int16_t nchan_inp, /* i : number of input channels */ int16_t *ICC_idx_out /* o : quantizer indices */ ) { @@ -1179,7 +1179,7 @@ static void ivas_param_mc_quantize_iccs( set_zero( ICC_vect, PARAM_MC_SZ_ICC_MAP ); set_zero( ICC_vect_q, PARAM_MC_SZ_ICC_MAP ); - Ny = nchan_input; + Ny = nchan_inp; /* Downsampling */ if ( ( hParamMC->hMetadataPMC.bAttackPresent == 0 ) && ( hParamMC->hMetadataPMC.param_frame_idx != hParamMC->hMetadataPMC.coding_band_mapping[freq_idx] ) ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 6c17a5711e..e863f3ded9 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -213,7 +213,8 @@ void ivas_spar_enc_close( const int16_t nchan_inp /* i : number of input channels */ ) { - int16_t num_chans; + int16_t nchan; + if ( hSpar != NULL ) { /* core-coder-VAD handle */ @@ -231,14 +232,14 @@ void ivas_spar_enc_close( } - num_chans = hSpar->hFbMixer->fb_cfg->num_in_chans; - assert( num_chans <= nchan_inp ); + nchan = hSpar->hFbMixer->fb_cfg->nchan_inp; + assert( nchan <= nchan_inp ); /* MD handle */ ivas_spar_md_enc_close( &hSpar->hMdEnc ); /* Covar. State handle */ - ivas_spar_covar_enc_close( &hSpar->hCovEnc, num_chans ); + ivas_spar_covar_enc_close( &hSpar->hCovEnc, nchan ); /* FB mixer handle */ ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs ); @@ -527,7 +528,7 @@ static ivas_error ivas_spar_enc_process( } #ifndef SBA_SPAR_HARM - cov_in_buf.num_ch = nchan_inp; + cov_in_buf.nchan = nchan_inp; #endif dtx_vad = ( hEncoderConfig->Opt_DTX_ON == 1 ) ? front_vad_flag : 1; @@ -645,7 +646,7 @@ static ivas_error ivas_spar_enc_process( *-----------------------------------------------------------------------------------------*/ #ifndef SBA_SPAR_HARM - cov_in_buf.num_ch = nchan_inp; + cov_in_buf.nchan = nchan_inp; #endif for ( i = 0; i < nchan_inp; i++ ) { @@ -793,9 +794,9 @@ static ivas_error ivas_spar_enc_process( if ( f_mat == 0 ) f_mat = fopen( "mixer_mat_enc", "w" ); - for ( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) + for ( i = 0; i < hSpar->hFbMixer->fb_cfg->nchan_out; i++ ) { - for ( j = 0; j < hSpar->hFbMixer->fb_cfg->num_in_chans; j++ ) + for ( j = 0; j < hSpar->hFbMixer->fb_cfg->nchan_inp; j++ ) { for ( k = 0; k < hSpar->hFbMixer->pFb->filterbank_num_bands; k++ ) { @@ -878,7 +879,7 @@ static ivas_error ivas_spar_enc_process( { if ( hEncoderConfig->Opt_AGC_ON > 0 ) { - ivas_agc_enc_process( hSpar->hAgcEnc, hMetaData, p_pcm_tmp, p_pcm_tmp, hSpar->hFbMixer->fb_cfg->num_out_chans, hEncoderConfig ); + ivas_agc_enc_process( hSpar->hAgcEnc, hMetaData, p_pcm_tmp, p_pcm_tmp, hSpar->hFbMixer->fb_cfg->nchan_out, hEncoderConfig ); } else { diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 7ae45903d5..6b8e43ba87 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -68,7 +68,7 @@ typedef enum ivas_strats_t * Static functions declaration *------------------------------------------------------------------------------------------*/ -static void ivas_band_mixer( float *cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t num_ch, int16_t *num_bands, int16_t red_band_fact ); +static void ivas_band_mixer( float *cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t nchan, int16_t *num_bands, int16_t red_band_fact ); static void ivas_get_band_differential_index( ivas_band_coeffs_ind_t *pBand_idx, const int16_t q_levels[2], const int16_t one_sided, const int16_t nB, const int16_t complex_cov, const int16_t dim, const ivas_coeffs_type_t coeff_type ); @@ -86,14 +86,14 @@ static void ivas_write_spar_md_bitstream( ivas_spar_md_enc_state_t *hMdEnc, cons static ivas_error ivas_spar_md_enc_init( ivas_spar_md_enc_state_t *hMdEnc, const ENCODER_CONFIG_HANDLE hEncoderConfig, const int16_t sba_order ); static void ivas_spar_quant_pred_coeffs_dtx( ivas_spar_md_t *pSpar_md, const float *pValues, const int16_t ndm, int16_t *pIndex, const int16_t dim1, float *pQuant ); -static void ivas_quant_p_per_band_dtx( float *pP_mat, const int16_t num_dec, const int16_t num_dmx, int16_t *ppIdx_pd, float *pP_out, const int16_t num_ch ); +static void ivas_quant_p_per_band_dtx( float *pP_mat, const int16_t num_dec, const int16_t num_dmx, int16_t *ppIdx_pd, float *pP_out, const int16_t nchan ); static void ivas_write_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, BSTR_ENC_HANDLE hMetaData, int16_t *num_dmx, int16_t *num_dec, const int16_t num_bands ); -static void ivas_quant_p_per_band( ivas_band_coeffs_t *pband_coeffs, ivas_band_coeffs_ind_t *pBand_coeffs_idx, ivas_quant_strat_t *pQs, const int16_t num_ch ); +static void ivas_quant_p_per_band( ivas_band_coeffs_t *pband_coeffs, ivas_band_coeffs_ind_t *pBand_coeffs_idx, ivas_quant_strat_t *pQs, const int16_t nchan ); static void ivas_quant_c_per_band( ivas_band_coeffs_t *pband_coeffs, ivas_band_coeffs_ind_t *pBand_coeffs_idx, ivas_quant_strat_t *pQs, const int16_t ndec, const int16_t ndm ); -static void ivas_quant_pred_coeffs_per_band( ivas_band_coeffs_t *pband_coeffs, ivas_band_coeffs_ind_t *pBand_coeffs_idx, ivas_quant_strat_t *pQs, const int16_t num_ch ); +static void ivas_quant_pred_coeffs_per_band( ivas_band_coeffs_t *pband_coeffs, ivas_band_coeffs_ind_t *pBand_coeffs_idx, ivas_quant_strat_t *pQs, const int16_t nchan ); /*------------------------------------------------------------------------- @@ -110,7 +110,7 @@ ivas_error ivas_spar_md_enc_open( { ivas_spar_md_enc_state_t *hMdEnc; ivas_error error; - int16_t num_channels, i, j; + int16_t nchan, i, j; error = IVAS_ERR_OK; @@ -119,23 +119,23 @@ ivas_error ivas_spar_md_enc_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD encoder" ); } - num_channels = 2 * sba_order + 2; + nchan = 2 * sba_order + 2; if ( ( hMdEnc->spar_md.band_coeffs = (ivas_band_coeffs_t *) count_malloc( IVAS_MAX_NUM_BANDS * sizeof( ivas_band_coeffs_t ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for band_coeffs in SPAR MD" ); } - if ( ( hMdEnc->mixer_mat = (float ***) count_malloc( num_channels * sizeof( float ** ) ) ) == NULL ) + if ( ( hMdEnc->mixer_mat = (float ***) count_malloc( nchan * sizeof( float ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - if ( ( hMdEnc->mixer_mat[i] = (float **) count_malloc( num_channels * sizeof( float * ) ) ) == NULL ) + if ( ( hMdEnc->mixer_mat[i] = (float **) count_malloc( nchan * sizeof( float * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( ( hMdEnc->mixer_mat[i][j] = (float *) count_malloc( IVAS_MAX_NUM_BANDS * sizeof( float ) ) ) == NULL ) { @@ -144,17 +144,17 @@ ivas_error ivas_spar_md_enc_open( } } - if ( ( hMdEnc->cov_real = (float ***) count_malloc( num_channels * sizeof( float ** ) ) ) == NULL ) + if ( ( hMdEnc->cov_real = (float ***) count_malloc( nchan * sizeof( float ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR cov real matrix" ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - if ( ( hMdEnc->cov_real[i] = (float **) count_malloc( num_channels * sizeof( float * ) ) ) == NULL ) + if ( ( hMdEnc->cov_real[i] = (float **) count_malloc( nchan * sizeof( float * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR cov real matrix" ); } - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( ( hMdEnc->cov_real[i][j] = (float *) count_malloc( IVAS_MAX_NUM_BANDS * sizeof( float ) ) ) == NULL ) { @@ -163,17 +163,17 @@ ivas_error ivas_spar_md_enc_open( } } - if ( ( hMdEnc->cov_dtx_real = (float ***) count_malloc( num_channels * sizeof( float ** ) ) ) == NULL ) + if ( ( hMdEnc->cov_dtx_real = (float ***) count_malloc( nchan * sizeof( float ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR cov dtx real matrix" ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - if ( ( hMdEnc->cov_dtx_real[i] = (float **) count_malloc( num_channels * sizeof( float * ) ) ) == NULL ) + if ( ( hMdEnc->cov_dtx_real[i] = (float **) count_malloc( nchan * sizeof( float * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR cov dtx real matrix" ); } - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( ( hMdEnc->cov_dtx_real[i][j] = (float *) count_malloc( IVAS_MAX_NUM_BANDS * sizeof( float ) ) ) == NULL ) { @@ -182,17 +182,17 @@ ivas_error ivas_spar_md_enc_open( } } - if ( ( hMdEnc->mixer_mat_local = (float ***) count_malloc( num_channels * sizeof( float ** ) ) ) == NULL ) + if ( ( hMdEnc->mixer_mat_local = (float ***) count_malloc( nchan * sizeof( float ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - if ( ( hMdEnc->mixer_mat_local[i] = (float **) count_malloc( num_channels * sizeof( float * ) ) ) == NULL ) + if ( ( hMdEnc->mixer_mat_local[i] = (float **) count_malloc( nchan * sizeof( float * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); } - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { if ( ( hMdEnc->mixer_mat_local[i][j] = (float *) count_malloc( IVAS_MAX_NUM_BANDS * sizeof( float ) ) ) == NULL ) { @@ -222,11 +222,11 @@ void ivas_spar_md_enc_close( ivas_spar_md_enc_state_t **hMdEnc_in /* i/o: SPAR MD encoder handle */ ) { - int16_t num_channels, i, j; + int16_t nchan, i, j; ivas_spar_md_enc_state_t *hMdEnc; hMdEnc = *hMdEnc_in; - num_channels = hMdEnc->num_umx_ch; + nchan = hMdEnc->num_umx_ch; if ( hMdEnc->spar_md.band_coeffs != NULL ) { @@ -235,9 +235,9 @@ void ivas_spar_md_enc_close( } if ( hMdEnc->mixer_mat != NULL ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { count_free( hMdEnc->mixer_mat[i][j] ); } @@ -248,10 +248,10 @@ void ivas_spar_md_enc_close( if ( hMdEnc->cov_real != NULL ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { count_free( hMdEnc->cov_real[i][j] ); } @@ -262,10 +262,10 @@ void ivas_spar_md_enc_close( if ( hMdEnc->cov_dtx_real != NULL ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { count_free( hMdEnc->cov_dtx_real[i][j] ); } @@ -276,10 +276,10 @@ void ivas_spar_md_enc_close( if ( hMdEnc->mixer_mat_local != NULL ) { - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { count_free( hMdEnc->mixer_mat_local[i][j] ); } @@ -313,9 +313,9 @@ static ivas_error ivas_spar_md_enc_init( float pFC[IVAS_MAX_NUM_BANDS]; int16_t table_idx; float PR_minmax[2]; - int16_t num_channels, i, j, k; + int16_t nchan, i, j, k; - num_channels = ivas_sba_get_nchan_metadata( sba_order ); + nchan = ivas_sba_get_nchan_metadata( sba_order ); table_idx = ivas_get_spar_table_idx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL ); @@ -328,7 +328,7 @@ static ivas_error ivas_spar_md_enc_init( pFC[i] = ivas_fb_fcs_12band_1ms[i] * hEncoderConfig->input_Fs * 0.5f; } - ivas_spar_set_enc_config( hMdEnc, hMdEnc->spar_md_cfg.max_freq_per_chan, hMdEnc->spar_md_cfg.nchan_transport, pFC, num_channels ); + ivas_spar_set_enc_config( hMdEnc, hMdEnc->spar_md_cfg.max_freq_per_chan, hMdEnc->spar_md_cfg.nchan_transport, pFC, nchan ); /* if(hMdEnc->spar_md_cfg.quant_strat[0].C.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].C.q_levels[1] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].PR.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].PR.q_levels[1] == 0 @@ -362,9 +362,9 @@ static ivas_error ivas_spar_md_enc_init( hMdEnc->spar_md_cfg.prior_strat = START; hMdEnc->spar_md_cfg.prev_quant_idx = -1; - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -373,9 +373,9 @@ static ivas_error ivas_spar_md_enc_init( } } - for ( i = 0; i < num_channels; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_channels; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { @@ -451,7 +451,7 @@ static ivas_error ivas_spar_set_enc_config( static void ivas_band_limit_dmx_matrix( ivas_spar_md_enc_state_t *hMdEnc, /* i/o: SPAR MD encoder handle */ - const int16_t num_ch, + const int16_t nchan, const int16_t num_bands, const int16_t bands_bw ) { @@ -461,9 +461,9 @@ static void ivas_band_limit_dmx_matrix( { ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; - for ( i = ndm; i < num_ch; i++ ) + for ( i = ndm; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { hMdEnc->mixer_mat[i][j][b] = 0; } @@ -482,7 +482,7 @@ static void ivas_band_limit_dmx_matrix( static void ivas_band_mixing( ivas_spar_md_enc_state_t *hMdEnc, /* i/o: SPAR MD encoder handle */ - const int16_t num_ch, + const int16_t nchan, const int16_t num_bands, const int16_t nchan_transport, const int16_t upmixed_bands ) @@ -494,7 +494,7 @@ static void ivas_band_mixing( for ( i = 0; i < nchan_transport; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = num_bands - 1; k >= 0; k-- ) { @@ -571,7 +571,7 @@ ivas_error ivas_spar_md_enc_process( float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; - int16_t i, b, qsi, ndm, ndec, num_ch, num_quant_strats; + int16_t i, b, qsi, ndm, ndec, nchan, num_quant_strats; int16_t j, planarCP; #ifdef SBA_SPAR_HARM int16_t k, bwidth, num_bands, num_bands_full, num_bands_bw; @@ -589,7 +589,7 @@ ivas_error ivas_spar_md_enc_process( float Wscale[IVAS_MAX_NUM_BANDS]; num_quant_strats = hMdEnc->spar_md_cfg.num_quant_strats; - num_ch = ivas_sba_get_nchan_metadata( sba_order ); + nchan = ivas_sba_get_nchan_metadata( sba_order ); active_w = hMdEnc->spar_md_cfg.active_w; nchan_transport = hMdEnc->spar_md_cfg.nchan_transport; @@ -660,9 +660,9 @@ ivas_error ivas_spar_md_enc_process( bands_bw = num_bands / nB; #ifdef SBA_SPAR_HARM - ivas_band_mixer( cov_real, num_ch, &num_bands, bands_bw ); + ivas_band_mixer( cov_real, nchan, &num_bands, bands_bw ); #else - ivas_band_mixer( pIn_buf->cov_real, num_ch, &num_bands, bands_bw ); + ivas_band_mixer( pIn_buf->cov_real, nchan, &num_bands, bands_bw ); #endif } else @@ -672,16 +672,16 @@ ivas_error ivas_spar_md_enc_process( } #ifdef SBA_SPAR_HARM - ivas_compute_spar_params( cov_real, dm_fv_re, 0, hMdEnc->mixer_mat, 0, nB, dtx_vad, num_ch, + ivas_compute_spar_params( cov_real, dm_fv_re, 0, hMdEnc->mixer_mat, 0, nB, dtx_vad, nchan, bands_bw, active_w, &hMdEnc->spar_md_cfg, &hMdEnc->spar_md, Wscale, 0 ); #else - ivas_compute_spar_params( pIn_buf->cov_real, dm_fv_re, 0, hMdEnc->mixer_mat, 0, nB, dtx_vad, num_ch, + ivas_compute_spar_params( pIn_buf->cov_real, dm_fv_re, 0, hMdEnc->mixer_mat, 0, nB, dtx_vad, nchan, bands_bw, active_w, &hMdEnc->spar_md_cfg, &hMdEnc->spar_md, Wscale, 0 ); #endif - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( b = 0; b < num_bands; b++ ) { @@ -722,12 +722,12 @@ ivas_error ivas_spar_md_enc_process( { ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; - if ( ndm != num_ch ) + if ( ndm != nchan ) { #ifdef SBA_SPAR_HARM - ivas_calc_c_p_coeffs( &hMdEnc->spar_md, cov_real, 0, hMdEnc->mixer_mat_local, num_ch, ndm, b, dtx_vad, 1, planarCP ); + ivas_calc_c_p_coeffs( &hMdEnc->spar_md, cov_real, 0, hMdEnc->mixer_mat_local, nchan, ndm, b, dtx_vad, 1, planarCP ); #else - ivas_calc_c_p_coeffs( &hMdEnc->spar_md, pIn_buf->cov_real, 0, hMdEnc->mixer_mat_local, num_ch, ndm, b, dtx_vad, 1, planarCP ); + ivas_calc_c_p_coeffs( &hMdEnc->spar_md, pIn_buf->cov_real, 0, hMdEnc->mixer_mat_local, nchan, ndm, b, dtx_vad, 1, planarCP ); #endif } } @@ -739,7 +739,7 @@ ivas_error ivas_spar_md_enc_process( if ( dtx_vad == 1 ) { - if ( ndm != num_ch ) + if ( ndm != nchan ) { #ifdef SPAR_HOA_DBG /* fprintf(stderr, "\n\n P coefficients: band %d\n", b); @@ -779,27 +779,27 @@ ivas_error ivas_spar_md_enc_process( #endif } - ivas_quant_p_per_band( &hMdEnc->spar_md.band_coeffs[b], &hMdEnc->spar_md.band_coeffs_idx[b], &hMdEnc->spar_md_cfg.quant_strat[qsi], num_ch ); + ivas_quant_p_per_band( &hMdEnc->spar_md.band_coeffs[b], &hMdEnc->spar_md.band_coeffs_idx[b], &hMdEnc->spar_md_cfg.quant_strat[qsi], nchan ); } - ivas_quant_pred_coeffs_per_band( &hMdEnc->spar_md.band_coeffs[b], &hMdEnc->spar_md.band_coeffs_idx[b], &hMdEnc->spar_md_cfg.quant_strat[qsi], num_ch ); + ivas_quant_pred_coeffs_per_band( &hMdEnc->spar_md.band_coeffs[b], &hMdEnc->spar_md.band_coeffs_idx[b], &hMdEnc->spar_md_cfg.quant_strat[qsi], nchan ); } else { - if ( ndm != num_ch ) + if ( ndm != nchan ) { - ivas_quant_p_per_band_dtx( hMdEnc->spar_md.band_coeffs[b].P_re, ndec, ndm, &hMdEnc->spar_md.band_coeffs_idx[b].decd_index_re[0], hMdEnc->spar_md.band_coeffs[b].P_quant_re, num_ch ); + ivas_quant_p_per_band_dtx( hMdEnc->spar_md.band_coeffs[b].P_re, ndec, ndm, &hMdEnc->spar_md.band_coeffs_idx[b].decd_index_re[0], hMdEnc->spar_md.band_coeffs[b].P_quant_re, nchan ); } - for ( i = 0; i < num_ch - 1; i++ ) + for ( i = 0; i < nchan - 1; i++ ) { hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i] = 0; } - ivas_spar_quant_pred_coeffs_dtx( &hMdEnc->spar_md, hMdEnc->spar_md.band_coeffs[b].pred_re, ndm, hMdEnc->spar_md.band_coeffs_idx[b].pred_index_re, num_ch - 1, hMdEnc->spar_md.band_coeffs[b].pred_quant_re ); + ivas_spar_quant_pred_coeffs_dtx( &hMdEnc->spar_md, hMdEnc->spar_md.band_coeffs[b].pred_re, ndm, hMdEnc->spar_md.band_coeffs_idx[b].pred_index_re, nchan - 1, hMdEnc->spar_md.band_coeffs[b].pred_quant_re ); } } - for ( i = 0; i < num_ch - 1; i++ ) + for ( i = 0; i < nchan - 1; i++ ) { for ( b = 0; b < num_bands; b++ ) { @@ -807,29 +807,29 @@ ivas_error ivas_spar_md_enc_process( } } - ivas_create_fullr_dmx_mat( pred_coeffs_re, dm_fv_re, hMdEnc->mixer_mat, num_ch, 0, num_bands, active_w, &hMdEnc->spar_md_cfg ); + ivas_create_fullr_dmx_mat( pred_coeffs_re, dm_fv_re, hMdEnc->mixer_mat, nchan, 0, num_bands, active_w, &hMdEnc->spar_md_cfg ); for ( b = 0; b < num_bands; b++ ) { ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; ndec = hMdEnc->spar_md_cfg.num_decorr_per_band[b * bands_bw]; - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { hMdEnc->mixer_mat[0][i][b] *= Wscale[b]; } - if ( ( ndm != num_ch ) && ( ndm != 1 ) ) + if ( ( ndm != nchan ) && ( ndm != 1 ) ) { #ifdef SBA_SPAR_HARM - ivas_calc_c_p_coeffs( &hMdEnc->spar_md, cov_real, 0, hMdEnc->mixer_mat, num_ch, ndm, b, dtx_vad, 0, planarCP ); + ivas_calc_c_p_coeffs( &hMdEnc->spar_md, cov_real, 0, hMdEnc->mixer_mat, nchan, ndm, b, dtx_vad, 0, planarCP ); #else - ivas_calc_c_p_coeffs( &hMdEnc->spar_md, pIn_buf->cov_real, 0, hMdEnc->mixer_mat, num_ch, ndm, b, dtx_vad, 0, planarCP ); + ivas_calc_c_p_coeffs( &hMdEnc->spar_md, pIn_buf->cov_real, 0, hMdEnc->mixer_mat, nchan, ndm, b, dtx_vad, 0, planarCP ); #endif #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n C coefficients: band %d\n", b); - for (i = 0; i < num_ch - ndm; i++) + for (i = 0; i < nchan - ndm; i++) { for (j = 0; j < ndm - 1; j++) { @@ -841,7 +841,7 @@ ivas_error ivas_spar_md_enc_process( #endif if ( planarCP ) { - for ( i = 0; i < num_ch - ndm; i++ ) + for ( i = 0; i < nchan - ndm; i++ ) { if ( !keep_planar[i] ) { @@ -854,7 +854,7 @@ ivas_error ivas_spar_md_enc_process( #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n Planar C coefficients: band %d\n", b); - for (i = 0; i < num_ch - ndm; i++) + for (i = 0; i < nchan - ndm; i++) { for (j = 0; j < ndm - 1; j++) { @@ -881,15 +881,15 @@ ivas_error ivas_spar_md_enc_process( } /* band limit downmix matrix */ - ivas_band_limit_dmx_matrix( hMdEnc, num_ch, num_bands, bands_bw ); + ivas_band_limit_dmx_matrix( hMdEnc, nchan, num_bands, bands_bw ); /* band mixing */ if ( bands_bw > 1 ) { #ifdef SBA_SPAR_HARM - ivas_band_mixing( hMdEnc, num_ch, num_bands, nchan_transport, num_bands_full ); + ivas_band_mixing( hMdEnc, nchan, num_bands, nchan_transport, num_bands_full ); #else - ivas_band_mixing( hMdEnc, num_ch, num_bands, nchan_transport, pIn_buf->num_bands ); + ivas_band_mixing( hMdEnc, nchan, num_bands, nchan_transport, pIn_buf->num_bands ); #endif } @@ -950,7 +950,7 @@ ivas_error ivas_spar_md_enc_process( { b = 0; fprintf( stdout, "\n\nMETADATA PR: band %d, qsi %d\n\n", b, qsi ); - for ( i = 0; i < num_ch - 1; i++ ) + for ( i = 0; i < nchan - 1; i++ ) { fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, //hMdEnc->spar_md.band_coeffs[b].pred_re[i], hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i], @@ -971,7 +971,7 @@ ivas_error ivas_spar_md_enc_process( } } fprintf( stdout, "\n\n METADATA Pd: band %d\n\n", b ); - for ( i = 0; i < num_ch - ndm; i++ ) + for ( i = 0; i < nchan - ndm; i++ ) { fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, //hMdEnc->spar_md.band_coeffs[b].P_re[i][i], hMdEnc->spar_md.band_coeffs[b].P_quant_re[i][i], @@ -985,10 +985,10 @@ ivas_error ivas_spar_md_enc_process( ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; fprintf( stdout, "\n\n Metadata PR (15x1), C(15x15), P(15x15): band %d\n", b ); - for ( i = 0; i < num_ch - 1; i++ ) + for ( i = 0; i < nchan - 1; i++ ) { fprintf( stdout, "i: %d -- %.2f\t|\t", i, hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i] ); - if ( i < num_ch - ndm ) + if ( i < nchan - ndm ) { if ( keep_planar[i] == 1 ) { @@ -1003,7 +1003,7 @@ ivas_error ivas_spar_md_enc_process( fprintf( stdout, "%.2f\t", hMdEnc->spar_md.band_coeffs[b].C_quant_re[i][j] ); } fprintf( stdout, "|\t" ); - for ( j = 0; j < num_ch - ndm; j++ ) + for ( j = 0; j < nchan - ndm; j++ ) { fprintf( stdout, "%.2f\t", hMdEnc->spar_md.band_coeffs[b].P_quant_re[j] ); } @@ -1035,12 +1035,12 @@ ivas_error ivas_spar_md_enc_process( { sprintf( f_name, "spar_band_pred_coeffs.bin" ); ( b == 0 && frame == 0 ) ? dbgwrite( &nB, sizeof( nB ), 1, 1, f_name ) : false; - num_elements = num_ch - 1; + num_elements = nchan - 1; ( b == 0 && frame == 0 ) ? dbgwrite( &num_elements, sizeof( num_elements ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_subframes, sizeof( num_subframes ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_block_groups, sizeof( num_block_groups ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &byte_size, sizeof( byte_size ), 1, 1, f_name ) : false; - for ( i = 0; i < num_ch - 1; i++ ) + for ( i = 0; i < nchan - 1; i++ ) { dbgwrite( &hMdEnc->spar_md.band_coeffs[b].pred_re[i], sizeof( float ), 1, 1, f_name ); } @@ -1060,23 +1060,23 @@ ivas_error ivas_spar_md_enc_process( } sprintf( f_name, "spar_band_P_coeffs.bin" ); ( b == 0 && frame == 0 ) ? dbgwrite( &nB, sizeof( nB ), 1, 1, f_name ) : false; - num_elements = num_ch - ndm; + num_elements = nchan - ndm; ( b == 0 && frame == 0 ) ? dbgwrite( &num_elements, sizeof( num_elements ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_subframes, sizeof( num_subframes ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_block_groups, sizeof( num_block_groups ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &byte_size, sizeof( byte_size ), 1, 1, f_name ) : false; - for ( i = 0; i < num_ch - ndm; i++ ) + for ( i = 0; i < nchan - ndm; i++ ) { dbgwrite( &hMdEnc->spar_md.band_coeffs[b].P_re[i], sizeof( float ), 1, 1, f_name ); } sprintf( f_name, "spar_band_pred_coeffs_quant.bin" ); ( b == 0 && frame == 0 ) ? dbgwrite( &nB, sizeof( nB ), 1, 1, f_name ) : false; - num_elements = num_ch - 1; + num_elements = nchan - 1; ( b == 0 && frame == 0 ) ? dbgwrite( &num_elements, sizeof( num_elements ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_subframes, sizeof( num_subframes ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_block_groups, sizeof( num_block_groups ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &byte_size, sizeof( byte_size ), 1, 1, f_name ) : false; - for ( i = 0; i < num_ch - 1; i++ ) + for ( i = 0; i < nchan - 1; i++ ) { dbgwrite( &hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i], sizeof( float ), 1, 1, f_name ); } @@ -1096,12 +1096,12 @@ ivas_error ivas_spar_md_enc_process( } sprintf( f_name, "spar_band_P_coeffs_quant.bin" ); ( b == 0 && frame == 0 ) ? dbgwrite( &nB, sizeof( nB ), 1, 1, f_name ) : false; - num_elements = num_ch - ndm; + num_elements = nchan - ndm; ( b == 0 && frame == 0 ) ? dbgwrite( &num_elements, sizeof( num_elements ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_subframes, sizeof( num_subframes ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &num_block_groups, sizeof( num_block_groups ), 1, 1, f_name ) : false; ( b == 0 && frame == 0 ) ? dbgwrite( &byte_size, sizeof( byte_size ), 1, 1, f_name ) : false; - for ( i = 0; i < num_ch - ndm; i++ ) + for ( i = 0; i < nchan - ndm; i++ ) { dbgwrite( &hMdEnc->spar_md.band_coeffs[b].P_quant_re[i], sizeof( float ), 1, 1, f_name ); } @@ -1136,7 +1136,7 @@ ivas_error ivas_spar_md_enc_process( static void ivas_band_mixer( float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], - const int16_t num_ch, + const int16_t nchan, int16_t *num_bands, int16_t red_band_fact ) { @@ -1147,9 +1147,9 @@ static void ivas_band_mixer( *num_bands /= red_band_fact; rem_band = orig_band - ( *num_bands * red_band_fact ); - for ( i = 0; i < num_ch; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < num_ch; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( k = 0; k < *num_bands - 1; k++ ) { @@ -1608,11 +1608,11 @@ static void ivas_quant_p_per_band_dtx( const int16_t num_dmx, int16_t *ppIdx_pd, float *pP_out, - const int16_t num_ch ) + const int16_t nchan ) { int16_t i; - int16_t dim = num_ch - num_dmx; - if ( num_dec == num_ch - 1 ) + int16_t dim = nchan - num_dmx; + if ( num_dec == nchan - 1 ) { for ( i = 0; i < dim; i++ ) { @@ -1629,7 +1629,7 @@ static void ivas_quant_p_per_band_dtx( } for ( i = 0; i < dim; i++ ) { - ivas_quantise_real_values( &pP_mat[i], dtx_pd_real_q_levels[num_ch - num_dec - 1][i], dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], &ppIdx_pd[i], &pP_out[i], 1 ); + ivas_quantise_real_values( &pP_mat[i], dtx_pd_real_q_levels[nchan - num_dec - 1][i], dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], &ppIdx_pd[i], &pP_out[i], 1 ); } return; } @@ -1758,9 +1758,9 @@ static void ivas_quant_pred_coeffs_per_band( ivas_band_coeffs_t *pband_coeffs, ivas_band_coeffs_ind_t *pBand_coeffs_idx, ivas_quant_strat_t *pQs, - const int16_t num_ch ) + const int16_t nchan ) { - ivas_quantise_real_values( pband_coeffs->pred_re, pQs->PR.q_levels[0], pQs->PR.min, pQs->PR.max, pBand_coeffs_idx->pred_index_re, pband_coeffs->pred_quant_re, ( num_ch - 1 ) ); + ivas_quantise_real_values( pband_coeffs->pred_re, pQs->PR.q_levels[0], pQs->PR.min, pQs->PR.max, pBand_coeffs_idx->pred_index_re, pband_coeffs->pred_quant_re, ( nchan - 1 ) ); return; } @@ -1836,7 +1836,7 @@ static void ivas_quant_p_per_band( ivas_band_coeffs_t *pband_coeffs, ivas_band_coeffs_ind_t *pBand_coeffs_idx, ivas_quant_strat_t *pQs, - const int16_t num_ch ) + const int16_t nchan ) { #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n P_d:\n"); @@ -1846,6 +1846,6 @@ static void ivas_quant_p_per_band( } fprintf(stderr, "\n\n");*/ #endif - ivas_quantise_real_values( pband_coeffs->P_re, pQs->P_r.q_levels[0], pQs->P_r.min, pQs->P_r.max, pBand_coeffs_idx->decd_index_re, pband_coeffs->P_quant_re, num_ch - 1 ); + ivas_quantise_real_values( pband_coeffs->P_re, pQs->P_r.q_levels[0], pQs->P_r.min, pQs->P_r.max, pBand_coeffs_idx->decd_index_re, pband_coeffs->P_quant_re, nchan - 1 ); return; } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index a4e8e1142a..d13da5794a 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -634,7 +634,7 @@ typedef struct ivas_enc_cov_handler_in_buf_t { float *ppIn_FR_real[IVAS_SPAR_MAX_CH]; float *ppIn_FR_imag[IVAS_SPAR_MAX_CH]; - int16_t num_ch; + int16_t nchan; int16_t transient_det; int16_t dtx_cov_flag; diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c index d993405b11..ee73254126 100644 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c +++ b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c @@ -181,47 +181,47 @@ const char *ivas_crend_map_in_fmt( int16_t ivas_get_num_channels( const int16_t ch_format ) { - int16_t num_channels = 0; + int16_t nchan = 0; switch ( ch_format ) { case MONO_1: - num_channels = 1; + nchan = 1; break; case BIN_2: case STEREO_2: - num_channels = 2; + nchan = 2; break; case FOA_4: - num_channels = FOA_CHANNELS; + nchan = FOA_CHANNELS; break; case MULT_CH_5_1: - num_channels = 6; + nchan = 6; break; case MULT_CH_7_1: - num_channels = 8; + nchan = 8; break; case HOA_9: - num_channels = 9; + nchan = 9; break; case HOA_16: - num_channels = 16; + nchan = 16; break; case OBA: - num_channels = 8; + nchan = 8; break; case MULT_CH_5_1_2: - num_channels = 8; + nchan = 8; break; case MULT_CH_7_1_4: - num_channels = 12; + nchan = 12; break; default: assert( !"Not supported Input format for Common Renderer!" ); break; } - return num_channels; + return nchan; } static ivas_result_t ivas_crend_mixer( -- GitLab From 597532f1fc409338ae5465b1e97f55b4ee55ea85 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Oct 2022 13:19:47 +0200 Subject: [PATCH 2/7] harmonize 'nchan' terminology --- lib_com/ivas_prot.h | 2 +- lib_dec/ivas_binauralRenderer.c | 70 ++++---- lib_dec/ivas_out_setup_conversion.c | 260 ++++++++++++++-------------- lib_dec/ivas_rotation.c | 27 ++- lib_dec/ivas_spar_decoder.c | 10 +- lib_dec/ivas_stat_dec.h | 2 +- lib_enc/ivas_spar_encoder.c | 14 +- 7 files changed, 191 insertions(+), 194 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 7e280a082f..77a90ae84c 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4594,7 +4594,7 @@ void rotateFrame_shd_cldfb( float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */ float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t nInChannels, /* i : number of channels */ + const int16_t nchan_inp, /* i : number of channels */ const int16_t shd_rot_max_order /* i : split-order rotation method */ ); diff --git a/lib_dec/ivas_binauralRenderer.c b/lib_dec/ivas_binauralRenderer.c index 45108a92fa..89626b7523 100644 --- a/lib_dec/ivas_binauralRenderer.c +++ b/lib_dec/ivas_binauralRenderer.c @@ -66,7 +66,7 @@ static void ivas_binRenderer_filterModule( for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + for ( chIdx = 0; chIdx < hBinRenderer->nchan_inp; chIdx++ ) { filterStatesLeftRealPtr = (float *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx][0] ); filterStatesLeftImagPtr = (float *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx][0] ); @@ -140,11 +140,11 @@ static ivas_error ivas_binRenderer_convModuleOpen( if ( !isLoudspeaker ) { - hBinRenderer->nInChannels = 16; + hBinRenderer->nchan_inp = 16; } else { - hBinRenderer->nInChannels = ( audioCfg2channels( input_config ) - isLoudspeaker ); // TODO maybe an audioCfg2channels_woLFE() function? Works as long as only 1 LFE is present + hBinRenderer->nchan_inp = ( audioCfg2channels( input_config ) - isLoudspeaker ); // TODO maybe an audioCfg2channels_woLFE() function? Works as long as only 1 LFE is present } if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && hRenderConfig->roomAcoustics.use_brir ) @@ -209,22 +209,22 @@ static ivas_error ivas_binRenderer_convModuleOpen( for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - if ( ( hBinRenConvModule->filterTapsLeftReal[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterTapsLeftReal[bandIdx] = (float **) count_malloc( hBinRenderer->nchan_inp * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterTapsLeftImag[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterTapsLeftImag[bandIdx] = (float **) count_malloc( hBinRenderer->nchan_inp * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterTapsRightReal[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterTapsRightReal[bandIdx] = (float **) count_malloc( hBinRenderer->nchan_inp * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterTapsRightImag[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterTapsRightImag[bandIdx] = (float **) count_malloc( hBinRenderer->nchan_inp * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } @@ -242,17 +242,17 @@ static ivas_error ivas_binRenderer_convModuleOpen( for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - if ( ( hBinRenConvModule->filterStatesLeftReal[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftReal[bandIdx] = (float **) count_malloc( hBinRenderer->nchan_inp * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag[bandIdx] = (float **) count_malloc( hBinRenderer->nchan_inp * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + for ( chIdx = 0; chIdx < hBinRenderer->nchan_inp; chIdx++ ) { if ( ( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx] = (float *) count_malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( float ) ) ) == NULL ) { @@ -269,7 +269,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set memories */ for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + for ( chIdx = 0; chIdx < hBinRenderer->nchan_inp; chIdx++ ) { int16_t tmp = 0; @@ -369,7 +369,7 @@ static void ivas_binaural_obtain_DMX( float realDMX[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float imagDMX[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) { - int16_t chIdx, bandIdx, k; + int16_t ch_in, bandIdx, k; // ToDo: hBinRenderer->ivas_format is never set to ISM_FORMAT -> TBV if ( hBinRenderer->ivas_format == MC_FORMAT || hBinRenderer->ivas_format == ISM_FORMAT ) @@ -377,34 +377,34 @@ static void ivas_binaural_obtain_DMX( /* Obtain the downmix */ float P_in[CLDFB_NO_CHANNELS_MAX]; float P_out, factEQ; - int16_t chOutIdx; + int16_t ch_out; float temp1, temp2; for ( k = 0; k < numTimeSlots; k++ ) { - for ( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) + for ( ch_out = 0; ch_out < BINAURAL_CHANNELS; ch_out++ ) { - set_zero( realDMX[chOutIdx][k], CLDFB_NO_CHANNELS_MAX ); - set_zero( imagDMX[chOutIdx][k], CLDFB_NO_CHANNELS_MAX ); + set_zero( realDMX[ch_out][k], CLDFB_NO_CHANNELS_MAX ); + set_zero( imagDMX[ch_out][k], CLDFB_NO_CHANNELS_MAX ); } } - for ( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) + for ( ch_out = 0; ch_out < BINAURAL_CHANNELS; ch_out++ ) { set_zero( P_in, hBinRenderer->conv_band ); - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + for ( ch_in = 0; ch_in < hBinRenderer->nchan_inp; ch_in++ ) { - float dmxConst = hBinRenderer->hReverb->dmxmtx[chOutIdx][chIdx]; + float dmxConst = hBinRenderer->hReverb->dmxmtx[ch_out][ch_in]; for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { for ( k = 0; k < numTimeSlots; k++ ) { - temp1 = RealBuffer[chIdx][k][bandIdx] * dmxConst; - temp2 = ImagBuffer[chIdx][k][bandIdx] * dmxConst; - realDMX[chOutIdx][k][bandIdx] += temp1; - imagDMX[chOutIdx][k][bandIdx] += temp2; + temp1 = RealBuffer[ch_in][k][bandIdx] * dmxConst; + temp2 = ImagBuffer[ch_in][k][bandIdx] * dmxConst; + realDMX[ch_out][k][bandIdx] += temp1; + imagDMX[ch_out][k][bandIdx] += temp2; P_in[bandIdx] += temp1 * temp1 + temp2 * temp2; } @@ -416,8 +416,8 @@ static void ivas_binaural_obtain_DMX( P_out = 0.f; for ( k = 0; k < numTimeSlots; k++ ) { - temp1 = realDMX[chOutIdx][k][bandIdx]; - temp2 = imagDMX[chOutIdx][k][bandIdx]; + temp1 = realDMX[ch_out][k][bandIdx]; + temp2 = imagDMX[ch_out][k][bandIdx]; P_out += temp1 * temp1 + temp2 * temp2; } factEQ = sqrtf( P_in[bandIdx] / ( P_out + 1e-20f ) ); @@ -429,8 +429,8 @@ static void ivas_binaural_obtain_DMX( factEQ = max( min( factEQ, 2.0f ), 0.5f ); for ( k = 0; k < numTimeSlots; k++ ) { - realDMX[chOutIdx][k][bandIdx] *= factEQ; - imagDMX[chOutIdx][k][bandIdx] *= factEQ; + realDMX[ch_out][k][bandIdx] *= factEQ; + imagDMX[ch_out][k][bandIdx] *= factEQ; } } } @@ -452,12 +452,12 @@ static void ivas_binaural_obtain_DMX( set_zero( outRealRightPtr, CLDFB_NO_CHANNELS_MAX ); set_zero( outImagRightPtr, CLDFB_NO_CHANNELS_MAX ); - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + for ( ch_in = 0; ch_in < hBinRenderer->nchan_inp; ch_in++ ) { - float foa_const = hBinRenderer->hReverb->foa_enc[chIdx][1]; + float foa_const = hBinRenderer->hReverb->foa_enc[ch_in][1]; - inRealPtr = (float *) &( RealBuffer[chIdx][k][0] ); - inImagPtr = (float *) &( ImagBuffer[chIdx][k][0] ); + inRealPtr = (float *) &( RealBuffer[ch_in][k][0] ); + inImagPtr = (float *) &( ImagBuffer[ch_in][k][0] ); for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -588,7 +588,7 @@ ivas_error ivas_binRenderer_open( /* initialize the dmx matrix */ for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - for ( k = 0; k < hBinRenderer->nInChannels; k++ ) + for ( k = 0; k < hBinRenderer->nchan_inp; k++ ) { hBinRenderer->hReverb->dmxmtx[chIdx][k] = dmxmtx[chIdx][k]; } @@ -679,7 +679,7 @@ static void ivas_binRenderer_convModuleClose( for ( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) { - for ( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) + for ( chIdx = 0; chIdx < ( *hBinRenderer )->nchan_inp; chIdx++ ) { count_free( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx] ); hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx] = NULL; @@ -912,9 +912,9 @@ void ivas_binRenderer( } /* HOA decoding to CICP19 if needed*/ - if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && hBinRenderer->nInChannels != 16 ) + if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && hBinRenderer->nchan_inp != 16 ) { - ivas_sba2mc_cldfb( *( hBinRenderer->hInputSetup ), RealBuffer, ImagBuffer, hBinRenderer->nInChannels, hBinRenderer->conv_band, hBinRenderer->hoa_dec_mtx ); + ivas_sba2mc_cldfb( *( hBinRenderer->hInputSetup ), RealBuffer, ImagBuffer, hBinRenderer->nchan_inp, hBinRenderer->conv_band, hBinRenderer->hoa_dec_mtx ); } ivas_binRenderer_filterModule( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, RealBuffer, ImagBuffer, hBinRenderer ); diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 2a02fb56e9..10436882cb 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -307,10 +307,9 @@ ivas_error ivas_ls_setup_conversion_open( ) { LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; - int16_t chIdx, inChannels, outChannels; + int16_t chIdx, nchan_inp, nchan_out; int16_t output_frame; int32_t output_Fs; - int16_t nchan_out; output_Fs = st_ivas->hDecoderConfig->output_Fs; nchan_out = st_ivas->hDecoderConfig->nchan_out; @@ -324,12 +323,11 @@ ivas_error ivas_ls_setup_conversion_open( assert( nchan_out <= MAX_OUTPUT_CHANNELS ); - outChannels = nchan_out; if ( st_ivas->renderer_type == RENDERER_MC_PARAMMC ) { - inChannels = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + nchan_inp = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; hLsSetUpConversion->sfbCnt = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); - for ( chIdx = 0; chIdx < outChannels; chIdx++ ) + for ( chIdx = 0; chIdx < nchan_out; chIdx++ ) { hLsSetUpConversion->targetEnergyPrev[chIdx] = (float *) count_malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( float ) ); hLsSetUpConversion->dmxEnergyPrev[chIdx] = (float *) count_malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( float ) ); @@ -344,7 +342,7 @@ ivas_error ivas_ls_setup_conversion_open( } else { - inChannels = st_ivas->nchan_transport; + nchan_inp = st_ivas->nchan_transport; /*Initialization of MDCT bands with TCX20 resolution */ ivas_lssetupconversion_mdct_init_bands( output_frame, TCX_20_CORE, &hLsSetUpConversion->sfbOffset[0], &hLsSetUpConversion->sfbCnt ); hLsSetUpConversion->targetEnergyPrev[0] = (float *) count_malloc( ( MAX_SFB + 2 ) * sizeof( float ) ); @@ -360,14 +358,14 @@ ivas_error ivas_ls_setup_conversion_open( /* Initialize the DMX conversion matrix */ - for ( chIdx = 0; chIdx < inChannels; chIdx++ ) + for ( chIdx = 0; chIdx < nchan_inp; chIdx++ ) { /* Allocate memory depending on the number of output channels */ - if ( ( hLsSetUpConversion->dmxMtx[chIdx] = (float *) count_malloc( outChannels * sizeof( float ) ) ) == NULL ) + if ( ( hLsSetUpConversion->dmxMtx[chIdx] = (float *) count_malloc( nchan_out * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for temp dmx matrix \n" ) ); } - set_zero( hLsSetUpConversion->dmxMtx[chIdx], outChannels ); + set_zero( hLsSetUpConversion->dmxMtx[chIdx], nchan_out ); } for ( ; chIdx < MAX_CICP_CHANNELS; chIdx++ ) @@ -455,7 +453,7 @@ void ivas_ls_setup_conversion( float output[][L_FRAME48k] /* i/o: LS input/output synthesis signal */ ) { - int16_t chInIdx, chOutIdx, idx; + int16_t ch_in, ch_out, idx; LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; float dmxCoeff, tmpVal; float output_tmp[MAX_OUTPUT_CHANNELS][L_FRAME48k]; @@ -464,12 +462,12 @@ void ivas_ls_setup_conversion( hLsSetUpConversion = st_ivas->hLsSetUpConversion; - for ( chOutIdx = 0; chOutIdx < st_ivas->hDecoderConfig->nchan_out; chOutIdx++ ) + for ( ch_out = 0; ch_out < st_ivas->hDecoderConfig->nchan_out; ch_out++ ) { - set_zero( output_tmp[chOutIdx], output_frame ); - for ( chInIdx = 0; chInIdx < st_ivas->nchan_transport; chInIdx++ ) + set_zero( output_tmp[ch_out], output_frame ); + for ( ch_in = 0; ch_in < st_ivas->nchan_transport; ch_in++ ) { - dmxCoeff = hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx]; + dmxCoeff = hLsSetUpConversion->dmxMtx[ch_in][ch_out]; if ( dmxCoeff == 0.f ) { @@ -479,24 +477,24 @@ void ivas_ls_setup_conversion( { for ( idx = 0; idx < output_frame; idx++ ) { - output_tmp[chOutIdx][idx] += output[chInIdx][idx]; + output_tmp[ch_out][idx] += output[ch_in][idx]; } } else { for ( idx = 0; idx < output_frame; idx++ ) { - tmpVal = dmxCoeff * output[chInIdx][idx]; - output_tmp[chOutIdx][idx] += tmpVal; + tmpVal = dmxCoeff * output[ch_in][idx]; + output_tmp[ch_out][idx] += tmpVal; } } } } /* Copy to output buffer */ - for ( chOutIdx = 0; chOutIdx < st_ivas->hDecoderConfig->nchan_out; chOutIdx++ ) + for ( ch_out = 0; ch_out < st_ivas->hDecoderConfig->nchan_out; ch_out++ ) { - mvr2r( output_tmp[chOutIdx], output[chOutIdx], output_frame ); + mvr2r( output_tmp[ch_out], output[ch_out], output_frame ); } wmops_sub_end(); @@ -517,8 +515,8 @@ void ivas_ls_setup_conversion_process_mdct( ) { /* Declaration of all required variables */ - int16_t i, bandIdx, chInIdx, chOutIdx, cpe_idx, subFrameIdx, binIdx, idx; - int16_t inChannels, outChannels, num_CPE; + int16_t i, bandIdx, ch_in, ch_out, cpe_idx, subFrameIdx, binIdx, idx; + int16_t nchan_in, nchan_out, num_CPE; int16_t transform_type[MAX_CICP_CHANNELS][2]; int16_t frameSize; float targetEnergy[MAX_SFB + 2], dmxEnergy[MAX_SFB + 2]; @@ -538,15 +536,15 @@ void ivas_ls_setup_conversion_process_mdct( wmops_sub_start( "LS_Renderer_MDCT" ); /* Assign all the declared variables */ - inChannels = st_ivas->nchan_transport; - outChannels = st_ivas->hDecoderConfig->nchan_out; + nchan_in = st_ivas->nchan_transport; + nchan_out = st_ivas->hDecoderConfig->nchan_out; num_CPE = st_ivas->nCPE; /* Assign output pointer to variable x */ - for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ ) + for ( ch_in = 0; ch_in < nchan_in; ch_in++ ) { - x[chInIdx][0] = &output[chInIdx][0]; - x[chInIdx][1] = &output[chInIdx][0] + L_FRAME48k / 2; + x[ch_in][0] = &output[ch_in][0]; + x[ch_in][1] = &output[ch_in][0] + L_FRAME48k / 2; } /* Assign all the declared handles*/ @@ -562,11 +560,11 @@ void ivas_ls_setup_conversion_process_mdct( for ( idx = 0; idx < CPE_CHANNELS; idx++ ) { /* get the channel index */ - chInIdx = cpe_idx * CPE_CHANNELS + idx; - assert( chInIdx <= inChannels ); - transform_type[chInIdx][0] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[0]; - transform_type[chInIdx][1] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[1]; - mct_chan_mode[chInIdx] = hCPE[cpe_idx]->hCoreCoder[idx]->mct_chan_mode; + ch_in = cpe_idx * CPE_CHANNELS + idx; + assert( ch_in <= nchan_in ); + transform_type[ch_in][0] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[0]; + transform_type[ch_in][1] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[1]; + mct_chan_mode[ch_in] = hCPE[cpe_idx]->hCoreCoder[idx]->mct_chan_mode; } } @@ -576,17 +574,17 @@ void ivas_ls_setup_conversion_process_mdct( set_zero( targetEnergy, MAX_SFB + 2 ); set_zero( dmxEnergy, MAX_SFB + 2 ); - for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { /* Step 0: Set the buffers to zero */ set_zero( dmxSignalReal, frameSize ); set_zero( dmxSignalImag, frameSize ); - for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ ) + for ( ch_in = 0; ch_in < nchan_in; ch_in++ ) { - dmxCoeff = hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx]; + dmxCoeff = hLsSetUpConversion->dmxMtx[ch_in][ch_out]; - if ( !( chInIdx == LFE_CHANNEL && st_ivas->hMCT->LFE_off ) && mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) + if ( !( ch_in == LFE_CHANNEL && st_ivas->hMCT->LFE_off ) && mct_chan_mode[ch_in] != MCT_CHAN_MODE_IGNORE ) { /* Step 1: Compute the target energy and DMX signal (possible since we have all signals in TCX20 resolution) */ if ( dmxCoeff ) @@ -595,19 +593,19 @@ void ivas_ls_setup_conversion_process_mdct( /* Convert the signal resolution to TCX20 */ /* initially, set pointers to input; if conversion occurs in (sub)frame, set to convertRes */ - sig[0] = pTmp[0] = x[chInIdx][0]; - sig[1] = pTmp[1] = x[chInIdx][1]; + sig[0] = pTmp[0] = x[ch_in][0]; + sig[1] = pTmp[1] = x[ch_in][1]; /* convert (sub)frames to higher frequency resolution */ - if ( transform_type[chInIdx][0] != TCX_20 ) + if ( transform_type[ch_in][0] != TCX_20 ) { for ( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ ) { - if ( transform_type[chInIdx][subFrameIdx] == TCX_5 ) + if ( transform_type[ch_in][subFrameIdx] == TCX_5 ) { /* subframe is TCX5, but TCX10 or TCX20 in other channel -> convert channel with TCX5 to TCX10 resolution */ pTmp[subFrameIdx] = sig[subFrameIdx] = convertRes + subFrameIdx * frameSize / 2; - convert_coeffs_to_higher_res( x[chInIdx][subFrameIdx], x[chInIdx][subFrameIdx] + frameSize / 4, pTmp[subFrameIdx], frameSize / 4 ); + convert_coeffs_to_higher_res( x[ch_in][subFrameIdx], x[ch_in][subFrameIdx] + frameSize / 4, pTmp[subFrameIdx], frameSize / 4 ); } } @@ -645,7 +643,7 @@ void ivas_ls_setup_conversion_process_mdct( } /* end of band loop */ } } - } /* end of chInIdx loop */ + } /* end of ch_in loop */ for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { @@ -677,11 +675,11 @@ void ivas_ls_setup_conversion_process_mdct( } /* Step 4: Perform equalization */ - for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ ) + for ( ch_in = 0; ch_in < nchan_in; ch_in++ ) { - if ( !( chInIdx == LFE_CHANNEL && st_ivas->hMCT->LFE_off ) && mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) + if ( !( ch_in == LFE_CHANNEL && st_ivas->hMCT->LFE_off ) && mct_chan_mode[ch_in] != MCT_CHAN_MODE_IGNORE ) { - if ( transform_type[chInIdx][0] == TCX_20 ) + if ( transform_type[ch_in][0] == TCX_20 ) { /* TCX20 */ for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) @@ -693,7 +691,7 @@ void ivas_ls_setup_conversion_process_mdct( ivas_lssetupconversion_computeEQFactor( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain ); for ( binIdx = start; binIdx < stop; binIdx++ ) { - x[chInIdx][0][binIdx] *= eqGain; + x[ch_in][0][binIdx] *= eqGain; } } } @@ -710,12 +708,12 @@ void ivas_ls_setup_conversion_process_mdct( for ( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ ) { - if ( transform_type[chInIdx][subFrameIdx] == TCX_10 ) + if ( transform_type[ch_in][subFrameIdx] == TCX_10 ) { /* TCX10 */ for ( binIdx = start; binIdx < stop; binIdx++ ) { - x[chInIdx][subFrameIdx][binIdx] *= eqGain; + x[ch_in][subFrameIdx][binIdx] *= eqGain; } } else @@ -726,8 +724,8 @@ void ivas_ls_setup_conversion_process_mdct( for ( binIdx = start_tcx5; binIdx < stop_tcx5; binIdx++ ) { - x[chInIdx][subFrameIdx][binIdx] *= eqGain; - x[chInIdx][subFrameIdx][binIdx + ( frameSize >> 2 )] *= eqGain; + x[ch_in][subFrameIdx][binIdx] *= eqGain; + x[ch_in][subFrameIdx][binIdx + ( frameSize >> 2 )] *= eqGain; } } } @@ -756,7 +754,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( int16_t i; int16_t idx; int16_t nchan_transport, nchan_out, nchan_transport_format; - int16_t chInIdx, chOutIdx, cpe_idx, subFrameIdx, binIdx; + int16_t ch_in, ch_out, cpe_idx, subFrameIdx, binIdx; int16_t band, bandIdx, num_bands; int16_t num_CPE; @@ -819,11 +817,11 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( for ( idx = 0; idx < CPE_CHANNELS; idx++ ) { /* get the channel index */ - chInIdx = cpe_idx * CPE_CHANNELS + idx; - assert( chInIdx <= nchan_transport ); - transform_type[chInIdx][0] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[0]; - transform_type[chInIdx][1] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[1]; - mct_chan_mode[chInIdx] = hCPE[cpe_idx]->hCoreCoder[idx]->mct_chan_mode; + ch_in = cpe_idx * CPE_CHANNELS + idx; + assert( ch_in <= nchan_transport ); + transform_type[ch_in][0] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[0]; + transform_type[ch_in][1] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[1]; + mct_chan_mode[ch_in] = hCPE[cpe_idx]->hCoreCoder[idx]->mct_chan_mode; } } @@ -833,43 +831,43 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( set_zero( targetEnergy, MAX_SFB + 2 ); set_zero( dmxEnergy, MAX_SFB + 2 ); - for ( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ ) + for ( ch_in = 0; ch_in < nchan_transport; ch_in++ ) { - if ( mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) + if ( mct_chan_mode[ch_in] != MCT_CHAN_MODE_IGNORE ) { /* initially, set pointers to input; if conversion occurs in (sub)frame, set to convertRes */ - sig[chInIdx][0] = pTmp[0] = x[chInIdx][0]; - sig[chInIdx][1] = pTmp[1] = x[chInIdx][1]; + sig[ch_in][0] = pTmp[0] = x[ch_in][0]; + sig[ch_in][1] = pTmp[1] = x[ch_in][1]; /* convert (sub)frames to higher frequency resolution */ - if ( transform_type[chInIdx][0] != TCX_20 ) + if ( transform_type[ch_in][0] != TCX_20 ) { for ( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ ) { - if ( transform_type[chInIdx][subFrameIdx] == TCX_5 ) + if ( transform_type[ch_in][subFrameIdx] == TCX_5 ) { /* subframe is TCX5, but TCX10 or TCX20 in other channel -> convert channel with TCX5 to TCX10 resolution */ - pTmp[subFrameIdx] = sig[chInIdx][subFrameIdx] = convertRes[chInIdx] + subFrameIdx * frameSize / 2; - convert_coeffs_to_higher_res( x[chInIdx][subFrameIdx], x[chInIdx][subFrameIdx] + frameSize / 4, pTmp[subFrameIdx], frameSize / 4 ); + pTmp[subFrameIdx] = sig[ch_in][subFrameIdx] = convertRes[ch_in] + subFrameIdx * frameSize / 2; + convert_coeffs_to_higher_res( x[ch_in][subFrameIdx], x[ch_in][subFrameIdx] + frameSize / 4, pTmp[subFrameIdx], frameSize / 4 ); } } /* convert channel with TCX10 to TCX20 resolution */ - sig[chInIdx][0] = convertRes[chInIdx]; - convert_coeffs_to_higher_res( pTmp[0], pTmp[1], sig[chInIdx][0], frameSize / 2 ); + sig[ch_in][0] = convertRes[ch_in]; + convert_coeffs_to_higher_res( pTmp[0], pTmp[1], sig[ch_in][0], frameSize / 2 ); } } } /* precalculate MDST estimate */ - for ( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ ) + for ( ch_in = 0; ch_in < nchan_transport; ch_in++ ) { - if ( mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) + if ( mct_chan_mode[ch_in] != MCT_CHAN_MODE_IGNORE ) { - mdst[chInIdx][0] = mdst[chInIdx][frameSize - 1] = 0.f; + mdst[ch_in][0] = mdst[ch_in][frameSize - 1] = 0.f; for ( i = 1; i < frameSize - 1; i++ ) { - mdst[chInIdx][i] = sig[chInIdx][0][i + 1] - sig[chInIdx][0][i - 1]; + mdst[ch_in][i] = sig[ch_in][0][i + 1] - sig[ch_in][0][i - 1]; } } } @@ -925,48 +923,48 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( /* Step 1.2, get target channel energies for the transported format as in ivas_param_mc_get_mono_stereo_mixing_matrices(), Nrqq calculation */ ild_q = hParamMC->icld_q + bandIdx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe; - for ( chInIdx = 0; chInIdx < nchan_transport_format; chInIdx++ ) + for ( ch_in = 0; ch_in < nchan_transport_format; ch_in++ ) { float ref_ener = 0.0f; int16_t ref_channel_cnt; int16_t ref_channel_idx; - for ( ref_channel_cnt = 0; ref_channel_cnt < hParamMC->hMetadataPMC->ild_mapping_conf->num_ref_channels[chInIdx]; ref_channel_cnt++ ) + for ( ref_channel_cnt = 0; ref_channel_cnt < hParamMC->hMetadataPMC->ild_mapping_conf->num_ref_channels[ch_in]; ref_channel_cnt++ ) { - ref_channel_idx = hParamMC->hMetadataPMC->ild_mapping_conf->ref_channel_idx[chInIdx][ref_channel_cnt]; + ref_channel_idx = hParamMC->hMetadataPMC->ild_mapping_conf->ref_channel_idx[ch_in][ref_channel_cnt]; ref_ener += cx[bandIdx][ref_channel_idx + ref_channel_idx * nchan_transport]; } - Nrqq[hParamMC->hMetadataPMC->ild_mapping_conf->ild_index[chInIdx]] = powf( 10.0f, ild_q[chInIdx] / 10.0f ) * hParamMC->hMetadataPMC->ild_factors[chInIdx] * ref_ener; + Nrqq[hParamMC->hMetadataPMC->ild_mapping_conf->ild_index[ch_in]] = powf( 10.0f, ild_q[ch_in] / 10.0f ) * hParamMC->hMetadataPMC->ild_factors[ch_in] * ref_ener; } /* Step 1.3 get target Cy like in ivas_param_mc_get_mono_stereo_mixing_matrices() (with dmx matrix from CICPX to MONO/STEREO saved in hParamMC) */ - for ( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { for ( i = 0; i < nchan_transport_format; i++ ) { - target_ch_ener[chOutIdx] += hParamMC->ls_conv_dmx_matrix[chOutIdx + i * nchan_out] * Nrqq[i]; + target_ch_ener[ch_out] += hParamMC->ls_conv_dmx_matrix[ch_out + i * nchan_out] * Nrqq[i]; } - cy[chOutIdx + nchan_out * chOutIdx] = target_ch_ener[chOutIdx]; + cy[ch_out + nchan_out * ch_out] = target_ch_ener[ch_out]; } /* Step 1.4 final target energy for the band would then be the sum over the diagonal of Cy*/ - for ( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - targetEnergy[bandIdx] += cy[chOutIdx + nchan_out * chOutIdx]; + targetEnergy[bandIdx] += cy[ch_out + nchan_out * ch_out]; } /* Step 2: Calculate DMX ener */ start = hLsSetUpConversion->sfbOffset[bandIdx]; stop = hLsSetUpConversion->sfbOffset[bandIdx + 1]; - for ( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - for ( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ ) + for ( ch_in = 0; ch_in < nchan_transport; ch_in++ ) { - if ( mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) + if ( mct_chan_mode[ch_in] != MCT_CHAN_MODE_IGNORE ) { - dmxCoeff = hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx]; + dmxCoeff = hLsSetUpConversion->dmxMtx[ch_in][ch_out]; /* Step 1: Compute the target energy and DMX signal (possible since we have all signals in TCX20 resolution) */ if ( dmxCoeff ) @@ -974,10 +972,10 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( /* Loop over all the bins in the band */ for ( binIdx = start; binIdx < stop; binIdx++ ) { - tmpDMXSig = dmxCoeff * sig[chInIdx][0][binIdx]; + tmpDMXSig = dmxCoeff * sig[ch_in][0][binIdx]; dmxSignalReal[binIdx] += tmpDMXSig; - tmpDMXSig = dmxCoeff * mdst[chInIdx][binIdx]; + tmpDMXSig = dmxCoeff * mdst[ch_in][binIdx]; dmxSignalImag[binIdx] += tmpDMXSig; } } @@ -1008,11 +1006,11 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( } /* Step 4: Perform equalization */ - for ( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ ) + for ( ch_in = 0; ch_in < nchan_transport; ch_in++ ) { - if ( mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) + if ( mct_chan_mode[ch_in] != MCT_CHAN_MODE_IGNORE ) { - if ( transform_type[chInIdx][0] == TCX_20 ) + if ( transform_type[ch_in][0] == TCX_20 ) { /*TCX20*/ for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) @@ -1024,7 +1022,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( ivas_lssetupconversion_computeEQFactor( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain ); for ( binIdx = start; binIdx < stop; binIdx++ ) { - x[chInIdx][0][binIdx] *= eqGain; + x[ch_in][0][binIdx] *= eqGain; } } } @@ -1041,12 +1039,12 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( for ( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ ) { - if ( transform_type[chInIdx][subFrameIdx] == TCX_10 ) + if ( transform_type[ch_in][subFrameIdx] == TCX_10 ) { /*TCX10*/ for ( binIdx = start; binIdx < stop; binIdx++ ) { - x[chInIdx][subFrameIdx][binIdx] *= eqGain; + x[ch_in][subFrameIdx][binIdx] *= eqGain; } } else @@ -1056,12 +1054,12 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( stop_tcx5 = ( stop + 1 ) / 2; for ( binIdx = start_tcx5; binIdx < stop_tcx5; binIdx++ ) { - x[chInIdx][subFrameIdx][binIdx] *= eqGain; + x[ch_in][subFrameIdx][binIdx] *= eqGain; } for ( binIdx = start_tcx5; binIdx < stop_tcx5; binIdx++ ) { - x[chInIdx][subFrameIdx][binIdx + ( frameSize >> 2 )] *= eqGain; + x[ch_in][subFrameIdx][binIdx + ( frameSize >> 2 )] *= eqGain; } } } @@ -1086,8 +1084,8 @@ void ivas_lssetupconversion_process_param_mc( int16_t channel_active[MAX_CICP_CHANNELS] /* i : bitmap indicating which output channels are active */ ) { - int16_t slotIdx, chOutIdx, chInIdx, bandIdx; - int16_t inChannels, outChannels; + int16_t slotIdx, ch_in, ch_out, bandIdx; + int16_t nchan_in, nchan_out; float targetEnergy[MAX_CICP_CHANNELS][CLDFB_NO_CHANNELS_MAX]; float dmxEnergy[MAX_CICP_CHANNELS][CLDFB_NO_CHANNELS_MAX]; float tmpDMXSig, dmxCoeff, tmpReal, tmpImag; @@ -1099,101 +1097,101 @@ void ivas_lssetupconversion_process_param_mc( wmops_sub_start( "LS_Renderer_Process_Param_MC" ); /* inits */ - inChannels = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; - outChannels = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + nchan_in = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + nchan_out = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; hLsSetUpConversion = st_ivas->hLsSetUpConversion; EQ = 0.0f; - set_s( channel_active, 0, outChannels ); + set_s( channel_active, 0, nchan_out ); /* Loop over each time slots and compute dmx for each time slot */ for ( slotIdx = 0; slotIdx < st_ivas->hParamMC->subframe_nbslots; slotIdx++ ) { /* copy buffers */ - for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ ) + for ( ch_in = 0; ch_in < nchan_in; ch_in++ ) { - mvr2r( Cldfb_RealBuffer_InOut[chInIdx][slotIdx], Cldfb_RealBuffer_tmp[chInIdx], CLDFB_NO_CHANNELS_MAX ); - mvr2r( Cldfb_ImagBuffer_InOut[chInIdx][slotIdx], Cldfb_ImagBuffer_tmp[chInIdx], CLDFB_NO_CHANNELS_MAX ); + mvr2r( Cldfb_RealBuffer_InOut[ch_in][slotIdx], Cldfb_RealBuffer_tmp[ch_in], CLDFB_NO_CHANNELS_MAX ); + mvr2r( Cldfb_ImagBuffer_InOut[ch_in][slotIdx], Cldfb_ImagBuffer_tmp[ch_in], CLDFB_NO_CHANNELS_MAX ); } /* set the buffers to zero */ - for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - set_f( Cldfb_RealBuffer_InOut[chOutIdx][slotIdx], 0.0f, CLDFB_NO_CHANNELS_MAX ); - set_f( Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx], 0.0f, CLDFB_NO_CHANNELS_MAX ); + set_f( Cldfb_RealBuffer_InOut[ch_out][slotIdx], 0.0f, CLDFB_NO_CHANNELS_MAX ); + set_f( Cldfb_ImagBuffer_InOut[ch_out][slotIdx], 0.0f, CLDFB_NO_CHANNELS_MAX ); - set_f( dmxEnergy[chOutIdx], 0.0f, CLDFB_NO_CHANNELS_MAX ); - set_f( targetEnergy[chOutIdx], 0.0f, CLDFB_NO_CHANNELS_MAX ); + set_f( dmxEnergy[ch_out], 0.0f, CLDFB_NO_CHANNELS_MAX ); + set_f( targetEnergy[ch_out], 0.0f, CLDFB_NO_CHANNELS_MAX ); } /* Compute the target energy and DMX signal */ - for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ ) + for ( ch_in = 0; ch_in < nchan_in; ch_in++ ) { - dmxCoeff = hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx]; + dmxCoeff = hLsSetUpConversion->dmxMtx[ch_in][ch_out]; if ( dmxCoeff == 0.0f ) { continue; } else { - channel_active[chOutIdx] |= 1; + channel_active[ch_out] |= 1; for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { - tmpDMXSig = dmxCoeff * Cldfb_RealBuffer_tmp[chInIdx][bandIdx]; - Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx] += tmpDMXSig; - targetEnergy[chOutIdx][bandIdx] += tmpDMXSig * tmpDMXSig; + tmpDMXSig = dmxCoeff * Cldfb_RealBuffer_tmp[ch_in][bandIdx]; + Cldfb_RealBuffer_InOut[ch_out][slotIdx][bandIdx] += tmpDMXSig; + targetEnergy[ch_out][bandIdx] += tmpDMXSig * tmpDMXSig; - tmpDMXSig = dmxCoeff * Cldfb_ImagBuffer_tmp[chInIdx][bandIdx]; - Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx] += tmpDMXSig; - targetEnergy[chOutIdx][bandIdx] += tmpDMXSig * tmpDMXSig; + tmpDMXSig = dmxCoeff * Cldfb_ImagBuffer_tmp[ch_in][bandIdx]; + Cldfb_ImagBuffer_InOut[ch_out][slotIdx][bandIdx] += tmpDMXSig; + targetEnergy[ch_out][bandIdx] += tmpDMXSig * tmpDMXSig; } } } } /* Compute the DMX energy */ - for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - if ( channel_active[chOutIdx] ) + if ( channel_active[ch_out] ) { for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { - tmpReal = Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx]; - tmpImag = Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx]; + tmpReal = Cldfb_RealBuffer_InOut[ch_out][slotIdx][bandIdx]; + tmpImag = Cldfb_ImagBuffer_InOut[ch_out][slotIdx][bandIdx]; - dmxEnergy[chOutIdx][bandIdx] = tmpReal * tmpReal + tmpImag * tmpImag; + dmxEnergy[ch_out][bandIdx] = tmpReal * tmpReal + tmpImag * tmpImag; } } } /* Peform energy smoothing */ - for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - if ( channel_active[chOutIdx] ) + if ( channel_active[ch_out] ) { for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { - targetEnergy[chOutIdx][bandIdx] = LS_OUT_CONV_SMOOTHING_FACTOR * targetEnergy[chOutIdx][bandIdx] + ( 1 - LS_OUT_CONV_SMOOTHING_FACTOR ) * hLsSetUpConversion->targetEnergyPrev[chOutIdx][bandIdx]; - dmxEnergy[chOutIdx][bandIdx] = LS_OUT_CONV_SMOOTHING_FACTOR * dmxEnergy[chOutIdx][bandIdx] + ( 1 - LS_OUT_CONV_SMOOTHING_FACTOR ) * hLsSetUpConversion->dmxEnergyPrev[chOutIdx][bandIdx]; - hLsSetUpConversion->targetEnergyPrev[chOutIdx][bandIdx] = targetEnergy[chOutIdx][bandIdx]; - hLsSetUpConversion->dmxEnergyPrev[chOutIdx][bandIdx] = dmxEnergy[chOutIdx][bandIdx]; + targetEnergy[ch_out][bandIdx] = LS_OUT_CONV_SMOOTHING_FACTOR * targetEnergy[ch_out][bandIdx] + ( 1 - LS_OUT_CONV_SMOOTHING_FACTOR ) * hLsSetUpConversion->targetEnergyPrev[ch_out][bandIdx]; + dmxEnergy[ch_out][bandIdx] = LS_OUT_CONV_SMOOTHING_FACTOR * dmxEnergy[ch_out][bandIdx] + ( 1 - LS_OUT_CONV_SMOOTHING_FACTOR ) * hLsSetUpConversion->dmxEnergyPrev[ch_out][bandIdx]; + hLsSetUpConversion->targetEnergyPrev[ch_out][bandIdx] = targetEnergy[ch_out][bandIdx]; + hLsSetUpConversion->dmxEnergyPrev[ch_out][bandIdx] = dmxEnergy[ch_out][bandIdx]; } } } /* Compute and perform equalization */ - for ( chOutIdx = 0; chOutIdx < outChannels; chOutIdx++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - if ( channel_active[chOutIdx] ) + if ( channel_active[ch_out] ) { for ( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { - ivas_lssetupconversion_computeEQFactor( &targetEnergy[chOutIdx][bandIdx], &dmxEnergy[chOutIdx][bandIdx], &EQ ); - Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx] *= EQ; - Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx] *= EQ; + ivas_lssetupconversion_computeEQFactor( &targetEnergy[ch_out][bandIdx], &dmxEnergy[ch_out][bandIdx], &EQ ); + Cldfb_RealBuffer_InOut[ch_out][slotIdx][bandIdx] *= EQ; + Cldfb_ImagBuffer_InOut[ch_out][slotIdx][bandIdx] *= EQ; } } } diff --git a/lib_dec/ivas_rotation.c b/lib_dec/ivas_rotation.c index 77809d8270..9e6cbca8c1 100644 --- a/lib_dec/ivas_rotation.c +++ b/lib_dec/ivas_rotation.c @@ -559,7 +559,7 @@ void rotateFrame_shd_cldfb( float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */ float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t nInChannels, /* i : number of channels */ + const int16_t nchan_inp, /* i : number of channels */ const int16_t shd_rot_max_order /* i : split-order rotation method */ ) { @@ -571,7 +571,7 @@ void rotateFrame_shd_cldfb( float realRot[2 * HEADROT_ORDER + 1], imagRot[2 * HEADROT_ORDER + 1]; float SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM]; - assert( nInChannels == HEADROT_SHMAT_DIM && "Number of channels must be 16!" ); + assert( nchan_inp == HEADROT_SHMAT_DIM && "Number of channels must be 16!" ); /* initialize rotation matrices with zeros */ for ( i = 0; i < HEADROT_SHMAT_DIM; i++ ) @@ -618,18 +618,18 @@ void rotateFrame_shd_cldfb( } /* unoptimized code for reference (full matrix multiplication) - for (n = 0; n < nInChannels; n++) + for (n = 0; n < nchan_inp; n++) { realRot[n] = 0.f; imagRot[n] = 0.f; - for (m = 0; m < nInChannels; m++) + for (m = 0; m < nchan_inp; m++) { realRot[n] += SHrotmat[n][m] * Cldfb_RealBuffer[m][i][iBand]; imagRot[n] += SHrotmat[n][m] * Cldfb_ImagBuffer[m][i][iBand]; } } - for (n = 0; n < nInChannels; n++) + for (n = 0; n < nchan_inp; n++) { Cldfb_RealBuffer[n][i][iBand] = realRot[n]; Cldfb_ImagBuffer[n][i][iBand] = imagRot[n]; @@ -666,14 +666,13 @@ void rotateFrame_sd_cldfb( float imagRot[MAX_CICP_CHANNELS - 1][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX]; float *p_realRot, *p_imagRot; float *p_real, *p_imag; - int16_t nInChannels; - int16_t isPlanar; + int16_t nchan_inp, isPlanar; wmops_sub_start( "rotateFrame_sd_cldfb" ); - nInChannels = hOutputSetup->nchan_out_woLFE; + nchan_inp = hOutputSetup->nchan_out_woLFE; isPlanar = 1; - for ( n = 0; n < nInChannels; n++ ) + for ( n = 0; n < nchan_inp; n++ ) { if ( hOutputSetup->ls_elevation[n] != 0 ) { @@ -686,7 +685,7 @@ void rotateFrame_sd_cldfb( QuatToRotMat( hHeadTrackData->Quaternions[hHeadTrackData->num_quaternions++], Rmat ); /* rotation of Euler angles */ - for ( n = 0; n < nInChannels; n++ ) + for ( n = 0; n < nchan_inp; n++ ) { rotateAziEle( hOutputSetup->ls_azimuth[n], hOutputSetup->ls_elevation[n], &azimuth, &elevation, Rmat, isPlanar ); if ( hEFAPdata != NULL && ( hOutputSetup->ls_azimuth[n] != azimuth || hOutputSetup->ls_elevation[n] != elevation ) ) @@ -695,17 +694,17 @@ void rotateFrame_sd_cldfb( } else { - set_zero( gains[n], nInChannels ); + set_zero( gains[n], nchan_inp ); gains[n][n] = 1.0f; } } /* Apply panning gains by mtx multiplication*/ - for ( n = 0; n < nInChannels; n++ ) + for ( n = 0; n < nchan_inp; n++ ) { set_zero( realRot[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_band ); set_zero( imagRot[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_band ); - for ( m = 0; m < nInChannels; m++ ) + for ( m = 0; m < nchan_inp; m++ ) { g1 = gains[m][n]; p_realRot = realRot[n]; @@ -728,7 +727,7 @@ void rotateFrame_sd_cldfb( } } - for ( n = 0; n < nInChannels; n++ ) + for ( n = 0; n < nchan_inp; n++ ) { p_realRot = realRot[n]; p_imagRot = imagRot[n]; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 8da866f194..27771a93d2 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1016,7 +1016,7 @@ void ivas_spar_dec_upmixer( *---------------------------------------------------------------------*/ /* set-up pointers */ - if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) + if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) { /* at this point, output channels are used as intermediate procesing buffers */ for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS; in_ch++ ) @@ -1076,7 +1076,7 @@ void ivas_spar_dec_upmixer( for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { /* determine SPAR parameters for this time slots */ - ivas_spar_get_parameters( hSpar, st_ivas->hDecoderConfig, ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES, nchan_out, nchan_inp, num_spar_bands, mixer_mat ); + ivas_spar_get_parameters( hSpar, hDecoderConfig, ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES, nchan_out, nchan_inp, num_spar_bands, mixer_mat ); for ( cldfb_band = 0; cldfb_band < num_cldfb_bands; cldfb_band++ ) { @@ -1125,7 +1125,7 @@ void ivas_spar_dec_upmixer( } } - if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) + if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) { ivas_dirac_dec( st_ivas, output, nchan_internal, cldfb_in_ts_re, cldfb_in_ts_im, i_sf ); } @@ -1150,7 +1150,7 @@ void ivas_spar_dec_upmixer( } else { - if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_FOA || + if ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM ) ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) @@ -1173,7 +1173,7 @@ void ivas_spar_dec_upmixer( else { /* CLDFB to time synthesis (overwrite mixer output) */ - for ( out_ch = 0; out_ch < st_ivas->hDecoderConfig->nchan_out; out_ch++ ) + for ( out_ch = 0; out_ch < hDecoderConfig->nchan_out; out_ch++ ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 9bfe233e8e..c856c36f31 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1327,7 +1327,7 @@ typedef struct ivas_binaural_rendering_struct int16_t max_band; /* band upto which rendering is performed */ int16_t conv_band; /* band upto which convolution in cldfb domain is performed */ int16_t timeSlots; /* number of time slots of binaural renderer */ - int16_t nInChannels; /* number input channels */ + int16_t nchan_inp; /* number input channels */ int8_t render_lfe; /* Flag to render LFE in binaural rendering*/ IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */ diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index e863f3ded9..4c7721f095 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -48,7 +48,7 @@ * Local function prototypes *--------------------------------------------------------------------*/ -static ivas_error ivas_spar_enc_process( Encoder_Struct *st_ivas, const ENCODER_CONFIG_HANDLE hEncoderConfig, BSTR_ENC_HANDLE hMetaData, const int16_t front_vad_flag, float data_f[][L_FRAME48k] ); +static ivas_error ivas_spar_enc_process( Encoder_Struct *st_ivas, BSTR_ENC_HANDLE hMetaData, const int16_t front_vad_flag, float data_f[][L_FRAME48k] ); /*------------------------------------------------------------------------- @@ -296,7 +296,7 @@ ivas_error ivas_spar_enc( ivas_sba_zero_vert_comp( data_f, st_ivas->sba_analysis_order, hEncoderConfig->sba_planar, input_frame ); } - if ( ( error = ivas_spar_enc_process( st_ivas, hEncoderConfig, hMetaData, st_ivas->hSpar->front_vad_flag, data_f ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_enc_process( st_ivas, hMetaData, st_ivas->hSpar->front_vad_flag, data_f ) ) != IVAS_ERR_OK ) { return error; } @@ -388,11 +388,10 @@ static void ivas_spar_enc_get_windowed_fr( *-----------------------------------------------------------------------------------------*/ static ivas_error ivas_spar_enc_process( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ - BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ - const int16_t front_vad_flag, /* i : front-VAD decision */ - float data_f[][L_FRAME48k] /* i/o: input/transport audio channels */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ + const int16_t front_vad_flag, /* i : front-VAD decision */ + float data_f[][L_FRAME48k] /* i/o: input/transport audio channels */ ) { float pcm_tmp[IVAS_SPAR_MAX_CH][L_FRAME48k * 2]; @@ -421,6 +420,7 @@ static ivas_error ivas_spar_enc_process( const int16_t *order; SPAR_ENC_HANDLE hSpar = st_ivas->hSpar; IVAS_QMETADATA_HANDLE hQMetaData = st_ivas->hQMetaData; + ENCODER_CONFIG_HANDLE hEncoderConfig = st_ivas->hEncoderConfig; int16_t ts, l_ts, orig_dirac_bands, num_del_samples; float *ppIn_FR_real[IVAS_SPAR_MAX_CH], *ppIn_FR_imag[IVAS_SPAR_MAX_CH]; float w_del_buf[IVAS_FB_1MS_48K_SAMP]; -- GitLab From b7b40a9bc98f7c9bcb4b6c32ffa6166cef5047cc Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Oct 2022 15:42:53 +0200 Subject: [PATCH 3/7] harmonize 'nchan' terminology --- lib_com/ivas_prot.h | 2 +- lib_com/ivas_spar_com.c | 86 +++++++------- lib_dec/ivas_sba_dec.c | 4 +- lib_dec/ivas_sba_rendering.c | 6 +- lib_dec/ivas_spar_md_dec.c | 215 +++++++++++++++++------------------ lib_enc/ivas_mc_param_enc.c | 13 ++- 6 files changed, 160 insertions(+), 166 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 77a90ae84c..8f7da9933e 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3977,7 +3977,7 @@ void ivas_get_spar_md_from_dirac( ivas_spar_md_com_cfg *hSpar_md_cfg, const int16_t start_band, const int16_t end_band, - const int16_t order, + const int16_t sba_order, const int16_t dtx_vad, float Wscale_d[IVAS_MAX_NUM_BANDS] ); diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index b9abd5f778..cb6501f3be 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -1645,11 +1645,11 @@ void ivas_get_spar_md_from_dirac( ivas_spar_md_com_cfg *hSpar_md_cfg, const int16_t start_band, const int16_t end_band, - const int16_t order, + const int16_t sba_order, const int16_t dtx_vad, float Wscale_d[IVAS_MAX_NUM_BANDS] ) { - int16_t nchan, band, i, j; + int16_t nchan_md, band, i, j; int16_t block, ch; float response_avg[MAX_OUTPUT_CHANNELS]; float response[MAX_PARAM_SPATIAL_SUBFRAMES][MAX_OUTPUT_CHANNELS]; @@ -1661,15 +1661,15 @@ void ivas_get_spar_md_from_dirac( float **ppMixer_mat[IVAS_MAX_FB_MIXER_OUT_CH]; float *pMixer_mat[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH]; float en_ratio_fac, diff_norm_order1, diff_norm_order2, diff_norm_order3; - int16_t ndm, foa_ch, hoa2_ch; + int16_t ndm, nchan_foa, nchan_md_hoa2; float P_dir_fact[IVAS_SPAR_MAX_CH - 1]; const int16_t *remix_order; remix_order = remix_order_set[hSpar_md_cfg->remix_unmix_order]; - nchan = 2 * order + 2; - hoa2_ch = 6; - foa_ch = FOA_CHANNELS; + nchan_md = ivas_sba_get_nchan_metadata( sba_order ); + nchan_md_hoa2 = ivas_sba_get_nchan_metadata( 2 ); + nchan_foa = FOA_CHANNELS; diff_norm_order1 = 3.0f; diff_norm_order2 = 5.0f; diff_norm_order3 = 7.0f; @@ -1689,39 +1689,39 @@ void ivas_get_spar_md_from_dirac( int16_t idx; ndm = hSpar_md_cfg->num_dmx_chans_per_band[start_band - 1]; P_norm[0] = 0.0f; - for ( i = 0; i < max( 0, foa_ch - ndm ); i++ ) + for ( i = 0; i < max( 0, nchan_foa - ndm ); i++ ) { P_norm[0] += hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i]; } - P_norm[0] *= diff_norm_order1 / min( diff_norm_order1, max( 0, foa_ch - ndm ) ); + P_norm[0] *= diff_norm_order1 / min( diff_norm_order1, max( 0, nchan_foa - ndm ) ); P_norm[1] = 0.0f; - for ( ; i < max( 0, min( nchan, hoa2_ch ) - ndm ); i++ ) + for ( ; i < max( 0, min( nchan_md, nchan_md_hoa2 ) - ndm ); i++ ) { P_norm[1] += hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i]; } - P_norm[1] *= diff_norm_order2 / min( diff_norm_order2, max( 0, min( nchan, hoa2_ch ) - ndm ) ); + P_norm[1] *= diff_norm_order2 / min( diff_norm_order2, max( 0, min( nchan_md, nchan_md_hoa2 ) - ndm ) ); P_norm[2] = 0.0f; - for ( ; i < nchan - ndm; i++ ) + for ( ; i < nchan_md - ndm; i++ ) { P_norm[2] += hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i]; } - P_norm[2] *= diff_norm_order3 / min( diff_norm_order3, max( 0, nchan - ndm ) ); + P_norm[2] *= diff_norm_order3 / min( diff_norm_order3, max( 0, nchan_md - ndm ) ); - for ( i = 0; i < max( 0, foa_ch - ndm ); i++ ) + for ( i = 0; i < max( 0, nchan_foa - ndm ); i++ ) { idx = remix_order[i + ndm] - ndm; P_dir_fact[idx] = hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i]; P_dir_fact[idx] = P_dir_fact[idx] / max( IVAS_FLT_EPS, P_norm[0] ); } - for ( ; i < max( 0, min( nchan, hoa2_ch ) - ndm ); i++ ) + for ( ; i < max( 0, min( nchan_md, nchan_md_hoa2 ) - ndm ); i++ ) { idx = remix_order[i + ndm] - ndm; P_dir_fact[idx] = hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i]; P_dir_fact[idx] = P_dir_fact[idx] / max( IVAS_FLT_EPS, P_norm[1] ); } - for ( ; i < nchan - ndm; i++ ) + for ( ; i < nchan_md - ndm; i++ ) { idx = remix_order[i + ndm] - ndm; P_dir_fact[idx] = hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i]; @@ -1743,24 +1743,24 @@ void ivas_get_spar_md_from_dirac( if ( n_ts > 1 ) { - ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][i_ts], (int16_t) ele_dirac[band][i_ts], response_avg, order ); + ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][i_ts], (int16_t) ele_dirac[band][i_ts], response_avg, sba_order ); } else { for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { - ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][block], (int16_t) ele_dirac[band][block], &( response[block][0] ), order ); + ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][block], (int16_t) ele_dirac[band][block], &( response[block][0] ), sba_order ); } /* average responses in all subframes*/ { float norm; - int16_t num_ch_order, hoa2_ch_order; + int16_t nchan_internal, nchan_hoa2; - num_ch_order = ivas_sba_get_nchan( order, 0 ); - hoa2_ch_order = 9; + nchan_internal = ivas_sba_get_nchan( sba_order, 0 ); + nchan_hoa2 = ivas_sba_get_nchan( 2, 0 ); - for ( ch = 0; ch < num_ch_order; ch++ ) + for ( ch = 0; ch < nchan_internal; ch++ ) { for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { @@ -1771,51 +1771,51 @@ void ivas_get_spar_md_from_dirac( /*normalize 1st order*/ norm = 0.0f; - for ( ch = 1; ch < foa_ch; ch++ ) + for ( ch = 1; ch < nchan_foa; ch++ ) { norm += response_avg[ch] * response_avg[ch]; } norm = max( EPSILON, sqrtf( norm ) ); - for ( ch = 1; ch < foa_ch; ch++ ) + for ( ch = 1; ch < nchan_foa; ch++ ) { response_avg[ch] /= norm; } /*normalize 2nd order*/ norm = 0.0f; - for ( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ ) + for ( ch = nchan_foa; ch < min( nchan_hoa2, nchan_internal ); ch++ ) { norm += response_avg[ch] * response_avg[ch]; } norm = max( EPSILON, sqrtf( norm ) ); - for ( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ ) + for ( ch = nchan_foa; ch < min( nchan_hoa2, nchan_internal ); ch++ ) { response_avg[ch] /= norm; } /*normalize 3rd order*/ norm = 0.0f; - for ( ch = hoa2_ch_order; ch < num_ch_order; ch++ ) + for ( ch = nchan_hoa2; ch < nchan_internal; ch++ ) { norm += response_avg[ch] * response_avg[ch]; } norm = max( EPSILON, sqrtf( norm ) ); - for ( ch = hoa2_ch_order; ch < num_ch_order; ch++ ) + for ( ch = nchan_hoa2; ch < nchan_internal; ch++ ) { response_avg[ch] /= norm; } } } - for ( i = FOA_CHANNELS + 1; i < nchan; i++ ) + for ( i = FOA_CHANNELS + 1; i < nchan_md; i++ ) { response_avg[i] = response_avg[HOA_keep_ind[i]]; } en_ratio_fac = ( 1.0f - diffuseness[band] ); - for ( i = 0; i < nchan; i++ ) + for ( i = 0; i < nchan_md; i++ ) { - for ( j = 0; j < nchan; j++ ) + for ( j = 0; j < nchan_md; j++ ) { if ( i == j ) { @@ -1835,11 +1835,11 @@ void ivas_get_spar_md_from_dirac( } else { - if ( i < foa_ch ) + if ( i < nchan_foa ) { cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) / diff_norm_order1; } - else if ( i < hoa2_ch ) + else if ( i < nchan_md_hoa2 ) { cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) / diff_norm_order2; } @@ -1851,11 +1851,11 @@ void ivas_get_spar_md_from_dirac( } else { - if ( i < foa_ch ) + if ( i < nchan_foa ) { cov_real_dirac[i][j][band] += ( 1.0f - en_ratio_fac ) / diff_norm_order1; } - else if ( i < hoa2_ch ) + else if ( i < nchan_md_hoa2 ) { cov_real_dirac[i][j][band] += ( 1.0f - en_ratio_fac ) / diff_norm_order2; } @@ -1874,9 +1874,9 @@ void ivas_get_spar_md_from_dirac( } } - for ( i = 0; i < nchan; i++ ) + for ( i = 0; i < nchan_md; i++ ) { - for ( j = 0; j < nchan; j++ ) + for ( j = 0; j < nchan_md; j++ ) { pCov_real[i][j] = cov_real_dirac[i][j]; } @@ -1892,9 +1892,9 @@ void ivas_get_spar_md_from_dirac( fid = fopen( "cov_real_dirac.txt", "wt" ); } - for ( i = 0; i < nchan; i++ ) + for ( i = 0; i < nchan_md; i++ ) { - for ( j = 0; j < nchan; j++ ) + for ( j = 0; j < nchan_md; j++ ) { for ( k = start_band; k < end_band; k++ ) { @@ -1907,7 +1907,7 @@ void ivas_get_spar_md_from_dirac( #endif ivas_compute_spar_params( pCov_real, dm_fv_re, i_ts, ppMixer_mat, start_band, end_band, dtx_vad, - nchan, 1, hSpar_md_cfg->active_w, hSpar_md_cfg, hSpar_md, Wscale, 1 ); + nchan_md, 1, hSpar_md_cfg->active_w, hSpar_md_cfg, hSpar_md, Wscale, 1 ); if ( mixer_mat != NULL ) { @@ -1917,15 +1917,15 @@ void ivas_get_spar_md_from_dirac( for ( i = 0; i < ndm; i++ ) { - for ( j = 0; j < nchan; j++ ) + for ( j = 0; j < nchan_md; j++ ) { mixer_mat[i][j][band + i_ts * IVAS_MAX_NUM_BANDS] = ppMixer_mat[i][j][band]; } } - for ( i = ndm; i < nchan; i++ ) + for ( i = ndm; i < nchan_md; i++ ) { - for ( j = 0; j < nchan; j++ ) + for ( j = 0; j < nchan_md; j++ ) { mixer_mat[i][j][band + i_ts * IVAS_MAX_NUM_BANDS] = 0.0f; } @@ -1933,7 +1933,7 @@ void ivas_get_spar_md_from_dirac( if ( ( ndm == 1 ) && ( Wscale_d != NULL ) ) { - for ( j = 0; j < nchan; j++ ) + for ( j = 0; j < nchan_md; j++ ) { mixer_mat[0][j][band + i_ts * IVAS_MAX_NUM_BANDS] *= Wscale_d[band]; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 2180cb79a3..c2b56f8b01 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -77,7 +77,7 @@ void ivas_mc2sba( assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); /* Init*/ - sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); + sba_num_chans = ivas_sba_get_nchan( sba_order, 0 ); for ( j = 0; j < sba_num_chans; j++ ) { set_zero( buffer_tmp[j], output_frame ); @@ -297,7 +297,7 @@ void ivas_ism2sba( assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" ); /* Init*/ - sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); + sba_num_chans = ivas_sba_get_nchan( sba_order, 0 ); for ( j = 0; j < sba_num_chans; j++ ) { set_zero( buffer_tmp[j], output_frame ); diff --git a/lib_dec/ivas_sba_rendering.c b/lib_dec/ivas_sba_rendering.c index 1efde66cf5..09f8c7a1ff 100644 --- a/lib_dec/ivas_sba_rendering.c +++ b/lib_dec/ivas_sba_rendering.c @@ -208,12 +208,12 @@ void ivas_sba_upmixer_renderer( const int16_t output_frame /* i : output frame length */ ) { - int16_t i, nchan_internal; + int16_t i, nchan; float temp; wmops_sub_start( "ivas_sba_upmixer_renderer" ); - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); + nchan = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); if ( st_ivas->nchan_transport >= 3 ) { @@ -227,7 +227,7 @@ void ivas_sba_upmixer_renderer( } /* Upmixer + Renderer */ - ivas_spar_dec_upmixer( st_ivas, output, nchan_internal, output_frame ); + ivas_spar_dec_upmixer( st_ivas, output, nchan, output_frame ); if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index a9307ddb82..bb81448b81 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -544,7 +544,7 @@ static ivas_error ivas_spar_set_dec_config( const int16_t nchan_transport, float *pFC ) { - int16_t i, j, nchan, dmx_ch; + int16_t i, j, nchan, nchan_dmx; for ( i = 0; i < nchan_transport; i++ ) { @@ -574,15 +574,15 @@ static ivas_error ivas_spar_set_dec_config( hMdDec->spar_md_cfg.num_umx_chs = nchan; - dmx_ch = 0; + nchan_dmx = 0; for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) { - dmx_ch = 0; + nchan_dmx = 0; for ( j = 0; j < nchan_transport; j++ ) { if ( pFC[i] < hMdDec->spar_md_cfg.max_freq_per_chan[j] ) { - dmx_ch += 1; + nchan_dmx += 1; } } @@ -590,7 +590,7 @@ static ivas_error ivas_spar_set_dec_config( hMdDec->spar_md_cfg.num_decorr_per_band[i] = nchan - hMdDec->spar_md_cfg.nchan_transport; } - hMdDec->spar_md_cfg.nchan_transport = dmx_ch; + hMdDec->spar_md_cfg.nchan_transport = nchan_dmx; return IVAS_ERR_OK; } @@ -750,18 +750,18 @@ void ivas_spar_smooth_md_dtx( const int16_t num_bands_out /* i : number of output bands */ ) { - int16_t j, k, b, dmx_ch; + int16_t j, k, b, nchan; float ramp, tar, prev, new_val; ramp = (float) hMdDec->dtx_md_smoothing_cntr / IVAS_DEFAULT_DTX_CNG_RAMP; for ( b = 0; b < num_bands_out; b++ ) { - dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; + nchan = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; for ( j = 1; j < FOA_CHANNELS; j++ ) { - for ( k = dmx_ch; k < FOA_CHANNELS; k++ ) + for ( k = nchan; k < FOA_CHANNELS; k++ ) { prev = hMdDec->spar_coeffs_prev.P_re[j][k][b]; tar = hMdDec->spar_coeffs_tar.P_re[j][k][b]; @@ -772,7 +772,7 @@ void ivas_spar_smooth_md_dtx( for ( j = 0; j < FOA_CHANNELS; j++ ) { - for ( k = 0; k < dmx_ch; k++ ) + for ( k = 0; k < nchan; k++ ) { prev = hMdDec->spar_coeffs_prev.C_re[j][k][b]; tar = hMdDec->spar_coeffs_tar.C_re[j][k][b]; @@ -787,12 +787,11 @@ void ivas_spar_smooth_md_dtx( { for ( b = 0; b < num_bands_out; b++ ) { - dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; + nchan = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; for ( j = 1; j < FOA_CHANNELS; j++ ) { - for ( k = dmx_ch; k < FOA_CHANNELS; k++ ) - + for ( k = nchan; k < FOA_CHANNELS; k++ ) { hMdDec->spar_coeffs.P_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.P_re[j][k][b]; } @@ -800,7 +799,7 @@ void ivas_spar_smooth_md_dtx( for ( j = 0; j < FOA_CHANNELS; j++ ) { - for ( k = 0; k < dmx_ch; k++ ) + for ( k = 0; k < nchan; k++ ) { hMdDec->spar_coeffs.C_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.C_re[j][k][b]; } @@ -956,12 +955,12 @@ static void ivas_get_spar_matrices( const int16_t nB, const int16_t sba_order ) { - int16_t numch_out, num_bands, dmx_ch, split_band; + int16_t nchan, num_bands, nchan_dmx, split_band; int16_t i, j, k, m, b, i_ts, active_w; const int16_t *order; float active_w_dm_fac, re; - numch_out = ivas_sba_get_nchan_metadata( sba_order ); + nchan = ivas_sba_get_nchan_metadata( sba_order ); num_bands = num_bands_out; order = remix_order_set[hMdDec->spar_md_cfg.remix_unmix_order]; @@ -970,9 +969,9 @@ static void ivas_get_spar_matrices( if ( split_band >= IVAS_MAX_NUM_BANDS ) { /*store previous 4x4 parameters for linear interpolation to current*/ - for ( i = 0; i < numch_out; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < numch_out; j++ ) + for ( j = 0; j < nchan; j++ ) { for ( b = 0; b < num_bands; b++ ) { @@ -985,15 +984,15 @@ static void ivas_get_spar_matrices( #ifdef SPAR_HOA_DBG /*for (b = 0; b < BANDS_12; b++) { - for (i = 0; i < IVAS_SPAR_MAX_CH - 1; i++) + for (i = 0; i < IVAS_SPAR_MAX_CH - 1; i++) + { + hMdDec->spar_md.band_coeffs[b].pred_re[i] = (float)(i + 1)/10; + for (j = 0; j < IVAS_SPAR_MAX_CH - 1; j++) { - hMdDec->spar_md.band_coeffs[b].pred_re[i] = (float)(i + 1)/10; - for (j = 0; j < IVAS_SPAR_MAX_CH - 1; j++) - { - hMdDec->spar_md.band_coeffs[b].C_re[i][j] = (float)(i + j * 20 + 1)/10; - hMdDec->spar_md.band_coeffs[b].P_re[i][j] = (float)(i + j * 20 + 1)/10; - } + hMdDec->spar_md.band_coeffs[b].C_re[i][j] = (float)(i + j * 20 + 1)/10; + hMdDec->spar_md.band_coeffs[b].P_re[i][j] = (float)(i + j * 20 + 1)/10; } + } }*/ #endif @@ -1002,9 +1001,9 @@ static void ivas_get_spar_matrices( for ( i_ts = 0; i_ts < n_ts; i_ts++ ) { - for ( i = 0; i < numch_out; i++ ) + for ( i = 0; i < nchan; i++ ) { - for ( j = 0; j < numch_out; j++ ) + for ( j = 0; j < nchan; j++ ) { set_zero( &hMdDec->spar_coeffs.C_re[i][j][i_ts * IVAS_MAX_NUM_BANDS], IVAS_MAX_NUM_BANDS ); set_zero( &hMdDec->spar_coeffs.P_re[i][j][i_ts * IVAS_MAX_NUM_BANDS], IVAS_MAX_NUM_BANDS ); @@ -1024,27 +1023,27 @@ static void ivas_get_spar_matrices( float tmp_C2_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; float tmp_dm_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[bw * b]; + nchan_dmx = hMdDec->spar_md_cfg.num_dmx_chans_per_band[bw * b]; - for ( j = 0; j < numch_out; j++ ) + for ( j = 0; j < nchan; j++ ) { - set_zero( tmp_C1_re[j], numch_out ); - set_zero( tmp_C2_re[j], numch_out ); - set_zero( tmp_dm_re[j], numch_out ); + set_zero( tmp_C1_re[j], nchan ); + set_zero( tmp_C2_re[j], nchan ); + set_zero( tmp_dm_re[j], nchan ); tmp_C1_re[j][j] = 1.0f; tmp_C2_re[j][j] = 1.0f; tmp_dm_re[j][j] = 1.0f; } - for ( j = 1; j < numch_out; j++ ) + for ( j = 1; j < nchan; j++ ) { tmp_C1_re[j][0] = hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re[j - 1]; } if ( active_w == 1 ) { - for ( j = 1; j < numch_out; j++ ) + for ( j = 1; j < nchan; j++ ) { tmp_C2_re[0][j] = active_w_dm_fac * -hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re[j - 1]; } @@ -1072,7 +1071,7 @@ static void ivas_get_spar_matrices( if ( hMdDec->spar_md_cfg.remix_unmix_order != 3 ) { - ivas_mat_col_rearrange( tmp_dm_re, order, i_ts, hMdDec->mixer_mat, b, numch_out ); + ivas_mat_col_rearrange( tmp_dm_re, order, i_ts, hMdDec->mixer_mat, b, nchan ); } else { @@ -1097,7 +1096,7 @@ static void ivas_get_spar_matrices( { if ( hMdDec->spar_md_cfg.remix_unmix_order != 3 ) { - ivas_mat_col_rearrange( tmp_C1_re, order, i_ts, hMdDec->mixer_mat, b, numch_out ); + ivas_mat_col_rearrange( tmp_C1_re, order, i_ts, hMdDec->mixer_mat, b, nchan ); } else { @@ -1119,63 +1118,62 @@ static void ivas_get_spar_matrices( } } - if ( dmx_ch > 0 ) + if ( nchan_dmx > 0 ) { float tmpC_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; float tmpP_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - for ( j = 0; j < numch_out; j++ ) + for ( j = 0; j < nchan; j++ ) { - set_zero( tmpC_re[j], numch_out ); - set_zero( tmpP_re[j], numch_out ); + set_zero( tmpC_re[j], nchan ); + set_zero( tmpP_re[j], nchan ); } - for ( j = 0; j < numch_out; j++ ) + for ( j = 0; j < nchan; j++ ) { - set_zero( tmpC_re[j], numch_out ); + set_zero( tmpC_re[j], nchan ); } - for ( k = 0; k < dmx_ch; k++ ) + for ( k = 0; k < nchan_dmx; k++ ) { tmpC_re[k][k] = 1; } - for ( j = dmx_ch; j < numch_out; j++ ) + for ( j = nchan_dmx; j < nchan; j++ ) { - for ( k = 1; k < dmx_ch; k++ ) + for ( k = 1; k < nchan_dmx; k++ ) { - tmpC_re[j][k] = hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re[j - dmx_ch][k - 1]; + tmpC_re[j][k] = hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re[j - nchan_dmx][k - 1]; } } #ifdef SPAR_HOA_DBG - /*fprintf(stdout, "C matrix1: %d x %d\n\n", numch_out, dmx_ch); - for (j = 0; j < numch_out; j++) + /*fprintf(stdout, "C matrix1: %d x %d\n\n", nchan, nchan_dmx); + for (j = 0; j < nchan; j++) { - for (k = 0; k < dmx_ch; k++) - { - fprintf(stdout, "%f, ", tmpC_re[j][k]); - } - fprintf(stdout, "\n"); - + for (k = 0; k < nchan_dmx; k++) + { + fprintf(stdout, "%f, ", tmpC_re[j][k]); + } + fprintf(stdout, "\n"); } - fprintf(stdout, "Mixer Mat: %d x %d\n\n", numch_out, numch_out); - for ( j = 0; j < numch_out; j++) + fprintf(stdout, "Mixer Mat: %d x %d\n\n", nchan, nchan); + for ( j = 0; j < nchan; j++) { - for (k = 0; k < numch_out; k++) - { - fprintf(stdout, "%f, ", hMdDec->mixer_mat[j][k][0][b]); - } - fprintf(stdout, "\n"); + for (k = 0; k < nchan; k++) + { + fprintf(stdout, "%f, ", hMdDec->mixer_mat[j][k][0][b]); + } + fprintf(stdout, "\n"); }*/ #endif - for ( j = dmx_ch; j < numch_out; j++ ) + for ( j = nchan_dmx; j < nchan; j++ ) { - for ( k = dmx_ch; k < numch_out; k++ ) + for ( k = nchan_dmx; k < nchan; k++ ) { - if ( ( j - dmx_ch ) == ( k - dmx_ch ) ) + if ( ( j - nchan_dmx ) == ( k - nchan_dmx ) ) { - tmpP_re[j][k] = hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re[k - dmx_ch]; + tmpP_re[j][k] = hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re[k - nchan_dmx]; } else { @@ -1186,34 +1184,32 @@ static void ivas_get_spar_matrices( #ifdef SPAR_HOA_DBG /*if (b == 0) { - fprintf(stdout, "tmp_P matrix: %d x %d\n\n", numch_out, dmx_ch); - for (j = 0; j < numch_out; j++) + fprintf(stdout, "tmp_P matrix: %d x %d\n\n", nchan, nchan_dmx); + for (j = 0; j < nchan; j++) + { + for (k = 0; k < nchan; k++) { - for (k = 0; k < numch_out; k++) - { - fprintf(stdout, "%f, ", tmpP_re[j][k]); - } - fprintf(stdout, "\n"); - + fprintf(stdout, "%f, ", tmpP_re[j][k]); } - fprintf(stdout, "Mixer Mat: %d x %d\n\n", numch_out, numch_out); - for (j = 0; j < numch_out; j++) + fprintf(stdout, "\n"); + } + fprintf(stdout, "Mixer Mat: %d x %d\n\n", nchan, nchan); + for (j = 0; j < nchan; j++) + { + for (k = 0; k < nchan; k++) { - for (k = 0; k < numch_out; k++) - { - fprintf(stdout, "%f, ", hMdDec->mixer_mat[j][k][0][b]); - } - fprintf(stdout, "\n"); - + fprintf(stdout, "%f, ", hMdDec->mixer_mat[j][k][0][b]); } + fprintf(stdout, "\n"); + } }*/ #endif - for ( j = 1; j < numch_out; j++ ) + for ( j = 1; j < nchan; j++ ) { - for ( k = dmx_ch; k < numch_out; k++ ) + for ( k = nchan_dmx; k < nchan; k++ ) { - for ( m = 0; m < numch_out; m++ ) + for ( m = 0; m < nchan; m++ ) { IVAS_RMULT_FLOAT( hMdDec->mixer_mat[j][m][b + i_ts * IVAS_MAX_NUM_BANDS], tmpP_re[m][k], re ); hMdDec->spar_coeffs.P_re[j][k][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] += re; @@ -1221,11 +1217,11 @@ static void ivas_get_spar_matrices( } } - for ( j = 0; j < numch_out; j++ ) + for ( j = 0; j < nchan; j++ ) { - for ( k = 0; k < dmx_ch; k++ ) + for ( k = 0; k < nchan_dmx; k++ ) { - for ( m = 0; m < numch_out; m++ ) + for ( m = 0; m < nchan; m++ ) { IVAS_RMULT_FLOAT( hMdDec->mixer_mat[j][m][b + i_ts * IVAS_MAX_NUM_BANDS], tmpC_re[m][k], re ); hMdDec->spar_coeffs.C_re[j][k][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] += re; @@ -1233,15 +1229,14 @@ static void ivas_get_spar_matrices( } } #ifdef SPAR_HOA_DBG - /*fprintf(stdout, "C matrix1: %d x %d\n\n", numch_out, dmx_ch); - for (j = 0; j < numch_out; j++) + /*fprintf(stdout, "C matrix1: %d x %d\n\n", nchan, nchan_dmx); + for (j = 0; j < nchan; j++) { - for (k = 0; k < dmx_ch; k++) + for (k = 0; k < nchan_dmx; k++) { fprintf(stdout, "%f, ", hMdDec->spar_coeffs.C_re[j][k][b]); } fprintf(stdout, "\n"); - }*/ #endif hMdDec->spar_coeffs.C_re[0][0][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] = @@ -1251,27 +1246,25 @@ static void ivas_get_spar_matrices( #ifdef SPAR_HOA_DBG /* for (b = 0; b < 1; b++) { - fprintf(stdout, "C matrix: %d x %d band %d\n\n", numch_out, dmx_ch, b); - for (j = 0; j < numch_out; j++) + fprintf(stdout, "C matrix: %d x %d band %d\n\n", nchan, nchan_dmx, b); + for (j = 0; j < nchan; j++) + { + for (k = 0; k < nchan; k++) { - for (k = 0; k < numch_out; k++) - { - fprintf(stdout, "%f, ", hMdDec->spar_coeffs.C_re[j][k][b]); - } - fprintf(stdout, "\n"); - + fprintf(stdout, "%f, ", hMdDec->spar_coeffs.C_re[j][k][b]); } - fprintf(stdout, "\nP matrix: %d x %d\n\n", numch_out, numch_out); + fprintf(stdout, "\n"); + } + fprintf(stdout, "\nP matrix: %d x %d\n\n", nchan, nchan); - for (j = 0; j < numch_out; j++) + for (j = 0; j < nchan; j++) + { + for (k = 0; k < nchan; k++) { - for (k = 0; k < numch_out; k++) - { - fprintf(stdout, "%f, ", hMdDec->spar_coeffs.P_re[j][k][b]); - } - fprintf(stdout, "\n"); - + fprintf(stdout, "%f, ", hMdDec->spar_coeffs.P_re[j][k][b]); } + fprintf(stdout, "\n"); + } }*/ #endif @@ -1280,18 +1273,18 @@ static void ivas_get_spar_matrices( { for ( b = 0; b < num_bands_out; b = b + bw ) { - dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; - for ( j = 0; j < numch_out; j++ ) + nchan_dmx = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; + for ( j = 0; j < nchan; j++ ) { - for ( k = dmx_ch; k < numch_out; k++ ) + for ( k = nchan_dmx; k < nchan; k++ ) { hMdDec->spar_coeffs.P_re[j][k][( b + 1 ) + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.P_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS]; } } - for ( j = 0; j < numch_out; j++ ) + for ( j = 0; j < nchan; j++ ) { - for ( k = 0; k < dmx_ch; k++ ) + for ( k = 0; k < nchan_dmx; k++ ) { hMdDec->spar_coeffs.C_re[j][k][( b + 1 ) + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.C_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS]; } diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 844a3c19bf..396a9a5ecd 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -436,21 +436,22 @@ static void ivas_param_mc_dmx( { int16_t i; const int16_t *idx; - int16_t dmx_ch; - int16_t inp_ch; + int16_t ch_dmx, ch_inp; const float *p_dmx_fac; + float *dmx_sample; idx = Param_MC_index; for ( i = 0; i < input_frame; i++ ) { p_dmx_fac = hParamMC->dmx_factors; - for ( dmx_ch = 0; dmx_ch < nchan_transport; dmx_ch++ ) + for ( ch_dmx = 0; ch_dmx < nchan_transport; ch_dmx++ ) { - float *dmx_sample = &data_dmx[idx[dmx_ch]][i]; + dmx_sample = &data_dmx[idx[ch_dmx]][i]; *dmx_sample = 0.0f; - for ( inp_ch = 0; inp_ch < nchan_inp; inp_ch++ ) + + for ( ch_inp = 0; ch_inp < nchan_inp; ch_inp++ ) { - ( *dmx_sample ) += data_f[idx[inp_ch]][i] * ( *( p_dmx_fac++ ) ); + ( *dmx_sample ) += data_f[idx[ch_inp]][i] * ( *( p_dmx_fac++ ) ); } } } -- GitLab From 646517efeca7d1234c1748084186ed02be613580 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Oct 2022 16:17:37 +0200 Subject: [PATCH 4/7] harmonize channel indexes --- lib_com/ivas_prot.h | 4 +- lib_dec/ivas_dec.c | 50 +++++++-------- lib_dec/ivas_dirac_dec.c | 10 +-- lib_dec/ivas_ism_param_dec.c | 22 +++---- lib_dec/ivas_sba_rendering.c | 35 ++++++----- lib_dec/ivas_spar_decoder.c | 114 +++++++++++++++++------------------ lib_enc/ivas_enc.c | 20 +++--- 7 files changed, 127 insertions(+), 128 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 8f7da9933e..b05d7961f4 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3996,8 +3996,8 @@ void ivas_spar_get_parameters( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ const int16_t ts, /* i : time slot index */ - const int16_t num_ch_out, /* i : number of channels out */ - const int16_t num_ch_in, /* i : number of channels in */ + const int16_t nchan_out, /* i : number of channels out */ + const int16_t nchan_inp, /* i : number of channels in */ const int16_t num_spar_bands, /* i : number of SPAR bands */ float par_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] /* o : mixing matrix */ ); diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 5d3a5a10f9..fec88a37c6 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -55,7 +55,7 @@ ivas_error ivas_dec( int16_t *data /* o : output synthesis signal */ ) { - int16_t n, output_frame, nchan_out; + int16_t ch, output_frame, nchan_out; Decoder_State *st; /* used for bitstream handling */ float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ /* IVAS_fmToDo: buffer can be allocated dynamically based on the actual number of output channels */ int16_t nchan_remapped; @@ -103,9 +103,9 @@ ivas_error ivas_dec( if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) { /* zero output when first frame(s) is lost */ - for ( n = 0; n < nchan_out; n++ ) + for ( ch = 0; ch < nchan_out; ch++ ) { - set_f( output[n], 0.0f, output_frame ); + set_f( output[ch], 0.0f, output_frame ); } #ifdef DEBUG_MODE_INFO @@ -125,9 +125,9 @@ ivas_error ivas_dec( } /* HP filtering */ - for ( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ ) + for ( ch = 0; ch < min( nchan_out, st_ivas->nchan_transport ); ch++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs ); } /* Rendering */ @@ -148,15 +148,15 @@ ivas_error ivas_dec( ivas_ism_metadata_dec( ivas_total_brate, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, NULL ); } - for ( n = 0; n < st_ivas->nchan_transport; n++ ) + for ( ch = 0; ch < st_ivas->nchan_transport; ch++ ) { - if ( ( error = ivas_sce_dec( st_ivas, n, &output[n], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, ch, &output[ch], output_frame, nb_bits_metadata[ch] ) ) != IVAS_ERR_OK ) { return error; } /* HP filtering */ - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs ); } /* Rendering */ @@ -297,9 +297,9 @@ ivas_error ivas_dec( /* HP filtering */ #ifndef DEBUG_SPAR_BYPASS_EVS_CODEC - for ( n = 0; n < nchan_remapped; n++ ) + for ( ch = 0; ch < nchan_remapped; ch++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs ); } #endif if ( st_ivas->ivas_format == SBA_FORMAT ) @@ -320,9 +320,9 @@ ivas_error ivas_dec( { float gain = 0.8414f; /* Todo: Temporary gain for roughly matching the loudness. To be tuned later together with other outputs. */ - for ( n = 0; n < nchan_remapped; n++ ) + for ( ch = 0; ch < nchan_remapped; ch++ ) { - v_multc( output[n], gain, output[n], output_frame ); + v_multc( output[ch], gain, output[ch], output_frame ); } } @@ -368,11 +368,11 @@ ivas_error ivas_dec( mvr2r( output_lfe_ch, output[LFE_CHANNEL], output_frame ); /* HP filtering */ - for ( n = 0; n < st_ivas->nchan_transport; n++ ) + for ( ch = 0; ch < st_ivas->nchan_transport; ch++ ) { - if ( n != LFE_CHANNEL ) + if ( ch != LFE_CHANNEL ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs ); } } @@ -427,9 +427,9 @@ ivas_error ivas_dec( } /* HP filtering */ - for ( n = 0; n < st_ivas->nchan_transport; n++ ) + for ( ch = 0; ch < st_ivas->nchan_transport; ch++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs ); } /* Rendering */ @@ -464,10 +464,10 @@ ivas_error ivas_dec( } /* Identify the index of the separated channel */ - n = st_ivas->hOutSetup.separateChannelIndex; + ch = st_ivas->hOutSetup.separateChannelIndex; /* Decode the separated channel to output[n] to be combined with the synthesized channels */ - if ( ( error = ivas_sce_dec( st_ivas, 0, &output[n], output_frame, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, &output[ch], output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -477,12 +477,12 @@ ivas_error ivas_dec( output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1_4 || output_config == AUDIO_CONFIG_5_1_2 || ( output_config == AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) { - ivas_lfe_synth_with_filters( st_ivas->hMasa->hMasaLfeSynth, output, output_frame, n, LFE_CHANNEL ); + ivas_lfe_synth_with_filters( st_ivas->hMasa->hMasaLfeSynth, output, output_frame, ch, LFE_CHANNEL ); } else if ( output_config == AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ - delay_signal( output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); + delay_signal( output[ch], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); } } else @@ -509,9 +509,9 @@ ivas_error ivas_dec( } /* HP filtering */ - for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + for ( ch = 0; ch < getNumChanSynthesis( st_ivas ); ch++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + hp20( output[ch], output_frame, st_ivas->mem_hp20_out[ch], output_Fs ); } /* Rendering */ @@ -529,9 +529,9 @@ ivas_error ivas_dec( } else if ( st_ivas->intern_config == AUDIO_CONFIG_5_1 && ( output_config == AUDIO_CONFIG_5_1_2 || output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1 ) ) { - for ( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; n++ ) + for ( ch = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; ch < st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; ch++ ) { - set_zero( output[n], output_frame ); + set_zero( output[ch], output_frame ); } } } diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 116288299d..17d474718f 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2343,12 +2343,12 @@ void ivas_dirac_dec( { float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; - int16_t outchannels; + int16_t nchan_out; idx_in = 0; idx_lfe = 0; - outchannels = hDirAC->hOutSetup.nchan_out_woLFE + hDirAC->hOutSetup.num_lfe; + nchan_out = hDirAC->hOutSetup.nchan_out_woLFE + hDirAC->hOutSetup.num_lfe; if ( hDirAC->hOutSetup.separateChannelEnabled && ( hDirAC->hOutSetup.output_config == AUDIO_CONFIG_5_1 || hDirAC->hOutSetup.output_config == AUDIO_CONFIG_7_1 || hDirAC->hOutSetup.output_config == AUDIO_CONFIG_5_1_2 || @@ -2356,7 +2356,7 @@ void ivas_dirac_dec( hDirAC->hOutSetup.output_config == AUDIO_CONFIG_7_1_4 || ( hDirAC->hOutSetup.output_config == AUDIO_CONFIG_LS_CUSTOM && st_ivas->hLsSetupCustom->separate_ch_found ) ) ) { - outchannels++; + nchan_out++; } if ( hDirAC->hOutSetup.separateChannelEnabled && hDirAC->hOutSetup.output_config == AUDIO_CONFIG_LS_CUSTOM ) @@ -2370,7 +2370,7 @@ void ivas_dirac_dec( mvr2r( &( output_f[st_ivas->hOutSetup.separateChannelIndex][subframe_start_sample] ), tmp_separated, num_samples_subframe ); mvr2r( &( output_f[LFE_CHANNEL][subframe_start_sample] ), tmp_lfe, num_samples_subframe ); - for ( ch = 0; ch < outchannels; ch++ ) + for ( ch = 0; ch < nchan_out; ch++ ) { if ( ( hDirAC->hOutSetup.num_lfe > 0 ) && ( hDirAC->hOutSetup.index_lfe[idx_lfe] == ch ) ) { @@ -2411,7 +2411,7 @@ void ivas_dirac_dec( } else { - for ( ch = 0; ch < outchannels; ch++ ) + for ( ch = 0; ch < nchan_out; ch++ ) { if ( ( hDirAC->hOutSetup.num_lfe > 0 ) && ( hDirAC->hOutSetup.index_lfe[idx_lfe] == ch ) ) { diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 460efb7e22..03932b51d9 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -285,7 +285,7 @@ static void ivas_param_ism_rendering( const int16_t num_ch_LS, const int16_t nchan_transport ) { - int16_t outchIdx, inchIdx, bin_idx; + int16_t ch_out, ch_inp, bin_idx; float tmp_1, mixing_matrix_smooth; tmp_1 = hDirAC->hParamIsmRendering->interpolator[slot_idx]; @@ -293,15 +293,15 @@ static void ivas_param_ism_rendering( for ( bin_idx = 0; bin_idx < hDirAC->num_freq_bands; bin_idx++ ) { /* smooth the mixing matrix */ - for ( outchIdx = 0; outchIdx < num_ch_LS; outchIdx++ ) + for ( ch_out = 0; ch_out < num_ch_LS; ch_out++ ) { - for ( inchIdx = 0; inchIdx < nchan_transport; inchIdx++ ) + for ( ch_inp = 0; ch_inp < nchan_transport; ch_inp++ ) { - mixing_matrix_smooth = tmp_1 * mixing_matrix[bin_idx][outchIdx + inchIdx * num_ch_LS] + - ( 1 - tmp_1 ) * hDirAC->hParamIsmRendering->mixing_matrix_lin_old[bin_idx][outchIdx + inchIdx * num_ch_LS]; + mixing_matrix_smooth = tmp_1 * mixing_matrix[bin_idx][ch_out + ch_inp * num_ch_LS] + + ( 1 - tmp_1 ) * hDirAC->hParamIsmRendering->mixing_matrix_lin_old[bin_idx][ch_out + ch_inp * num_ch_LS]; - Cldfb_RealBuffer[outchIdx][out_slot_idx][bin_idx] += mixing_matrix_smooth * Cldfb_RealBuffer_in[inchIdx][slot_idx][bin_idx]; - Cldfb_ImagBuffer[outchIdx][out_slot_idx][bin_idx] += mixing_matrix_smooth * Cldfb_ImagBuffer_in[inchIdx][slot_idx][bin_idx]; + Cldfb_RealBuffer[ch_out][out_slot_idx][bin_idx] += mixing_matrix_smooth * Cldfb_RealBuffer_in[ch_inp][slot_idx][bin_idx]; + Cldfb_ImagBuffer[ch_out][out_slot_idx][bin_idx] += mixing_matrix_smooth * Cldfb_ImagBuffer_in[ch_inp][slot_idx][bin_idx]; } } } @@ -354,7 +354,7 @@ static void ivas_param_ism_update_mixing_matrix( const int16_t nchan_inp, const int16_t nchan_out ) { - int16_t inchIdx, outchIdx, bin_idx, band_idx; + int16_t ch_inp, ch_out, bin_idx, band_idx; int16_t brange[2]; for ( band_idx = 0; band_idx < hDirAC->hParamIsm->nbands; band_idx++ ) @@ -364,11 +364,11 @@ static void ivas_param_ism_update_mixing_matrix( for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) { - for ( inchIdx = 0; inchIdx < nchan_inp; inchIdx++ ) + for ( ch_inp = 0; ch_inp < nchan_inp; ch_inp++ ) { - for ( outchIdx = 0; outchIdx < nchan_out; outchIdx++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - hDirAC->hParamIsmRendering->mixing_matrix_lin_old[bin_idx][outchIdx + inchIdx * nchan_out] = mixing_matrix[bin_idx][outchIdx + inchIdx * nchan_out]; + hDirAC->hParamIsmRendering->mixing_matrix_lin_old[bin_idx][ch_out + ch_inp * nchan_out] = mixing_matrix[bin_idx][ch_out + ch_inp * nchan_out]; } } } diff --git a/lib_dec/ivas_sba_rendering.c b/lib_dec/ivas_sba_rendering.c index 09f8c7a1ff..20db40d71b 100644 --- a/lib_dec/ivas_sba_rendering.c +++ b/lib_dec/ivas_sba_rendering.c @@ -256,7 +256,7 @@ void ivas_sba_mix_matrix_determiner( { int16_t i, ch; float temp; - int16_t num_bands_out, nchan_transport, nchan_out; + int16_t num_bands_out, nchan_transport; /* Convert numeric range */ for ( ch = 0; ch < nchan_remapped; ch++ ) @@ -281,11 +281,10 @@ void ivas_sba_mix_matrix_determiner( /* AGC */ nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - nchan_out = nchan_transport; ivas_agc_dec_process( hSpar->hAgcDec, output, output, nchan_transport, output_frame ); /* Convert numeric range back */ - for ( ch = 0; ch < nchan_out; ch++ ) + for ( ch = 0; ch < nchan_transport; ch++ ) { for ( i = 0; i < output_frame; i++ ) { @@ -322,7 +321,7 @@ void ivas_sba_prototype_renderer( int16_t b, ts; int16_t num_cldfb_bands, nchan_inp, nchan_out; int16_t cldfb_band; - int16_t out_ch, in_ch; + int16_t ch_out, ch_in; int16_t firstSlot, slotEnd, firstInCh, inChEnd, firstOutCh, outChEnd; int16_t sf_idx; @@ -367,17 +366,17 @@ void ivas_sba_prototype_renderer( float cldfb_par; ivas_fb_bin_to_band_data_t *bin2band = &hSpar->hFbMixer->pFb->fb_bin_to_band; - for ( out_ch = firstOutCh; out_ch < outChEnd; out_ch++ ) + for ( ch_out = firstOutCh; ch_out < outChEnd; ch_out++ ) { - out_re[out_ch] = 0.0f; - out_im[out_ch] = 0.0f; + out_re[ch_out] = 0.0f; + out_im[ch_out] = 0.0f; - for ( in_ch = firstInCh; in_ch < inChEnd; in_ch++ ) + for ( ch_in = firstInCh; ch_in < inChEnd; ch_in++ ) { if ( cldfb_band < CLDFB_PAR_WEIGHT_START_BAND ) /* tuning parameter, depends on how much SPAR Filters overlap for the CLDFB bands */ { spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band]; - cldfb_par = mixer_mat[out_ch][in_ch][spar_band]; + cldfb_par = mixer_mat[ch_out][ch_in][spar_band]; } else { @@ -385,20 +384,20 @@ void ivas_sba_prototype_renderer( for ( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ ) { /* accumulate contributions from all SPAR bands */ - cldfb_par += mixer_mat[out_ch][in_ch][spar_band] * bin2band->pp_cldfb_weights_per_spar_band[cldfb_band][spar_band]; + cldfb_par += mixer_mat[ch_out][ch_in][spar_band] * bin2band->pp_cldfb_weights_per_spar_band[cldfb_band][spar_band]; } } - out_re[out_ch] += inRe[in_ch][ts][cldfb_band] * cldfb_par; - out_im[out_ch] += inIm[in_ch][ts][cldfb_band] * cldfb_par; + out_re[ch_out] += inRe[ch_in][ts][cldfb_band] * cldfb_par; + out_im[ch_out] += inIm[ch_in][ts][cldfb_band] * cldfb_par; } } /*update CLDFB data with the parameter-modified data*/ - for ( out_ch = firstOutCh; out_ch < outChEnd; out_ch++ ) + for ( ch_out = firstOutCh; ch_out < outChEnd; ch_out++ ) { - inRe[out_ch][ts][cldfb_band] = out_re[out_ch]; - inIm[out_ch][ts][cldfb_band] = out_im[out_ch]; + inRe[ch_out][ts][cldfb_band] = out_re[ch_out]; + inIm[ch_out][ts][cldfb_band] = out_im[ch_out]; } } @@ -413,13 +412,13 @@ void ivas_sba_prototype_renderer( mvr2r( hSpar->hMdDec->mixer_mat_prev[3][0][0], hSpar->hMdDec->mixer_mat_prev[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); mvr2r( hSpar->hMdDec->mixer_mat_prev[4][0][0], hSpar->hMdDec->mixer_mat_prev[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - for ( out_ch = 0; out_ch < nchan_out; out_ch++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - for ( in_ch = 0; in_ch < nchan_inp; in_ch++ ) + for ( ch_in = 0; ch_in < nchan_inp; ch_in++ ) { for ( b = 0; b < num_spar_bands; b++ ) { - hSpar->hMdDec->mixer_mat_prev[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][b + sf_idx * IVAS_MAX_NUM_BANDS]; + hSpar->hMdDec->mixer_mat_prev[4][ch_out][ch_in][b] = hSpar->hMdDec->mixer_mat[ch_out][ch_in][b + sf_idx * IVAS_MAX_NUM_BANDS]; } } } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 27771a93d2..b9327c4208 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -777,12 +777,12 @@ void ivas_spar_get_parameters( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ const int16_t ts, - const int16_t num_ch_out, - const int16_t num_ch_in, + const int16_t nchan_out, + const int16_t nchan_inp, const int16_t num_spar_bands, float par_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] ) { - int16_t spar_band, out_ch, in_ch; + int16_t spar_band, ch_out, ch_in; float weight, weight_20ms; int16_t ts0, ts1, split_band; @@ -791,30 +791,30 @@ void ivas_spar_get_parameters( split_band = SPAR_DIRAC_SPLIT_START_BAND; for ( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) { - for ( out_ch = 0; out_ch < num_ch_out; out_ch++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + for ( ch_in = 0; ch_in < nchan_inp; ch_in++ ) { 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*/ + && ( 0 == ivas_is_res_channel( ch_out, hSpar->hMdDec->spar_md_cfg.nchan_transport ) ) /* sub-frame processing for missing channels in all frequency bands*/ ) { 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]; + par_mat[ch_out][ch_in][spar_band] = ( 1.0f - weight ) * hSpar->hMdDec->mixer_mat_prev[ts0][ch_out][ch_in][spar_band] + + weight * hSpar->hMdDec->mixer_mat_prev[ts1][ch_out][ch_in][spar_band]; } else { - par_mat[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; + par_mat[ch_out][ch_in][spar_band] = hSpar->hMdDec->mixer_mat[ch_out][ch_in][spar_band]; } } 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]; + par_mat[ch_out][ch_in][spar_band] = ( 1.0f - weight_20ms ) * hSpar->hMdDec->mixer_mat_prev[prev_idx][ch_out][ch_in][spar_band] + weight_20ms * hSpar->hMdDec->mixer_mat[ch_out][ch_in][spar_band]; } } } @@ -832,26 +832,26 @@ void ivas_spar_get_parameters( static void ivas_spar_get_skip_mat( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - const int16_t num_ch_out, - const int16_t num_ch_in, + const int16_t nchan_out, + const int16_t nchan_inp, const int16_t num_spar_bands, int16_t skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH] ) { - int16_t spar_band, out_ch, in_ch; + int16_t spar_band, ch_out, ch_in; int16_t i_ts, skip_flag; - for ( out_ch = 0; out_ch < num_ch_out; out_ch++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + for ( ch_in = 0; ch_in < nchan_inp; ch_in++ ) { - skip_mat[out_ch][in_ch] = 1; + skip_mat[ch_out][ch_in] = 1; skip_flag = 1; for ( i_ts = 0; i_ts < MAX_PARAM_SPATIAL_SUBFRAMES; i_ts++ ) { for ( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) { - if ( hSpar->hMdDec->mixer_mat_prev[1 + i_ts][out_ch][in_ch][spar_band] != 0.0f || hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band + i_ts * MAX_PARAM_SPATIAL_SUBFRAMES] != 0.0f ) + if ( hSpar->hMdDec->mixer_mat_prev[1 + i_ts][ch_out][ch_in][spar_band] != 0.0f || hSpar->hMdDec->mixer_mat[ch_out][ch_in][spar_band + i_ts * MAX_PARAM_SPATIAL_SUBFRAMES] != 0.0f ) { skip_flag = 0; break; @@ -860,7 +860,7 @@ static void ivas_spar_get_skip_mat( if ( skip_flag == 0 ) { - skip_mat[out_ch][in_ch] = 0; + skip_mat[ch_out][ch_in] = 0; break; } } @@ -888,7 +888,7 @@ void ivas_spar_dec_upmixer( int16_t cldfb_band, num_cldfb_bands; float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX]; float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX]; - int16_t i, b, ts, out_ch, in_ch; + int16_t i, b, ts, ch_out, ch_in; int16_t num_spar_bands, spar_band, num_bands_out, split_band; float Pcm_tmp[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float *pPcm_tmp[MAX_OUTPUT_CHANNELS]; @@ -937,9 +937,9 @@ void ivas_spar_dec_upmixer( } for ( smp = 0; smp < L_FRAME48k; smp++ ) { - for ( in_ch = 0; in_ch < nchan_transport; in_ch++ ) + for ( ch_in = 0; ch_in < nchan_transport; ch_in++ ) { - fread( &output[in_ch][smp], sizeof( float ), 1, fid_enc ); + fread( &output[ch_in][smp], sizeof( float ), 1, fid_enc ); } } } @@ -1019,23 +1019,23 @@ void ivas_spar_dec_upmixer( if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) { /* at this point, output channels are used as intermediate procesing buffers */ - for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS; in_ch++ ) + for ( ch_in = 0; ch_in < MAX_OUTPUT_CHANNELS; ch_in++ ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { - cldfb_in_ts_re[in_ch][ts] = &Pcm_tmp[in_ch][ts * num_cldfb_bands]; - cldfb_in_ts_im[in_ch][ts] = &Pcm_tmp[in_ch][ts * num_cldfb_bands + 4 * num_cldfb_bands]; + cldfb_in_ts_re[ch_in][ts] = &Pcm_tmp[ch_in][ts * num_cldfb_bands]; + cldfb_in_ts_im[ch_in][ts] = &Pcm_tmp[ch_in][ts * num_cldfb_bands + 4 * num_cldfb_bands]; } } } else { - for ( in_ch = 0; in_ch < nchan_inp; in_ch++ ) + for ( ch_in = 0; ch_in < nchan_inp; ch_in++ ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { - cldfb_in_ts_re[in_ch][ts] = &Pcm_tmp[in_ch][ts * num_cldfb_bands]; - cldfb_in_ts_im[in_ch][ts] = &Pcm_tmp[in_ch][ts * num_cldfb_bands + 4 * num_cldfb_bands]; + cldfb_in_ts_re[ch_in][ts] = &Pcm_tmp[ch_in][ts * num_cldfb_bands]; + cldfb_in_ts_im[ch_in][ts] = &Pcm_tmp[ch_in][ts * num_cldfb_bands + 4 * num_cldfb_bands]; } } } @@ -1060,16 +1060,16 @@ void ivas_spar_dec_upmixer( for ( int16_t i_sf = 0; i_sf < MAX_PARAM_SPATIAL_SUBFRAMES; i_sf++ ) { /* CLDFB analysis of incoming frame */ - for ( in_ch = 0; in_ch < nchan_inp; in_ch++ ) + for ( ch_in = 0; ch_in < nchan_inp; ch_in++ ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { cldfbAnalysis_ts( - &output[in_ch][( ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES ) * num_cldfb_bands], - cldfb_in_ts_re[in_ch][ts], - cldfb_in_ts_im[in_ch][ts], + &output[ch_in][( ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES ) * num_cldfb_bands], + cldfb_in_ts_re[ch_in][ts], + cldfb_in_ts_im[ch_in][ts], num_cldfb_bands, - st_ivas->cldfbAnaDec[in_ch] ); + st_ivas->cldfbAnaDec[ch_in] ); } } @@ -1085,21 +1085,21 @@ void ivas_spar_dec_upmixer( float cldfb_par; ivas_fb_bin_to_band_data_t *bin2band = &hSpar->hFbMixer->pFb->fb_bin_to_band; - for ( out_ch = 0; out_ch < nchan_out; out_ch++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - out_re[out_ch] = 0.0f; - out_im[out_ch] = 0.0f; + out_re[ch_out] = 0.0f; + out_im[ch_out] = 0.0f; - for ( in_ch = 0; in_ch < nchan_inp; in_ch++ ) + for ( ch_in = 0; ch_in < nchan_inp; ch_in++ ) { - if ( b_skip_mat[out_ch][in_ch] ) + if ( b_skip_mat[ch_out][ch_in] ) { continue; } else if ( cldfb_band < CLDFB_PAR_WEIGHT_START_BAND ) /* tuning parameter, depends on how much SPAR Filters overlap for the CLDFB bands */ { spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band]; - cldfb_par = mixer_mat[out_ch][in_ch][spar_band]; + cldfb_par = mixer_mat[ch_out][ch_in][spar_band]; } else { @@ -1107,20 +1107,20 @@ void ivas_spar_dec_upmixer( for ( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ ) { /* accumulate contributions from all SPAR bands */ - cldfb_par += mixer_mat[out_ch][in_ch][spar_band] * bin2band->pp_cldfb_weights_per_spar_band[cldfb_band][spar_band]; + cldfb_par += mixer_mat[ch_out][ch_in][spar_band] * bin2band->pp_cldfb_weights_per_spar_band[cldfb_band][spar_band]; } } - out_re[out_ch] += cldfb_in_ts_re[in_ch][ts][cldfb_band] * cldfb_par; - out_im[out_ch] += cldfb_in_ts_im[in_ch][ts][cldfb_band] * cldfb_par; + out_re[ch_out] += cldfb_in_ts_re[ch_in][ts][cldfb_band] * cldfb_par; + out_im[ch_out] += cldfb_in_ts_im[ch_in][ts][cldfb_band] * cldfb_par; } } /*update CLDFB data with the parameter-modified data*/ - for ( out_ch = 0; out_ch < nchan_out; out_ch++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - cldfb_in_ts_re[out_ch][ts][cldfb_band] = out_re[out_ch]; - cldfb_in_ts_im[out_ch][ts][cldfb_band] = out_im[out_ch]; + cldfb_in_ts_re[ch_out][ts][cldfb_band] = out_re[ch_out]; + cldfb_in_ts_im[ch_out][ts][cldfb_band] = out_im[ch_out]; } } } @@ -1132,12 +1132,12 @@ void ivas_spar_dec_upmixer( if ( st_ivas->hDirAC != NULL ) { - int16_t outchannels, idx_in, idx_lfe, ch; + int16_t nchan, idx_in, idx_lfe, ch; idx_in = 0; idx_lfe = 0; - outchannels = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - for ( ch = 0; ch < outchannels; ch++ ) + nchan = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + for ( ch = 0; ch < nchan; ch++ ) { if ( ( st_ivas->hOutSetup.num_lfe > 0 ) && ( st_ivas->hOutSetup.index_lfe[idx_lfe] == ch ) ) { @@ -1167,26 +1167,26 @@ void ivas_spar_dec_upmixer( } } #ifdef DEBUG_SBA_AUDIO_DUMP - hSpar->numOutChannels = outchannels; + hSpar->numOutChannels = nchan; #endif } else { /* CLDFB to time synthesis (overwrite mixer output) */ - for ( out_ch = 0; out_ch < hDecoderConfig->nchan_out; out_ch++ ) + for ( ch_out = 0; ch_out < hDecoderConfig->nchan_out; ch_out++ ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { cldfbSynthesis( - &cldfb_in_ts_re[out_ch][ts], - &cldfb_in_ts_im[out_ch][ts], - &output[out_ch][( ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES ) * num_cldfb_bands], + &cldfb_in_ts_re[ch_out][ts], + &cldfb_in_ts_im[ch_out][ts], + &output[ch_out][( ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES ) * num_cldfb_bands], num_cldfb_bands, - st_ivas->cldfbSynDec[out_ch] ); + st_ivas->cldfbSynDec[ch_out] ); } } #ifdef DEBUG_SBA_AUDIO_DUMP - hSpar->numOutChannels = numch_out_dirac; + hSpar->numOutChannels = nchan; #endif } #ifdef DEBUG_SBA_AUDIO_DUMP @@ -1204,13 +1204,13 @@ void ivas_spar_dec_upmixer( mvr2r( hSpar->hMdDec->mixer_mat_prev[3][0][0], hSpar->hMdDec->mixer_mat_prev[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); mvr2r( hSpar->hMdDec->mixer_mat_prev[4][0][0], hSpar->hMdDec->mixer_mat_prev[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - for ( out_ch = 0; out_ch < nchan_out; out_ch++ ) + for ( ch_out = 0; ch_out < nchan_out; ch_out++ ) { - for ( in_ch = 0; in_ch < nchan_inp; in_ch++ ) + for ( ch_in = 0; ch_in < nchan_inp; ch_in++ ) { for ( b = 0; b < num_spar_bands; b++ ) { - hSpar->hMdDec->mixer_mat_prev[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][b + i_sf * IVAS_MAX_NUM_BANDS]; + hSpar->hMdDec->mixer_mat_prev[4][ch_out][ch_in][b] = hSpar->hMdDec->mixer_mat[ch_out][ch_in][b + i_sf * IVAS_MAX_NUM_BANDS]; } } } diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 75ffc5212d..9482a9e003 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -55,7 +55,7 @@ ivas_error ivas_enc( const int16_t n_samples /* i : number of input samples */ ) { - int16_t i, n, input_frame, n_samples_chan, nchan_inp; + int16_t i, ch, input_frame, n_samples_chan, nchan_inp; int32_t input_Fs; IVAS_FORMAT ivas_format; ENCODER_CONFIG_HANDLE hEncoderConfig; @@ -90,8 +90,8 @@ ivas_error ivas_enc( * convert 'short' input data to 'float' *----------------------------------------------------------------*/ - n = 0; - while ( n < nchan_inp ) + ch = 0; + while ( ch < nchan_inp ) { #ifdef DEBUG_MODE_LFE if ( n == LFE_CHANNEL ) @@ -99,23 +99,23 @@ ivas_error ivas_enc( int16_t tmp[L_FRAME48k]; for ( i = 0; i < n_samples_chan; i++ ) { - tmp[i] = data[i * nchan_inp + n]; + tmp[i] = data[i * nchan_inp + nch]; } dbgwrite( tmp, sizeof( int16_t ), n_samples_chan, 1, "./lfe_chan_in.raw" ); } #endif for ( i = 0; i < n_samples_chan; i++ ) { - data_f[n][i] = (float) data[i * nchan_inp + n]; + data_f[ch][i] = (float) data[i * nchan_inp + ch]; } - n++; + ch++; } if ( n_samples_chan < input_frame ) { - for ( n = 0; n < nchan_inp; n++ ) + for ( ch = 0; ch < nchan_inp; ch++ ) { - set_f( data_f[n] + n_samples_chan, 0.0f, input_frame - n_samples_chan ); + set_f( data_f[ch] + n_samples_chan, 0.0f, input_frame - n_samples_chan ); } } @@ -127,10 +127,10 @@ ivas_error ivas_enc( * HP filtering *----------------------------------------------------------------*/ - n = getNumChanAnalysis( st_ivas ); + ch = getNumChanAnalysis( st_ivas ); #ifndef DEBUG_SPAR_BYPASS_EVS_CODEC /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */ - for ( i = 0; i < n; i++ ) + for ( i = 0; i < ch; i++ ) { if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) /*TODO: is the HPF needed for LFE channel? */ { -- GitLab From cdaa9dd9cd043d1a161e6d34ecf2254a7438a4bf Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Oct 2022 16:38:57 +0200 Subject: [PATCH 5/7] fix prerenderer compilation error --- lib_util/ivas_prerenderer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_util/ivas_prerenderer.c b/lib_util/ivas_prerenderer.c index a2c0b4c710..018d8f1dc5 100644 --- a/lib_util/ivas_prerenderer.c +++ b/lib_util/ivas_prerenderer.c @@ -1715,7 +1715,7 @@ static void ivas_limiter_prerenderer( } channels = hLimiter->channel_ptrs; - num_channels = hLimiter->num_channels; + num_channels = hLimiter->nchan; for ( c = 0; c < num_channels; ++c ) { -- GitLab From 4fa66a3781fbaf08f92aada216f69cb4e63cf410 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 20 Oct 2022 15:53:59 +0200 Subject: [PATCH 6/7] change nchan -> nchan_dmx --- lib_dec/ivas_spar_md_dec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index bb81448b81..ac950784f3 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -750,18 +750,18 @@ void ivas_spar_smooth_md_dtx( const int16_t num_bands_out /* i : number of output bands */ ) { - int16_t j, k, b, nchan; + int16_t j, k, b, nchan_dmx; float ramp, tar, prev, new_val; ramp = (float) hMdDec->dtx_md_smoothing_cntr / IVAS_DEFAULT_DTX_CNG_RAMP; for ( b = 0; b < num_bands_out; b++ ) { - nchan = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; + nchan_dmx = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; for ( j = 1; j < FOA_CHANNELS; j++ ) { - for ( k = nchan; k < FOA_CHANNELS; k++ ) + for ( k = nchan_dmx; k < FOA_CHANNELS; k++ ) { prev = hMdDec->spar_coeffs_prev.P_re[j][k][b]; tar = hMdDec->spar_coeffs_tar.P_re[j][k][b]; @@ -772,7 +772,7 @@ void ivas_spar_smooth_md_dtx( for ( j = 0; j < FOA_CHANNELS; j++ ) { - for ( k = 0; k < nchan; k++ ) + for ( k = 0; k < nchan_dmx; k++ ) { prev = hMdDec->spar_coeffs_prev.C_re[j][k][b]; tar = hMdDec->spar_coeffs_tar.C_re[j][k][b]; @@ -787,11 +787,11 @@ void ivas_spar_smooth_md_dtx( { for ( b = 0; b < num_bands_out; b++ ) { - nchan = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; + nchan_dmx = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; for ( j = 1; j < FOA_CHANNELS; j++ ) { - for ( k = nchan; k < FOA_CHANNELS; k++ ) + for ( k = nchan_dmx; k < FOA_CHANNELS; k++ ) { hMdDec->spar_coeffs.P_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.P_re[j][k][b]; } @@ -799,7 +799,7 @@ void ivas_spar_smooth_md_dtx( for ( j = 0; j < FOA_CHANNELS; j++ ) { - for ( k = 0; k < nchan; k++ ) + for ( k = 0; k < nchan_dmx; k++ ) { hMdDec->spar_coeffs.C_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.C_re[j][k][b]; } -- GitLab From 1657df9b89ad6db4f8b3935e61974f4120acead2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 21 Oct 2022 12:52:20 +0200 Subject: [PATCH 7/7] fix merge issue --- lib_enc/ivas_spar_md_enc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 0a546157f3..b42f8bd660 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -838,7 +838,6 @@ ivas_error ivas_spar_md_enc_process( } } - ivas_create_fullr_dmx_mat( pred_coeffs_re, dm_fv_re, hMdEnc->mixer_mat, nchan, 0, num_bands, active_w, &hMdEnc->spar_md_cfg ); #ifdef SBA_HOA_HBR_IMPROV if ( hMdEnc->spar_hoa_md_flag ) { @@ -855,6 +854,8 @@ ivas_error ivas_spar_md_enc_process( } #endif + ivas_create_fullr_dmx_mat( pred_coeffs_re, dm_fv_re, hMdEnc->mixer_mat, nchan, 0, num_bands, active_w, &hMdEnc->spar_md_cfg ); + for ( b = 0; b < num_bands; b++ ) { ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; -- GitLab