From 25fda054b935135e3e42b8dac9eb4a469177f08c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 10 Jun 2024 15:09:25 +0530 Subject: [PATCH 1/2] cleanup of float struct members, replacing libcom functions in encoder with fxd [x] Cleanup of structure members from ivas_stat_rend [x] Cleanup of ivas_dirac_dec_binaural_render and ivas_omasa_dirac_td_binaural_jb [x] Cleanup of cy_auto_diff_smooth and cy_auto_diff_smooth_prev [x] Integration of lib_com fixed functions in encoder [x] dirac_output_synthesis_state_structure cleanup --- lib_com/ivas_fb_mixer.c | 126 +++++++- lib_com/ivas_masa_com.c | 137 +++----- lib_com/ivas_prot.h | 4 +- lib_com/ivas_prot_fx.h | 36 +++ lib_com/ivas_sba_config.c | 127 +++++++- lib_com/ivas_spar_com.c | 10 +- lib_dec/ivas_dirac_dec.c | 247 +-------------- lib_dec/ivas_dirac_output_synthesis_cov.c | 27 +- lib_dec/ivas_init_dec.c | 6 +- lib_dec/ivas_jbm_dec.c | 71 ++++- lib_dec/ivas_omasa_dec.c | 116 +++---- lib_dec/ivas_output_config.c | 5 +- lib_dec/ivas_sba_dec.c | 9 +- lib_dec/ivas_spar_decoder.c | 12 +- lib_dec/ivas_spar_md_dec.c | 8 +- lib_dec/lib_dec_fx.c | 31 +- lib_enc/ivas_init_enc.c | 16 + lib_enc/ivas_masa_enc.c | 143 +++++++++ lib_enc/ivas_osba_enc.c | 8 + lib_enc/ivas_sba_enc.c | 8 + lib_enc/ivas_spar_encoder.c | 6 +- lib_enc/ivas_spar_md_enc.c | 18 +- lib_enc/ivas_stat_enc.h | 4 + lib_enc/lib_enc.c | 12 + lib_rend/ivas_allrad_dec.c | 5 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 110 +++++-- lib_rend/ivas_dirac_decorr_dec.c | 309 ++++++++----------- lib_rend/ivas_dirac_output_synthesis_dec.c | 117 ------- lib_rend/ivas_dirac_rend.c | 21 +- lib_rend/ivas_mcmasa_ana.c | 11 +- lib_rend/ivas_output_init.c | 9 + lib_rend/ivas_output_init_fx.c | 4 +- lib_rend/ivas_prot_rend.h | 13 +- lib_rend/ivas_stat_rend.h | 48 +-- lib_rend/ivas_vbap.c | 11 +- lib_rend/lib_rend.c | 136 +------- lib_util/hrtf_file_reader.c | 83 ++--- lib_util/masa_file_reader.c | 7 + 38 files changed, 1037 insertions(+), 1034 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index d3dceac37..a03655eed 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -527,8 +527,8 @@ ivas_error ivas_FB_mixer_open_fx( { if ( fb_cfg->num_out_chans == 0 ) { - hFbMixer->ppFilterbank_inFR_re[i] = NULL; - hFbMixer->ppFilterbank_inFR_im[i] = NULL; + hFbMixer->ppFilterbank_inFR_re_fx[i] = NULL; + hFbMixer->ppFilterbank_inFR_im_fx[i] = NULL; } else { @@ -650,7 +650,7 @@ ivas_error ivas_FB_mixer_open_fx( for ( j = start_diff_band_non48k; j < num_bands; j++ ) { -#if 1 ////////////////////////////////// FLOAT //////////////////////// +#if 0 ////////////////////////////////// FLOAT //////////////////////// if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); @@ -961,7 +961,7 @@ void ivas_FB_mixer_close( } #ifdef IVAS_FLOAT_FIXED - FOR( j = start_diff_band_non48k; j < num_bands; j++ ) + FOR ( j = start_diff_band_non48k; j < num_bands; j++ ) { free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] ); hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] = NULL; @@ -995,6 +995,124 @@ void ivas_FB_mixer_close( return; } +#ifdef IVAS_FLOAT_FIXED +void ivas_FB_mixer_close_fx( + IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ + const int32_t sampling_rate, /* i : sampling rate in Hz */ + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ +) +{ + IVAS_FB_MIXER_HANDLE hFbMixer; + IVAS_FB_CFG *fb_cfg; + int16_t i, j, num_bands; + int16_t num_chs_alloc; + + hFbMixer = *hFbMixer_in; + fb_cfg = hFbMixer->fb_cfg; + + IF ( fb_cfg->active_w_mixing == -1 ) + { + num_chs_alloc = 0; + } + ELSE IF ( fb_cfg->active_w_mixing ) + { + num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); + } + ELSE + { + num_chs_alloc = 1; /* only W channel processed for predicting YZX */ + } + + IF ( hFbMixer != NULL ) + { + FOR ( i = 0; i < num_chs_alloc; i++ ) + { + IF ( fb_cfg->num_out_chans > 0 ) + { + j = fb_cfg->remix_order[i]; + + free( hFbMixer->ppFilterbank_inFR_re_fx[j] ); + hFbMixer->ppFilterbank_inFR_re_fx[j] = NULL; + + free( hFbMixer->ppFilterbank_inFR_im_fx[j] ); + hFbMixer->ppFilterbank_inFR_im_fx[j] = NULL; + } + } + + IF ( fb_cfg->active_w_mixing == -1 ) + { + num_chs_alloc = 0; + } + ELSE + { + num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); + } + + FOR ( i = 0; i < num_chs_alloc; i++ ) + { + free( hFbMixer->ppFilterbank_prior_input_fx[i] ); + hFbMixer->ppFilterbank_prior_input_fx[i] = NULL; + } + + IF ( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) ) + { + free( hFbMixer->prior_mixer_fx[0][0] ); + hFbMixer->prior_mixer_fx[0][0] = NULL; + } + + IF ( !spar_reconfig_flag ) + { + IF ( fb_cfg->num_out_chans > 0 ) + { + num_bands = hFbMixer->pFb->filterbank_num_bands; + + IF ( fb_cfg->active_w_mixing != -1 ) + { + FOR ( i = 0; i < num_bands; i++ ) + { + free( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band_fx[i] ); + hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band_fx[i] = NULL; + } + } + + IF ( sampling_rate != 48000 ) + { + int16_t start_diff_band_non48k; + start_diff_band_non48k = num_bands - hFbMixer->num_diff_bands; + + FOR ( j = start_diff_band_non48k; j < num_bands; j++ ) + { + free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] ); + hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] = NULL; + + free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[1][j] ); + hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[1][j] = NULL; + } + } + } + IF ( hFbMixer->pFb != NULL ) + { + free( hFbMixer->pFb ); + hFbMixer->pFb = NULL; + } + } + + IF ( hFbMixer->fb_cfg != NULL ) + { + free( hFbMixer->fb_cfg ); + hFbMixer->fb_cfg = NULL; + } + + IF ( !spar_reconfig_flag ) + { + free( hFbMixer ); + hFbMixer = NULL; + } + } + + return; +} +#endif /*-----------------------------------------------------------------------------------------* * Function ivas_fb_mixer_pcm_ingest() diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index c4cac721c..bce454a57 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -58,13 +58,13 @@ * Local prototypes *---------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static int16_t quantize_theta_masa( float x, const int16_t no_cb, float *xhat ); -#ifdef IVAS_FLOAT_FIXED -static Word16 quantize_theta_masa_fx( const Word32 x_fx, const Word16 no_cb, Word32 *xhat_fx ); -#endif static int16_t quantize_phi_masa( float phi, const int16_t flag_delta, float *phi_hat, const int16_t n ); -#ifdef IVAS_FLOAT_FIXED +#else +static Word16 quantize_theta_masa_fx( const Word32 x_fx, const Word16 no_cb, Word32 *xhat_fx ); + static int16_t quantize_phi_masa_fx( const Word32 phi, const Word16 flag_delta, Word32 *phi_hat, const Word16 n ); #endif @@ -75,6 +75,7 @@ static int16_t quantize_phi_masa_fx( const Word32 phi, const Word16 flag_delta, * Set-up MASA coding elements and bitrates *---------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_masa_set_elements( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t mc_mode, /* i : MC format mode */ @@ -164,7 +165,7 @@ void ivas_masa_set_elements( return; } - +#else void ivas_masa_set_elements_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ const Word16 mc_mode, /* i : MC format mode */ @@ -282,6 +283,8 @@ void ivas_masa_set_elements_fx( return; } +#endif + /*--------------------------------------------------------------- * generate_gridEq() @@ -289,6 +292,7 @@ void ivas_masa_set_elements_fx( * generate Spherical grid *---------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void generate_gridEq( SPHERICAL_GRID_DATA *data /* o : data structure for grid */ ) @@ -322,8 +326,7 @@ void generate_gridEq( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void generate_gridEq_fx( SPHERICAL_GRID_DATA *data /* o : data structure for grid */ ) @@ -355,6 +358,7 @@ void generate_gridEq_fx( * and other metadata properties. *---------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_masa_set_coding_config( MASA_CODEC_CONFIG *config, /* i/o: MASA coding config structure */ int16_t *band_mapping, /* o : Band mapping used */ @@ -484,15 +488,7 @@ void ivas_masa_set_coding_config( return; } - -#ifdef IVAS_FLOAT_FIXED -/*--------------------------------------------------------------- - * ivas_masa_set_coding_config_fx() - * - * Sets MASA codec parameters based on bitrate, number of directions, - * and other metadata properties. - *---------------------------------------------------------------*/ - +#else void ivas_masa_set_coding_config_fx( MASA_CODEC_CONFIG *config, /* i/o: MASA coding config structure */ Word16 *band_mapping, /* o : Band mapping used */ @@ -654,6 +650,7 @@ void ivas_masa_set_coding_config_fx( * *---------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void masa_sample_rate_band_correction( MASA_CODEC_CONFIG *config, /* i/o: MASA codec config */ int16_t *band_mapping, /* i/o: Band mapping used and modified */ @@ -702,17 +699,9 @@ void masa_sample_rate_band_correction( for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { hQMetaData->q_direction[0].band_data[band].azimuth[sf] = 0.0f; -#ifdef IVAS_FLOAT_FIXED - hQMetaData->q_direction[0].band_data[band].azimuth_fx[sf] = 0; -#endif hQMetaData->q_direction[0].band_data[band].elevation[sf] = 0.0f; -#ifdef IVAS_FLOAT_FIXED - hQMetaData->q_direction[0].band_data[band].elevation_fx[sf] = 0; -#endif hQMetaData->q_direction[0].band_data[band].energy_ratio[sf] = 0.0f; -#ifdef IVAS_FLOAT_FIXED - hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[sf] = 0; -#endif + if ( hQMetaData->coherence_flag && hQMetaData->q_direction[0].coherence_band_data != NULL ) { hQMetaData->q_direction[0].coherence_band_data[band].spread_coherence[sf] = 0u; @@ -721,17 +710,8 @@ void masa_sample_rate_band_correction( if ( hQMetaData->no_directions == 2 ) { hQMetaData->q_direction[1].band_data[band].azimuth[sf] = 0.0f; -#ifdef IVAS_FLOAT_FIXED - hQMetaData->q_direction[1].band_data[band].azimuth_fx[sf] = 0; -#endif hQMetaData->q_direction[1].band_data[band].elevation[sf] = 0.0f; -#ifdef IVAS_FLOAT_FIXED - hQMetaData->q_direction[1].band_data[band].elevation_fx[sf] = 0; -#endif hQMetaData->q_direction[1].band_data[band].energy_ratio[sf] = 0.0f; -#ifdef IVAS_FLOAT_FIXED - hQMetaData->q_direction[1].band_data[band].energy_ratio_fx[sf] = 0; -#endif if ( hQMetaData->coherence_flag && hQMetaData->q_direction[1].coherence_band_data != NULL ) { @@ -774,8 +754,7 @@ void masa_sample_rate_band_correction( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void masa_sample_rate_band_correction_fx( MASA_CODEC_CONFIG *config, /* i/o: MASA codec config */ Word16 *band_mapping, /* i/o: Band mapping used and modified */ @@ -899,6 +878,7 @@ void masa_sample_rate_band_correction_fx( *------------------------------------------------------------------------*/ /*! r: output index for direction */ +#ifndef IVAS_FLOAT_FIXED uint16_t index_theta_phi_16( float *p_theta, /* i/o: input elevation to be indexed */ float *p_phi, /* i/o: input azimuth to be indexed */ @@ -988,15 +968,7 @@ uint16_t index_theta_phi_16( return idx_sph; } - -#ifdef IVAS_FLOAT_FIXED -/*------------------------------------------------------------------------- - * index_theta_phi_16_fx() - * - * - *------------------------------------------------------------------------*/ - -/*! r: output index for direction */ +#else UWord16 index_theta_phi_16_fx( Word32 *p_theta, /* i/o: input elevation to be indexed */ Word32 *p_phi, /* i/o: input azimuth to be indexed */ @@ -1102,6 +1074,7 @@ UWord16 index_theta_phi_16_fx( } #endif + /*------------------------------------------------------------------------- * quantize_phi_masa() * @@ -1109,6 +1082,7 @@ UWord16 index_theta_phi_16_fx( *------------------------------------------------------------------------*/ /*! r: output index */ +#ifndef IVAS_FLOAT_FIXED static int16_t quantize_theta_masa( float x, /* i : theta value to be quantized */ const int16_t no_cb, /* i : number of codewords */ @@ -1142,15 +1116,7 @@ static int16_t quantize_theta_masa( return imin; } - -#ifdef IVAS_FLOAT_FIXED -/*------------------------------------------------------------------------- - * quantize_theta_masa_fx() - * - * - *------------------------------------------------------------------------*/ - -/*! r: output index */ +#else static Word16 quantize_theta_masa_fx( const Word32 x_fx, /* i : theta value to be quantized */ const Word16 no_cb, /* i : number of codewords */ @@ -1186,6 +1152,7 @@ static Word16 quantize_theta_masa_fx( } #endif + /*------------------------------------------------------------------------- * quantize_phi_masa() * @@ -1193,6 +1160,7 @@ static Word16 quantize_theta_masa_fx( *------------------------------------------------------------------------*/ /*! r: index azimuth */ +#ifndef IVAS_FLOAT_FIXED static int16_t quantize_phi_masa( float phi, /* i : azimuth value */ const Word16 flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ @@ -1238,15 +1206,7 @@ static int16_t quantize_phi_masa( return id_phi; } - -#ifdef IVAS_FLOAT_FIXED -/*------------------------------------------------------------------------- - * quantize_phi_masa_fx() - * - * - *------------------------------------------------------------------------*/ - -/*! r: index azimuth */ +#else static Word16 quantize_phi_masa_fx( const Word32 phi_fx, /* i : azimuth value */ const Word16 flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ @@ -1301,9 +1261,9 @@ static Word16 quantize_phi_masa_fx( return id_phi; } - #endif + /*------------------------------------------------------------------------- * deindex_sph_idx() * @@ -1614,6 +1574,7 @@ void deindex_sph_idx_fx( *---------------------------------------------------------------*/ /*! r: valid or not 1/0 */ +#ifndef IVAS_FLOAT_FIXED int16_t valid_ratio_index( int16_t index, /* i : index to be checked */ const int16_t K, /* i : L1 norm to check against */ @@ -1650,8 +1611,7 @@ int16_t valid_ratio_index( return out; } - -#ifdef IVAS_FLOAT_FIXED +#else Word16 valid_ratio_index_fx( Word16 index, /* i : index to be checked */ const Word16 K, /* i : L1 norm to check against */ @@ -1708,6 +1668,7 @@ Word16 valid_ratio_index_fx( * Obtains ISM ratio values from the quantized indexes *---------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void reconstruct_ism_ratios( int16_t *ratio_ism_idx, /* i : index vector */ const int16_t nchan_ism, /* i : number of components/objects */ @@ -1734,14 +1695,7 @@ void reconstruct_ism_ratios( return; } - - -/*--------------------------------------------------------------- - * reconstruct_ism_ratios_fx() - * - * Obtains ISM ratio values from the quantized indexes - *---------------------------------------------------------------*/ - +#else void reconstruct_ism_ratios_fx( Word16 *ratio_ism_idx, /* i : index vector Q0 */ const Word16 nchan_ism, /* i : number of components/objects Q0 */ @@ -1774,6 +1728,7 @@ void reconstruct_ism_ratios_fx( return; } +#endif /*--------------------------------------------------------------- @@ -1783,6 +1738,7 @@ void reconstruct_ism_ratios_fx( * to the total audio scene *---------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_omasa_modify_masa_energy_ratios( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_MAXIMUM_CODING_SUBBANDS] ) @@ -1811,15 +1767,7 @@ void ivas_omasa_modify_masa_energy_ratios( return; } - -#ifdef IVAS_FLOAT_FIXED -/*--------------------------------------------------------------- - * ivas_omasa_modify_masa_energy_ratios_fx() - * - * Updates energy ratios by taking into account the MASA content contribution - * to the total audio scene - *---------------------------------------------------------------*/ - +#else void ivas_omasa_modify_masa_energy_ratios_fx( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ Word32 masa_to_total_energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_MAXIMUM_CODING_SUBBANDS] /* Q30 */ ) @@ -1863,6 +1811,7 @@ void ivas_omasa_modify_masa_energy_ratios_fx( * Obtain ISM ratio indexes for even content distribution bbetween objects *---------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void distribute_evenly_ism( int16_t *idx, /* o : index values */ const int16_t K, /* i : sum of indexes */ @@ -1895,14 +1844,7 @@ void distribute_evenly_ism( return; } - -#ifdef IVAS_FLOAT_FIXED -/*--------------------------------------------------------------- - * distribute_evenly_ism_fx() - * - * Obtain ISM ratio indexes for even content distribution bbetween objects - *---------------------------------------------------------------*/ - +#else void distribute_evenly_ism_fx( Word16 *idx, /* o : index values */ const Word16 K, /* i : sum of indexes */ @@ -1959,6 +1901,7 @@ void distribute_evenly_ism_fx( *---------------------------------------------------------------*/ /*! r: CPE bitrate value */ +#ifndef IVAS_FLOAT_FIXED int32_t calculate_cpe_brate_MASA_ISM( const ISM_MODE ism_mode, /* i : ism mode */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ @@ -1994,16 +1937,7 @@ int32_t calculate_cpe_brate_MASA_ISM( return cpe_brate; } - - -/*--------------------------------------------------------------- - * calculate_cpe_brate_MASA_ISM_fx() - * - * Calculates bitrate for MASA_ISM mode that is not used for separated objects, - * * but for the CPE part (metadata included) - *---------------------------------------------------------------*/ - -/*! r: CPE bitrate value */ +#else Word32 calculate_cpe_brate_MASA_ISM_fx( const ISM_MODE ism_mode, /* i : ism mode */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ @@ -2044,3 +1978,4 @@ Word32 calculate_cpe_brate_MASA_ISM_fx( return cpe_brate; } +#endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index ca0bcf69e..058e962ac 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -7379,7 +7379,7 @@ ivas_error ivas_omasa_ism_metadata_dec( const int16_t dirac_bs_md_write_idx, /* i : DirAC bitstream write index */ int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ); - +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_omasa_dirac_td_binaural_jbm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of samples requested */ @@ -7388,7 +7388,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( const int16_t nchan_transport, /* i : number of transport channels */ float *output_f[] /* o : rendered time signal */ ); - +#endif void ivas_omasa_rearrange_channels( float *output[], /* o : output synthesis signal */ const int16_t nchan_transport_ism, /* i : number of ISM TCs */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 61a49b5d1..10885e58b 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2223,6 +2223,12 @@ ivas_error ivas_FB_mixer_open_fx( const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */ ); +void ivas_FB_mixer_close_fx( + IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ + const int32_t sampling_rate, /* i : sampling rate in Hz */ + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ +); + void ivas_fb_mixer_cross_fading_fx( IVAS_FB_MIXER_HANDLE hFbMixer, Word32 **ppOut_pcm_fx, @@ -2232,4 +2238,34 @@ void ivas_fb_mixer_cross_fading_fx( const int16_t frame_len, const int16_t cf_offset ); +// ivas_omasa_dec.c +ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailable, /* o : number of samples still to render */ + const Word16 nchan_transport, /* i : number of transport channels */ + Word32 *output_fx[] /* o : rendered time signal */ +); + +Word16 ivas_sba_get_analysis_order_fx( + const Word32 ivas_total_brate, /* i : IVAS total bitrate */ + const Word16 sba_order /* i : Ambisonic (SBA) order */ +); + +Word16 ivas_sba_get_nchan_metadata_fx( + const Word16 sba_order, /* i : Ambisonic (SBA) order */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +void ivas_sba_get_spar_hoa_ch_ind_fx( + const Word16 num_md_chs, /* i : number of MD channels */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate */ + Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] ); + +void ivas_sba_get_spar_hoa_md_flag_fx( + const Word16 sba_order, /* i : Ambisonic (SBA) order */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate */ + Word16 *spar_hoa_md_flag, + Word16 *spar_hoa_dirac2spar_md_flag ); #endif diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 737127e59..23096223f 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -50,6 +50,7 @@ * Configure SBA coding *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_sba_config( const int32_t sba_total_brate, /* i : SBA total bitrate */ int16_t sba_order, /* i : Ambisonic (SBA) order */ @@ -113,8 +114,7 @@ void ivas_sba_config( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void ivas_sba_config_fx( const Word32 sba_total_brate, /* i : SBA total bitrate */ Word16 sba_order, /* i : Ambisonic (SBA) order */ @@ -126,6 +126,7 @@ void ivas_sba_config_fx( Word16 *element_mode /* o : element mode of the core coder */ ) { + test(); IF( ( LT_16( sba_order, 0 ) ) && ( LT_16( nb_channels, 0 ) ) ) { assert( 0 && "Either order or number of channels must be positive" ); @@ -136,7 +137,7 @@ void ivas_sba_config_fx( } ELSE IF( LT_16( nb_channels, 0 ) ) { - nb_channels = (Word16) ivas_sba_get_nchan_fx( sba_order, sba_planar ); + nb_channels = ivas_sba_get_nchan_fx( sba_order, sba_planar ); } ELSE { @@ -161,24 +162,31 @@ void ivas_sba_config_fx( IF( EQ_16( *nchan_transport, 1 ) ) { *nSCE = 1; + move16(); *nCPE = 0; + move16(); *element_mode = IVAS_SCE; + move16(); } ELSE { *nSCE = 0; + move16(); *nCPE = shr( *nchan_transport, 1 ); IF( NE_16( i_mult( 2, ( *nCPE ) ), *nchan_transport ) ) { *nCPE = add( *nCPE, 1 ); } *element_mode = IVAS_CPE_MDCT; + move16(); } } return; } #endif + + /*-------------------------------------------------------------------* * ivas_sba_get_order() * @@ -186,6 +194,7 @@ void ivas_sba_config_fx( *-------------------------------------------------------------------*/ /*! r: Ambisonic (SBA) order */ +#ifndef IVAS_FLOAT_FIXED int16_t ivas_sba_get_order( const int16_t nb_channels, /* i : Number of ambisonic channels */ const int16_t sba_planar /* i : SBA Planar flag */ @@ -208,15 +217,17 @@ int16_t ivas_sba_get_order( return ( sba_order ); } - -#ifdef IVAS_FLOAT_FIXED +#else Word16 ivas_sba_get_order_fx( const Word16 nb_channels, /* i : Number of ambisonic channels */ const Word16 sba_planar /* i : SBA Planar flag */ ) { Word16 sba_order; - Word16 exp = 0; + + /* sba_order = (int16_t) sqrtf( (float) nb_channels ) - 1 */ + Word16 sba_order_non_sba_planar[MAX_INPUT_CHANNELS] = { 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3 }; + IF( sba_planar ) { sba_order = shr( sub( nb_channels, 1 ), 1 ); @@ -224,7 +235,8 @@ Word16 ivas_sba_get_order_fx( } ELSE { - sba_order = sub( Sqrt16( nb_channels, &exp ), MAX16B ); // 15 - exp + sba_order = sba_order_non_sba_planar[nb_channels - 1]; + move16(); assert( ( EQ_16( mult( add( sba_order, 1 ), add( sba_order, 1 ) ), nb_channels ) ) && "Number of channels not supported in SBA!" ); } @@ -234,6 +246,7 @@ Word16 ivas_sba_get_order_fx( } #endif + /*-------------------------------------------------------------------* * ivas_sba_get_analysis_order() * @@ -241,7 +254,26 @@ Word16 ivas_sba_get_order_fx( *-------------------------------------------------------------------*/ /*! r: Ambisonic (SBA) order used for analysis and coding */ -Word16 ivas_sba_get_analysis_order( +#ifndef IVAS_FLOAT_FIXED +int16_t ivas_sba_get_analysis_order( + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ +) +{ + int16_t sba_analysis_order; + + sba_analysis_order = sba_order; + + if ( ivas_total_brate < SBA_MIN_BRATE_HOA ) + { + /* Hard coding the sba_analysis_order as 1 as higher not supported below SBA_MIN_BRATE_HOA bitrate */ + sba_analysis_order = SBA_FOA_ORDER; + } + + return sba_analysis_order; +} +#else +Word16 ivas_sba_get_analysis_order_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ const Word16 sba_order /* i : Ambisonic (SBA) order */ ) @@ -249,15 +281,18 @@ Word16 ivas_sba_get_analysis_order( Word16 sba_analysis_order; sba_analysis_order = sba_order; + move16(); IF( LT_32( ivas_total_brate, SBA_MIN_BRATE_HOA ) ) { /* Hard coding the sba_analysis_order as 1 as higher not supported below SBA_MIN_BRATE_HOA bitrate */ sba_analysis_order = SBA_FOA_ORDER; + move16(); } return sba_analysis_order; } +#endif /*-------------------------------------------------------------------* @@ -285,7 +320,7 @@ int16_t ivas_sba_get_nchan( return ( nb_channels ); } - +#ifdef IVAS_FLOAT_FIXED Word16 ivas_sba_get_nchan_fx( const Word16 sba_order, /* i : Ambisonic (SBA) order */ const Word16 sba_planar /* i : SBA planar flag */ @@ -295,15 +330,17 @@ Word16 ivas_sba_get_nchan_fx( IF( sba_planar ) { - nb_channels = add( mult( 2, sba_order ), 1 ); + nb_channels = add( shl( sba_order, 1 ), 1 ); } ELSE { - nb_channels = mult0( add( sba_order, 1 ), add( sba_order, 1 ) ); + nb_channels = i_mult( add( sba_order, 1 ), add( sba_order, 1 ) ); } return ( nb_channels ); } +#endif + /*-------------------------------------------------------------------* * ivas_sba_get_nchan_metadata() @@ -313,7 +350,7 @@ Word16 ivas_sba_get_nchan_fx( /*! r: number of ambisonics metadata channels */ #ifdef IVAS_FLOAT_FIXED -Word16 ivas_sba_get_nchan_metadata( +Word16 ivas_sba_get_nchan_metadata_fx( const Word16 sba_order, /* i : Ambisonic (SBA) order */ const Word32 ivas_total_brate /* i : IVAS total bitrate */ ) @@ -342,7 +379,7 @@ Word16 ivas_sba_get_nchan_metadata( return ( nb_channels ); } -#else +#endif int16_t ivas_sba_get_nchan_metadata( const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int32_t ivas_total_brate /* i : IVAS total bitrate */ @@ -370,7 +407,6 @@ int16_t ivas_sba_get_nchan_metadata( return ( nb_channels ); } -#endif /*-------------------------------------------------------------------* @@ -380,7 +416,33 @@ int16_t ivas_sba_get_nchan_metadata( *-------------------------------------------------------------------*/ /*! r: flag indicating to code SPAR HOA MD for all bands */ +#ifndef IVAS_FLOAT_FIXED void ivas_sba_get_spar_hoa_ch_ind( + const int16_t num_md_chs, /* i : number of MD channels */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] ) +{ + int16_t ch; + const int16_t *hoa_ind; + + if ( ivas_total_brate >= IVAS_512k ) + { + hoa_ind = HOA_keep_ind_spar512; + } + else + { + hoa_ind = HOA_keep_ind_spar; + } + + for ( ch = 0; ch < num_md_chs; ch++ ) + { + HOA_md_ind[ch] = hoa_ind[ch]; + } + + return; +} +#else +void ivas_sba_get_spar_hoa_ch_ind_fx( const Word16 num_md_chs, /* i : number of MD channels */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] ) @@ -400,10 +462,12 @@ void ivas_sba_get_spar_hoa_ch_ind( FOR( ch = 0; ch < num_md_chs; ch++ ) { HOA_md_ind[ch] = hoa_ind[ch]; + move16(); } return; } +#endif /*-------------------------------------------------------------------* @@ -412,32 +476,67 @@ void ivas_sba_get_spar_hoa_ch_ind( * Get the flag to code SPAR HOA MD for all band *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_sba_get_spar_hoa_md_flag( + const int16_t sba_order, /* i : Ambisonic (SBA) order */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + int16_t *spar_hoa_md_flag, + int16_t *spar_hoa_dirac2spar_md_flag ) +{ + if ( sba_order > 1 && ivas_total_brate >= IVAS_256k ) + { + *spar_hoa_md_flag = 1; + } + else + { + *spar_hoa_md_flag = 0; + } + + if ( sba_order > 1 && ivas_total_brate >= IVAS_512k ) + { + *spar_hoa_dirac2spar_md_flag = 0; + } + else + { + *spar_hoa_dirac2spar_md_flag = 1; + } + + return; +} +#else +void ivas_sba_get_spar_hoa_md_flag_fx( const Word16 sba_order, /* i : Ambisonic (SBA) order */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ Word16 *spar_hoa_md_flag, Word16 *spar_hoa_dirac2spar_md_flag ) { + test(); IF( GT_16( sba_order, 1 ) && GE_32( ivas_total_brate, IVAS_256k ) ) { *spar_hoa_md_flag = 1; + move16(); } ELSE { *spar_hoa_md_flag = 0; + move16(); } + test(); IF( GT_16( sba_order, 1 ) && GE_32( ivas_total_brate, IVAS_512k ) ) { *spar_hoa_dirac2spar_md_flag = 0; + move16(); } ELSE { *spar_hoa_dirac2spar_md_flag = 1; + move16(); } return; } +#endif /*-------------------------------------------------------------------* diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index a7299b89f..f37d9ce7d 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -3154,9 +3154,9 @@ void ivas_get_spar_md_from_dirac_fx( remix_order = remix_order_set[hSpar_md_cfg->remix_unmix_order]; - num_ch = ivas_sba_get_nchan_metadata( order, IVAS_256k /*dummy value as order is always 1 in this function*/ ); + num_ch = ivas_sba_get_nchan_metadata_fx( order, IVAS_256k /*dummy value as order is always 1 in this function*/ ); - hoa2_ch = ivas_sba_get_nchan_metadata( SBA_HOA2_ORDER, IVAS_256k /*dummy value as order is always 1 in this function*/ ); + hoa2_ch = ivas_sba_get_nchan_metadata_fx( SBA_HOA2_ORDER, IVAS_256k /*dummy value as order is always 1 in this function*/ ); // hoa2_ch max 6 foa_ch = FOA_CHANNELS; // foa_ch 4; @@ -3318,8 +3318,8 @@ void ivas_get_spar_md_from_dirac_fx( Word16 norm_q; int16_t num_ch_order, hoa2_ch_order; - num_ch_order = ivas_sba_get_nchan( order, 0 ); - hoa2_ch_order = ivas_sba_get_nchan( SBA_HOA2_ORDER, 0 ); + num_ch_order = ivas_sba_get_nchan_fx( order, 0 ); + hoa2_ch_order = ivas_sba_get_nchan_fx( SBA_HOA2_ORDER, 0 ); for ( ch = 0; ch < num_ch_order; ch++ ) { @@ -6765,7 +6765,7 @@ void ivas_spar_set_bitrate_config_fx( num_PR_bits_dirac_bands = s_max( 0, num_PR_bits_dirac_bands ); num_PR_bits_dirac_bands = i_mult( num_PR_bits_dirac_bands, DIRAC_TO_SPAR_HBR_PRED_CHS ); - n_input = ivas_sba_get_nchan_metadata( sba_order, ivas_total_brate ); + n_input = ivas_sba_get_nchan_metadata_fx( sba_order, ivas_total_brate ); n_dmx = ivas_spar_br_table_consts[table_idx].nchan_transport; n_dec = sub( n_input, n_dmx ); bits_PR = ivas_spar_br_table_consts_fx[table_idx].q_lvls[quant_strat][0]; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 1dbb0e8ee..cadcb29a9 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -182,11 +182,7 @@ static ivas_error ivas_dirac_rend_config_fx( Word16 num_outputs_dir_old; Word16 num_outputs_diff_old; Word16 num_protos_diff_old; - /*Todo: remove float code*/ - float *proto_frame_f_old; -#ifdef IVAS_FLOAT_FIXED Word32 *proto_frame_f_old_fx; -#endif Word16 proto_signal_decorr_on_old; uint16_t i, j, k; Word32 ls_azimuth_fx[MAX_OUTPUT_CHANNELS]; @@ -244,7 +240,7 @@ static ivas_error ivas_dirac_rend_config_fx( nchan_transport_orig = st_ivas->nchan_transport; IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - st_ivas->nchan_transport = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + st_ivas->nchan_transport = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); } nchan_transport = st_ivas->nchan_transport; @@ -729,13 +725,6 @@ IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) || EQ_16( hDirAC IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { -#if 1 /*TODO : remove float code*/ - IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->proto_frame_f ) - { - free( hDirACRend->proto_frame_f ); - } - hDirACRend->proto_frame_f = NULL; -#endif IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->proto_frame_f_fx ) { free( hDirACRend->proto_frame_f_fx ); @@ -761,25 +750,6 @@ ELSE } } hDirACRend->proto_frame_f_len = 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands; -#ifdef TRUE - /*Todo : to remove float code*/ - if ( flag_config == DIRAC_OPEN || ( flag_config == DIRAC_RECONFIGURE && hDirACRend->proto_frame_f == NULL ) ) - { - if ( ( hDirACRend->proto_frame_f = (float *) malloc( sizeof( float ) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - } - else if ( flag_config == DIRAC_RECONFIGURE && ( hDirACRend->num_protos_diff != num_protos_diff_old ) ) - { - proto_frame_f_old = hDirACRend->proto_frame_f; - free( proto_frame_f_old ); - if ( ( hDirACRend->proto_frame_f = (float *) malloc( sizeof( float ) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - } -#endif } IF( EQ_16( flag_config, DIRAC_OPEN ) ) @@ -3542,8 +3512,9 @@ void ivas_dirac_dec_render_sf_fx( if ( h_dirac_output_synthesis_params->use_onset_filters && ( hDirAC->hConfig->dec_param_estim != TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) ) { - h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + tmp1 = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, num_channels_dir * hSpatParamRendCom->num_freq_bands, tmp1 - h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = tmp1; } if ( hDirAC->hConfig->dec_param_estim == TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) @@ -3552,18 +3523,13 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, num_channels_dir * hSpatParamRendCom->num_freq_bands, shift ); h_dirac_output_synthesis_state->q_cy_auto_dir_smooth += shift; - // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - // floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_dir_smooth, h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - shift = L_norm_arr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, num_channels_dir * hSpatParamRendCom->num_freq_bands ); scale_sig32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, num_channels_dir * hSpatParamRendCom->num_freq_bands, shift ); h_dirac_output_synthesis_state->q_cy_cross_dir_smooth += shift; - /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_cross_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands );*/ - - h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + tmp1 = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, num_channels_dir * hSpatParamRendCom->num_freq_bands, tmp1 ); + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth += tmp1; } if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) @@ -3629,51 +3595,40 @@ void ivas_dirac_dec_render_sf_fx( /////////////////////////////////////////////////////////////////////////////////////////////// size = hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands; size_ho = ( hodirac_flag ) ? size * DIRAC_HO_NUMSECTORS : size; + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, Q26 - hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ); hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = Q26; - hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, size ); + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size_ho ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size_ho, shift ); hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth += shift; - // hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, size_ho ); - // floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, size_ho ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho, Q26 - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev ); hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = Q26; - // hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = Q26; - // floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho ); - + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr, Q26 - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ); hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth = Q26; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr, Q26 - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ); hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = Q26; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); } ELSE { - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE, Q26 - hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ); + hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26; Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, size_ho ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, size_ho, shift ); hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev += shift; - /*hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, size_ho ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, size_ho );*/ - shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho, shift ); hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev += shift; - - /*hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, size_ho ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho );*/ - - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); + tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE, tmp1 ); + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev += tmp1; tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands, tmp1 ); @@ -5026,178 +4981,10 @@ void ivas_dirac_dec_render_sf_fx( #ifdef IVAS_FLOAT_FIXED /////////////////////////////////////////////////////// FIXED TO FLOAT ////////////////////////////////////////////////////////////////////////////////////////// - IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) - { - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, hSpatParamRendCom->num_freq_bands ); - // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, hSpatParamRendCom->num_freq_bands ); - } - ELSE - { - // me2f_buf( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, 31 - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, hSpatParamRendCom->num_freq_bands ); - // me2f_buf( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, 31 - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hSpatParamRendCom->num_freq_bands ); - } - } - IF( st_ivas->hMasa == NULL && EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - /*fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - - IF( hodirac_flag ) - { - fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], &hDirACRend->h_output_synthesis_psd_state.direct_responses[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - }*/ - } - ELSE - { - /*fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - }*/ - } - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - /*IF( nchan_transport >= 4 ) - { - fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, 5 * hSpatParamRendCom->num_freq_bands ); - }*/ - // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, 2 * nchan_transport * hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx] ); - // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, 2 * hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx] ); - } - ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) - { - // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ) ); - fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); - // fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - } - ELSE - { - SWITCH( nchan_transport ) - { - case 11: - case 8: - case 6: - case 4: - // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( i_mult( 2, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); - me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); - // fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - BREAK; - case 2: - IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) - { - // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 6, hSpatParamRendCom->num_freq_bands ) ) ); - } - ELSE - { - // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ) ); - } - me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); - // fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - BREAK; - case 1: - // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 2, hSpatParamRendCom->num_freq_bands ) ) ); - me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ) ); - // fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - BREAK; - } - } - - IF( EQ_16( hDirACRend->proto_signal_decorr_on, 1 ) ) - { - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - } - ELSE - { - /* me2f_buf( DirAC_mem.frame_dec_f_fx, 31 - DirAC_mem.frame_dec_f_q, DirAC_mem.frame_dec_f, DirAC_mem.frame_dec_f_len ); - - hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f;*/ - } - } - ELSE - { - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - } - ELSE - { - hDirACRend->proto_frame_dec_f = hDirACRend->proto_frame_f; - } - } - - if ( hDirAC->hConfig->dec_param_estim == FALSE && hodirac_flag ) + IF(EQ_16(hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD)) { - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - // fixedToFloat_arrL( h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->direct_power_factor, h_dirac_output_synthesis_state->direct_power_factor_q, 2 * hSpatParamRendCom->num_freq_bands ); - // fixedToFloat_arrL( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor, h_dirac_output_synthesis_state->diffuse_power_factor_q, 2 * hSpatParamRendCom->num_freq_bands ); - } - else - { - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - // hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], 31 - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); - // hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], 31 - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); - } - } - } - else if ( hDirAC->hConfig->dec_param_estim == TRUE ) - { - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - // hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], 31 - h_dirac_output_synthesis_state->direct_power_factor_q ); - // hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], 31 - h_dirac_output_synthesis_state->diffuse_power_factor_q ); - } - // fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, (num_channels_dir) *hSpatParamRendCom->num_freq_bands ); - } - else - { - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - // hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); - // hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); - } - } - } - - if ( h_dirac_output_synthesis_params->use_onset_filters && ( hDirAC->hConfig->dec_param_estim != TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands ); - } - - if ( hDirAC->hConfig->dec_param_estim == TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - // fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, h_dirac_output_synthesis_state->cy_auto_dir_smooth, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - // fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - } - - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - // fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, size_ho ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); - // fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); - hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev; hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev; - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, size ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); - } - ELSE - { - // fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, size ); - // fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, size_ho ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, size ); - // fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, size ); - // fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); - - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, size ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); } if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 1374393e3..6c09458ba 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -201,13 +201,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( h_dirac_output_synthesis_params->interpolator_fx[idx - 1] = div_s( idx, interp_length ); } Copy32( proto_matrix, h_dirac_output_synthesis_params->proto_matrix_fx, nchan_in * nchan_out ); - -#if 1 /*TODO: To be removed later***************************************************************************************/ - if ( ( h_dirac_output_synthesis_params->proto_matrix = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); - } -#endif + h_dirac_output_synthesis_params->proto_matrix_e = 5; return IVAS_ERR_OK; } #else @@ -413,17 +407,6 @@ void ivas_dirac_dec_output_synthesis_cov_init_fx( set16_fx( h_dirac_output_synthesis_state->mixing_matrix_exp, 0, CLDFB_NO_CHANNELS_MAX ); set16_fx( h_dirac_output_synthesis_state->mixing_matrix_res_old_exp, 0, CLDFB_NO_CHANNELS_MAX ); set16_fx( h_dirac_output_synthesis_state->mixing_matrix_res_exp, 0, CLDFB_NO_CHANNELS_MAX ); -#if 1 /*TODO: To be removed :Floating point initializations*/ - // FOR ( idx = 0; idx < n_param_bands; idx++ ) - //{ - // set_zero( h_dirac_output_synthesis_state->mixing_matrix[idx], nchan_out * nchan_in ); - // } - - // FOR ( idx = 0; idx < n_param_bands_res; idx++ ) - //{ - // set_zero( h_dirac_output_synthesis_state->mixing_matrix_res[idx], nchan_out * nchan_out ); - // } -#endif return; } @@ -573,14 +556,6 @@ void ivas_dirac_dec_output_synthesis_cov_close_fx( free( h_dirac_output_synthesis_state->mixing_matrix_res_exp ); h_dirac_output_synthesis_state->mixing_matrix_res_exp = NULL; } -#if 1 /*TODO: To be removed later(floating point dealloc)*/ - /* free proto_matrix */ - IF( h_dirac_output_synthesis_params->proto_matrix != NULL ) - { - free( h_dirac_output_synthesis_params->proto_matrix ); - h_dirac_output_synthesis_params->proto_matrix = NULL; - } -#endif return; } #else diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 7a179371f..5b5fcfb55 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -158,7 +158,7 @@ ivas_error ivas_dec_setup( ELSE { /* set Ambisonic (SBA) order used for analysis and coding */ - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order ); ivas_sba_config_fx( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); } } @@ -256,9 +256,9 @@ ivas_error ivas_dec_setup( ELSE { /* set Ambisonic (SBA) order used for analysis and coding */ - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order ); - ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); + ivas_sba_config_fx( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); /*correct number of CPEs for discrete ISM coding*/ IF( GT_16( st_ivas->ini_frame, 0 ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 56ad79dbb..7002b0453 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2368,7 +2368,11 @@ void ivas_jbm_dec_feed_tc_to_renderer( { nchan_out_cov = nchan_out_transport; } - f2me_buf( st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, &st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_e, nchan_out_cov * nchan_transport ); + // f2me_buf( st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, &st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_e, nchan_out_cov * nchan_transport ); + + // Word16 shift_p = L_norm_arr(st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, nchan_out_cov * nchan_transport); + // scale_sig32(st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, nchan_out_cov * nchan_transport, shift_p); + // st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_e -= shift_p; scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, -1 ); st_ivas->hParamMC->proto_matrix_int_e = 1; @@ -2696,7 +2700,15 @@ ivas_error ivas_jbm_dec_render( { if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { +#ifndef IVAS_FLOAT_FIXED ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, st_ivas->nchan_transport, p_output ); +#else + ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, st_ivas->nchan_transport, p_output_fx ); + FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; ++i ) + { + fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, *nSamplesRendered ); + } +#endif } else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { @@ -2930,7 +2942,15 @@ ivas_error ivas_jbm_dec_render( /* Loudspeakers, Ambisonics or Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { +#ifndef IVAS_FLOAT_FIXED ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); +#else + ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); + FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; ++i ) + { + fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, *nSamplesRendered ); + } +#endif } else if ( st_ivas->ivas_format == MASA_FORMAT ) { @@ -2973,10 +2993,6 @@ ivas_error ivas_jbm_dec_render( #if 1 /*Float to fixed conversion*/ SPAR_DEC_HANDLE hSpar; hSpar = st_ivas->hSpar; -#ifndef MSAN_FIX - uint16_t nchan_internal; - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); -#endif hSpar->hMdDec->Q_mixer_mat = 30; #endif // @@ -3000,14 +3016,34 @@ ivas_error ivas_jbm_dec_render( { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { +#ifndef IVAS_FLOAT_FIXED if ( ( error = ivas_omasa_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK ) { return error; } +#else + IF( ( error = ivas_omasa_dirac_td_binaural_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ) ) != IVAS_ERR_OK ) + { + return error; + } + + FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; ++i ) + { + fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, *nSamplesRendered ); + } +#endif } else { +#ifndef IVAS_FLOAT_FIXED ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); +#else + ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); + FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; ++i ) + { + fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, *nSamplesRendered ); + } +#endif } } else if ( st_ivas->renderer_type == RENDERER_DIRAC ) @@ -3168,7 +3204,15 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { +#ifndef IVAS_FLOAT_FIXED ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); +#else + ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); + FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; ++i ) + { + fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, *nSamplesRendered ); + } +#endif } else { @@ -3488,9 +3532,10 @@ ivas_error ivas_jbm_dec_render( } // ftf for ivas_dirac_dec_decorr_process_fx - Word16 tmp_e; - f2me_buf( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, &tmp_e, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len ); - st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer = 31 - tmp_e; + Word16 tmp; + tmp = L_norm_arr( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len ); + scale_sig32( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len, tmp ); + st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer += tmp; } if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) { @@ -3514,8 +3559,6 @@ ivas_error ivas_jbm_dec_render( Word16 tempp; FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++ ) { - - tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], nchan_transport * nchan_out_cov ); scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], nchan_transport * nchan_out_cov, tempp ); st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx], tempp ); @@ -3582,7 +3625,15 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { +#ifndef IVAS_FLOAT_FIXED ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); +#else + ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); + FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; ++i ) + { + fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, *nSamplesRendered ); + } +#endif } else if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) /* rendering to CICPxx and Ambisonics */ { diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index fb302068d..be58073f4 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -1263,7 +1263,7 @@ void ivas_omasa_dirac_rend_jbm( return; } - +#ifndef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * ivas_omasa_dirac_td_binaural_render() * @@ -1281,29 +1281,14 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( { int16_t n; float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; -#ifdef IVAS_FLOAT_FIXED - Word16 gain_fx = OMASA_TDREND_MATCHING_GAIN_FX; -#else float gain = OMASA_TDREND_MATCHING_GAIN; -#endif ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; -#ifdef IVAS_FLOAT_FIXED - Word32 *tc_local_fx[MAX_TRANSPORT_CHANNELS]; -#else float *tc_local[MAX_TRANSPORT_CHANNELS]; -#endif -#ifdef MSAN_FIX - Word32 *p_sepobj_fx[MAX_NUM_OBJECTS]; - Word32 data_separated_objects_fx[MAX_NUM_OBJECTS][L_FRAME48k]; -#endif // MSAN_FIX for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { p_sepobj[n] = &data_separated_objects[n][0]; -#ifdef MSAN_FIX - p_sepobj_fx[n] = &data_separated_objects_fx[n][0]; -#endif // MSAN_FIX } /* Delay the object signals to match the CLDFB delay. Delay the whole buffer with the first rendering call of the stretched buffer. */ @@ -1315,16 +1300,9 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( for ( n = 0; n < st_ivas->nchan_ism; n++ ) { -#ifdef IVAS_FLOAT_FIXED - tc_local_fx[n] = st_ivas->hTcBuffer->tc_fx[n + 2]; - v_multc_fixed_16( tc_local_fx[n], gain_fx, tc_local_fx[n], tcBufferSize ); - - delay_signal_fx( tc_local_fx[n], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size ); -#else tc_local[n] = st_ivas->hTcBuffer->tc[n + 2]; v_multc( tc_local[n], gain, tc_local[n], tcBufferSize ); delay_signal_float( tc_local[n], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); -#endif // IVAS_FLOAT_FIXED } } @@ -1333,60 +1311,82 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( /* reset combined orientation access index before calling the td renderer */ ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); -#ifdef IVAS_FLOAT_FIXED -#if 1 /* TODO: remove float to fix conversions */ - Word16 q_factor = Q11; -#ifndef MSAN_FIX - Word32 rend_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; - Word32 *p_rend_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; - for ( int i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) { - p_rend_output_fx[i] = rend_output_fx[i]; - for ( int j = 0; j < L_FRAME48k; j++ ) - { - p_rend_output_fx[i][j] = floatToFixed( p_sepobj[i][j], Q11 ); - } + return error; } -#endif -#endif -#ifdef MSAN_FIX - IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, q_factor, *nSamplesRendered ) ) != IVAS_ERR_OK ) + for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { - return error; + v_add( output_f[n], p_sepobj[n], output_f[n], *nSamplesRendered ); } + + return IVAS_ERR_OK; +} #else - IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_rend_output_fx, q_factor, *nSamplesRendered ) ) != IVAS_ERR_OK ) +/*--------------------------------------------------------------------------* + * ivas_omasa_dirac_td_binaural_render() + * + * Binaural rendering in OMASA format for JBM + *--------------------------------------------------------------------------*/ + +ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailable, /* o : number of samples still to render */ + const Word16 nchan_transport, /* i : number of transport channels */ + Word32 *output_fx[] /* o : rendered time signal */ +) +{ + Word16 n; + Word16 gain_fx = OMASA_TDREND_MATCHING_GAIN_FX; + move16(); + ivas_error error; + Word32 *tc_local_fx[MAX_TRANSPORT_CHANNELS]; + Word32 *p_sepobj_fx[MAX_NUM_OBJECTS]; + Word32 data_separated_objects_fx[MAX_NUM_OBJECTS][L_FRAME48k]; + Word16 q_factor = Q11; + move16(); + + FOR( n = 0; n < MAX_NUM_OBJECTS; n++ ) { - return error; + p_sepobj_fx[n] = &data_separated_objects_fx[n][0]; } -#endif -#if 1 /* TODO: remove fixed to float conversions */ - for ( int i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) + + /* Delay the object signals to match the CLDFB delay. Delay the whole buffer with the first rendering call of the stretched buffer. */ + IF( EQ_16( st_ivas->hSpatParamRendCom->slots_rendered, 0 ) ) { - for ( int j = 0; j < L_FRAME48k; j++ ) + Word16 tcBufferSize; + + tcBufferSize = imult1616( st_ivas->hSpatParamRendCom->num_slots, st_ivas->hSpatParamRendCom->slot_size ); + + FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { -#ifdef MSAN_FIX - p_sepobj[i][j] = fixedToFloat( p_sepobj_fx[i][j], Q11 ); -#else - p_sepobj[i][j] = fixedToFloat( p_rend_output_fx[i][j], Q11 ); -#endif + tc_local_fx[n] = st_ivas->hTcBuffer->tc_fx[n + 2]; + v_multc_fixed_16( tc_local_fx[n], gain_fx, tc_local_fx[n], tcBufferSize ); + + delay_signal_fx( tc_local_fx[n], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size ); } } -#endif -#else - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) + + ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, nchan_transport, output_fx ); + + /* reset combined orientation access index before calling the td renderer */ + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + + IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, q_factor, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } -#endif - for ( n = 0; n < BINAURAL_CHANNELS; n++ ) + + FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) { - v_add( output_f[n], p_sepobj[n], output_f[n], *nSamplesRendered ); + v_add_fx( output_fx[n], p_sepobj_fx[n], output_fx[n], *nSamplesRendered ); } return IVAS_ERR_OK; } - +#endif /*--------------------------------------------------------------------------* * ivas_omasa_rearrange_channels() diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 18d7b0c50..2e34c3508 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -36,6 +36,9 @@ #include "ivas_prot.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-------------------------------------------------------------------------* @@ -166,7 +169,7 @@ void ivas_renderer_select( IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + nchan_internal = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); test(); test(); test(); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 214a5e430..9da244a34 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -802,7 +802,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( nchan_transport_old = st_ivas->nchan_transport; sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order ); *nSamplesFlushed = 0; granularity_new = st_ivas->hTcBuffer->n_samples_granularity; @@ -896,7 +896,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( #endif // IVAS_FLOAT_FIXED /* restore correct values for the current frame*/ - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order ); st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; } else if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) @@ -1356,7 +1356,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - tc_nchan_to_allocate = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + tc_nchan_to_allocate = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { @@ -1820,6 +1820,7 @@ void ivas_sba_dec_digest_tc_fx( * * *-------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED ivas_error ivas_sba_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -1843,7 +1844,7 @@ ivas_error ivas_sba_dec_render_fx( move16(); hSpar = st_ivas->hSpar; hSpatParamRendCom = st_ivas->hSpatParamRendCom; - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + nchan_internal = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); nchan_out = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); FOR( ch = 0; ch < nchan_out; ch++ ) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 52a12a737..09757dbf8 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -296,7 +296,7 @@ ivas_error ivas_spar_dec_open_fx( sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); - num_channels_internal = ivas_sba_get_nchan_metadata( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate ); + num_channels_internal = ivas_sba_get_nchan_metadata_fx( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate ); hSpar = st_ivas->hSpar; @@ -531,7 +531,11 @@ void ivas_spar_dec_close( ivas_td_decorr_dec_close( &( *hSpar )->hTdDecorr ); /* FB mixer handle */ +#ifdef IVAS_FLOAT_FIXED + ivas_FB_mixer_close_fx( &( *hSpar )->hFbMixer, output_Fs, spar_reconfig_flag ); +#else ivas_FB_mixer_close( &( *hSpar )->hFbMixer, output_Fs, spar_reconfig_flag ); +#endif /* AGC */ #ifdef IVAS_FLOAT_FIXED @@ -1456,7 +1460,7 @@ static ivas_error ivas_spar_dec_MD_fx( move16(); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); - num_channels = ivas_sba_get_nchan_metadata( sba_order, ivas_total_brate ); + num_channels = ivas_sba_get_nchan_metadata_fx( sba_order, ivas_total_brate ); num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; @@ -2369,7 +2373,7 @@ void ivas_spar_dec_agc_pca_fx( IF( hSpar->hMdDec->td_decorr_flag ) { - num_in_ingest = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + num_in_ingest = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); move16(); } ELSE @@ -2632,7 +2636,7 @@ void ivas_spar_dec_digest_tc_fx( /* TD decorrelator */ default_frame = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + nchan_internal = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); FOR( ch = 0; ch < nchan_internal; ch++ ) { diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index dbfa58e17..125d7c7ae 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -970,9 +970,9 @@ ivas_error ivas_spar_md_dec_init( Word32 *pFC_fx = NULL, PR_minmax_fx[2]; ivas_error error; - ivas_sba_get_spar_hoa_md_flag( sba_order, hDecoderConfig->ivas_total_brate, &hMdDec->spar_hoa_md_flag, &hMdDec->spar_hoa_dirac2spar_md_flag ); + ivas_sba_get_spar_hoa_md_flag_fx( sba_order, hDecoderConfig->ivas_total_brate, &hMdDec->spar_hoa_md_flag, &hMdDec->spar_hoa_dirac2spar_md_flag ); - ivas_sba_get_spar_hoa_ch_ind( num_channels, hDecoderConfig->ivas_total_brate, hMdDec->HOA_md_ind ); + ivas_sba_get_spar_hoa_ch_ind_fx( num_channels, hDecoderConfig->ivas_total_brate, hMdDec->HOA_md_ind ); hMdDec->spar_md.num_bands = ( hMdDec->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); @@ -1114,7 +1114,7 @@ static ivas_error ivas_spar_set_dec_config( hMdDec->spar_md_cfg.max_freq_per_chan[i] = ivas_spar_br_table_consts[hMdDec->table_idx].fpcs; } - nchan = ivas_sba_get_nchan_metadata( ivas_spar_br_table_consts[hMdDec->table_idx].sba_order, ivas_spar_br_table_consts[hMdDec->table_idx].ivas_total_brate ); + nchan = ivas_sba_get_nchan_metadata_fx( ivas_spar_br_table_consts[hMdDec->table_idx].sba_order, ivas_spar_br_table_consts[hMdDec->table_idx].ivas_total_brate ); switch ( nchan ) { @@ -1360,7 +1360,7 @@ void ivas_spar_md_dec_process_fx( active_w_vlbr = ( st_ivas->hDecoderConfig->ivas_total_brate < IVAS_24k4 ) ? 1 : 0; - num_md_chs = ivas_sba_get_nchan_metadata( sba_order, st_ivas->hDecoderConfig->ivas_total_brate ); + num_md_chs = ivas_sba_get_nchan_metadata_fx( sba_order, st_ivas->hDecoderConfig->ivas_total_brate ); num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 2764728f6..63830ac15 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -782,25 +782,12 @@ ivas_error IVAS_DEC_FeedFrame_Serial( { PARAM_MC_DEC_HANDLE hParamMC; hParamMC = hIvasDec->st_ivas->hParamMC; - Word16 nchan_out_transport, nchan_out_cov; MC_LS_SETUP mc_ls_setup; - Word16 nchan_transport, i; + Word16 i; mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( hIvasDec->st_ivas->transport_config ); hIvasDec->st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); - nchan_transport = hIvasDec->st_ivas->nchan_transport; - nchan_out_transport = hIvasDec->st_ivas->hTransSetup.nchan_out_woLFE + hIvasDec->st_ivas->hTransSetup.num_lfe; - IF( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) - { - nchan_out_cov = hIvasDec->st_ivas->hOutSetup.nchan_out_woLFE + hIvasDec->st_ivas->hOutSetup.num_lfe; - move16(); - } - ELSE - { - nchan_out_cov = nchan_out_transport; - } IF( hParamMC ) { - fixedToFloat_arrL( hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, 26, nchan_transport * nchan_out_cov ); FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) { fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); @@ -1219,25 +1206,11 @@ static ivas_error IVAS_DEC_Setup( { PARAM_MC_DEC_HANDLE hParamMC; hParamMC = st_ivas->hParamMC; - Word16 nchan_out_transport, nchan_out_cov; MC_LS_SETUP mc_ls_setup; - Word16 nchan_transport; mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); - nchan_transport = st_ivas->nchan_transport; - nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; - IF( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) - { - nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - move16(); - } - ELSE - { - nchan_out_cov = nchan_out_transport; - } IF( hParamMC ) { - fixedToFloat_arrL( hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, 26, nchan_transport * nchan_out_cov ); IF( st_ivas->hParamMC->diff_proto_info ) { FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) @@ -1301,7 +1274,7 @@ static ivas_error IVAS_DEC_Setup( { IF( st_ivas->hParamMC ) { - fixedToFloat_arrL( st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, 26, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_len ); + // fixedToFloat_arrL( st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, 26, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_len ); IF( st_ivas->hParamMC->diff_proto_info ) FOR( i = 0; i < st_ivas->hParamMC->diff_proto_info->num_protos_diff; i++ ) { diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 6137f0114..d48aa6997 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -588,7 +588,11 @@ ivas_error ivas_init_encoder( if ( ivas_format == SBA_FORMAT ) { +#ifndef IVAS_FLOAT_FIXED st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); +#else + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); +#endif if ( ( error = ivas_spar_enc_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) { @@ -727,7 +731,11 @@ ivas_error ivas_init_encoder( return error; } +#ifndef IVAS_FLOAT_FIXED st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); +#else + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); +#endif if ( ( error = ivas_spar_enc_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) { @@ -1141,7 +1149,11 @@ ivas_error ivas_init_encoder_fx( IF( ivas_format == SBA_FORMAT ) { +#ifndef IVAS_FLOAT_FIXED st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); +#else + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); +#endif IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK ) { @@ -1280,7 +1292,11 @@ ivas_error ivas_init_encoder_fx( return error; } +#ifndef IVAS_FLOAT_FIXED st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); +#else + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); +#endif if ( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 2ff2e226d..6f10ae187 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -40,6 +40,8 @@ #include "wmc_auto.h" #include "prot.h" #ifdef IVAS_FLOAT_FIXED +#include "prot_fx1.h" +#include "prot_fx2.h" #include "ivas_prot_fx.h" #endif @@ -112,7 +114,11 @@ ivas_error ivas_masa_enc_open( hEncoderConfig = st_ivas->hEncoderConfig; +#ifndef IVAS_FLOAT_FIXED generate_gridEq( &( hMasa->data.Sph_Grid16 ) ); +#else + generate_gridEq_fx( &( hMasa->data.Sph_Grid16 ) ); +#endif if ( hEncoderConfig->ivas_format == MASA_FORMAT || hEncoderConfig->ivas_format == MASA_ISM_FORMAT ) { @@ -140,7 +146,11 @@ ivas_error ivas_masa_enc_open( } } +#ifndef IVAS_FLOAT_FIXED ivas_masa_set_elements( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); +#else + ivas_masa_set_elements_fx( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); +#endif mvs2s( DirAC_block_grouping, hMasa->config.block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); mvs2s( MASA_band_grouping_24, hMasa->config.band_grouping, MASA_FREQUENCY_BANDS + 1 ); @@ -490,10 +500,18 @@ ivas_error ivas_masa_encode( /* Encode metadata */ masa_total_brate = ivas_total_brate; +#ifndef IVAS_FLOAT_FIXED if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_DISC ) { masa_total_brate = calculate_cpe_brate_MASA_ISM( ism_mode, ivas_total_brate, nchan_ism ); } +#else + test(); + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MASA_MODE_DISC ) ) + { + masa_total_brate = calculate_cpe_brate_MASA_ISM_fx( ism_mode, ivas_total_brate, nchan_ism ); + } +#endif if ( masa_total_brate >= IVAS_384k ) { @@ -520,11 +538,49 @@ ivas_error ivas_masa_encode( } } +#ifndef IVAS_FLOAT_FIXED if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { /* Modify spatial metadata based on the MASA-to-total energy ratios */ ivas_omasa_modify_masa_energy_ratios( hQMetaData, hMasa->data.hOmasaData->masa_to_total_energy_ratio ); } +#else + Word16 b, d; + + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + for ( b = 0; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) + { + for ( d = 0; d < hQMetaData->no_directions; d++ ) + { + floatToFixed_arr32( hQMetaData->q_direction[d].band_data[b].energy_ratio, hQMetaData->q_direction[d].band_data[b].energy_ratio_fx, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); + } + } + + for ( b = 0; b < MAX_PARAM_SPATIAL_SUBFRAMES; ++b ) + { + floatToFixed_arr32( hMasa->data.hOmasaData->masa_to_total_energy_ratio[b], hMasa->data.hOmasaData->masa_to_total_energy_ratio_fx[b], Q30, MASA_MAXIMUM_CODING_SUBBANDS ); + } + } + + test(); + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + /* Modify spatial metadata based on the MASA-to-total energy ratios */ + ivas_omasa_modify_masa_energy_ratios_fx( hQMetaData, hMasa->data.hOmasaData->masa_to_total_energy_ratio_fx ); + } + + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + for ( b = 0; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) + { + for ( d = 0; d < hQMetaData->no_directions; d++ ) + { + fixedToFloat_arrL( hQMetaData->q_direction[d].band_data[b].energy_ratio_fx, hQMetaData->q_direction[d].band_data[b].energy_ratio, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); + } + } + } +#endif *nb_bits_metadata = hMetaData->nb_bits_tot; @@ -702,7 +758,11 @@ ivas_error ivas_masa_enc_config( } } +#ifndef IVAS_FLOAT_FIXED ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, ivas_format, st_ivas->ism_mode, ism_total_brate ); +#else + ivas_masa_set_elements_fx( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, ivas_format, st_ivas->ism_mode, ism_total_brate ); +#endif hQMetaData->is_masa_ivas_format = 1; @@ -731,6 +791,7 @@ ivas_error ivas_masa_enc_config( hMasa->config.numberOfDirections = 1; } +#ifndef IVAS_FLOAT_FIXED if ( ivas_format == MASA_ISM_FORMAT ) { ivas_masa_set_coding_config( &( hMasa->config ), hMasa->data.band_mapping, st_ivas->hCPE[0]->element_brate, st_ivas->nchan_transport, MC_MODE_NONE ); @@ -739,6 +800,16 @@ ivas_error ivas_masa_enc_config( { ivas_masa_set_coding_config( &( hMasa->config ), hMasa->data.band_mapping, ivas_total_brate, st_ivas->nchan_transport, ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) ); } +#else + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) ) + { + ivas_masa_set_coding_config_fx( &( hMasa->config ), hMasa->data.band_mapping, st_ivas->hCPE[0]->element_brate, st_ivas->nchan_transport, MC_MODE_NONE ); + } + ELSE + { + ivas_masa_set_coding_config_fx( &( hMasa->config ), hMasa->data.band_mapping, ivas_total_brate, st_ivas->nchan_transport, ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) ); + } +#endif /* Setup importance weights for two-direction band selection. */ if ( hMasa->config.numberOfDirections == 2 ) @@ -825,10 +896,18 @@ ivas_error ivas_masa_enc_config( st_ivas->hQMetaData->q_direction->cfg.inactiveBands = 0; masa_total_brate = ivas_total_brate; +#ifndef IVAS_FLOAT_FIXED if ( ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { masa_total_brate = calculate_cpe_brate_MASA_ISM( st_ivas->ism_mode, ivas_total_brate, st_ivas->hEncoderConfig->nchan_ism ); } +#else + test(); + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + masa_total_brate = calculate_cpe_brate_MASA_ISM_fx( st_ivas->ism_mode, ivas_total_brate, st_ivas->hEncoderConfig->nchan_ism ); + } +#endif if ( masa_total_brate >= IVAS_384k && ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) ) { int16_t continueLoop; @@ -859,7 +938,39 @@ ivas_error ivas_masa_enc_config( } } +#ifndef IVAS_FLOAT_FIXED masa_sample_rate_band_correction( &( hMasa->config ), hMasa->data.band_mapping, hQMetaData, maxBand, masa_total_brate >= IVAS_384k, NULL ); +#else + Word16 numBands48k = hMasa->config.numCodingBands, band; + + for ( band = 0; band < numBands48k; band++ ) + { + floatToFixed_arrL( hQMetaData->q_direction[0].band_data[band].azimuth, hQMetaData->q_direction[0].band_data[band].azimuth_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + floatToFixed_arrL( hQMetaData->q_direction[0].band_data[band].elevation, hQMetaData->q_direction[0].band_data[band].elevation_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + floatToFixed_arrL( hQMetaData->q_direction[0].band_data[band].energy_ratio, hQMetaData->q_direction[0].band_data[band].energy_ratio_fx, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); + if ( hQMetaData->no_directions == 2 ) + { + floatToFixed_arrL( hQMetaData->q_direction[1].band_data[band].azimuth, hQMetaData->q_direction[1].band_data[band].azimuth_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + floatToFixed_arrL( hQMetaData->q_direction[1].band_data[band].elevation, hQMetaData->q_direction[1].band_data[band].elevation_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + floatToFixed_arrL( hQMetaData->q_direction[1].band_data[band].energy_ratio, hQMetaData->q_direction[1].band_data[band].energy_ratio_fx, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); + } + } + + masa_sample_rate_band_correction_fx( &( hMasa->config ), hMasa->data.band_mapping, hQMetaData, maxBand, masa_total_brate >= IVAS_384k, NULL ); + + for ( band = 0; band < numBands48k; band++ ) + { + fixedToFloat_arrL( hQMetaData->q_direction[0].band_data[band].azimuth_fx, hQMetaData->q_direction[0].band_data[band].azimuth, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + fixedToFloat_arrL( hQMetaData->q_direction[0].band_data[band].elevation_fx, hQMetaData->q_direction[0].band_data[band].elevation, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + fixedToFloat_arrL( hQMetaData->q_direction[0].band_data[band].energy_ratio_fx, hQMetaData->q_direction[0].band_data[band].energy_ratio, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); + if ( hQMetaData->no_directions == 2 ) + { + fixedToFloat_arrL( hQMetaData->q_direction[1].band_data[band].azimuth_fx, hQMetaData->q_direction[1].band_data[band].azimuth, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + fixedToFloat_arrL( hQMetaData->q_direction[1].band_data[band].elevation_fx, hQMetaData->q_direction[1].band_data[band].elevation, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + fixedToFloat_arrL( hQMetaData->q_direction[1].band_data[band].energy_ratio_fx, hQMetaData->q_direction[1].band_data[band].energy_ratio, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); + } + } +#endif if ( hMasa->config.numTwoDirBands >= hMasa->config.numCodingBands ) { @@ -1997,7 +2108,11 @@ void ivas_masa_enc_reconfigure( } } +#ifndef IVAS_FLOAT_FIXED ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); +#else + ivas_masa_set_elements_fx( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); +#endif } return; @@ -2063,8 +2178,19 @@ static void average_masa_metadata( hMeta->directional_meta[i].elevation[j][k] = atan2f( z_sum, sqrtf( x_sum * x_sum + y_sum * y_sum ) ) / EVS_PI * 180.0f; if ( useSphGrid == TRUE ) { +#ifndef IVAS_FLOAT_FIXED hMeta->directional_meta[i].spherical_index[j][k] = index_theta_phi_16( &( hMeta->directional_meta[i].elevation[j][k] ), &( hMeta->directional_meta[i].azimuth[j][k] ), Sph_Grid16 ); +#else + hMeta->directional_meta[i].elevation_fx[j][k] = floatToFixed( hMeta->directional_meta[i].elevation[j][k], Q22 ); + hMeta->directional_meta[i].azimuth_fx[j][k] = floatToFixed( hMeta->directional_meta[i].azimuth[j][k], Q22 ); + + hMeta->directional_meta[i].spherical_index[j][k] = index_theta_phi_16_fx( &( hMeta->directional_meta[i].elevation_fx[j][k] ), + &( hMeta->directional_meta[i].azimuth_fx[j][k] ), Sph_Grid16 ); + + hMeta->directional_meta[i].elevation[j][k] = fixedToFloat( hMeta->directional_meta[i].elevation_fx[j][k], Q22 ); + hMeta->directional_meta[i].azimuth[j][k] = fixedToFloat( hMeta->directional_meta[i].azimuth_fx[j][k], Q22 ); +#endif } vec_len = sqrtf( x_sum * x_sum + y_sum * y_sum + z_sum * z_sum ); hMeta->directional_meta[i].energy_ratio[j][k] = vec_len / ( energy_sum + EPSILON ); @@ -2737,7 +2863,11 @@ static void quantize_ratio_ism_vector( { if ( masa_to_total_energy_ratio >= MASA2TOTAL_THR ) { +#ifndef IVAS_FLOAT_FIXED distribute_evenly_ism( idx, max_sum_idx, nchan_ism ); +#else + distribute_evenly_ism_fx( idx, max_sum_idx, nchan_ism ); +#endif } else { @@ -2856,7 +2986,11 @@ static int16_t index_slice_enum( i = 0; while ( i <= x ) { +#ifndef IVAS_FLOAT_FIXED if ( valid_ratio_index( i, 7, nchan_ism - 1 ) ) +#else + IF( valid_ratio_index_fx( i, 7, nchan_ism - 1 ) ) +#endif { index++; } @@ -3533,7 +3667,16 @@ static void ivas_encode_masaism_metadata( } /* reconstructed values */ +#ifndef IVAS_FLOAT_FIXED reconstruct_ism_ratios( ratio_ism_idx[band], nchan_ism, step, hMasa->data.hOmasaData->q_energy_ratio_ism[sf][band] ); +#else + Word16 step_fx = float_to_fix16( step, Q15 ); + floatToFixed_arr32( hMasa->data.hOmasaData->q_energy_ratio_ism[sf][band], hMasa->data.hOmasaData->q_energy_ratio_ism_fx[sf][band], Q30, MAX_NUM_OBJECTS ); + + reconstruct_ism_ratios_fx( ratio_ism_idx[band], nchan_ism, step_fx, hMasa->data.hOmasaData->q_energy_ratio_ism_fx[sf][band] ); + + fixedToFloat_arrL( hMasa->data.hOmasaData->q_energy_ratio_ism_fx[sf][band], hMasa->data.hOmasaData->q_energy_ratio_ism[sf][band], Q30, MAX_NUM_OBJECTS ); +#endif } if ( ( nchan_ism > 2 ) && ( idx_separated_object == nchan_ism - 1 ) ) diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 39df60bfd..296dbce5c 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -40,6 +40,9 @@ #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*------------------------------------------------------------------------- @@ -205,8 +208,13 @@ ivas_error ivas_osba_enc_reconfig( nchan_transport_old = st_ivas->nchan_transport; nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; +#ifndef IVAS_FLOAT_FIXED st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); +#else + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, hEncoderConfig->sba_order ); + analysis_order_old = ivas_sba_get_analysis_order_fx( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); +#endif nbands_old = st_ivas->hQMetaData->q_direction->cfg.nbands; ndir_old = st_ivas->hQMetaData->no_directions; diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 6be86728f..cbd9c869d 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -41,6 +41,9 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-------------------------------------------------------------------* @@ -111,8 +114,13 @@ ivas_error ivas_sba_enc_reconfigure( nchan_transport_old = st_ivas->nchan_transport; nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; +#ifndef IVAS_FLOAT_FIXED st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); +#else + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, hEncoderConfig->sba_order ); + analysis_order_old = ivas_sba_get_analysis_order_fx( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); +#endif nbands_old = st_ivas->hQMetaData->q_direction->cfg.nbands; ndir_old = st_ivas->hQMetaData->no_directions; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index b304ea80f..0352d0fc9 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -297,7 +297,7 @@ ivas_error ivas_spar_enc_open_fx( hSpar->spar_reconfig_flag = 0; input_Fs = hEncoderConfig->input_Fs; sba_order_internal = extract_l( L_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ) ); - nchan_inp = ivas_sba_get_nchan_metadata( sba_order_internal, hEncoderConfig->ivas_total_brate ); + nchan_inp = ivas_sba_get_nchan_metadata_fx( sba_order_internal, hEncoderConfig->ivas_total_brate ); assert( nchan_inp <= hEncoderConfig->nchan_inp ); ivas_total_brate = hEncoderConfig->ivas_total_brate; @@ -819,7 +819,11 @@ static ivas_error ivas_spar_enc_process( input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); sba_order = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); +#ifndef IVAS_FLOAT_FIXED nchan_inp = ivas_sba_get_nchan_metadata( sba_order, hEncoderConfig->ivas_total_brate ); +#else + nchan_inp = ivas_sba_get_nchan_metadata_fx( sba_order, hEncoderConfig->ivas_total_brate ); +#endif assert( nchan_inp <= hEncoderConfig->nchan_inp ); nchan_fb_in = hSpar->hFbMixer->fb_cfg->nchan_fb_in; diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 11c013dd1..b7a74310e 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -186,7 +186,7 @@ ivas_error ivas_spar_md_enc_open_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD encoder" ); } - num_channels = ivas_sba_get_nchan_metadata( sba_order, hEncoderConfig->ivas_total_brate ); + num_channels = ivas_sba_get_nchan_metadata_fx( sba_order, hEncoderConfig->ivas_total_brate ); IF( ( hMdEnc->mixer_mat_local_fx = (Word32 ***) malloc( num_channels * sizeof( Word32 ** ) ) ) == NULL ) { @@ -313,9 +313,15 @@ ivas_error ivas_spar_md_enc_init( float PR_minmax[2]; int16_t num_channels, i, j, k; +#ifndef IVAS_FLOAT_FIXED ivas_sba_get_spar_hoa_md_flag( sba_order, hEncoderConfig->ivas_total_brate, &hMdEnc->spar_hoa_md_flag, &hMdEnc->spar_hoa_dirac2spar_md_flag ); num_channels = ivas_sba_get_nchan_metadata( sba_order, hEncoderConfig->ivas_total_brate ); ivas_sba_get_spar_hoa_ch_ind( num_channels, hEncoderConfig->ivas_total_brate, hMdEnc->HOA_md_ind ); +#else + ivas_sba_get_spar_hoa_md_flag_fx( sba_order, hEncoderConfig->ivas_total_brate, &hMdEnc->spar_hoa_md_flag, &hMdEnc->spar_hoa_dirac2spar_md_flag ); + num_channels = ivas_sba_get_nchan_metadata_fx( sba_order, hEncoderConfig->ivas_total_brate ); + ivas_sba_get_spar_hoa_ch_ind_fx( num_channels, hEncoderConfig->ivas_total_brate, hMdEnc->HOA_md_ind ); +#endif table_idx = ivas_get_spar_table_idx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL ); hMdEnc->spar_md.prior_dyn_active_w_flag = 0; @@ -379,9 +385,9 @@ ivas_error ivas_spar_md_enc_init_fx( Word16 table_idx; Word16 num_channels, i, j, k; - ivas_sba_get_spar_hoa_md_flag( sba_order, hEncoderConfig->ivas_total_brate, &hMdEnc->spar_hoa_md_flag, &hMdEnc->spar_hoa_dirac2spar_md_flag ); - num_channels = ivas_sba_get_nchan_metadata( sba_order, hEncoderConfig->ivas_total_brate ); - ivas_sba_get_spar_hoa_ch_ind( num_channels, hEncoderConfig->ivas_total_brate, hMdEnc->HOA_md_ind ); + ivas_sba_get_spar_hoa_md_flag_fx( sba_order, hEncoderConfig->ivas_total_brate, &hMdEnc->spar_hoa_md_flag, &hMdEnc->spar_hoa_dirac2spar_md_flag ); + num_channels = ivas_sba_get_nchan_metadata_fx( sba_order, hEncoderConfig->ivas_total_brate ); + ivas_sba_get_spar_hoa_ch_ind_fx( num_channels, hEncoderConfig->ivas_total_brate, hMdEnc->HOA_md_ind ); table_idx = ivas_get_spar_table_idx_fx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL ); hMdEnc->spar_md.prior_dyn_active_w_flag = 0; @@ -669,7 +675,11 @@ ivas_error ivas_spar_md_enc_process( } num_quant_strats = hMdEnc->spar_md_cfg.num_quant_strats; +#ifndef IVAS_FLOAT_FIXED num_ch = ivas_sba_get_nchan_metadata( sba_order, hEncoderConfig->ivas_total_brate ); +#else + num_ch = ivas_sba_get_nchan_metadata_fx( sba_order, hEncoderConfig->ivas_total_brate ); +#endif active_w = ( hMdEnc->spar_md_cfg.active_w == 1 ) || ( dyn_active_w_flag == 1 ); nchan_transport = hMdEnc->spar_md_cfg.nchan_transport; diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 3342895be..e804e272f 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1010,6 +1010,10 @@ typedef struct ivas_omasa_encoder_one_data_struct float energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; +#ifdef IVAS_FLOAT_FIXED + Word32 q_energy_ratio_ism_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; /* Q30 */ + Word32 masa_to_total_energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q30 */ +#endif float lp_noise_CPE; /* LP filtered total noise estimation */ int16_t omasa_stereo_sw_cnt; diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 5f4329e03..33c01705d 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -520,7 +520,11 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( hEncoderConfig->sba_order = order; /* Input in ACN/SN3D in all cases (3D and planar): get number of channels */ +#ifndef IVAS_FLOAT_FIXED hEncoderConfig->nchan_inp = ivas_sba_get_nchan( hEncoderConfig->sba_order, 0 ); /*planar input arg. deliberately set to zero since input always in ACN/SN3D*/ +#else + hEncoderConfig->nchan_inp = ivas_sba_get_nchan_fx( hEncoderConfig->sba_order, 0 ); /*planar input arg. deliberately set to zero since input always in ACN/SN3D*/ +#endif hEncoderConfig->Opt_PCA_ON = (int16_t) Opt_PCA_ON; @@ -612,7 +616,11 @@ ivas_error IVAS_ENC_ConfigureForSBAObjects( /* Input in ACN/SN3D in all cases (3D and planar): get number of channels */ /*Input file will always contain all channels for a given order irrespective of planar flag*/ +#ifndef IVAS_FLOAT_FIXED st_ivas->hEncoderConfig->nchan_inp = ivas_sba_get_nchan( st_ivas->hEncoderConfig->sba_order, 0 ) + numObjects; +#else + st_ivas->hEncoderConfig->nchan_inp = add( ivas_sba_get_nchan_fx( st_ivas->hEncoderConfig->sba_order, 0 ), (Word16) numObjects ); +#endif st_ivas->hEncoderConfig->Opt_PCA_ON = (int16_t) Opt_PCA_ON; @@ -918,7 +926,11 @@ static ivas_error configureEncoder( { st_ivas->ism_mode = ivas_omasa_ism_mode_select( st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); +#ifndef IVAS_FLOAT_FIXED cpe_brate = calculate_cpe_brate_MASA_ISM( st_ivas->ism_mode, st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); +#else + cpe_brate = calculate_cpe_brate_MASA_ISM_fx( st_ivas->ism_mode, st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); +#endif /*adapt element_mode according to the bit-rate*/ if ( hEncoderConfig->element_mode_init != IVAS_SCE ) diff --git a/lib_rend/ivas_allrad_dec.c b/lib_rend/ivas_allrad_dec.c index 62422fb03..98328dc56 100644 --- a/lib_rend/ivas_allrad_dec.c +++ b/lib_rend/ivas_allrad_dec.c @@ -39,6 +39,9 @@ #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-----------------------------------------------------------------------* @@ -218,7 +221,7 @@ ivas_error ivas_sba_get_hoa_dec_matrix_fx( return error; } - num_harm = ivas_sba_get_nchan( ambisonics_order, 0 ); + num_harm = ivas_sba_get_nchan_fx( ambisonics_order, 0 ); /* Get t-design values */ num_td = SBA_T_DESIGN_11_SIZE; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 132225604..156108264 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -121,9 +121,11 @@ typedef struct parambin_rend_config_data * Local function prototypes *------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static void ivas_dirac_dec_binaural_internal_fx( Decoder_Struct *st_ivas, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_f[], const Word16 nchan_transport, const Word16 subframe ); +#else static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, float *output_f[], const int16_t nchan_transport, const int16_t subframe ); -#ifndef IVAS_FLOAT_FIXED static void ivas_dirac_dec_decorrelate_slot( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const int16_t num_freq_bands, const int16_t slot, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); #endif @@ -749,12 +751,12 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( } #endif +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * void ivas_dirac_dec_binaural_render() * * *------------------------------------------------------------------------*/ - void ivas_dirac_dec_binaural_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -823,7 +825,81 @@ void ivas_dirac_dec_binaural_render( return; } +#else +/*------------------------------------------------------------------------- + * void ivas_dirac_dec_binaural_render_fx() + * + * + *------------------------------------------------------------------------*/ +void ivas_dirac_dec_binaural_render_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ + UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ + UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const Word16 nchan_transport, /* i : number of transport channels */ + Word32 *output_f[] /* o : rendered time signal */ +) +{ + Word16 slots_to_render, first_sf, last_sf, subframe_idx; + UWord16 slot_size, ch; + UWord16 nchan_out; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + Word32 *output_fx_local[MAX_OUTPUT_CHANNELS]; + Word32 output_fx_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word16 output_length; + + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + nchan_out = BINAURAL_CHANNELS; + FOR ( ch = 0; ch < nchan_out; ch++ ) + { + output_fx_local[ch] = output_fx_local_buff[ch]; + } + slot_size = NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ + slots_to_render = s_min( sub( hSpatParamRendCom->num_slots, hSpatParamRendCom->slots_rendered ), idiv1616( (Word16) nSamplesAsked, (Word16) slot_size ) ); + *nSamplesRendered = imult1616( slots_to_render, slot_size ); + first_sf = hSpatParamRendCom->subframes_rendered; + last_sf = first_sf; + + WHILE( GT_16( slots_to_render, 0 ) ) + { + slots_to_render = sub( slots_to_render, hSpatParamRendCom->subframe_nbslots[last_sf] ); + last_sf++; + } + output_length = 0; + FOR ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) + { + Word16 n_samples_sf = imult1616( slot_size, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + ivas_dirac_dec_binaural_internal_fx( st_ivas, st_ivas->hCombinedOrientationData, output_fx_local, nchan_transport, subframe_idx ); + + FOR ( ch = 0; ch < nchan_out; ch++ ) + { + output_fx_local[ch] += n_samples_sf; + } + + output_length = add( output_length, n_samples_sf ); + + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); + } + + FOR ( ch = 0; ch < nchan_out; ch++ ) + { + Copy32( output_fx_local_buff[ch], output_f[ch], output_length ); + } + + IF( EQ_16( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->num_slots ) ) + { + hSpatParamRendCom->dirac_read_idx = add( hSpatParamRendCom->dirac_read_idx, DEFAULT_JBM_SUBFRAMES_5MS ) % hSpatParamRendCom->dirac_md_buffer_length; + } + + *nSamplesAvailable = imult1616( sub( hSpatParamRendCom->num_slots, hSpatParamRendCom->slots_rendered ), slot_size ); + + return; +} +#endif /*------------------------------------------------------------------------- * ivas_dirac_dec_binaural_sba_gain() @@ -1134,10 +1210,10 @@ static void ivas_dirac_dec_binaural_internal( return; } #else -static void ivas_dirac_dec_binaural_internal( +static void ivas_dirac_dec_binaural_internal_fx( Decoder_Struct *st_ivas, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - float *output_f[], + Word32 *output_fx[], const int16_t nchan_transport, const int16_t subframe ) { @@ -1194,7 +1270,7 @@ static void ivas_dirac_dec_binaural_internal( DIFFUSE_DISTRIBUTION_DATA diffuseDistData; Word16 nBins, offsetSamples; Word16 i, j; - Word16 q_mat; + Word16 q_mat, q_out; hDiracDecBin = st_ivas->hDiracDecBin; assert( hDiracDecBin ); hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -1486,25 +1562,18 @@ static void ivas_dirac_dec_binaural_internal( } ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_fx, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); #if 1 - Word32 *output_fx[MAX_OUTPUT_CHANNELS]; - Word32 output_fx_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - Word16 q_out; - q_inp = Q6; FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - output_fx[ch] = output_fx_buff[ch]; - } - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; } #endif q_mat = hDiracDecBin->q_processMtx; + move16(); q_mat = s_min( q_mat, hDiracDecBin->q_processMtxPrev ); q_mat = s_min( q_mat, hDiracDecBin->q_processMtxDec ); q_mat = s_min( q_mat, hDiracDecBin->q_processMtxDecPrev ); @@ -1531,9 +1600,13 @@ static void ivas_dirac_dec_binaural_internal( } } hDiracDecBin->q_processMtx = q_mat; + move16(); hDiracDecBin->q_processMtxPrev = q_mat; + move16(); hDiracDecBin->q_processMtxDec = q_mat; + move16(); hDiracDecBin->q_processMtxDecPrev = q_mat; + move16(); ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat ); @@ -1542,14 +1615,13 @@ static void ivas_dirac_dec_binaural_internal( hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe] ); hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 ); -#if 1 FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - fixedToFloat_arrL32( output_fx[ch], output_f[ch], q_out, imult1616( nBins, hSpatParamRendCom->subframe_nbslots[subframe] ) ); + scale_sig32( output_fx[ch], imult1616( nBins, hSpatParamRendCom->subframe_nbslots[subframe] ), 11 - q_out ); // Scaling to Q11 scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; + move16(); } -#endif return; } @@ -7330,8 +7402,8 @@ static void ivas_masa_ext_rend_parambin_internal( max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_fx, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, - 0, NULL ); + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, + 0, NULL ); #if 1 Word16 q_out; diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c index c1830eaed..d9cf168dc 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -489,15 +489,6 @@ ivas_error ivas_dirac_dec_decorr_open_fx( Copy( &split_frequencies_bands[0], freq_domain_decorr_ap_params->split_frequency_bands, add( freq_domain_decorr_ap_params->num_split_frequency_bands, 1 ) ); /* calc buffer size and allocate arrays */ -#if 1 - /*float code to be cleaned up*/ - freq_domain_decorr_ap_state->decorr_buffer = NULL; - freq_domain_decorr_ap_state->direct_energy_smooth = NULL; - freq_domain_decorr_ap_state->reverb_energy_smooth = NULL; - freq_domain_decorr_ap_params->pre_delay = NULL; - freq_domain_decorr_ap_params->filter_length = NULL; -#endif -#ifdef IVAS_FLOAT_FIXED freq_domain_decorr_ap_state->decorr_buffer_fx = NULL; freq_domain_decorr_ap_params->filter_coeff_num_real_fx = NULL; freq_domain_decorr_ap_params->filter_coeff_den_real_fx = NULL; @@ -507,39 +498,12 @@ ivas_error ivas_dirac_dec_decorr_open_fx( freq_domain_decorr_ap_params->phase_coeff_imag_fx = NULL; freq_domain_decorr_ap_state->direct_energy_smooth_fx = NULL; freq_domain_decorr_ap_state->reverb_energy_smooth_fx = NULL; -#endif + freq_domain_decorr_ap_params->pre_delay = NULL; + freq_domain_decorr_ap_params->filter_length = NULL; - IF( num_outputs_diff > 0 ) + IF ( num_outputs_diff > 0 ) { buffer_size_decorr = ( ap_pre_delay[split_band_index_start] + ap_filter_length[split_band_index_start] ); -#if 1 - if ( ( freq_domain_decorr_ap_state->decorr_buffer = (float *) malloc( sizeof( float ) * 2 * buffer_size_decorr * num_outputs_diff * freq_domain_decorr_ap_params->max_band_decorr ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); - } - set_f( freq_domain_decorr_ap_state->decorr_buffer, 0.0f, 2 * buffer_size_decorr * num_outputs_diff * freq_domain_decorr_ap_params->max_band_decorr ); - - if ( ( freq_domain_decorr_ap_state->direct_energy_smooth = (float *) malloc( sizeof( float ) * freq_domain_decorr_ap_params->max_band_decorr * num_outputs_diff ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); - } - - if ( ( freq_domain_decorr_ap_state->reverb_energy_smooth = (float *) malloc( sizeof( float ) * freq_domain_decorr_ap_params->max_band_decorr * num_outputs_diff ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); - } - - if ( ( freq_domain_decorr_ap_params->pre_delay = (Word16 *) malloc( sizeof( Word16 ) * freq_domain_decorr_ap_params->num_split_frequency_bands ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); - } - if ( ( freq_domain_decorr_ap_params->filter_length = (Word16 *) malloc( sizeof( Word16 ) * freq_domain_decorr_ap_params->num_split_frequency_bands ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); - } - set_f( freq_domain_decorr_ap_state->direct_energy_smooth, 0.0f, freq_domain_decorr_ap_params->max_band_decorr * num_outputs_diff ); - set_f( freq_domain_decorr_ap_state->reverb_energy_smooth, 0.0f, freq_domain_decorr_ap_params->max_band_decorr * num_outputs_diff ); -#endif IF( ( freq_domain_decorr_ap_state->decorr_buffer_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * buffer_size_decorr * num_outputs_diff * freq_domain_decorr_ap_params->max_band_decorr ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); @@ -577,12 +541,22 @@ ivas_error ivas_dirac_dec_decorr_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); } + + IF((freq_domain_decorr_ap_params->pre_delay = (Word16 *)malloc(sizeof(Word16) * freq_domain_decorr_ap_params->num_split_frequency_bands)) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n")); + } + IF((freq_domain_decorr_ap_params->filter_length = (Word16 *)malloc(sizeof(Word16) * freq_domain_decorr_ap_params->num_split_frequency_bands)) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n")); + } + set32_fx( freq_domain_decorr_ap_state->direct_energy_smooth_fx, 0, freq_domain_decorr_ap_params->max_band_decorr * num_outputs_diff ); set32_fx( freq_domain_decorr_ap_state->reverb_energy_smooth_fx, 0, freq_domain_decorr_ap_params->max_band_decorr * num_outputs_diff ); freq_domain_decorr_ap_state->q_direct_energy_smooth = freq_domain_decorr_ap_state->q_reverb_energy_smooth = Q31; /* compute filter coefficients */ - FOR( k = 0; k < freq_domain_decorr_ap_params->num_split_frequency_bands; k++ ) + FOR ( k = 0; k < freq_domain_decorr_ap_params->num_split_frequency_bands; k++ ) { k_in = freq_domain_decorr_ap_params->split_frequency_bands[k]; k_out = freq_domain_decorr_ap_params->split_frequency_bands[k + 1]; @@ -591,11 +565,11 @@ ivas_error ivas_dirac_dec_decorr_open_fx( freq_domain_decorr_ap_params->filter_length[k] = add( ap_filter_length[band_table_idx], 1 ); freq_domain_decorr_ap_params->pre_delay[k] = ap_pre_delay[band_table_idx]; - FOR( l = 0; l < num_outputs_diff; l++ ) + FOR ( l = 0; l < num_outputs_diff; l++ ) { - FOR( m = 0; m < num_bands; m++ ) + FOR ( m = 0; m < num_bands; m++ ) { - n = add( k_in, m ); + n = add(k_in , m); Word32 cur_lattice_delta_phi_32_fx = L_mult( ap_lattice_delta_phi_fx[l * DIRAC_MAX_DECORR_FILTER_LEN + ap_filter_length[k] - 1], (Word16) floatToFixed( n, 10 ) ); cur_lattice_delta_phi_fx = extract_h( cur_lattice_delta_phi_32_fx ); // Q10 @@ -1011,19 +985,19 @@ void ivas_dirac_dec_decorr_process_fx( } q_aux_buffer += q_shift; #else - (void) maximum_abs_32_fx( &input_frame_fx[0], 2 * num_protos_dir * num_freq_bands, &max_abs_val ); + (void)maximum_abs_32_fx(&input_frame_fx[0], 2 * num_protos_dir * num_freq_bands, &max_abs_val); q_shift = getScaleFactor32( &input_frame_fx[0], 2 * num_protos_dir * num_freq_bands ) - guarded_bits; - IF( LT_16( q_shift, sub( 0, guarded_bits ) ) && NE_32( max_abs_val, 0 ) ) + IF (LT_16(q_shift , sub(0, guarded_bits)) && NE_32(max_abs_val, 0)) { - q_shift = sub( 0, guarded_bits ); + q_shift = sub(0, guarded_bits); } - ELSE IF( EQ_32( max_abs_val, 0 ) ) + ELSE IF (EQ_32(max_abs_val, 0)) { q_shift = 0; } - FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) + FOR ( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++) { - v_shr( &input_frame_fx[2 * ch_idx * num_freq_bands], negate( q_shift ), &aux_buffer_fx[2 * ch_idx * num_freq_bands], 2 * num_freq_bands ); + v_shr(&input_frame_fx[2 * ch_idx * num_freq_bands], negate(q_shift), &aux_buffer_fx[2 * ch_idx * num_freq_bands], 2 * num_freq_bands); } FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) { @@ -1299,17 +1273,17 @@ void ivas_dirac_dec_decorr_process_fx( h_freq_domain_decorr_ap_state->q_direct_energy_smooth = sub( 31, e_direct_energy_smooth ); // scaling energy buffers for better precision for higher values// - q_shift = L_norm_arr( h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616( num_protos_dir, max_band_decorr ) ); - Scale_sig32( h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616( num_protos_dir, max_band_decorr ), q_shift ); + q_shift = L_norm_arr(h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616(num_protos_dir, max_band_decorr)); + Scale_sig32(h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616(num_protos_dir, max_band_decorr), q_shift); h_freq_domain_decorr_ap_state->q_direct_energy_smooth = h_freq_domain_decorr_ap_state->q_direct_energy_smooth + q_shift; - q_shift = L_norm_arr( h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, imult1616( num_channels, max_band_decorr ) ); - Scale_sig32( h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, imult1616( num_channels, max_band_decorr ), q_shift ); + q_shift = L_norm_arr(h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, imult1616(num_channels, max_band_decorr)); + Scale_sig32(h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, imult1616(num_channels, max_band_decorr), q_shift); h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = h_freq_domain_decorr_ap_state->q_reverb_energy_smooth + q_shift; - e_reverb_energy_smooth = sub( 31, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); - e_direct_energy_smooth = sub( 31, h_freq_domain_decorr_ap_state->q_direct_energy_smooth ); + e_reverb_energy_smooth = sub(31 , h_freq_domain_decorr_ap_state->q_reverb_energy_smooth); + e_direct_energy_smooth = sub(31 , h_freq_domain_decorr_ap_state->q_direct_energy_smooth); // this step is b/c we are left shifting frame_dec_fx at the end of below for loop/ #ifdef MSAN_FIX @@ -1444,150 +1418,129 @@ void ivas_dirac_dec_decorr_process_fx( #ifdef IVAS_FLOAT_FIXED void ivas_dirac_dec_decorr_close_fx( - HANDLE_DIRAC_DECORR_PARAMS *ph_freq_domain_decorr_ap_params, - HANDLE_DIRAC_DECORR_STATE *ph_freq_domain_decorr_ap_state ) + HANDLE_DIRAC_DECORR_PARAMS *ph_freq_domain_decorr_ap_params, + HANDLE_DIRAC_DECORR_STATE *ph_freq_domain_decorr_ap_state) { - DIRAC_ONSET_DETECTION_STATE *dirac_onset_detection_state; + DIRAC_ONSET_DETECTION_STATE *dirac_onset_detection_state; - /*-----------------------------------------------------------------* - * check input handles - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * check input handles + *-----------------------------------------------------------------*/ - if ( ph_freq_domain_decorr_ap_params == NULL || ph_freq_domain_decorr_ap_state == NULL ) - { - return; - } + if (ph_freq_domain_decorr_ap_params == NULL || ph_freq_domain_decorr_ap_state == NULL) + { + return; + } - if ( *ph_freq_domain_decorr_ap_params == NULL || *ph_freq_domain_decorr_ap_state == NULL ) - { - return; - } + if (*ph_freq_domain_decorr_ap_params == NULL || *ph_freq_domain_decorr_ap_state == NULL) + { + return; + } - /*-----------------------------------------------------------------* - * free onset filter arrays - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * free onset filter arrays + *-----------------------------------------------------------------*/ - dirac_onset_detection_state = &( *ph_freq_domain_decorr_ap_state )->h_onset_detection_power_state; + dirac_onset_detection_state = &(*ph_freq_domain_decorr_ap_state)->h_onset_detection_power_state; #ifdef IVAS_FLOAT_FIXED - IF( dirac_onset_detection_state->onset_detector_1_fx != NULL ) - { - free( dirac_onset_detection_state->onset_detector_1_fx ); - dirac_onset_detection_state->onset_detector_1_fx = NULL; - } - - IF( dirac_onset_detection_state->onset_detector_2_fx != NULL ) - { - free( dirac_onset_detection_state->onset_detector_2_fx ); - dirac_onset_detection_state->onset_detector_2_fx = NULL; - } + IF(dirac_onset_detection_state->onset_detector_1_fx != NULL) + { + free(dirac_onset_detection_state->onset_detector_1_fx); + dirac_onset_detection_state->onset_detector_1_fx = NULL; + } + + IF(dirac_onset_detection_state->onset_detector_2_fx != NULL) + { + free(dirac_onset_detection_state->onset_detector_2_fx); + dirac_onset_detection_state->onset_detector_2_fx = NULL; + } #endif - /*-----------------------------------------------------------------* - * memory deallocation - *-----------------------------------------------------------------*/ - - /* free decorrelation buffer */ - if ( ( *ph_freq_domain_decorr_ap_state )->decorr_buffer != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_state )->decorr_buffer ); - ( *ph_freq_domain_decorr_ap_state )->decorr_buffer = NULL; - } - - /* free ducker smoothed direct energy buffer */ - if ( ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth ); - ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth = NULL; - } - - /* free ducker smoothed reverb energy buffer */ - if ( ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth ); - ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth = NULL; - } + /*-----------------------------------------------------------------* + * memory deallocation + *-----------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED - IF( ( *ph_freq_domain_decorr_ap_state )->decorr_buffer_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_state )->decorr_buffer_fx ); - ( *ph_freq_domain_decorr_ap_state )->decorr_buffer_fx = NULL; - } - - /* free ducker smoothed direct energy buffer */ - IF( ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth_fx ); - ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth_fx = NULL; - } - - /* free ducker smoothed reverb energy buffer */ - IF( ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth_fx ); - ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth_fx = NULL; - } + IF((*ph_freq_domain_decorr_ap_state)->decorr_buffer_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_state)->decorr_buffer_fx); + (*ph_freq_domain_decorr_ap_state)->decorr_buffer_fx = NULL; + } + + /* free ducker smoothed direct energy buffer */ + IF((*ph_freq_domain_decorr_ap_state)->direct_energy_smooth_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_state)->direct_energy_smooth_fx); + (*ph_freq_domain_decorr_ap_state)->direct_energy_smooth_fx = NULL; + } + + /* free ducker smoothed reverb energy buffer */ + IF((*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth_fx); + (*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth_fx = NULL; + } #endif - /* free pre-delay param buffer */ - if ( ( *ph_freq_domain_decorr_ap_params )->pre_delay != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_params )->pre_delay ); - ( *ph_freq_domain_decorr_ap_params )->pre_delay = NULL; - } - - /* free filter length param buffer */ - if ( ( *ph_freq_domain_decorr_ap_params )->filter_length != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_params )->filter_length ); - ( *ph_freq_domain_decorr_ap_params )->filter_length = NULL; - } - - /* free pre-delay param buffer */ - if ( ( *ph_freq_domain_decorr_ap_params )->split_frequency_bands != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_params )->split_frequency_bands ); - ( *ph_freq_domain_decorr_ap_params )->split_frequency_bands = NULL; - } + /* free pre-delay param buffer */ + if ((*ph_freq_domain_decorr_ap_params)->pre_delay != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->pre_delay); + (*ph_freq_domain_decorr_ap_params)->pre_delay = NULL; + } + + /* free filter length param buffer */ + if ((*ph_freq_domain_decorr_ap_params)->filter_length != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->filter_length); + (*ph_freq_domain_decorr_ap_params)->filter_length = NULL; + } + + /* free pre-delay param buffer */ + if ((*ph_freq_domain_decorr_ap_params)->split_frequency_bands != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->split_frequency_bands); + (*ph_freq_domain_decorr_ap_params)->split_frequency_bands = NULL; + } #ifdef IVAS_FLOAT_FIXED /* free filter coeff param buffers */ - IF( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real_fx ); - ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real_fx = NULL; - } - - /* free pre-delay param buffer */ - IF( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real_fx ); - ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real_fx = NULL; - } - - /* free pre-delay param buffer */ - IF( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag_fx ); - ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag_fx = NULL; - } + IF((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real_fx); + (*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real_fx = NULL; + } /* free pre-delay param buffer */ - IF( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real_fx ); - ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real_fx = NULL; - } + IF((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real_fx); + (*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real_fx = NULL; + } + + /* free pre-delay param buffer */ + IF((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag_fx); + (*ph_freq_domain_decorr_ap_params)->phase_coeff_imag_fx = NULL; + } + + /* free pre-delay param buffer */ + IF((*ph_freq_domain_decorr_ap_params)->phase_coeff_real_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->phase_coeff_real_fx); + (*ph_freq_domain_decorr_ap_params)->phase_coeff_real_fx = NULL; + } #endif - /* free pointers to state and parameter structs */ - free( *ph_freq_domain_decorr_ap_params ); - *ph_freq_domain_decorr_ap_params = NULL; + /* free pointers to state and parameter structs */ + free(*ph_freq_domain_decorr_ap_params); + *ph_freq_domain_decorr_ap_params = NULL; - free( *ph_freq_domain_decorr_ap_state ); - *ph_freq_domain_decorr_ap_state = NULL; + free(*ph_freq_domain_decorr_ap_state); + *ph_freq_domain_decorr_ap_state = NULL; - return; + return; } #else void ivas_dirac_dec_decorr_close( @@ -1743,7 +1696,7 @@ static void get_lattice_coeffs_fx( { Word16 k; - FOR( k = 0; k < ap_filter_length[band_index]; k++ ) + FOR ( k = 0; k < ap_filter_length[band_index]; k++ ) { Word16 cur_lattice_coeff = ap_lattice_coeffs_fx[band_index][channel_index * ap_filter_length[band_index] + k]; lattice_coeffs[k] = cur_lattice_coeff; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 73154c600..2390b1d5f 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -219,11 +219,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { size = hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir; } - /*TODO : remove float code*/ - /*if ( ( dirac_output_synthesis_state->cy_cross_dir_smooth_prev = (float *) malloc( size * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - }*/ IF( ( dirac_output_synthesis_state->cy_cross_dir_smooth_prev_fx = (Word32 *) malloc( size * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); @@ -231,12 +226,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( dirac_output_synthesis_state->cy_cross_dir_smooth_prev_len = size; IF( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - /*TODO : remove float code*/ - // dirac_output_synthesis_state->cy_auto_dir_smooth_prev = NULL; - if ( ( dirac_output_synthesis_state->cy_auto_diff_smooth_prev = (float *) malloc( dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - } dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx = NULL; IF( ( dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx = (Word32 *) malloc( dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff * sizeof( Word32 ) ) ) == NULL ) { @@ -246,20 +235,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( } ELSE { - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) - { - if ( ( dirac_output_synthesis_state->cy_auto_diff_smooth_prev = (float *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - } - } - else - { - if ( ( dirac_output_synthesis_state->cy_auto_diff_smooth_prev = (float *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - } - } IF( ( dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); @@ -285,11 +260,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( } /* direct and diffuse gain buffers */ - /*TODO : remove float code*/ - if ( ( dirac_output_synthesis_state->gains_dir_prev = (float *) malloc( size * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - } IF( ( dirac_output_synthesis_state->gains_dir_prev_fx = (Word32 *) malloc( size * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); @@ -297,11 +267,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( dirac_output_synthesis_state->gains_dir_prev_len = size; IF( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - /*TODO : remove float code*/ - if ( ( dirac_output_synthesis_state->gains_diff_prev = (float *) malloc( dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - } IF( ( dirac_output_synthesis_state->gains_diff_prev_fx = (Word32 *) malloc( dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); @@ -310,11 +275,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( } ELSE IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_PSD_SHD && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_MONO ) { - /*TODO : remove float code*/ - if ( ( dirac_output_synthesis_state->gains_diff_prev = (float *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - } IF( ( dirac_output_synthesis_state->gains_diff_prev_fx = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); @@ -323,11 +283,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( } ELSE { - /*TODO : remove float code*/ - if ( ( dirac_output_synthesis_state->gains_diff_prev = (float *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - } IF( ( dirac_output_synthesis_state->gains_diff_prev_fx = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); @@ -816,46 +771,6 @@ void ivas_dirac_dec_output_synthesis_init_fx( *-----------------------------------------------------------------*/ /* initialize buffers */ - /*if ( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev != NULL ) - { - set_zero( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir ); - }*/ - - if ( hodirac_flag ) - { - size = hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * DIRAC_HO_NUMSECTORS; - } - else - { - size = hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir; - } - // set_zero( h_dirac_output_synthesis_state->cy_cross_dir_smooth_prev, size ); - - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - set_zero( h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff ); - } - else if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_PSD_SHD ) - { - set_zero( h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff ); - } - else - { - set_zero( h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir ); - } - - set_zero( h_dirac_output_synthesis_state->gains_dir_prev, size ); - - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - set_zero( h_dirac_output_synthesis_state->gains_diff_prev, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff ); - } - else - { - set_zero( h_dirac_output_synthesis_state->gains_diff_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir ); - } - -#ifdef IVAS_FLOAT_FIXED IF( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx != NULL ) { set32_fx( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx, 0, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir ); @@ -910,7 +825,6 @@ void ivas_dirac_dec_output_synthesis_init_fx( set32_fx( h_dirac_output_synthesis_state->proto_power_diff_smooth_prev_fx, 0, h_dirac_output_synthesis_params->max_band_decorr * nchan_out_woLFE ); } h_dirac_output_synthesis_state->proto_power_diff_smooth_prev_q = Q31; -#endif return; } @@ -1029,36 +943,6 @@ void ivas_dirac_dec_output_synthesis_close_fx( * memory deallocation *-----------------------------------------------------------------*/ - /* free target power buffers */ - /*if ( ( dirac_output_synthesis_state )->cy_auto_dir_smooth_prev != NULL ) - { - free( ( dirac_output_synthesis_state )->cy_auto_dir_smooth_prev ); - ( dirac_output_synthesis_state )->cy_auto_dir_smooth_prev = NULL; - }*/ - /*if ( ( dirac_output_synthesis_state )->cy_cross_dir_smooth_prev != NULL ) - { - free( ( dirac_output_synthesis_state )->cy_cross_dir_smooth_prev ); - ( dirac_output_synthesis_state )->cy_cross_dir_smooth_prev = NULL; - }*/ - if ( ( dirac_output_synthesis_state )->cy_auto_diff_smooth_prev != NULL ) - { - free( ( dirac_output_synthesis_state )->cy_auto_diff_smooth_prev ); - ( dirac_output_synthesis_state )->cy_auto_diff_smooth_prev = NULL; - } - - /* free gain buffers */ - if ( ( dirac_output_synthesis_state )->gains_dir_prev != NULL ) - { - free( ( dirac_output_synthesis_state )->gains_dir_prev ); - ( dirac_output_synthesis_state )->gains_dir_prev = NULL; - } - if ( ( dirac_output_synthesis_state )->gains_diff_prev != NULL ) - { - free( ( dirac_output_synthesis_state )->gains_diff_prev ); - ( dirac_output_synthesis_state )->gains_diff_prev = NULL; - } - -#ifdef IVAS_FLOAT_FIXED /* free interpolator */ IF( ( dirac_output_synthesis_params )->interpolator_fx != NULL ) { @@ -1137,7 +1021,6 @@ void ivas_dirac_dec_output_synthesis_close_fx( free( ( dirac_output_synthesis_state )->gains_diff_prev_fx ); ( dirac_output_synthesis_state )->gains_diff_prev_fx = NULL; } -#endif return; } #endif diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 744035fa6..320138fc8 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -745,13 +745,6 @@ void ivas_dirac_rend_close_fx( /* States */ /* free prototype signal buffers */ -#if 1 /* TODO: remove float code */ - IF( hDirACRend->proto_frame_f != NULL ) - { - free( hDirACRend->proto_frame_f ); - hDirACRend->proto_frame_f = NULL; - } -#endif IF( hDirACRend->proto_frame_f_fx != NULL ) { free( hDirACRend->proto_frame_f_fx ); @@ -1410,12 +1403,13 @@ ivas_error ivas_dirac_alloc_mem( if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->cy_auto_diff_smooth = (float *) malloc( sizeof( float ) * size ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } set_zero( hDirAC_mem->cy_auto_diff_smooth, size ); -#ifdef IVAS_FLOAT_FIXED +#else if ( ( hDirAC_mem->cy_auto_diff_smooth_fx = (Word32 *) malloc( sizeof( Word32 ) * size ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); @@ -1426,12 +1420,13 @@ ivas_error ivas_dirac_alloc_mem( } else { +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->cy_auto_diff_smooth = (float *) malloc( sizeof( float ) * num_outputs_diff * num_freq_bands_diff ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } set_zero( hDirAC_mem->cy_auto_diff_smooth, num_outputs_diff * num_freq_bands_diff ); -#ifdef IVAS_FLOAT_FIXED +#else if ( ( hDirAC_mem->cy_auto_diff_smooth_fx = (Word32 *) malloc( sizeof( Word32 ) * num_outputs_diff * num_freq_bands_diff ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); @@ -1440,7 +1435,6 @@ ivas_error ivas_dirac_alloc_mem( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len = num_outputs_diff * num_freq_bands_diff; #endif } - hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth = hDirAC_mem->cy_auto_diff_smooth; #ifdef IVAS_FLOAT_FIXED hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx = hDirAC_mem->cy_cross_dir_smooth_fx; hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx = hDirAC_mem->cy_auto_diff_smooth_fx; @@ -1450,6 +1444,7 @@ ivas_error ivas_dirac_alloc_mem( move16(); #else hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth = hDirAC_mem->cy_cross_dir_smooth; + hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth = hDirAC_mem->cy_auto_diff_smooth; #endif /*Responses (gains/factors)*/ @@ -1735,10 +1730,6 @@ void ivas_dirac_free_mem_fx( { free( hDirAC_mem->cy_cross_dir_smooth_fx ); } - IF( hDirAC_mem->cy_auto_diff_smooth != NULL ) - { - free( hDirAC_mem->cy_auto_diff_smooth ); - } IF( hDirAC_mem->cy_auto_diff_smooth_fx != NULL ) { free( hDirAC_mem->cy_auto_diff_smooth_fx ); @@ -1880,7 +1871,7 @@ void compute_hoa_encoder_mtx_fx( { Word16 k, num_sh; - num_sh = (Word16) ivas_sba_get_nchan_fx( ambisonics_order, 0 ); + num_sh = ivas_sba_get_nchan_fx( ambisonics_order, 0 ); FOR( k = 0; k < num_responses; k++ ) { ivas_dirac_dec_get_response_fixed( shr( extract_h( azimuth[k] ), Q22 - Q16 ), shr( extract_h( elevation[k] ), Q22 - Q16 ), &response_fx[k * num_sh], ambisonics_order ); // Q29 diff --git a/lib_rend/ivas_mcmasa_ana.c b/lib_rend/ivas_mcmasa_ana.c index 48d9c50f5..d210b3603 100644 --- a/lib_rend/ivas_mcmasa_ana.c +++ b/lib_rend/ivas_mcmasa_ana.c @@ -2331,12 +2331,14 @@ static void computeEvenLayout( } #endif + /*------------------------------------------------------------------------- * ivas_create_masa_out_meta() * * *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_create_masa_out_meta( MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: MASA metadata handle */ SPHERICAL_GRID_DATA *Sph_Grid16, /* i : Spherical grid */ @@ -2414,14 +2416,7 @@ void ivas_create_masa_out_meta( return; } - -#ifdef IVAS_FLOAT_FIXED -/*------------------------------------------------------------------------- - * ivas_create_masa_out_meta() - * - * - *------------------------------------------------------------------------*/ - +#else void ivas_create_masa_out_meta_fx( MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: MASA metadata handle */ SPHERICAL_GRID_DATA *Sph_Grid16, /* i : Spherical grid */ diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 6ff205616..861a0db0e 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -40,6 +40,7 @@ #include "ivas_prot.h" #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" /*-------------------------------------------------------------------------* * audioCfg2channels() * @@ -530,7 +531,11 @@ Word16 ivas_get_nchan_buffers_dec( ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) { Word16 nchan_internal; +#ifndef IVAS_FLOAT_FIXED nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); +#else + nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); +#endif nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; move16(); @@ -584,7 +589,11 @@ Word16 ivas_get_nchan_buffers_dec( ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { Word16 nchan_internal; +#ifndef IVAS_FLOAT_FIXED nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); +#else + nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); +#endif nchan_out_buff = add( st_ivas->nchan_ism, st_ivas->nchan_transport ); IF( st_ivas->hMCT != NULL ) diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 708c93caf..2dc4f75d6 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -44,7 +44,7 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) { Word16 nchan_internal; - nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); + nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; move16(); @@ -99,7 +99,7 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx( ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { Word16 nchan_internal; - nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); + nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); nchan_out_buff = add( st_ivas->nchan_ism, st_ivas->nchan_transport ); IF( st_ivas->hMCT != NULL ) diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 8e25239b7..66555279d 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -339,7 +339,7 @@ void ivas_dirac_dec_binaural_sba_gain( const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ const int16_t output_frame /* i : output frame length */ ); - +#ifndef IVAS_FLOAT_FIXED void ivas_dirac_dec_binaural_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -348,7 +348,16 @@ void ivas_dirac_dec_binaural_render( const int16_t nchan_transport, /* i : number of transport channels */ float *output_f[] /* o : rendered time signal */ ); - +#else +void ivas_dirac_dec_binaural_render_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ + UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ + UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const Word16 nchan_transport, /* i : number of transport channels */ + Word32 *output_f[] /* o : rendered time signal */ +); +#endif void ivas_masa_ext_rend_parambin_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 8d83587e6..2c9d1ae7c 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -181,16 +181,17 @@ typedef struct dirac_decorr_params_structure typedef struct dirac_decorr_state_structure { +#ifndef IVAS_FLOAT_FIXED float *decorr_buffer; float *direct_energy_smooth; float *reverb_energy_smooth; -#ifdef IVAS_FLOAT_FIXED - Word32 *decorr_buffer_fx; +#else + Word32 *decorr_buffer_fx; /* Q(q_decorr_buffer) */ Word16 q_decorr_buffer; Word16 decorr_buffer_len; - Word32 *direct_energy_smooth_fx; + Word32 *direct_energy_smooth_fx; /* Q(q_direct_energy_smooth) */ Word16 q_direct_energy_smooth; - Word32 *reverb_energy_smooth_fx; + Word32 *reverb_energy_smooth_fx; /* Q(q_reverb_energy_smooth) */ Word16 q_reverb_energy_smooth; #endif @@ -306,8 +307,8 @@ typedef struct dirac_dec_stack_mem Word32 *direct_responses_fx; Word32 *direct_responses_square_fx; #endif + /* Target co-variance mtx */ - float *cy_auto_diff_smooth; #ifdef IVAS_FLOAT_FIXED Word32 *cy_auto_dir_smooth_fx; Word32 *cy_cross_dir_smooth_fx; @@ -315,6 +316,7 @@ typedef struct dirac_dec_stack_mem #else float *cy_cross_dir_smooth; float *cy_auto_dir_smooth; + float *cy_auto_diff_smooth; #endif #ifndef IVAS_FLOAT_FIXED @@ -325,7 +327,7 @@ typedef struct dirac_dec_stack_mem Word16 reference_power_q; Word16 reference_power_smooth_q; Word16 reference_power_len; - Word32 *onset_filter_fx; /* Q31 */ + Word32 *onset_filter_fx; /* Q31 */ #endif } DIRAC_DEC_STACK_MEM, *DIRAC_DEC_STACK_MEM_HANDLE; @@ -342,18 +344,19 @@ typedef struct dirac_output_synthesis_params_structure float *alpha_synthesis; float *alpha_synthesis_fast; #else - Word16 *interpolator_fx; /* Q15 */ - Word16 *alpha_synthesis_fx; /* Q15 */ - Word16 *alpha_synthesis_fast_fx; /* Q15 */ + Word16 *interpolator_fx; /* Q15 */ + Word16 *alpha_synthesis_fx; /* Q15 */ + Word16 *alpha_synthesis_fast_fx; /* Q15 */ #endif int16_t numAlphas; int16_t numAlphasFast; - float *proto_matrix; #ifdef IVAS_FLOAT_FIXED Word32 *proto_matrix_fx; Word16 proto_matrix_e; Word16 proto_matrix_len; +#else + float *proto_matrix; #endif #ifndef IVAS_FLOAT_FIXED @@ -400,22 +403,24 @@ typedef struct dirac_output_synthesis_state_structure #endif /* Output gain memories */ +#ifndef IVAS_FLOAT_FIXED 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. */ +#endif /* only pointer to local buffers */ #ifndef IVAS_FLOAT_FIXED 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. */ -#endif float *cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ +#endif /* PSD memories */ #ifndef IVAS_FLOAT_FIXED 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. */ -#endif float *cy_auto_diff_smooth_prev; /* Target auto PSD of diffuse sound of previous synthesis block. Size: num_freq_bands*num_channels. */ +#endif #ifndef IVAS_FLOAT_FIXED const float *onset_filter; @@ -706,14 +711,14 @@ typedef struct ivas_dirac_rend_data_structure int16_t proto_signal_decorr_on; /*Decoder states=memories*/ +#ifndef IVAS_FLOAT_FIXED float *proto_frame_f; float *proto_frame_dec_f; -#ifdef IVAS_FLOAT_FIXED - Word32 *proto_frame_f_fx; +#else + Word32 *proto_frame_f_fx; /* Q(proto_frame_f_q) */ Word16 proto_frame_f_q; Word16 proto_frame_f_len; - - Word32 *proto_frame_dec_f_fx; + Word32 *proto_frame_dec_f_fx; /* Q(proto_frame_dec_f_q) */ Word16 proto_frame_dec_f_q; Word16 proto_frame_dec_f_len; #endif @@ -743,11 +748,11 @@ typedef struct ivas_dirac_rend_data_structure typedef struct vbap_vs_triplet_structure { uint8_t speaker_node[3]; +#ifndef IVAS_FLOAT_FIXED float inverse_matrix[3][3]; -#ifdef IVAS_FLOAT_FIXED - Word32 inverse_matrix_fx[3][3]; +#else + Word32 inverse_matrix_fx[3][3]; /* Q(q_inverse_matrix) */ Word16 q_inverse_matrix; - Word16 exp_inv_matrix; #endif } VBAP_VS_TRIPLET; @@ -1679,9 +1684,12 @@ typedef struct int16_t elevBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS]; const float *elevBsShape; int16_t elevSegSamples; +#ifndef IVAS_FLOAT_FIXED float resamp_factor; -#ifdef IVAS_FLOAT_FIXED +#else Word16 resamp_factor_fx; /*Q14*/ +#endif +#ifdef IVAS_FLOAT_FIXED const Word32 *elevKSeq_fx; /* Array, length elevDim3-2 */ const Word32 *azimKSeq_fx; /* Array, length azimDim3-2 */ const Word32 *W_fx; /* Array, size (elevDim3*azimDim3) x K */ diff --git a/lib_rend/ivas_vbap.c b/lib_rend/ivas_vbap.c index 3d91b4128..7a51c4aa8 100644 --- a/lib_rend/ivas_vbap.c +++ b/lib_rend/ivas_vbap.c @@ -2182,7 +2182,7 @@ static Word16 check_and_store_triplet_fx( ) { Word16 ch_check; - Word16 k, i, j; + Word16 k; Word16 speaker_node_found_inside_triplet; UWord8 triplet_ok; @@ -2197,7 +2197,6 @@ static Word16 check_and_store_triplet_fx( speaker_node_triplet_unit_vec_matrix_fx[2] = speaker_node_data[chC].unit_vec_fx; Word16 exp_inv_mat = 31; matrix_inverse_3x3_32_fx( speaker_node_triplet_unit_vec_matrix_fx, inverse_matrix_fx, &exp_inv_mat ); - triplets[*triplet_index].exp_inv_matrix = exp_inv_mat; triplets[*triplet_index].q_inverse_matrix = 31 - exp_inv_mat; /* Check through all speaker nodes that none of them are within the triplet. @@ -2227,14 +2226,6 @@ static Word16 check_and_store_triplet_fx( { Copy32( inverse_matrix_fx[k], triplets[*triplet_index].inverse_matrix_fx[k], 3 ); } - /*TODO : Clean up float code*/ - FOR( i = 0; i < 3; i++ ) - { - FOR( j = 0; j < 3; j++ ) - { - triplets[*triplet_index].inverse_matrix[i][j] = me2f( triplets[*triplet_index].inverse_matrix_fx[i][j], exp_inv_mat ); - } - } /* Get center azimuth for fast search use */ Word32 tmp_a = L_add( L_shr( L_add( speaker_node_data[chA].unit_vec_fx[1], speaker_node_data[chB].unit_vec_fx[1] ), 2 ), L_shr( speaker_node_data[chC].unit_vec_fx[1], 2 ) ); // Q28 /*Condition to make tmp_a 0 to adress precision loss seen*/ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 4a2db0827..63c64149e 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -13283,7 +13283,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( /* Directional and diffuses components in SHD */ /* Diffuseness components up to 1st order */ hDirACRend->num_outputs_diff = ( min( hDirACRend->hOutSetup.ambisonics_order, 1 ) + 1 ) * ( min( hDirACRend->hOutSetup.ambisonics_order, 1 ) + 1 ); - hDirACRend->num_outputs_dir = ivas_sba_get_nchan( hDirACRend->hOutSetup.ambisonics_order, 0 ); + hDirACRend->num_outputs_dir = ivas_sba_get_nchan_fx( hDirACRend->hOutSetup.ambisonics_order, 0 ); } ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) { @@ -13492,19 +13492,10 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { -#if 1 /*TODO :To be removed later(after dependecy on buffer_energyis completely removed)*/ - hDirACRend->proto_frame_f = NULL; -#endif hDirACRend->proto_frame_f_fx = NULL; } ELSE { -#if 1 /*TODO: To be removed later(after dependency on proto_frame_f is completely removed)*/ - IF( ( hDirACRend->proto_frame_f = (float *) malloc( sizeof( float ) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } -#endif IF( ( hDirACRend->proto_frame_f_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); @@ -14759,7 +14750,6 @@ static void intermidiate_ext_dirac_render( { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; - // floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); } else { @@ -14769,27 +14759,23 @@ static void intermidiate_ext_dirac_render( { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; - // floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); } else if ( ( ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) && ( masa_band_mapping != NULL ) ) || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_MONO ) { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; - // floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); } ELSE IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) /*VBAP*/ { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; - // floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); } } else if ( hDirACRend->panningConf == DIRAC_PANNING_VBAP ) /*VBAP*/ { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; - // floatToFixed_arrL32(hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult(hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir)); } } } @@ -14807,53 +14793,36 @@ static void intermidiate_ext_dirac_render( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev += shift; } - /*if ( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth ) - { - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len ); - }*/ - - /*if ( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev ) - { - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len ); - ; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len ); - }*/ if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx ) { Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len, shift ); hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth += shift; } - /*if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth ) - { - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth, hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len ); - }*/ Word16 num_channels_dir = hDirACRend->num_outputs_dir; if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS ) { num_channels_dir = hDirACRend->hOutSetup.nchan_out_woLFE; } - if ( h_dirac_output_synthesis_state->cy_auto_diff_smooth ) + if ( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx ) { - h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len ); + tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len, tmp ); + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth += tmp; } - if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev ) + if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx ) { - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len ); - ; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len ); + tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len, tmp ); + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev += tmp; } + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_len, Q26 - hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ); hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = Q26; + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_len, Q26 - hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ); hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_len ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_len ); - if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx ) { Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir ); @@ -14861,16 +14830,11 @@ static void intermidiate_ext_dirac_render( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev += shift; } - /*if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev ) - { - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len ); - }*/ if ( hDirACRend->proto_signal_decorr_on == 1 ) { - Word16 tmp_e; - f2me_buf( hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_fx, &tmp_e, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_len ); - hDirACRend->h_freq_domain_decorr_ap_state->q_decorr_buffer = 31 - tmp_e; + tmp = L_norm_arr( hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_fx, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_len ); + scale_sig32( hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_fx, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_len, tmp ); + hDirACRend->h_freq_domain_decorr_ap_state->q_decorr_buffer += tmp; } if ( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len > 0 ) @@ -14887,8 +14851,6 @@ static void intermidiate_ext_dirac_render( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = 31 - hr_exp; } - // f2me_buf(hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len); - // hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = 31 - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q; FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { /* CLDFB Analysis*/ @@ -14897,10 +14859,6 @@ static void intermidiate_ext_dirac_render( hMasaExtRend->cldfbAnaRend[ch]->Q_cldfb_state = Q11; } } - // if(DirAC_mem.frame_dec_f) - //{ - // //f2me_buf(DirAC_mem.frame_dec_f, DirAC_mem.frame_dec_f_fx, &hDirACRend->proto_frame_dec_f_q, DirAC_mem.frame_dec_f_len); - // } hDirACRend->proto_frame_dec_f_q = 31 - hDirACRend->proto_frame_dec_f_q; if ( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) @@ -14926,72 +14884,6 @@ static void intermidiate_ext_dirac_render( } else { - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - // hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); - // hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); - } - - /* - IF(EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - ELSE - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } - }*/ - /*if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len ); - }*/ - /*if ( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len ); - }*/ - /*if ( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len ); - }*/ - /*if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len ); - }*/ - if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len ); - } - if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len ); - } - if ( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_len ); - } - if ( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_len ); - } - // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len); - if ( hDirACRend->proto_signal_decorr_on == 1 ) - { - fixedToFloat_arrL32( hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_fx, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer, hDirACRend->h_freq_domain_decorr_ap_state->q_decorr_buffer, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_len ); - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL( hDirACRend->h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, hDirACRend->h_freq_domain_decorr_ap_state->direct_energy_smooth, hDirACRend->h_freq_domain_decorr_ap_state->q_direct_energy_smooth, hDirACRend->num_protos_diff * hDirACRend->h_freq_domain_decorr_ap_params->max_band_decorr ); - fixedToFloat_arrL( hDirACRend->h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, hDirACRend->h_freq_domain_decorr_ap_state->reverb_energy_smooth, hDirACRend->h_freq_domain_decorr_ap_state->q_reverb_energy_smooth, hDirACRend->num_protos_diff * hDirACRend->h_freq_domain_decorr_ap_params->max_band_decorr ); - } - } - // fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len); - fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f_len ); - // fixedToFloat_arrL32(DirAC_mem.frame_dec_f_fx, DirAC_mem.frame_dec_f, DirAC_mem.frame_dec_f_q, DirAC_mem.frame_dec_f_len); - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[hSpatParamRendCom->subframes_rendered]; slot_idx++ ) { /* CLDFB Analysis*/ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 549d4cb4d..536668bac 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -260,10 +260,10 @@ static void LoadBSplineBinaryITD( modelITD->elevKSeq_dyn = (float *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( float ) ); fread( modelITD->elevKSeq_dyn, sizeof( float ), modelITD->elevDim3 - 2, f_hrtf ); #ifdef IVAS_FLOAT_FIXED - modelITD->elevKSeq_dyn_fx = (Word32 *) malloc( sizeof( Word32 ) * ( modelITD->elevDim3 - 2 ) ); - for ( int i = 0; i < modelITD->elevDim3 - 2; i++ ) + modelITD->elevKSeq_dyn_fx = (Word32 *)malloc(sizeof(Word32)*(modelITD->elevDim3 - 2)); + for (int i = 0; i < modelITD->elevDim3 - 2; i++) { - modelITD->elevKSeq_dyn_fx[i] = float_to_fix( modelITD->elevKSeq_dyn[i], 22 ); + modelITD->elevKSeq_dyn_fx[i] = float_to_fix(modelITD->elevKSeq_dyn[i], 22); } #endif @@ -273,9 +273,9 @@ static void LoadBSplineBinaryITD( fread( modelITD->azimKSeq_dyn, sizeof( float ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf ); #ifdef IVAS_FLOAT_FIXED modelITD->azimKSeq_dyn_fx = (Word32 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ - for ( int i = 0; i < ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ); i++ ) + for (int i = 0; i < ((modelITD->azimDim3 + 1) / 2 - 2); i++) { - modelITD->azimKSeq_dyn_fx[i] = float_to_fix( modelITD->azimKSeq_dyn[i], Q22 ); + modelITD->azimKSeq_dyn_fx[i] = float_to_fix(modelITD->azimKSeq_dyn[i], Q22); } #endif @@ -297,9 +297,9 @@ static void LoadBSplineBinaryITD( fread( modelITD->azimBsShape_dyn, sizeof( float ), tmp, f_hrtf ); #ifdef IVAS_FLOAT_FIXED modelITD->azimBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); - for ( int i = 0; i < tmp; i++ ) + for (int i = 0; i < tmp; i++) { - modelITD->azimBsShape_dyn_fx[i] = float_to_fix( modelITD->azimBsShape_dyn[i], Q30 ); + modelITD->azimBsShape_dyn_fx[i] = float_to_fix(modelITD->azimBsShape_dyn[i], Q30); } #endif @@ -315,9 +315,9 @@ static void LoadBSplineBinaryITD( fread( modelITD->elevBsShape_dyn, sizeof( float ), tmp, f_hrtf ); #ifdef IVAS_FLOAT_FIXED modelITD->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); - for ( int i = 0; i < tmp; i++ ) + for (int i = 0; i < tmp; i++) { - modelITD->elevBsShape_dyn_fx[i] = float_to_fix( modelITD->elevBsShape_dyn[i], Q30 ); + modelITD->elevBsShape_dyn_fx[i] = float_to_fix(modelITD->elevBsShape_dyn[i], Q30); } #endif @@ -388,8 +388,9 @@ static ivas_error LoadBSplineBinary( HrFiltSet_p->SampleRate = 16000; if ( HrFiltSet_p->ModelParams.UseItdModel ) { +#ifndef IVAS_FLOAT_FIXED HrFiltSet_p->ModelParamsITD.resamp_factor = RESAMPLE_FACTOR_16_48; -#ifdef IVAS_FLOAT_FIXED +#else HrFiltSet_p->ModelParamsITD.resamp_factor_fx = RESAMPLE_FACTOR_16_48_FX; #endif } @@ -398,8 +399,9 @@ static ivas_error LoadBSplineBinary( HrFiltSet_p->SampleRate = 32000; if ( HrFiltSet_p->ModelParams.UseItdModel ) { +#ifndef IVAS_FLOAT_FIXED HrFiltSet_p->ModelParamsITD.resamp_factor = RESAMPLE_FACTOR_32_48; -#ifdef IVAS_FLOAT_FIXED +#else HrFiltSet_p->ModelParamsITD.resamp_factor_fx = RESAMPLE_FACTOR_32_48_FX; #endif } @@ -408,8 +410,9 @@ static ivas_error LoadBSplineBinary( HrFiltSet_p->SampleRate = 48000; if ( HrFiltSet_p->ModelParams.UseItdModel ) { +#ifndef IVAS_FLOAT_FIXED HrFiltSet_p->ModelParamsITD.resamp_factor = 1.0f; -#ifdef IVAS_FLOAT_FIXED +#else HrFiltSet_p->ModelParamsITD.resamp_factor_fx = ONE_IN_Q14; #endif } @@ -427,7 +430,7 @@ static ivas_error LoadBSplineBinary( fread( model->elevKSeq_dyn, sizeof( float ), model->elevDim3 - 2, f_hrtf ); #ifdef IVAS_FLOAT_FIXED model->elevKSeq_dyn_fx = (Word32 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); - for ( i = 0; i < ( model->elevDim3 - 2 ); i++ ) + for ( i = 0; i < (model->elevDim3 - 2); i++ ) { model->elevKSeq_dyn_fx[i] = float_to_fix( model->elevKSeq_dyn[i], Q22 ); } @@ -448,9 +451,9 @@ static ivas_error LoadBSplineBinary( fread( model->azimKSeq[i], sizeof( float ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf ); #ifdef IVAS_FLOAT_FIXED model->azimKSeq_fx[i] = (Word32 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) ); - for ( int j = 0; j < ( model->azimDim3_dyn[i] + 1 ); j++ ) + for (int j = 0; j < (model->azimDim3_dyn[i] + 1); j++) { - model->azimKSeq_fx[i][j] = float_to_fix( model->azimKSeq[i][j], Q22 ); + model->azimKSeq_fx[i][j] = float_to_fix(model->azimKSeq[i][j], Q22); } #endif } @@ -486,9 +489,9 @@ static ivas_error LoadBSplineBinary( fread( model->azimBsShape_dyn[i], sizeof( float ), tmp, f_hrtf ); #ifdef IVAS_FLOAT_FIXED model->azimBsShape_dyn_fx[i] = (Word32 *) malloc( tmp * sizeof( Word32 ) ); - for ( int j = 0; j < tmp; j++ ) + for (int j = 0; j < tmp; j++) { - model->azimBsShape_dyn_fx[i][j] = float_to_fix( model->azimBsShape_dyn[i][j], Q30 ); + model->azimBsShape_dyn_fx[i][j] = float_to_fix(model->azimBsShape_dyn[i][j], Q30); } #endif fread( &model->azimSegSamples_dyn[i], sizeof( int16_t ), 1, f_hrtf ); @@ -506,10 +509,10 @@ static ivas_error LoadBSplineBinary( model->elevBsShape_dyn = (float *) malloc( tmp * sizeof( float ) ); fread( model->elevBsShape_dyn, sizeof( float ), tmp, f_hrtf ); #ifdef IVAS_FLOAT_FIXED - model->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); + model->elevBsShape_dyn_fx = (Word32 *)malloc(tmp * sizeof(Word32)); for ( i = 0; i < tmp; i++ ) { - model->elevBsShape_dyn_fx[i] = float_to_fix( model->elevBsShape_dyn[i], Q30 ); + model->elevBsShape_dyn_fx[i] = float_to_fix(model->elevBsShape_dyn[i], Q30); } #endif @@ -785,9 +788,9 @@ static void HRTF_energy_sections_precalc( pAlphaR += AlphaN; #ifdef IVAS_FLOAT_FIXED tmp_fx = *pAlphaL_fx; - *pEL_fx = L_add( *pEL_fx, L_shr( Mpy_32_32( tmp_fx, tmp_fx ), 1 ) ); /* one guard bit */ + *pEL_fx = L_add(*pEL_fx, L_shr(Mpy_32_32(tmp_fx, tmp_fx), 1)); /* one guard bit */ tmp_fx = *pAlphaR_fx; - *pER_fx = L_add( *pER_fx, L_shr( Mpy_32_32( tmp_fx, tmp_fx ), 1 ) ); /* one guard bit */ + *pER_fx = L_add(*pER_fx, L_shr(Mpy_32_32(tmp_fx, tmp_fx), 1)); /* one guard bit */ pAlphaL_fx += AlphaN; pAlphaR_fx += AlphaN; #endif @@ -803,8 +806,8 @@ static void HRTF_energy_sections_precalc( model->EL = (const float *) model->EL_dyn; model->ER = (const float *) model->ER_dyn; #ifdef IVAS_FLOAT_FIXED - model->EL_dyn_e = add( shl( model->AlphaL_e, 1 ), 1 ); // 2 * AlphaL_e + 1 (one guard bit) - model->ER_dyn_e = add( shl( model->AlphaR_e, 1 ), 1 ); // 2 * AlphaR_e + 1 (one guard bit) + model->EL_dyn_e = add(shl(model->AlphaL_e, 1), 1); // 2 * AlphaL_e + 1 (one guard bit) + model->ER_dyn_e = add(shl(model->AlphaR_e, 1), 1); // 2 * AlphaR_e + 1 (one guard bit) model->EL_fx = model->EL_dyn_fx; model->EL_e = model->EL_dyn_e; @@ -895,7 +898,7 @@ ivas_error dealloc_HRTF_binary( free( hHrtf->ModelParams.azimKSeq ); #ifdef IVAS_FLOAT_FIXED free( (void *) hHrtf->ModelParams.azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ - FOR( i = 0; i < hHrtf->ModelParams.elevDim3; i++ ) + FOR ( i = 0; i < hHrtf->ModelParams.elevDim3; i++ ) { free( hHrtf->ModelParams.azimKSeq_fx[i] ); } @@ -1049,7 +1052,7 @@ static ivas_error create_HRTF_from_rawdata( for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { //( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) ); - ( *hHRTF )->inv_diffuse_weight_fx[i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); + ( *hHRTF )->inv_diffuse_weight_fx[i] = ( Word16 ) (* ( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15); hrtf_data_rptr += sizeof( float ); } @@ -1074,8 +1077,8 @@ static ivas_error create_HRTF_from_rawdata( for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( float ); - // memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - for ( Word16 l = 0; l < ( *hHRTF )->pIndex_frequency_max[i][j][k]; l++ ) + //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for ( Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max[i][j][k]; l++ ) { float *tmp, temp_buf[1]; tmp = temp_buf; @@ -1083,12 +1086,12 @@ static ivas_error create_HRTF_from_rawdata( pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); hrtf_data_rptr += sizeof( float ); } - // hrtf_data_rptr += mem_size; + //hrtf_data_rptr += mem_size; pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max[i][j][k]; } } } - mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); + mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); /* coeff_im (the size depends on pIndex_frequency_max) */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) @@ -1106,8 +1109,8 @@ static ivas_error create_HRTF_from_rawdata( for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( float ); - // memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - for ( Word16 l = 0; l < ( *hHRTF )->pIndex_frequency_max[i][j][k]; l++ ) + //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for (Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max[i][j][k]; l++) { float *tmp, temp_buf[1]; tmp = temp_buf; @@ -1115,7 +1118,7 @@ static ivas_error create_HRTF_from_rawdata( pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); hrtf_data_rptr += sizeof( float ); } - // hrtf_data_rptr += mem_size; + //hrtf_data_rptr += mem_size; pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max[i][j][k]; } } @@ -1143,8 +1146,8 @@ static ivas_error create_HRTF_from_rawdata( for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( float ); - // memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - for ( Word16 l = 0; l < ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; l++ ) + //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for (Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max_diffuse[j][k]; l++) { float *tmp, temp_buf[1]; tmp = temp_buf; @@ -1152,7 +1155,7 @@ static ivas_error create_HRTF_from_rawdata( pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); hrtf_data_rptr += sizeof( float ); } - // hrtf_data_rptr += mem_size; + //hrtf_data_rptr += mem_size; pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; } } @@ -1173,8 +1176,8 @@ static ivas_error create_HRTF_from_rawdata( for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( float ); - // memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - for ( Word16 l = 0; l < ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; l++ ) + //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for ( Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max_diffuse[j][k]; l++ ) { float *tmp, temp_buf[1]; tmp = temp_buf; @@ -1182,7 +1185,7 @@ static ivas_error create_HRTF_from_rawdata( pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); hrtf_data_rptr += sizeof( float ); } - // hrtf_data_rptr += mem_size; + //hrtf_data_rptr += mem_size; pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; } } @@ -2186,11 +2189,11 @@ static ivas_error create_parambin_HRTF_from_rawdata( /*adding conversion as file reading is done in float*/ floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); - // memcpy( ( *hHRTF )->parametricEarlyPartEneCorrection, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); + //memcpy( ( *hHRTF )->parametricEarlyPartEneCorrection, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); memcpy( f_tmp_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); /*adding conversion as file reading is done in float*/ - floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricEarlyPartEneCorrection_fx, Q28, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( f_tmp_reverb, (*hHRTF)->parametricEarlyPartEneCorrection_fx, Q28, CLDFB_NO_CHANNELS_MAX ); return IVAS_ERR_OK; } diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 1a6943825..653149eb0 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -35,6 +35,9 @@ #include "ivas_stat_com.h" #include #include +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif struct MasaFileReader @@ -71,7 +74,11 @@ MasaFileReader *MasaFileReader_open( self = calloc( sizeof( MasaFileReader ), 1 ); self->file = file; +#ifndef IVAS_FLOAT_FIXED generate_gridEq( &self->sph_grid16 ); +#else + generate_gridEq_fx( &self->sph_grid16 ); +#endif return self; } -- GitLab From 55bd5603660f4013c47076a42a0e708fd0b40d4f Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 10 Jun 2024 15:19:44 +0530 Subject: [PATCH 2/2] Clang formatting changes --- lib_com/ivas_fb_mixer.c | 36 +-- lib_dec/ivas_dirac_dec.c | 2 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 18 +- lib_rend/ivas_dirac_decorr_dec.c | 246 +++++++++---------- lib_rend/ivas_stat_rend.h | 2 +- lib_util/hrtf_file_reader.c | 74 +++--- 6 files changed, 189 insertions(+), 189 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index a03655eed..749952dfd 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -961,7 +961,7 @@ void ivas_FB_mixer_close( } #ifdef IVAS_FLOAT_FIXED - FOR ( j = start_diff_band_non48k; j < num_bands; j++ ) + FOR( j = start_diff_band_non48k; j < num_bands; j++ ) { free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] ); hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] = NULL; @@ -1010,11 +1010,11 @@ void ivas_FB_mixer_close_fx( hFbMixer = *hFbMixer_in; fb_cfg = hFbMixer->fb_cfg; - IF ( fb_cfg->active_w_mixing == -1 ) + IF( fb_cfg->active_w_mixing == -1 ) { num_chs_alloc = 0; } - ELSE IF ( fb_cfg->active_w_mixing ) + ELSE IF( fb_cfg->active_w_mixing ) { num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); } @@ -1023,11 +1023,11 @@ void ivas_FB_mixer_close_fx( num_chs_alloc = 1; /* only W channel processed for predicting YZX */ } - IF ( hFbMixer != NULL ) + IF( hFbMixer != NULL ) { - FOR ( i = 0; i < num_chs_alloc; i++ ) + FOR( i = 0; i < num_chs_alloc; i++ ) { - IF ( fb_cfg->num_out_chans > 0 ) + IF( fb_cfg->num_out_chans > 0 ) { j = fb_cfg->remix_order[i]; @@ -1039,7 +1039,7 @@ void ivas_FB_mixer_close_fx( } } - IF ( fb_cfg->active_w_mixing == -1 ) + IF( fb_cfg->active_w_mixing == -1 ) { num_chs_alloc = 0; } @@ -1048,39 +1048,39 @@ void ivas_FB_mixer_close_fx( num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); } - FOR ( i = 0; i < num_chs_alloc; i++ ) + FOR( i = 0; i < num_chs_alloc; i++ ) { free( hFbMixer->ppFilterbank_prior_input_fx[i] ); hFbMixer->ppFilterbank_prior_input_fx[i] = NULL; } - IF ( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) ) + IF( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) ) { free( hFbMixer->prior_mixer_fx[0][0] ); hFbMixer->prior_mixer_fx[0][0] = NULL; } - IF ( !spar_reconfig_flag ) + IF( !spar_reconfig_flag ) { - IF ( fb_cfg->num_out_chans > 0 ) + IF( fb_cfg->num_out_chans > 0 ) { num_bands = hFbMixer->pFb->filterbank_num_bands; - IF ( fb_cfg->active_w_mixing != -1 ) + IF( fb_cfg->active_w_mixing != -1 ) { - FOR ( i = 0; i < num_bands; i++ ) + FOR( i = 0; i < num_bands; i++ ) { free( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band_fx[i] ); hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band_fx[i] = NULL; } } - IF ( sampling_rate != 48000 ) + IF( sampling_rate != 48000 ) { int16_t start_diff_band_non48k; start_diff_band_non48k = num_bands - hFbMixer->num_diff_bands; - FOR ( j = start_diff_band_non48k; j < num_bands; j++ ) + FOR( j = start_diff_band_non48k; j < num_bands; j++ ) { free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] ); hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] = NULL; @@ -1090,20 +1090,20 @@ void ivas_FB_mixer_close_fx( } } } - IF ( hFbMixer->pFb != NULL ) + IF( hFbMixer->pFb != NULL ) { free( hFbMixer->pFb ); hFbMixer->pFb = NULL; } } - IF ( hFbMixer->fb_cfg != NULL ) + IF( hFbMixer->fb_cfg != NULL ) { free( hFbMixer->fb_cfg ); hFbMixer->fb_cfg = NULL; } - IF ( !spar_reconfig_flag ) + IF( !spar_reconfig_flag ) { free( hFbMixer ); hFbMixer = NULL; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index cadcb29a9..148c40a3c 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -4981,7 +4981,7 @@ void ivas_dirac_dec_render_sf_fx( #ifdef IVAS_FLOAT_FIXED /////////////////////////////////////////////////////// FIXED TO FLOAT ////////////////////////////////////////////////////////////////////////////////////////// - IF(EQ_16(hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD)) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev; hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 156108264..c429f551e 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -832,12 +832,12 @@ void ivas_dirac_dec_binaural_render( * *------------------------------------------------------------------------*/ void ivas_dirac_dec_binaural_render_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ const Word16 nchan_transport, /* i : number of transport channels */ - Word32 *output_f[] /* o : rendered time signal */ + Word32 *output_f[] /* o : rendered time signal */ ) { Word16 slots_to_render, first_sf, last_sf, subframe_idx; @@ -850,7 +850,7 @@ void ivas_dirac_dec_binaural_render_fx( hSpatParamRendCom = st_ivas->hSpatParamRendCom; nchan_out = BINAURAL_CHANNELS; - FOR ( ch = 0; ch < nchan_out; ch++ ) + FOR( ch = 0; ch < nchan_out; ch++ ) { output_fx_local[ch] = output_fx_local_buff[ch]; } @@ -869,12 +869,12 @@ void ivas_dirac_dec_binaural_render_fx( } output_length = 0; - FOR ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) + FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { Word16 n_samples_sf = imult1616( slot_size, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); ivas_dirac_dec_binaural_internal_fx( st_ivas, st_ivas->hCombinedOrientationData, output_fx_local, nchan_transport, subframe_idx ); - FOR ( ch = 0; ch < nchan_out; ch++ ) + FOR( ch = 0; ch < nchan_out; ch++ ) { output_fx_local[ch] += n_samples_sf; } @@ -885,7 +885,7 @@ void ivas_dirac_dec_binaural_render_fx( ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); } - FOR ( ch = 0; ch < nchan_out; ch++ ) + FOR( ch = 0; ch < nchan_out; ch++ ) { Copy32( output_fx_local_buff[ch], output_f[ch], output_length ); } @@ -1562,7 +1562,7 @@ static void ivas_dirac_dec_binaural_internal_fx( } ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_fx, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); #if 1 q_inp = Q6; @@ -7402,8 +7402,8 @@ static void ivas_masa_ext_rend_parambin_internal( max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_fx, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, - 0, NULL ); + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, + 0, NULL ); #if 1 Word16 q_out; diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c index d9cf168dc..2e952223d 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -501,7 +501,7 @@ ivas_error ivas_dirac_dec_decorr_open_fx( freq_domain_decorr_ap_params->pre_delay = NULL; freq_domain_decorr_ap_params->filter_length = NULL; - IF ( num_outputs_diff > 0 ) + IF( num_outputs_diff > 0 ) { buffer_size_decorr = ( ap_pre_delay[split_band_index_start] + ap_filter_length[split_band_index_start] ); IF( ( freq_domain_decorr_ap_state->decorr_buffer_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * buffer_size_decorr * num_outputs_diff * freq_domain_decorr_ap_params->max_band_decorr ) ) == NULL ) @@ -542,13 +542,13 @@ ivas_error ivas_dirac_dec_decorr_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); } - IF((freq_domain_decorr_ap_params->pre_delay = (Word16 *)malloc(sizeof(Word16) * freq_domain_decorr_ap_params->num_split_frequency_bands)) == NULL) + IF( ( freq_domain_decorr_ap_params->pre_delay = (Word16 *) malloc( sizeof( Word16 ) * freq_domain_decorr_ap_params->num_split_frequency_bands ) ) == NULL ) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); } - IF((freq_domain_decorr_ap_params->filter_length = (Word16 *)malloc(sizeof(Word16) * freq_domain_decorr_ap_params->num_split_frequency_bands)) == NULL) + IF( ( freq_domain_decorr_ap_params->filter_length = (Word16 *) malloc( sizeof( Word16 ) * freq_domain_decorr_ap_params->num_split_frequency_bands ) ) == NULL ) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); } set32_fx( freq_domain_decorr_ap_state->direct_energy_smooth_fx, 0, freq_domain_decorr_ap_params->max_band_decorr * num_outputs_diff ); @@ -556,7 +556,7 @@ ivas_error ivas_dirac_dec_decorr_open_fx( freq_domain_decorr_ap_state->q_direct_energy_smooth = freq_domain_decorr_ap_state->q_reverb_energy_smooth = Q31; /* compute filter coefficients */ - FOR ( k = 0; k < freq_domain_decorr_ap_params->num_split_frequency_bands; k++ ) + FOR( k = 0; k < freq_domain_decorr_ap_params->num_split_frequency_bands; k++ ) { k_in = freq_domain_decorr_ap_params->split_frequency_bands[k]; k_out = freq_domain_decorr_ap_params->split_frequency_bands[k + 1]; @@ -565,11 +565,11 @@ ivas_error ivas_dirac_dec_decorr_open_fx( freq_domain_decorr_ap_params->filter_length[k] = add( ap_filter_length[band_table_idx], 1 ); freq_domain_decorr_ap_params->pre_delay[k] = ap_pre_delay[band_table_idx]; - FOR ( l = 0; l < num_outputs_diff; l++ ) + FOR( l = 0; l < num_outputs_diff; l++ ) { - FOR ( m = 0; m < num_bands; m++ ) + FOR( m = 0; m < num_bands; m++ ) { - n = add(k_in , m); + n = add( k_in, m ); Word32 cur_lattice_delta_phi_32_fx = L_mult( ap_lattice_delta_phi_fx[l * DIRAC_MAX_DECORR_FILTER_LEN + ap_filter_length[k] - 1], (Word16) floatToFixed( n, 10 ) ); cur_lattice_delta_phi_fx = extract_h( cur_lattice_delta_phi_32_fx ); // Q10 @@ -985,19 +985,19 @@ void ivas_dirac_dec_decorr_process_fx( } q_aux_buffer += q_shift; #else - (void)maximum_abs_32_fx(&input_frame_fx[0], 2 * num_protos_dir * num_freq_bands, &max_abs_val); + (void) maximum_abs_32_fx( &input_frame_fx[0], 2 * num_protos_dir * num_freq_bands, &max_abs_val ); q_shift = getScaleFactor32( &input_frame_fx[0], 2 * num_protos_dir * num_freq_bands ) - guarded_bits; - IF (LT_16(q_shift , sub(0, guarded_bits)) && NE_32(max_abs_val, 0)) + IF( LT_16( q_shift, sub( 0, guarded_bits ) ) && NE_32( max_abs_val, 0 ) ) { - q_shift = sub(0, guarded_bits); + q_shift = sub( 0, guarded_bits ); } - ELSE IF (EQ_32(max_abs_val, 0)) + ELSE IF( EQ_32( max_abs_val, 0 ) ) { q_shift = 0; } - FOR ( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++) + FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) { - v_shr(&input_frame_fx[2 * ch_idx * num_freq_bands], negate(q_shift), &aux_buffer_fx[2 * ch_idx * num_freq_bands], 2 * num_freq_bands); + v_shr( &input_frame_fx[2 * ch_idx * num_freq_bands], negate( q_shift ), &aux_buffer_fx[2 * ch_idx * num_freq_bands], 2 * num_freq_bands ); } FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) { @@ -1273,17 +1273,17 @@ void ivas_dirac_dec_decorr_process_fx( h_freq_domain_decorr_ap_state->q_direct_energy_smooth = sub( 31, e_direct_energy_smooth ); // scaling energy buffers for better precision for higher values// - q_shift = L_norm_arr(h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616(num_protos_dir, max_band_decorr)); - Scale_sig32(h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616(num_protos_dir, max_band_decorr), q_shift); + q_shift = L_norm_arr( h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616( num_protos_dir, max_band_decorr ) ); + Scale_sig32( h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616( num_protos_dir, max_band_decorr ), q_shift ); h_freq_domain_decorr_ap_state->q_direct_energy_smooth = h_freq_domain_decorr_ap_state->q_direct_energy_smooth + q_shift; - q_shift = L_norm_arr(h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, imult1616(num_channels, max_band_decorr)); - Scale_sig32(h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, imult1616(num_channels, max_band_decorr), q_shift); + q_shift = L_norm_arr( h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, imult1616( num_channels, max_band_decorr ) ); + Scale_sig32( h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx, imult1616( num_channels, max_band_decorr ), q_shift ); h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = h_freq_domain_decorr_ap_state->q_reverb_energy_smooth + q_shift; - e_reverb_energy_smooth = sub(31 , h_freq_domain_decorr_ap_state->q_reverb_energy_smooth); - e_direct_energy_smooth = sub(31 , h_freq_domain_decorr_ap_state->q_direct_energy_smooth); + e_reverb_energy_smooth = sub( 31, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); + e_direct_energy_smooth = sub( 31, h_freq_domain_decorr_ap_state->q_direct_energy_smooth ); // this step is b/c we are left shifting frame_dec_fx at the end of below for loop/ #ifdef MSAN_FIX @@ -1418,129 +1418,129 @@ void ivas_dirac_dec_decorr_process_fx( #ifdef IVAS_FLOAT_FIXED void ivas_dirac_dec_decorr_close_fx( - HANDLE_DIRAC_DECORR_PARAMS *ph_freq_domain_decorr_ap_params, - HANDLE_DIRAC_DECORR_STATE *ph_freq_domain_decorr_ap_state) + HANDLE_DIRAC_DECORR_PARAMS *ph_freq_domain_decorr_ap_params, + HANDLE_DIRAC_DECORR_STATE *ph_freq_domain_decorr_ap_state ) { - DIRAC_ONSET_DETECTION_STATE *dirac_onset_detection_state; + DIRAC_ONSET_DETECTION_STATE *dirac_onset_detection_state; - /*-----------------------------------------------------------------* - * check input handles - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * check input handles + *-----------------------------------------------------------------*/ - if (ph_freq_domain_decorr_ap_params == NULL || ph_freq_domain_decorr_ap_state == NULL) - { - return; - } + if ( ph_freq_domain_decorr_ap_params == NULL || ph_freq_domain_decorr_ap_state == NULL ) + { + return; + } - if (*ph_freq_domain_decorr_ap_params == NULL || *ph_freq_domain_decorr_ap_state == NULL) - { - return; - } + if ( *ph_freq_domain_decorr_ap_params == NULL || *ph_freq_domain_decorr_ap_state == NULL ) + { + return; + } - /*-----------------------------------------------------------------* - * free onset filter arrays - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * free onset filter arrays + *-----------------------------------------------------------------*/ - dirac_onset_detection_state = &(*ph_freq_domain_decorr_ap_state)->h_onset_detection_power_state; + dirac_onset_detection_state = &( *ph_freq_domain_decorr_ap_state )->h_onset_detection_power_state; #ifdef IVAS_FLOAT_FIXED - IF(dirac_onset_detection_state->onset_detector_1_fx != NULL) - { - free(dirac_onset_detection_state->onset_detector_1_fx); - dirac_onset_detection_state->onset_detector_1_fx = NULL; - } - - IF(dirac_onset_detection_state->onset_detector_2_fx != NULL) - { - free(dirac_onset_detection_state->onset_detector_2_fx); - dirac_onset_detection_state->onset_detector_2_fx = NULL; - } + IF( dirac_onset_detection_state->onset_detector_1_fx != NULL ) + { + free( dirac_onset_detection_state->onset_detector_1_fx ); + dirac_onset_detection_state->onset_detector_1_fx = NULL; + } + + IF( dirac_onset_detection_state->onset_detector_2_fx != NULL ) + { + free( dirac_onset_detection_state->onset_detector_2_fx ); + dirac_onset_detection_state->onset_detector_2_fx = NULL; + } #endif - /*-----------------------------------------------------------------* - * memory deallocation - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * memory deallocation + *-----------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED - IF((*ph_freq_domain_decorr_ap_state)->decorr_buffer_fx != NULL) - { - free((*ph_freq_domain_decorr_ap_state)->decorr_buffer_fx); - (*ph_freq_domain_decorr_ap_state)->decorr_buffer_fx = NULL; - } - - /* free ducker smoothed direct energy buffer */ - IF((*ph_freq_domain_decorr_ap_state)->direct_energy_smooth_fx != NULL) - { - free((*ph_freq_domain_decorr_ap_state)->direct_energy_smooth_fx); - (*ph_freq_domain_decorr_ap_state)->direct_energy_smooth_fx = NULL; - } - - /* free ducker smoothed reverb energy buffer */ - IF((*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth_fx != NULL) - { - free((*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth_fx); - (*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth_fx = NULL; - } + IF( ( *ph_freq_domain_decorr_ap_state )->decorr_buffer_fx != NULL ) + { + free( ( *ph_freq_domain_decorr_ap_state )->decorr_buffer_fx ); + ( *ph_freq_domain_decorr_ap_state )->decorr_buffer_fx = NULL; + } + + /* free ducker smoothed direct energy buffer */ + IF( ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth_fx != NULL ) + { + free( ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth_fx ); + ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth_fx = NULL; + } + + /* free ducker smoothed reverb energy buffer */ + IF( ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth_fx != NULL ) + { + free( ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth_fx ); + ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth_fx = NULL; + } #endif - /* free pre-delay param buffer */ - if ((*ph_freq_domain_decorr_ap_params)->pre_delay != NULL) - { - free((*ph_freq_domain_decorr_ap_params)->pre_delay); - (*ph_freq_domain_decorr_ap_params)->pre_delay = NULL; - } - - /* free filter length param buffer */ - if ((*ph_freq_domain_decorr_ap_params)->filter_length != NULL) - { - free((*ph_freq_domain_decorr_ap_params)->filter_length); - (*ph_freq_domain_decorr_ap_params)->filter_length = NULL; - } - - /* free pre-delay param buffer */ - if ((*ph_freq_domain_decorr_ap_params)->split_frequency_bands != NULL) - { - free((*ph_freq_domain_decorr_ap_params)->split_frequency_bands); - (*ph_freq_domain_decorr_ap_params)->split_frequency_bands = NULL; - } + /* free pre-delay param buffer */ + if ( ( *ph_freq_domain_decorr_ap_params )->pre_delay != NULL ) + { + free( ( *ph_freq_domain_decorr_ap_params )->pre_delay ); + ( *ph_freq_domain_decorr_ap_params )->pre_delay = NULL; + } + + /* free filter length param buffer */ + if ( ( *ph_freq_domain_decorr_ap_params )->filter_length != NULL ) + { + free( ( *ph_freq_domain_decorr_ap_params )->filter_length ); + ( *ph_freq_domain_decorr_ap_params )->filter_length = NULL; + } + + /* free pre-delay param buffer */ + if ( ( *ph_freq_domain_decorr_ap_params )->split_frequency_bands != NULL ) + { + free( ( *ph_freq_domain_decorr_ap_params )->split_frequency_bands ); + ( *ph_freq_domain_decorr_ap_params )->split_frequency_bands = NULL; + } #ifdef IVAS_FLOAT_FIXED /* free filter coeff param buffers */ - IF((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real_fx != NULL) - { - free((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real_fx); - (*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real_fx = NULL; - } + IF( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real_fx != NULL ) + { + free( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real_fx ); + ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real_fx = NULL; + } + + /* free pre-delay param buffer */ + IF( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real_fx != NULL ) + { + free( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real_fx ); + ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real_fx = NULL; + } /* free pre-delay param buffer */ - IF((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real_fx != NULL) - { - free((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real_fx); - (*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real_fx = NULL; - } - - /* free pre-delay param buffer */ - IF((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag_fx != NULL) - { - free((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag_fx); - (*ph_freq_domain_decorr_ap_params)->phase_coeff_imag_fx = NULL; - } - - /* free pre-delay param buffer */ - IF((*ph_freq_domain_decorr_ap_params)->phase_coeff_real_fx != NULL) - { - free((*ph_freq_domain_decorr_ap_params)->phase_coeff_real_fx); - (*ph_freq_domain_decorr_ap_params)->phase_coeff_real_fx = NULL; - } + IF( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag_fx != NULL ) + { + free( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag_fx ); + ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag_fx = NULL; + } + + /* free pre-delay param buffer */ + IF( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real_fx != NULL ) + { + free( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real_fx ); + ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real_fx = NULL; + } #endif - /* free pointers to state and parameter structs */ - free(*ph_freq_domain_decorr_ap_params); - *ph_freq_domain_decorr_ap_params = NULL; + /* free pointers to state and parameter structs */ + free( *ph_freq_domain_decorr_ap_params ); + *ph_freq_domain_decorr_ap_params = NULL; - free(*ph_freq_domain_decorr_ap_state); - *ph_freq_domain_decorr_ap_state = NULL; + free( *ph_freq_domain_decorr_ap_state ); + *ph_freq_domain_decorr_ap_state = NULL; - return; + return; } #else void ivas_dirac_dec_decorr_close( @@ -1696,7 +1696,7 @@ static void get_lattice_coeffs_fx( { Word16 k; - FOR ( k = 0; k < ap_filter_length[band_index]; k++ ) + FOR( k = 0; k < ap_filter_length[band_index]; k++ ) { Word16 cur_lattice_coeff = ap_lattice_coeffs_fx[band_index][channel_index * ap_filter_length[band_index] + k]; lattice_coeffs[k] = cur_lattice_coeff; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 2c9d1ae7c..0cf951fad 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1687,7 +1687,7 @@ typedef struct #ifndef IVAS_FLOAT_FIXED float resamp_factor; #else - Word16 resamp_factor_fx; /*Q14*/ + Word16 resamp_factor_fx; /*Q14*/ #endif #ifdef IVAS_FLOAT_FIXED const Word32 *elevKSeq_fx; /* Array, length elevDim3-2 */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 536668bac..048a86470 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -260,10 +260,10 @@ static void LoadBSplineBinaryITD( modelITD->elevKSeq_dyn = (float *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( float ) ); fread( modelITD->elevKSeq_dyn, sizeof( float ), modelITD->elevDim3 - 2, f_hrtf ); #ifdef IVAS_FLOAT_FIXED - modelITD->elevKSeq_dyn_fx = (Word32 *)malloc(sizeof(Word32)*(modelITD->elevDim3 - 2)); - for (int i = 0; i < modelITD->elevDim3 - 2; i++) + modelITD->elevKSeq_dyn_fx = (Word32 *) malloc( sizeof( Word32 ) * ( modelITD->elevDim3 - 2 ) ); + for ( int i = 0; i < modelITD->elevDim3 - 2; i++ ) { - modelITD->elevKSeq_dyn_fx[i] = float_to_fix(modelITD->elevKSeq_dyn[i], 22); + modelITD->elevKSeq_dyn_fx[i] = float_to_fix( modelITD->elevKSeq_dyn[i], 22 ); } #endif @@ -273,9 +273,9 @@ static void LoadBSplineBinaryITD( fread( modelITD->azimKSeq_dyn, sizeof( float ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf ); #ifdef IVAS_FLOAT_FIXED modelITD->azimKSeq_dyn_fx = (Word32 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ - for (int i = 0; i < ((modelITD->azimDim3 + 1) / 2 - 2); i++) + for ( int i = 0; i < ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ); i++ ) { - modelITD->azimKSeq_dyn_fx[i] = float_to_fix(modelITD->azimKSeq_dyn[i], Q22); + modelITD->azimKSeq_dyn_fx[i] = float_to_fix( modelITD->azimKSeq_dyn[i], Q22 ); } #endif @@ -297,9 +297,9 @@ static void LoadBSplineBinaryITD( fread( modelITD->azimBsShape_dyn, sizeof( float ), tmp, f_hrtf ); #ifdef IVAS_FLOAT_FIXED modelITD->azimBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); - for (int i = 0; i < tmp; i++) + for ( int i = 0; i < tmp; i++ ) { - modelITD->azimBsShape_dyn_fx[i] = float_to_fix(modelITD->azimBsShape_dyn[i], Q30); + modelITD->azimBsShape_dyn_fx[i] = float_to_fix( modelITD->azimBsShape_dyn[i], Q30 ); } #endif @@ -315,9 +315,9 @@ static void LoadBSplineBinaryITD( fread( modelITD->elevBsShape_dyn, sizeof( float ), tmp, f_hrtf ); #ifdef IVAS_FLOAT_FIXED modelITD->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); - for (int i = 0; i < tmp; i++) + for ( int i = 0; i < tmp; i++ ) { - modelITD->elevBsShape_dyn_fx[i] = float_to_fix(modelITD->elevBsShape_dyn[i], Q30); + modelITD->elevBsShape_dyn_fx[i] = float_to_fix( modelITD->elevBsShape_dyn[i], Q30 ); } #endif @@ -430,7 +430,7 @@ static ivas_error LoadBSplineBinary( fread( model->elevKSeq_dyn, sizeof( float ), model->elevDim3 - 2, f_hrtf ); #ifdef IVAS_FLOAT_FIXED model->elevKSeq_dyn_fx = (Word32 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); - for ( i = 0; i < (model->elevDim3 - 2); i++ ) + for ( i = 0; i < ( model->elevDim3 - 2 ); i++ ) { model->elevKSeq_dyn_fx[i] = float_to_fix( model->elevKSeq_dyn[i], Q22 ); } @@ -451,9 +451,9 @@ static ivas_error LoadBSplineBinary( fread( model->azimKSeq[i], sizeof( float ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf ); #ifdef IVAS_FLOAT_FIXED model->azimKSeq_fx[i] = (Word32 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) ); - for (int j = 0; j < (model->azimDim3_dyn[i] + 1); j++) + for ( int j = 0; j < ( model->azimDim3_dyn[i] + 1 ); j++ ) { - model->azimKSeq_fx[i][j] = float_to_fix(model->azimKSeq[i][j], Q22); + model->azimKSeq_fx[i][j] = float_to_fix( model->azimKSeq[i][j], Q22 ); } #endif } @@ -489,9 +489,9 @@ static ivas_error LoadBSplineBinary( fread( model->azimBsShape_dyn[i], sizeof( float ), tmp, f_hrtf ); #ifdef IVAS_FLOAT_FIXED model->azimBsShape_dyn_fx[i] = (Word32 *) malloc( tmp * sizeof( Word32 ) ); - for (int j = 0; j < tmp; j++) + for ( int j = 0; j < tmp; j++ ) { - model->azimBsShape_dyn_fx[i][j] = float_to_fix(model->azimBsShape_dyn[i][j], Q30); + model->azimBsShape_dyn_fx[i][j] = float_to_fix( model->azimBsShape_dyn[i][j], Q30 ); } #endif fread( &model->azimSegSamples_dyn[i], sizeof( int16_t ), 1, f_hrtf ); @@ -509,10 +509,10 @@ static ivas_error LoadBSplineBinary( model->elevBsShape_dyn = (float *) malloc( tmp * sizeof( float ) ); fread( model->elevBsShape_dyn, sizeof( float ), tmp, f_hrtf ); #ifdef IVAS_FLOAT_FIXED - model->elevBsShape_dyn_fx = (Word32 *)malloc(tmp * sizeof(Word32)); + model->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); for ( i = 0; i < tmp; i++ ) { - model->elevBsShape_dyn_fx[i] = float_to_fix(model->elevBsShape_dyn[i], Q30); + model->elevBsShape_dyn_fx[i] = float_to_fix( model->elevBsShape_dyn[i], Q30 ); } #endif @@ -788,9 +788,9 @@ static void HRTF_energy_sections_precalc( pAlphaR += AlphaN; #ifdef IVAS_FLOAT_FIXED tmp_fx = *pAlphaL_fx; - *pEL_fx = L_add(*pEL_fx, L_shr(Mpy_32_32(tmp_fx, tmp_fx), 1)); /* one guard bit */ + *pEL_fx = L_add( *pEL_fx, L_shr( Mpy_32_32( tmp_fx, tmp_fx ), 1 ) ); /* one guard bit */ tmp_fx = *pAlphaR_fx; - *pER_fx = L_add(*pER_fx, L_shr(Mpy_32_32(tmp_fx, tmp_fx), 1)); /* one guard bit */ + *pER_fx = L_add( *pER_fx, L_shr( Mpy_32_32( tmp_fx, tmp_fx ), 1 ) ); /* one guard bit */ pAlphaL_fx += AlphaN; pAlphaR_fx += AlphaN; #endif @@ -806,8 +806,8 @@ static void HRTF_energy_sections_precalc( model->EL = (const float *) model->EL_dyn; model->ER = (const float *) model->ER_dyn; #ifdef IVAS_FLOAT_FIXED - model->EL_dyn_e = add(shl(model->AlphaL_e, 1), 1); // 2 * AlphaL_e + 1 (one guard bit) - model->ER_dyn_e = add(shl(model->AlphaR_e, 1), 1); // 2 * AlphaR_e + 1 (one guard bit) + model->EL_dyn_e = add( shl( model->AlphaL_e, 1 ), 1 ); // 2 * AlphaL_e + 1 (one guard bit) + model->ER_dyn_e = add( shl( model->AlphaR_e, 1 ), 1 ); // 2 * AlphaR_e + 1 (one guard bit) model->EL_fx = model->EL_dyn_fx; model->EL_e = model->EL_dyn_e; @@ -898,7 +898,7 @@ ivas_error dealloc_HRTF_binary( free( hHrtf->ModelParams.azimKSeq ); #ifdef IVAS_FLOAT_FIXED free( (void *) hHrtf->ModelParams.azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ - FOR ( i = 0; i < hHrtf->ModelParams.elevDim3; i++ ) + FOR( i = 0; i < hHrtf->ModelParams.elevDim3; i++ ) { free( hHrtf->ModelParams.azimKSeq_fx[i] ); } @@ -1052,7 +1052,7 @@ static ivas_error create_HRTF_from_rawdata( for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { //( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) ); - ( *hHRTF )->inv_diffuse_weight_fx[i] = ( Word16 ) (* ( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15); + ( *hHRTF )->inv_diffuse_weight_fx[i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); hrtf_data_rptr += sizeof( float ); } @@ -1077,8 +1077,8 @@ static ivas_error create_HRTF_from_rawdata( for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( float ); - //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - for ( Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max[i][j][k]; l++ ) + // memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for ( Word16 l = 0; l < ( *hHRTF )->pIndex_frequency_max[i][j][k]; l++ ) { float *tmp, temp_buf[1]; tmp = temp_buf; @@ -1086,12 +1086,12 @@ static ivas_error create_HRTF_from_rawdata( pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); hrtf_data_rptr += sizeof( float ); } - //hrtf_data_rptr += mem_size; + // hrtf_data_rptr += mem_size; pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max[i][j][k]; } } } - mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); + mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); /* coeff_im (the size depends on pIndex_frequency_max) */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) @@ -1109,8 +1109,8 @@ static ivas_error create_HRTF_from_rawdata( for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( float ); - //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - for (Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max[i][j][k]; l++) + // memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for ( Word16 l = 0; l < ( *hHRTF )->pIndex_frequency_max[i][j][k]; l++ ) { float *tmp, temp_buf[1]; tmp = temp_buf; @@ -1118,7 +1118,7 @@ static ivas_error create_HRTF_from_rawdata( pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); hrtf_data_rptr += sizeof( float ); } - //hrtf_data_rptr += mem_size; + // hrtf_data_rptr += mem_size; pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max[i][j][k]; } } @@ -1146,8 +1146,8 @@ static ivas_error create_HRTF_from_rawdata( for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( float ); - //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - for (Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max_diffuse[j][k]; l++) + // memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for ( Word16 l = 0; l < ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; l++ ) { float *tmp, temp_buf[1]; tmp = temp_buf; @@ -1155,7 +1155,7 @@ static ivas_error create_HRTF_from_rawdata( pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); hrtf_data_rptr += sizeof( float ); } - //hrtf_data_rptr += mem_size; + // hrtf_data_rptr += mem_size; pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; } } @@ -1176,8 +1176,8 @@ static ivas_error create_HRTF_from_rawdata( for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( float ); - //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - for ( Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max_diffuse[j][k]; l++ ) + // memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for ( Word16 l = 0; l < ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; l++ ) { float *tmp, temp_buf[1]; tmp = temp_buf; @@ -1185,7 +1185,7 @@ static ivas_error create_HRTF_from_rawdata( pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); hrtf_data_rptr += sizeof( float ); } - //hrtf_data_rptr += mem_size; + // hrtf_data_rptr += mem_size; pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; } } @@ -2189,11 +2189,11 @@ static ivas_error create_parambin_HRTF_from_rawdata( /*adding conversion as file reading is done in float*/ floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); - //memcpy( ( *hHRTF )->parametricEarlyPartEneCorrection, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); + // memcpy( ( *hHRTF )->parametricEarlyPartEneCorrection, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); memcpy( f_tmp_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); /*adding conversion as file reading is done in float*/ - floatToFixed_arrL( f_tmp_reverb, (*hHRTF)->parametricEarlyPartEneCorrection_fx, Q28, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricEarlyPartEneCorrection_fx, Q28, CLDFB_NO_CHANNELS_MAX ); return IVAS_ERR_OK; } -- GitLab