diff --git a/lib_com/ivas_lfe_com.c b/lib_com/ivas_lfe_com.c index 1a464a0b8e1760413cb8bbf9d7a3d5cf62d8ddee..01e479da46399c912d696da5ae310bbfca8c8f2d 100644 --- a/lib_com/ivas_lfe_com.c +++ b/lib_com/ivas_lfe_com.c @@ -41,6 +41,9 @@ #include "cnst.h" #include #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-----------------------------------------------------------------------------------------* @@ -153,36 +156,25 @@ void ivas_lfe_lpf_select_filt_coeff_fx( * Initialize LFE window *-----------------------------------------------------------------------------------------*/ -void ivas_lfe_window_init( +#ifdef IVAS_FLOAT_FIXED +void ivas_lfe_window_init_fx( LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle */ - const Word32 sampling_rate, /* i : sampling rate */ - const Word16 frame_len /* i : frame length in samples */ + const Word32 sampling_rate, /* i : sampling rate */ + const Word16 frame_len /* i : frame length in samples */ ) { /* Set window coefficients */ - IF ( EQ_32(sampling_rate, 48000 )) + IF( EQ_32( sampling_rate, 48000 ) ) { - hLFEWindow->pWindow_coeffs = ivas_lfe_window_coeff_48k; -#ifdef IVAS_FLOAT_FIXED hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_48k_fx; -#endif - } - ELSE IF ( EQ_32(sampling_rate, 32000) ) + ELSE IF( EQ_32( sampling_rate, 32000 ) ) { - hLFEWindow->pWindow_coeffs = ivas_lfe_window_coeff_32k; -#ifdef IVAS_FLOAT_FIXED hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_32k_fx; -#endif - } - ELSE IF ( EQ_32(sampling_rate, 16000) ) + ELSE IF( EQ_32( sampling_rate, 16000 ) ) { - hLFEWindow->pWindow_coeffs = ivas_lfe_window_coeff_16k; -#ifdef IVAS_FLOAT_FIXED hLFEWindow->pWindow_coeffs_fx = ivas_lfe_window_coeff_16k_fx; -#endif - } ELSE { @@ -190,20 +182,47 @@ void ivas_lfe_window_init( } /* 10ms stride, MDCT will be done in two iterations */ - hLFEWindow->dct_len = shr(frame_len, 1); + hLFEWindow->dct_len = shr( frame_len, 1 ); - hLFEWindow->fade_len = NS2SA(sampling_rate, IVAS_LFE_FADE_NS); - -#ifdef IVAS_FLOAT_FIXED /* 8ms of latency */ - hLFEWindow->zero_pad_len = (mult(IVAS_ZERO_PAD_LEN_MULT_FAC_fx, sub(hLFEWindow->dct_len, hLFEWindow->fade_len))); - hLFEWindow->full_len = add(add(hLFEWindow->zero_pad_len, hLFEWindow->fade_len), hLFEWindow->dct_len); -#else - hLFEWindow->zero_pad_len = (int16_t)(IVAS_ZERO_PAD_LEN_MULT_FAC * (hLFEWindow->dct_len - hLFEWindow->fade_len)); - hLFEWindow->full_len = hLFEWindow->zero_pad_len + hLFEWindow->fade_len + hLFEWindow->dct_len; + hLFEWindow->fade_len = NS2SA( sampling_rate, IVAS_LFE_FADE_NS ); + hLFEWindow->zero_pad_len = ( mult( IVAS_ZERO_PAD_LEN_MULT_FAC_fx, sub( hLFEWindow->dct_len, hLFEWindow->fade_len ) ) ); + hLFEWindow->full_len = add( add( hLFEWindow->zero_pad_len, hLFEWindow->fade_len ), hLFEWindow->dct_len ); + + return; +} #endif +void ivas_lfe_window_init( + LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle */ + const int32_t sampling_rate, /* i : sampling rate */ + const int16_t frame_len /* i : frame length in samples */ +) +{ + /* Set window coefficients */ + if ( sampling_rate == 48000 ) + { + hLFEWindow->pWindow_coeffs = ivas_lfe_window_coeff_48k; + } + else if ( sampling_rate == 32000 ) + { + hLFEWindow->pWindow_coeffs = ivas_lfe_window_coeff_32k; + } + else if ( sampling_rate == 16000 ) + { + hLFEWindow->pWindow_coeffs = ivas_lfe_window_coeff_16k; + } + else + { + assert( !"8kHz LFE Window not supported" ); + } + /* 10ms stride, MDCT will be done in two iterations */ + hLFEWindow->dct_len = frame_len >> 1; + /* 8ms of latency */ + hLFEWindow->fade_len = NS2SA( sampling_rate, IVAS_LFE_FADE_NS ); + hLFEWindow->zero_pad_len = (int16_t) ( IVAS_ZERO_PAD_LEN_MULT_FAC * ( hLFEWindow->dct_len - hLFEWindow->fade_len ) ); + hLFEWindow->full_len = hLFEWindow->zero_pad_len + hLFEWindow->fade_len + hLFEWindow->dct_len; return; } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index aa02ae30c9eb40b241abf6d03766b150410480a1..41fa20009327a9ade19a7469d4f8d42c2e6dde0d 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -7002,8 +7002,8 @@ void ivas_lfe_tdplc( void ivas_lfe_window_init( LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle */ - const Word32 sampling_rate, /* i : sampling rate */ - const Word16 frame_len /* i : frame length in samples */ + const int32_t sampling_rate, /* i : sampling rate */ + const int16_t frame_len /* i : frame length in samples */ ); void ivas_lfe_lpf_select_filt_coeff( diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 177156f76ebf2df835bc1b355030cc1d06210dac..a9b72e0677f8e76ce225a59c1b3c4131194073da 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2190,17 +2190,23 @@ void ivas_param_mc_dec_read_BS_fx( ); ivas_error ivas_omasa_data_open_fx( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); void ivas_omasa_data_close_fx( - MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ + MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ ); ivas_error ivas_mc_dec_config_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 idx, /* i : LS config. index */ UWord16 *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ - Word16 *data /* o : output synthesis signal */ + Word16 *data /* o : output synthesis signal */ +); + +void ivas_lfe_window_init_fx( + LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle */ + const Word32 sampling_rate, /* i : sampling rate */ + const Word16 frame_len /* i : frame length in samples */ ); #endif diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index d78695d1ec94c7424fcf253a09adaa9a06b1820c..29cca5c9251a37e8d5b7deb22324fdc3dff27b0d 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -330,25 +330,12 @@ static ivas_error ivas_dirac_rend_config_fx( IF( EQ_16( flag_config, DIRAC_OPEN ) ) { -#ifdef TRUE - /*TODO : remove float code*/ - if ( ( hDirACRend->frequency_axis = (float *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - set_f( hDirACRend->frequency_axis, 0.0f, hSpatParamRendCom->num_freq_bands ); -#endif IF( ( hDirACRend->frequency_axis_fx = (Word16 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } set16_fx( hDirACRend->frequency_axis_fx, 0, hSpatParamRendCom->num_freq_bands ); ivas_dirac_dec_get_frequency_axis_fx( hDirACRend->frequency_axis_fx, output_Fs, hSpatParamRendCom->num_freq_bands ); - - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - hDirACRend->frequency_axis[i] = (float) hDirACRend->frequency_axis_fx[i]; - } } IF( ( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) && EQ_16( hDirACRend->panningConf, DIRAC_PANNING_HOA3 ) && EQ_16( nchan_transport, 2 ) ) @@ -550,13 +537,6 @@ static ivas_error ivas_dirac_rend_config_fx( /* direct/diffuse responses */ IF( EQ_16( flag_config, DIRAC_OPEN ) ) { -#ifdef TRUE - /*Todo : to clean up float code*/ - IF( ( hDirACRend->diffuse_response_function = (float *) malloc( sizeof( float ) * hDirACRend->num_outputs_dir ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } -#endif IF( ( hDirACRend->diffuse_response_function_fx = (Word16 *) malloc( sizeof( Word16 ) * hDirACRend->num_outputs_dir ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); @@ -565,15 +545,6 @@ static ivas_error ivas_dirac_rend_config_fx( /* reallocate static memory */ ELSE IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && NE_16( hDirACRend->num_outputs_dir, num_outputs_dir_old ) ) { -#ifdef TRUE - /*Todo : Remove float code*/ - free( hDirACRend->diffuse_response_function ); - hDirACRend->diffuse_response_function = NULL; - IF( ( hDirACRend->diffuse_response_function = (float *) malloc( sizeof( float ) * hDirACRend->num_outputs_dir ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } -#endif free( hDirACRend->diffuse_response_function_fx ); hDirACRend->diffuse_response_function_fx = NULL; IF( ( hDirACRend->diffuse_response_function_fx = (Word16 *) malloc( sizeof( Word16 ) * hDirACRend->num_outputs_dir ) ) == NULL ) @@ -586,44 +557,15 @@ static ivas_error ivas_dirac_rend_config_fx( initDiffuseResponses_fx( hDirACRend->diffuse_response_function_fx, nchan_out_woLFE, hDirACRend->hOutSetup.output_config, hDirACRend->hOutSetup, hDirACRend->hOutSetup.ambisonics_order, st_ivas->ivas_format, &hDirACRend->num_ele_spk_no_diffuse_rendering, st_ivas->transport_config ); - FOR( i = 0; i < hDirACRend->num_outputs_dir; i++ ) - { - hDirACRend->diffuse_response_function[i] = fix16_to_float( hDirACRend->diffuse_response_function_fx[i], 15 ); - } } ELSE { initDiffuseResponses_fx( hDirACRend->diffuse_response_function_fx, hDirACRend->num_outputs_dir, IVAS_AUDIO_CONFIG_FOA, hDirACRend->hOutSetup, hDirACRend->hOutSetup.ambisonics_order, st_ivas->ivas_format, &hDirACRend->num_ele_spk_no_diffuse_rendering, IVAS_AUDIO_CONFIG_INVALID ); - - FOR( i = 0; i < hDirACRend->num_outputs_dir; i++ ) - { - hDirACRend->diffuse_response_function[i] = fix16_to_float( hDirACRend->diffuse_response_function_fx[i], 15 ); - } } IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) { -#ifdef TRUE - /*TODO : to remove float code*/ - if ( EQ_16( flag_config, DIRAC_OPEN ) ) - { - if ( ( hDirACRend->hoa_encoder = (float *) malloc( nchan_out_woLFE * hDirACRend->num_outputs_diff * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - } - else if ( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->hoa_encoder && ( NE_16( hDirACRend->num_outputs_diff, num_outputs_diff_old ) ) ) - { - free( hDirACRend->hoa_encoder ); - hDirACRend->hoa_encoder = NULL; - if ( ( hDirACRend->hoa_encoder = (float *) malloc( nchan_out_woLFE * hDirACRend->num_outputs_diff * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - } - set_f( hDirACRend->hoa_encoder, 0.0f, nchan_out_woLFE * hDirACRend->num_outputs_diff ); -#endif IF( EQ_16( flag_config, DIRAC_OPEN ) ) { IF( ( hDirACRend->hoa_encoder_fx = (Word32 *) malloc( nchan_out_woLFE * hDirACRend->num_outputs_diff * sizeof( Word32 ) ) ) == NULL ) @@ -631,7 +573,7 @@ static ivas_error ivas_dirac_rend_config_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } } - ELSE IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->hoa_encoder && ( NE_16( hDirACRend->num_outputs_diff, num_outputs_diff_old ) ) ) + ELSE IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->hoa_encoder_fx && ( NE_16( hDirACRend->num_outputs_diff, num_outputs_diff_old ) ) ) { free( hDirACRend->hoa_encoder_fx ); hDirACRend->hoa_encoder_fx = NULL; @@ -641,24 +583,10 @@ static ivas_error ivas_dirac_rend_config_fx( } } set32_fx( hDirACRend->hoa_encoder_fx, 0, nchan_out_woLFE * hDirACRend->num_outputs_diff ); - hDirACRend->hoa_encoder_len = nchan_out_woLFE * hDirACRend->num_outputs_diff; - compute_hoa_encoder_mtx_fx( ls_azimuth_fx, ls_elevation_fx, hDirACRend->hoa_encoder_fx, hDirACRend->num_outputs_diff, hDirACRend->hOutSetup.ambisonics_order ); - FOR( i = 0; i < nchan_out_woLFE * hDirACRend->num_outputs_diff; i++ ) - { - hDirACRend->hoa_encoder[i] = fix_to_float( hDirACRend->hoa_encoder_fx[i], Q29 ); - } } ELSE { -#ifdef TRUE - /*todo: clean up float code*/ - IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->hoa_encoder ) - { - free( hDirACRend->hoa_encoder ); - } - hDirACRend->hoa_encoder = NULL; -#endif IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->hoa_encoder_fx ) { free( hDirACRend->hoa_encoder_fx ); @@ -3635,7 +3563,6 @@ void ivas_dirac_dec_render_sf_fx( { IF( EQ_16( hSpatParamRendCom->numParametricDirections, 2 ) ) { - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, Q15, hDirACRend->num_outputs_dir ); floatToFixed_arrL32( hSpatParamRendCom->energy_ratio1[md_idx], hSpatParamRendCom->energy_ratio1_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); floatToFixed_arrL32( hSpatParamRendCom->energy_ratio2[md_idx], hSpatParamRendCom->energy_ratio2_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); } @@ -3871,9 +3798,6 @@ void ivas_dirac_dec_render_sf_fx( 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 ); - - hDirACRend->diffuse_response_function_q = Q15; - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, hDirACRend->diffuse_response_function_q, hDirACRend->num_outputs_dir ); } ELSE { @@ -4720,10 +4644,6 @@ void ivas_dirac_dec_render_sf_fx( { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hDirACRend->h_output_synthesis_psd_params.max_band_decorr, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); } - IF( NE_16( hDirACRend->diffuse_response_function_q, Q15 ) ) - { - Scale_sig( hDirACRend->diffuse_response_function_fx, hDirACRend->num_outputs_dir, sub( Q15, hDirACRend->diffuse_response_function_q ) ); - } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, Q26 ) ) { scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ) ); @@ -5505,8 +5425,6 @@ void ivas_dirac_dec_render_sf_fx( 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 ); } - - fixedToFloat_arr( hDirACRend->h_output_synthesis_psd_params.interpolator_fx, hDirACRend->h_output_synthesis_psd_params.interpolator, Q15, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); 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 ); diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index f1f010f5bb1bfe476937b2dcf3778409ee9b1e40..21ae3761bbcc0e402a935a1f6f84c9bdf01ba77c 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -194,14 +194,13 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); } - for ( idx = 1; idx <= interp_length; ++idx ) + FOR( idx = 1; idx <= interp_length; ++idx ) { 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***************************************************************************************/ - h_dirac_output_synthesis_params->alpha_synthesis = NULL; 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" ) ); @@ -234,22 +233,6 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( { h_dirac_output_synthesis_state->mixing_matrix_res[idx] = NULL; } - - /*-----------------------------------------------------------------* - * prepare processing parameters - *-----------------------------------------------------------------*/ - - /* compute interpolator */ - if ( ( h_dirac_output_synthesis_params->interpolator = (float *) malloc( interp_length * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); - } - - for ( idx = 1; idx <= interp_length; ++idx ) - { - h_dirac_output_synthesis_params->interpolator[idx - 1] = (float) idx / (float) interp_length; - } - #endif return IVAS_ERR_OK; } @@ -369,6 +352,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( } #endif + #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * ivas_dirac_dec_output_synthesis_get_interpolator_fx() @@ -394,9 +378,7 @@ void ivas_dirac_dec_output_synthesis_get_interpolator_fx( return; } -#endif - - +#else /*-------------------------------------------------------------------* * ivas_dirac_dec_output_synthesis_get_interpolator() * @@ -417,6 +399,7 @@ void ivas_dirac_dec_output_synthesis_get_interpolator( return; } +#endif /*-------------------------------------------------------------------* @@ -617,20 +600,6 @@ void ivas_dirac_dec_output_synthesis_cov_close_fx( h_dirac_output_synthesis_state->mixing_matrix_res_exp = NULL; } #if 1/*TODO: To be removed later(floating point dealloc)*/ - /* free interpolator */ - IF ( h_dirac_output_synthesis_params->interpolator != NULL ) - { - free( h_dirac_output_synthesis_params->interpolator ); - h_dirac_output_synthesis_params->interpolator = NULL; - } - - /* free alpha */ - IF ( h_dirac_output_synthesis_params->alpha_synthesis != NULL ) - { - free( h_dirac_output_synthesis_params->alpha_synthesis ); - h_dirac_output_synthesis_params->alpha_synthesis = NULL; - } - /* free proto_matrix */ IF ( h_dirac_output_synthesis_params->proto_matrix != NULL ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index ebf6b23e22bd0562fd506af42ca7f25fdd5c5bf6..0947468a246671b39d4242316013dc630333f007 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2003,7 +2003,6 @@ ivas_error ivas_init_decoder_fx( } if ( hParamMC ) { - fixedToFloat_arr( hParamMC->h_output_synthesis_params.interpolator_fx, hParamMC->h_output_synthesis_params.interpolator, 15, DEFAULT_JBM_CLDFB_TIMESLOTS ); 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++ ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 4ed5d0f63561eb63f0c8650b9e84b5107f68be7c..76a0a6951bf80b57a304542e1598ae075e46cbdb 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1188,10 +1188,7 @@ ivas_error ivas_jbm_dec_tc_fx( IF( EQ_32( st_ivas->hQMetaData->no_directions, 2 ) ) { st_ivas->hSpatParamRendCom->energy_ratio2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio2_fx[i][j], 30 ); - st_ivas->hSpatParamRendCom->spreadCoherence2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->spreadCoherence2_fx[i][j], 15 ); } - st_ivas->hSpatParamRendCom->surroundingCoherence[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->surroundingCoherence_fx[i][j], 15 ); - st_ivas->hSpatParamRendCom->spreadCoherence[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->spreadCoherence_fx[i][j], 15 ); } } } @@ -2178,9 +2175,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( for ( Word16 bin_idx = 0; bin_idx < nBins; bin_idx++ ) { hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = float_to_fix16( hSpatParamRendCom->energy_ratio1[sf_idx][bin_idx], 15 ); - hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = float_to_fix16( hSpatParamRendCom->spreadCoherence[sf_idx][bin_idx], 15 ); - hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = float_to_fix16( hSpatParamRendCom->surroundingCoherence[sf_idx][bin_idx], 15 ); - hSpatParamRendCom->spreadCoherence2_fx[sf_idx][bin_idx] = float_to_fix16( hSpatParamRendCom->spreadCoherence2[sf_idx][bin_idx], 15 ); hSpatParamRendCom->energy_ratio2_fx[sf_idx][bin_idx] = float_to_fix16( hSpatParamRendCom->energy_ratio2[sf_idx][bin_idx], 15 ); } } @@ -2202,9 +2196,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( for ( Word16 bin_idx = 0; bin_idx < nBins; bin_idx++ ) { hSpatParamRendCom->energy_ratio1[sf_idx][bin_idx] = fixedToFloat( hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx], 15 ); - hSpatParamRendCom->spreadCoherence[sf_idx][bin_idx] = fixedToFloat( hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx], 15 ); - hSpatParamRendCom->surroundingCoherence[sf_idx][bin_idx] = fixedToFloat( hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx], 15 ); - hSpatParamRendCom->spreadCoherence2[sf_idx][bin_idx] = fixedToFloat( hSpatParamRendCom->spreadCoherence2_fx[sf_idx][bin_idx], 15 ); hSpatParamRendCom->energy_ratio2[sf_idx][bin_idx] = fixedToFloat( hSpatParamRendCom->energy_ratio2_fx[sf_idx][bin_idx], 15 ); } } @@ -2848,9 +2839,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = sub(st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], shift); } - me2f_buf_16(st_ivas->hParamMC->h_output_synthesis_params.interpolator_fx, 0, st_ivas->hParamMC->h_output_synthesis_params.interpolator, n_render_timeslots ); - - FOR(Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++) { me2f_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix[param_band_idx], nchan_out_cov * nchan_transport); @@ -4582,7 +4570,6 @@ ivas_error ivas_jbm_dec_render( } } - floatToFixed_arr16(st_ivas->hParamMC->h_output_synthesis_params.interpolator, st_ivas->hParamMC->h_output_synthesis_params.interpolator_fx, 15, DEFAULT_JBM_CLDFB_TIMESLOTS); if ((st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM)) { if (st_ivas->hCombinedOrientationData && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV) diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index ecda2cb2e16976ed28b9695ba30f40cfc798c83b..18bb18224ad9eca3a766fb4de22c4d7b7b0a1d84 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -437,7 +437,7 @@ ivas_error ivas_create_lfe_dec_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LFE window structure\n" ) ); } - ivas_lfe_window_init( hLFE->pWindow_state, output_Fs, output_frame ); + ivas_lfe_window_init_fx( hLFE->pWindow_state, output_Fs, output_frame ); /* Initialization for entropy coding */ hLFE->cum_freq_models[0][0] = ivas_str_lfe_freq_models.entropy_coder_model_fine_sg1; diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 06b7ed543b9e00efa07830ca96c3b5f6b6b92eb5..d83a1bfb437116a17aaf5bab0a7625ce0cc60225 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -3656,8 +3656,6 @@ void ivas_spar_param_to_masa_param_mapping_fx( // Tobe deleted hSpatParamRendCom->energy_ratio1[dirac_write_idx][bin] = (float) hSpatParamRendCom->energy_ratio1_fx[dirac_write_idx][bin] / ONE_IN_Q31; hSpatParamRendCom->diffuseness_vector[dirac_write_idx][bin] = (float) hSpatParamRendCom->diffuseness_vector_fx[dirac_write_idx][bin] / ONE_IN_Q31; - hSpatParamRendCom->spreadCoherence[dirac_write_idx][bin] = 0.0f; - hSpatParamRendCom->surroundingCoherence[dirac_write_idx][bin] = 0.0f; //// diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 0cb463858e487ccd641f7f67932ab975bbe41bd1..9db6b9ae6aa9e1bba3638e43506c9cad7cba29aa 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -3526,11 +3526,13 @@ void ivas_param_mc_dec_digest_tc( } #endif + /*------------------------------------------------------------------------- * ivas_param_mc_dec() * * Parametric MC decoding process *------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void ivas_param_mc_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -3916,33 +3918,10 @@ void ivas_param_mc_dec_render( int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; int16_t nchan_out_cov; /*CLDFB*/ - -#ifdef IVAS_FLOAT_FIXED - Word32 Cldfb_RealBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 output_f_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - Word32 *p_output_f_fx[MAX_OUTPUT_CHANNELS]; - for (i = 0; i < MAX_OUTPUT_CHANNELS; i++) { - p_output_f_fx[i] = output_f_fx[i]; - } -#endif float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; -#ifndef IVAS_FLOAT_FIXED float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; -#endif - for ( i = 0; i < MAX_INTERN_CHANNELS; i++) { - for (int j = 0; j < PARAM_MC_MAX_NSLOTS_IN_SUBFRAME; j++) { - for (int k = 0; k < CLDFB_NO_CHANNELS_MAX; k++) { - Cldfb_RealBuffer[i][j][k] = 0; - Cldfb_ImagBuffer[i][j][k] = 0; - - } - } - } /*Decorrelator*/ float onset_filter[MAX_CICP_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* format converter */ @@ -3952,198 +3931,130 @@ void ivas_param_mc_dec_render( uint32_t output_Fs; hParamMC = st_ivas->hParamMC; - assert(hParamMC); + assert( hParamMC ); - push_wmops("param_mc_dec_render"); + push_wmops( "param_mc_dec_render" ); - set_s(channel_active, 0, MAX_CICP_CHANNELS); + set_s( channel_active, 0, MAX_CICP_CHANNELS ); nchan_transport = st_ivas->nchan_transport; nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; nchan_out_init = nchan_out_transport; output_Fs = st_ivas->hDecoderConfig->output_Fs; - if (st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { nchan_out_cldfb = BINAURAL_CHANNELS; - set_s(channel_active, 1, nchan_out_cldfb); - if (st_ivas->hCombinedOrientationData) + set_s( channel_active, 1, nchan_out_cldfb ); + if ( st_ivas->hCombinedOrientationData ) { nchan_out_init = MAX_INTERN_CHANNELS; } nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; } - else if (hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB) + else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) { nchan_out_cov = nchan_out_transport; nchan_out_cldfb = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; } - else if (hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO) + else 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; nchan_out_cldfb = nchan_out_cov; - set_s(channel_active, 1, nchan_out_cov); + set_s( channel_active, 1, nchan_out_cov ); } else { nchan_out_cov = nchan_out_transport; nchan_out_cldfb = nchan_out_transport; - set_s(channel_active, 1, nchan_out_cov); + set_s( channel_active, 1, nchan_out_cov ); } /* set everything to zero that will not be decoded */ nband_synth = hParamMC->band_grouping[hParamMC->num_param_bands_synth]; nbands_to_zero = hParamMC->num_freq_bands - nband_synth; - for (ch = 0; ch < nchan_out_init; ch++) + for ( ch = 0; ch < nchan_out_init; ch++ ) { - for (slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++) + for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) { - set_zero(&(Cldfb_RealBuffer[ch][slot_idx][nband_synth]), nbands_to_zero); - set_zero(&(Cldfb_ImagBuffer[ch][slot_idx][nband_synth]), nbands_to_zero); -#ifdef IVAS_FLOAT_FIXED - set32_fx(&(Cldfb_RealBuffer_fx[ch][slot_idx][nband_synth]), 0, nbands_to_zero); - set32_fx(&(Cldfb_ImagBuffer_fx[ch][slot_idx][nband_synth]), 0, nbands_to_zero); -#endif + set_zero( &( Cldfb_RealBuffer[ch][slot_idx][nband_synth] ), nbands_to_zero ); + set_zero( &( Cldfb_ImagBuffer[ch][slot_idx][nband_synth] ), nbands_to_zero ); } } /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = min(hParamMC->num_slots - hParamMC->slots_rendered, nSamplesAsked / NS2SA(output_Fs, CLDFB_SLOT_NS)); - *nSamplesRendered = slots_to_render * NS2SA(output_Fs, CLDFB_SLOT_NS); + slots_to_render = min( hParamMC->num_slots - hParamMC->slots_rendered, nSamplesAsked / NS2SA( output_Fs, CLDFB_SLOT_NS ) ); + *nSamplesRendered = slots_to_render * NS2SA( output_Fs, CLDFB_SLOT_NS ); first_sf = hParamMC->subframes_rendered; last_sf = first_sf; - while (slots_to_render > 0) + while ( slots_to_render > 0 ) { slots_to_render -= hParamMC->subframe_nbslots[last_sf]; last_sf++; } - if (st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC) + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { - for (subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++) + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { slots_to_render += hParamMC->subframe_nbslots[subframe_idx]; } } slot_idx_start = hParamMC->slots_rendered; slot_idx_start_cldfb_synth = 0; - for (subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++) + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { -#ifdef IVAS_FLOAT_FIXED - Word16 len = slot_idx_start_cldfb_synth * hParamMC->num_freq_bands + hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx]; - for (i = 0; i < nchan_out_cldfb; i++) - { - floatToFixed_arrL(output_f[i], output_f_fx[i], Q11, len); - } -#endif - - for (slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; slot_idx++, hParamMC->slots_rendered++) + for ( slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; slot_idx++, hParamMC->slots_rendered++ ) { - if (hParamMC->max_band_decorr > 0) + if ( hParamMC->max_band_decorr > 0 ) { /*-----------------------------------------------------------------* * protoype signal computation *-----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - - floatToFixed_arrL(hParamMC->Cldfb_RealBuffer_tc, hParamMC->Cldfb_RealBuffer_tc_fx, Q12, hParamMC->sz); - - floatToFixed_arrL(hParamMC->Cldfb_ImagBuffer_tc, hParamMC->Cldfb_ImagBuffer_tc_fx, Q12, hParamMC->sz); - - FOR(Word16 x = 0; x < hParamMC->diff_proto_info->num_protos_diff; x++) - { - Word16 num_source_ch = hParamMC->diff_proto_info->num_source_chan_diff[x]; - move16(); - - floatToFixed_arrL(hParamMC->diff_proto_info->proto_fac[x], hParamMC->diff_proto_info->proto_fac_fx[x], Q30, num_source_ch); - } - - param_mc_protoSignalComputation_fx(&hParamMC->Cldfb_RealBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], - &hParamMC->Cldfb_ImagBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], - hParamMC->proto_frame_f_fx, hParamMC->diff_proto_info, - hParamMC->num_freq_bands); - - fixedToFloat_arrL(hParamMC->proto_frame_f_fx, hParamMC->proto_frame_f, Q11, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands); - -#else - param_mc_protoSignalComputation(&hParamMC->Cldfb_RealBuffer_tc[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], - &hParamMC->Cldfb_ImagBuffer_tc[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], - hParamMC->proto_frame_f, hParamMC->diff_proto_info, - hParamMC->num_freq_bands); -#endif + param_mc_protoSignalComputation( &hParamMC->Cldfb_RealBuffer_tc[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], + &hParamMC->Cldfb_ImagBuffer_tc[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], + hParamMC->proto_frame_f, hParamMC->diff_proto_info, + hParamMC->num_freq_bands ); /*-----------------------------------------------------------------* * frequency domain decorrelation *-----------------------------------------------------------------*/ - /* decorrelate prototype frame */ - ivas_dirac_dec_decorr_process(hParamMC->num_freq_bands, - hParamMC->num_outputs_diff, - hParamMC->diff_proto_info->num_protos_diff, - DIRAC_SYNTHESIS_COV_MC_LS, - nchan_transport, - hParamMC->proto_frame_f, - hParamMC->diff_proto_info->num_protos_diff, - hParamMC->diff_proto_info->proto_index_diff, - hParamMC->proto_frame_dec_f,//output - onset_filter, - hParamMC->h_freq_domain_decorr_ap_params, - hParamMC->h_freq_domain_decorr_ap_state); + /* decorrelate prototype frame */ + ivas_dirac_dec_decorr_process( hParamMC->num_freq_bands, + hParamMC->num_outputs_diff, + hParamMC->diff_proto_info->num_protos_diff, + DIRAC_SYNTHESIS_COV_MC_LS, + nchan_transport, + hParamMC->proto_frame_f, + hParamMC->diff_proto_info->num_protos_diff, + hParamMC->diff_proto_info->proto_index_diff, + hParamMC->proto_frame_dec_f, + onset_filter, + hParamMC->h_freq_domain_decorr_ap_params, + hParamMC->h_freq_domain_decorr_ap_state ); /* copy decorrelated frame directly to output CLDFB buffer, acts also as intermediate */ /* memory for the decorrelated signal */ -#ifdef IVAS_FLOAT_FIXED - f2me_buf(hParamMC->proto_frame_dec_f, hParamMC->proto_frame_dec_f_fx, &hParamMC->exp_proto_frame_dec_f, nchan_out_cov * 2 * hParamMC->num_freq_bands); - ivas_param_mc_dec_copy_diffuse_proto(hParamMC, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, nchan_out_cov, slot_idx); - FOR(int k = 0; k < nchan_out_cov; k++) - { - FOR(int l = 0; l < hParamMC->h_output_synthesis_params.max_band_decorr; l++) - { - Cldfb_RealBuffer[k][slot_idx][l] = me2f(Cldfb_RealBuffer_fx[k][slot_idx][l], hParamMC->exp_proto_frame_dec_f); - Cldfb_ImagBuffer[k][slot_idx][l] = me2f(Cldfb_ImagBuffer_fx[k][slot_idx][l], hParamMC->exp_proto_frame_dec_f); - } - } -#else - ivas_param_mc_dec_copy_diffuse_proto(hParamMC, Cldfb_RealBuffer, Cldfb_ImagBuffer, nchan_out_cov, slot_idx); -#endif + ivas_param_mc_dec_copy_diffuse_proto( hParamMC, Cldfb_RealBuffer, Cldfb_ImagBuffer, nchan_out_cov, slot_idx ); } /*-----------------------------------------------------------------* * output synthesis *-----------------------------------------------------------------*/ - ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot(&hParamMC->Cldfb_RealBuffer_tc[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], - &hParamMC->Cldfb_ImagBuffer_tc[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], - Cldfb_RealBuffer, Cldfb_ImagBuffer, - hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, slot_idx, slot_idx + slot_idx_start, - nchan_transport, nchan_out_cov, hParamMC); + ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( &hParamMC->Cldfb_RealBuffer_tc[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], + &hParamMC->Cldfb_ImagBuffer_tc[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], + Cldfb_RealBuffer, Cldfb_ImagBuffer, + hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, slot_idx, slot_idx + slot_idx_start, + nchan_transport, nchan_out_cov, hParamMC ); - if ((st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM)) + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) { if ( - st_ivas->hCombinedOrientationData && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV) + st_ivas->hCombinedOrientationData && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { -#ifdef IVAS_FLOAT_FIXED -#if 1 - Word16 Q_hoa_encoder = 31; - floatToFixed_arrL(hParamMC->hoa_encoder, hParamMC->hoa_encoder_fx, Q_hoa_encoder, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS); - - Word16 Q_Cldfb_ImagBuffer, Q_Cldfb_RealBuffer; - Q_Cldfb_ImagBuffer = Q_factor_arrL(&Cldfb_ImagBuffer[0][0][0], 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX) - 5;/*max value =MAX_INTERN_CHANNELS(=16)*Cldfb_ImagBuffer_fx*/ - Q_Cldfb_RealBuffer = Q_factor_arrL(&Cldfb_RealBuffer[0][0][0], 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX) - 5; - floatToFixed_arrL(&Cldfb_ImagBuffer[0][0][0], &Cldfb_ImagBuffer_fx[0][0][0], Q_Cldfb_ImagBuffer, 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX); - floatToFixed_arrL(&Cldfb_RealBuffer[0][0][0], &Cldfb_RealBuffer_fx[0][0][0], Q_Cldfb_RealBuffer, 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX); -#endif - ivas_param_mc_mc2sba_cldfb_fx(st_ivas->hTransSetup, hParamMC->hoa_encoder_fx, slot_idx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, nband_synth, GAIN_LFE_FX); -#if 1 - - fixedToFloat_arrL(&Cldfb_ImagBuffer_fx[0][0][0], &Cldfb_ImagBuffer[0][0][0], Q_Cldfb_ImagBuffer, 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX); - fixedToFloat_arrL(&Cldfb_RealBuffer_fx[0][0][0], &Cldfb_RealBuffer[0][0][0], Q_Cldfb_RealBuffer, 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX); -#endif // IVAS_FLOAT_FIXED -#else - ivas_param_mc_mc2sba_cldfb(st_ivas->hTransSetup, hParamMC->hoa_encoder, slot_idx, Cldfb_RealBuffer, Cldfb_ImagBuffer, nband_synth, GAIN_LFE); -#endif // IVAS_FLOAT_FIXED - + ivas_param_mc_mc2sba_cldfb( st_ivas->hTransSetup, hParamMC->hoa_encoder, slot_idx, Cldfb_RealBuffer, Cldfb_ImagBuffer, nband_synth, GAIN_LFE ); } else { @@ -4153,41 +4064,43 @@ void ivas_param_mc_dec_render( IVAS_OUTPUT_SETUP hLsSetup; hLsSetup = st_ivas->hTransSetup; + /* If LFE should be rendered, add it to other channels before removing */ - if (st_ivas->hBinRenderer->render_lfe) + if ( st_ivas->hBinRenderer->render_lfe ) { - for (idx_lfe = 0; idx_lfe < hLsSetup.num_lfe; idx_lfe++) + for ( idx_lfe = 0; idx_lfe < hLsSetup.num_lfe; idx_lfe++ ) { /* Copy just the first band of LFE*/ - v_multc(Cldfb_RealBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], (GAIN_LFE / hLsSetup.nchan_out_woLFE), Cldfb_RealBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], 1); - v_multc(Cldfb_ImagBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], (GAIN_LFE / hLsSetup.nchan_out_woLFE), Cldfb_ImagBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], 1); + v_multc( Cldfb_RealBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], ( GAIN_LFE / hLsSetup.nchan_out_woLFE ), Cldfb_RealBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], 1 ); + v_multc( Cldfb_ImagBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], ( GAIN_LFE / hLsSetup.nchan_out_woLFE ), Cldfb_ImagBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], 1 ); - for (ch = 0; ch < (hLsSetup.nchan_out_woLFE + hLsSetup.num_lfe); ch++) + for ( ch = 0; ch < ( hLsSetup.nchan_out_woLFE + hLsSetup.num_lfe ); ch++ ) { - if (hLsSetup.index_lfe[idx_lfe] != ch) + if ( hLsSetup.index_lfe[idx_lfe] != ch ) { - v_add(Cldfb_RealBuffer[ch][slot_idx], Cldfb_RealBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_RealBuffer[ch][slot_idx], 1); - v_add(Cldfb_ImagBuffer[ch][slot_idx], Cldfb_ImagBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_ImagBuffer[ch][slot_idx], 1); + v_add( Cldfb_RealBuffer[ch][slot_idx], Cldfb_RealBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_RealBuffer[ch][slot_idx], 1 ); + v_add( Cldfb_ImagBuffer[ch][slot_idx], Cldfb_ImagBuffer[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_ImagBuffer[ch][slot_idx], 1 ); } } } } + idx_out = 0; idx_lfe = 0; - for (ch = 0; ch < (hLsSetup.nchan_out_woLFE + hLsSetup.num_lfe); ch++) + for ( ch = 0; ch < ( hLsSetup.nchan_out_woLFE + hLsSetup.num_lfe ); ch++ ) { - if ((hLsSetup.num_lfe > 0) && (hLsSetup.index_lfe[idx_lfe] == ch)) + if ( ( hLsSetup.num_lfe > 0 ) && ( hLsSetup.index_lfe[idx_lfe] == ch ) ) { - if (idx_lfe < (hLsSetup.num_lfe - 1)) + if ( idx_lfe < ( hLsSetup.num_lfe - 1 ) ) { idx_lfe++; } } - else if (ch != idx_out) + else if ( ch != idx_out ) { - mvr2r(Cldfb_RealBuffer[ch][slot_idx], Cldfb_RealBuffer[idx_out][slot_idx], nband_synth); - mvr2r(Cldfb_ImagBuffer[ch][slot_idx], Cldfb_ImagBuffer[idx_out][slot_idx], nband_synth); + mvr2r( Cldfb_RealBuffer[ch][slot_idx], Cldfb_RealBuffer[idx_out][slot_idx], nband_synth ); + mvr2r( Cldfb_ImagBuffer[ch][slot_idx], Cldfb_ImagBuffer[idx_out][slot_idx], nband_synth ); idx_out++; } else @@ -4199,183 +4112,36 @@ void ivas_param_mc_dec_render( } } - if (st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -#ifdef IVAS_FLOAT_FIXED - Word16 j, k; - for (i = 0; i < MAX_OUTPUT_CHANNELS; i++) - { - for (j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++) - { - for (k = 0; k < CLDFB_NO_CHANNELS_MAX; k++) - { - Cldfb_RealBuffer_fx[i][j][k] = (Word32)floatToFixed(Cldfb_RealBuffer[i][j][k], Q6); - Cldfb_ImagBuffer_fx[i][j][k] = (Word32)floatToFixed(Cldfb_ImagBuffer[i][j][k], Q6); - } - } - } - if (st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hBinRenderer->rotInCldfb) - { - if (st_ivas->hBinRenderer->hInputSetup->is_loudspeaker_setup == 0) - { - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][i][j] = (Word32)floatToFixed(st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx][i][j], 30); - } - } - } - } + ivas_binRenderer( st_ivas->hBinRenderer, + st_ivas->hCombinedOrientationData, + hParamMC->subframe_nbslots[subframe_idx], + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); - Word16 input_q = 6; - /* Implement binaural rendering */ - ivas_binRenderer_fx(st_ivas->hBinRenderer, - st_ivas->hCombinedOrientationData, - hParamMC->subframe_nbslots[subframe_idx], - Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, - Cldfb_RealBuffer_fx, - Cldfb_ImagBuffer_fx, &input_q); - /* fixed to float */ - for (i = 0; i < MAX_OUTPUT_CHANNELS; i++) - { - for (j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++) - { - for (k = 0; k < CLDFB_NO_CHANNELS_MAX; k++) - { - Cldfb_RealBuffer[i][j][k] = fixedToFloat(Cldfb_RealBuffer_fx[i][j][k], input_q); - Cldfb_ImagBuffer[i][j][k] = fixedToFloat(Cldfb_ImagBuffer_fx[i][j][k], input_q); - } - } - } - - for (int idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++) - { - for (int idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++) - { - Scale_sig32(Cldfb_RealBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, 6 - input_q); - Scale_sig32(Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, 6 - input_q); - } - } - - /* for (i = 0; i < BINAURAL_CHANNELS; i++) - { - for (j = 0; j < hParamMC->subframe_nbslots[subframe_idx]; j++) - { - for (k = 0; k < CLDFB_NO_CHANNELS_MAX; k++) - { - Cldfb_RealBuffer_Binaural[i][j][k] = fix_to_float(Cldfb_RealBuffer_Binaural_fx[i][j][k], Q6); - Cldfb_ImagBuffer_Binaural[i][j][k] = fix_to_float(Cldfb_ImagBuffer_Binaural_fx[i][j][k], Q6); - } - } - }*/ -#else - ivas_binRenderer(st_ivas->hBinRenderer, - st_ivas->hCombinedOrientationData, - hParamMC->subframe_nbslots[subframe_idx], - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer); - -#endif /* update combined orientation access index */ - ivas_combined_orientation_update_index(st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx]); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); } - else if (hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB) + else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) { /* format conversion*/ -#ifdef IVAS_FLOAT_FIXED - Word16 inChannels = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; - Word16 num_timeslots = hParamMC->subframe_nbslots[subframe_idx]; - Word16 j; - FOR(i = 0; i < inChannels; ++i) - { - FOR(j = 0; j < num_timeslots; ++j) - { - floatToFixed_arrL(Cldfb_RealBuffer[i][j], Cldfb_RealBuffer_fx[i][j], Q9, st_ivas->hLsSetUpConversion->sfbCnt); - floatToFixed_arrL(Cldfb_ImagBuffer[i][j], Cldfb_ImagBuffer_fx[i][j], Q9, st_ivas->hLsSetUpConversion->sfbCnt); - } - } - ivas_lssetupconversion_process_param_mc_fx(st_ivas, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, channel_active); - FOR(i = 0; i < inChannels; ++i) - { - FOR(j = 0; j < num_timeslots; ++j) - { - fixedToFloat_arrL(Cldfb_RealBuffer_fx[i][j], Cldfb_RealBuffer[i][j], Q9, st_ivas->hLsSetUpConversion->sfbCnt); - fixedToFloat_arrL(Cldfb_ImagBuffer_fx[i][j], Cldfb_ImagBuffer[i][j], Q9, st_ivas->hLsSetUpConversion->sfbCnt); - } - } -#else - ivas_lssetupconversion_process_param_mc(st_ivas, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer, Cldfb_ImagBuffer, channel_active); -#endif + ivas_lssetupconversion_process_param_mc( st_ivas, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer, Cldfb_ImagBuffer, channel_active ); } /* CLDFB synthesis */ -#ifdef IVAS_FLOAT_FIXED - - floatToFixed_arrL(&Cldfb_ImagBuffer[0][0][0], &Cldfb_ImagBuffer_fx[0][0][0], Q6, 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX); - floatToFixed_arrL(&Cldfb_RealBuffer[0][0][0], &Cldfb_RealBuffer_fx[0][0][0], Q6, 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX); - - /* CLDFB synthesis */ - for (ch = 0; ch < nchan_out_cldfb; ch++) - { - Word32 *RealBuffer_fx[16]; - Word32 *ImagBuffer_fx[16]; - - if (channel_active[ch]) - { - /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - for (i = 0; i < hParamMC->subframe_nbslots[subframe_idx]; i++) - { - if (st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM) - { - RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[ch][i]; - ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[ch][i]; - } - else - { - RealBuffer_fx[i] = Cldfb_RealBuffer_fx[ch][i]; - ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[ch][i]; - } - } - - for (i = 0; i < st_ivas->cldfbSynDec[ch]->p_filter_length; i++) - { - st_ivas->cldfbSynDec[ch]->cldfb_state_fx[i] = (Word32)(st_ivas->cldfbSynDec[ch]->cldfb_state[i] * (1LL << (5))); - } - scale_sig32(output_f_fx[ch], len, 5 - 11); - - cldfbSynthesis_ivas_fx(RealBuffer_fx, ImagBuffer_fx, &(output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands]), - hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch]); - - scale_sig32(output_f_fx[ch], len, 11 - 5); - for (i = 0; i < st_ivas->cldfbSynDec[ch]->p_filter_length; i++) - { - st_ivas->cldfbSynDec[ch]->cldfb_state[i] = ((float)st_ivas->cldfbSynDec[ch]->cldfb_state_fx[i] / (1LL << (5))); - } - fixedToFloat_arrL(output_f_fx[ch], output_f[ch], Q11, len); - } - else - { - set32_fx(&(output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands]), 0, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx]); - fixedToFloat_arrL(output_f_fx[ch], output_f[ch], Q11, len); - } - } - slot_idx_start += hParamMC->subframe_nbslots[subframe_idx]; - slot_idx_start_cldfb_synth += hParamMC->subframe_nbslots[subframe_idx]; - } -#else - for (ch = 0; ch < nchan_out_cldfb; ch++) + for ( ch = 0; ch < nchan_out_cldfb; ch++ ) { float *RealBuffer[16]; float *ImagBuffer[16]; - if (channel_active[ch]) + if ( channel_active[ch] ) { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - for (i = 0; i < hParamMC->subframe_nbslots[subframe_idx]; i++) + for ( i = 0; i < hParamMC->subframe_nbslots[subframe_idx]; i++ ) { - if (st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { RealBuffer[i] = Cldfb_RealBuffer_Binaural[ch][i]; ImagBuffer[i] = Cldfb_ImagBuffer_Binaural[ch][i]; @@ -4387,77 +4153,38 @@ void ivas_param_mc_dec_render( } } - cldfbSynthesis_ivas(RealBuffer, ImagBuffer, &(output_f[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands]), - hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch]); + cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), + hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); } else { - set_f(&(output_f[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands]), 0.0f, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx]); + set_f( &( output_f[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), 0.0f, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); } } slot_idx_start += hParamMC->subframe_nbslots[subframe_idx]; slot_idx_start_cldfb_synth += hParamMC->subframe_nbslots[subframe_idx]; -} -#endif - -#ifdef IVAS_FLOAT_FIXED - if (hParamMC->slots_rendered == hParamMC->num_slots) - { - FOR(Word16 param_band_idx = 0; param_band_idx < hParamMC->hMetadataPMC->nbands_coded; param_band_idx++) { - f2me_buf(hParamMC->h_output_synthesis_cov_state.mixing_matrix[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], &hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx], nchan_transport * nchan_out_cov); - IF(hParamMC->band_grouping[param_band_idx] < hParamMC->h_output_synthesis_params.max_band_decorr) { - f2me_buf(hParamMC->h_output_synthesis_cov_state.mixing_matrix_res[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], &hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx], nchan_transport * nchan_out_cov); - } - } } -#endif - if (st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC) + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { -#ifdef IVAS_FLOAT_FIXED - ivas_mc2sba_fx(st_ivas->hIntSetup, p_output_f_fx, p_output_f_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0); -#else - ivas_mc2sba(st_ivas->hIntSetup, output_f, output_f, hParamMC->num_freq_bands * slots_to_render, st_ivas->hOutSetup.ambisonics_order, 0.f); -#endif // IVAS_FLOAT_FIXED + ivas_mc2sba( st_ivas->hIntSetup, output_f, output_f, hParamMC->num_freq_bands * slots_to_render, st_ivas->hOutSetup.ambisonics_order, 0.f ); } /* update */ - - if (hParamMC->slots_rendered == hParamMC->num_slots) + if ( hParamMC->slots_rendered == hParamMC->num_slots ) { -#ifdef IVAS_FLOAT_FIXED hParamMC->hMetadataPMC->last_coded_bwidth = hParamMC->hMetadataPMC->coded_bwidth; - param_mc_update_mixing_matrices_fx(hParamMC, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_transport, nchan_out_cov); -#else - param_mc_update_mixing_matrices(hParamMC, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_transport, nchan_out_cov); -#endif + param_mc_update_mixing_matrices( hParamMC, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_transport, nchan_out_cov ); } + hParamMC->subframes_rendered = last_sf; + *nSamplesAvailableNext = ( hParamMC->num_slots - hParamMC->slots_rendered ) * NS2SA( output_Fs, CLDFB_SLOT_NS ); + pop_wmops(); -#ifdef IVAS_FLOAT_FIXED -if (st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC) -{ - FOR(i = 0; i < MAX_OUTPUT_CHANNELS; i++) - { - fixedToFloat_arrL(output_f_fx[i], output_f[i], Q11, *nSamplesRendered); - } -} -if (hParamMC->slots_rendered == hParamMC->num_slots) -{ - FOR(Word16 param_band_idx = 0; param_band_idx < hParamMC->hMetadataPMC->nbands_coded; param_band_idx++) { - IF(hParamMC->band_grouping[param_band_idx] < hParamMC->h_output_synthesis_params.max_band_decorr) { - mvr2r(hParamMC->h_output_synthesis_cov_state.mixing_matrix_res[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[param_band_idx], nchan_transport * nchan_out_cov); - } - mvr2r(hParamMC->h_output_synthesis_cov_state.mixing_matrix[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[param_band_idx], nchan_transport * nchan_out_cov); - } + return; } #endif -hParamMC->subframes_rendered = last_sf; -*nSamplesAvailableNext = (hParamMC->num_slots - hParamMC->slots_rendered) * NS2SA(output_Fs, CLDFB_SLOT_NS); -pop_wmops(); -return; -} -#endif + /*------------------------------------------------------------------------- * ivas_param_mc_dec() * diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 40f8de567e3595c136687ad336217feec3c852e7..d29f63cebc4208588b5296c53065b9e6db0f8b73 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -613,8 +613,6 @@ ivas_error ivas_spar_dec_fx( { st_ivas->hSpatParamRendCom->energy_ratio2_fx[i][j] = float_to_fix( st_ivas->hSpatParamRendCom->energy_ratio2[i][j], 30 ); } - st_ivas->hSpatParamRendCom->surroundingCoherence_fx[i][j] = float_to_fix16( st_ivas->hSpatParamRendCom->surroundingCoherence[i][j], 15 ); - st_ivas->hSpatParamRendCom->spreadCoherence_fx[i][j] = float_to_fix16( st_ivas->hSpatParamRendCom->spreadCoherence[i][j], 15 ); } } } @@ -712,8 +710,6 @@ ivas_error ivas_spar_dec_fx( { st_ivas->hSpatParamRendCom->energy_ratio2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio2_fx[i][j], 30 ); } - st_ivas->hSpatParamRendCom->surroundingCoherence[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->surroundingCoherence_fx[i][j], 15 ); - st_ivas->hSpatParamRendCom->spreadCoherence[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->spreadCoherence_fx[i][j], 15 ); } } } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 97c00f323987dbe7b97b0b85aada30663e9af54f..69c5ddb6788c8e7fe2ddb3d30052aae3299eac4f 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1321,10 +1321,7 @@ static ivas_error IVAS_DEC_GetTcSamples( IF(EQ_32(st_ivas->hQMetaData->no_directions, 2)) { st_ivas->hSpatParamRendCom->energy_ratio2[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->energy_ratio2_fx[i][j], 30); - st_ivas->hSpatParamRendCom->spreadCoherence2[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->spreadCoherence2_fx[i][j], 15); } - st_ivas->hSpatParamRendCom->surroundingCoherence[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->surroundingCoherence_fx[i][j], 15); - st_ivas->hSpatParamRendCom->spreadCoherence[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->spreadCoherence_fx[i][j], 15); } } } diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c index b476af9e3c4b05cc6652cf959e2c3d0efe0f32c6..657e633a3f9ffd0064aef45b09d30bcb3a800787 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -54,9 +54,9 @@ #define DIRAC_DUCK_ALPHA 0.8f #define DIRAC_DUCK_GAMMA 1.5f #ifdef IVAS_FLOAT_FIXED -#define DIRAC_DUCK_GAMMA_FX 1610612736 // Q30 -#define DIRAC_DUCK_ALPHA_FX 1717986944 //Q31 -#define ONE_M_DIRAC_DUCK_ALPHA 429496736 //Q31 +#define DIRAC_DUCK_GAMMA_FX 1610612736 /* Q30 */ +#define DIRAC_DUCK_ALPHA_FX 1717986944 /* Q31 */ +#define ONE_M_DIRAC_DUCK_ALPHA 429496736 /* Q31 */ #endif /*------------------------------------------------------------------------- @@ -65,9 +65,8 @@ #ifndef IVAS_FLOAT_FIXED static void get_lattice_coeffs( const int16_t band_index, const int16_t channel_index, float *lattice_coeffs ); -#endif static void lattice2allpass( const int16_t filter_length, const float *lattice_coeffs, float *filter_coeffs_num_real, float *filter_coeffs_den_real ); -#ifdef IVAS_FLOAT_FIXED +#else static void get_lattice_coeffs_fx( const Word16 band_index, const Word16 channel_index, Word16 *lattice_coeffs ); static void lattice2allpass_fx( const int16_t filter_length, const Word16 *lattice_coeffs_fx, Word16 *filter_coeffs_num_real_fx, Word16 *filter_coeffs_den_real_fx ); #endif @@ -77,6 +76,8 @@ static void lattice2allpass_fx( const int16_t filter_length, const Word16 *latti * * Allocate and initialize TD decorrelator decoder handle *------------------------------------------------------------------------*/ + +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_dirac_dec_decorr_open( DIRAC_DECORR_PARAMS **ph_freq_domain_decorr_ap_params, DIRAC_DECORR_STATE **ph_freq_domain_decorr_ap_state, @@ -105,72 +106,72 @@ ivas_error ivas_dirac_dec_decorr_open( * prepare library opening *-----------------------------------------------------------------*/ - /* allocate structs */ - if ((freq_domain_decorr_ap_params = (DIRAC_DECORR_PARAMS *)malloc(sizeof(DIRAC_DECORR_PARAMS))) == NULL) + /* allocate structs */ + if ( ( freq_domain_decorr_ap_params = (DIRAC_DECORR_PARAMS *) malloc( sizeof( DIRAC_DECORR_PARAMS ) ) ) == 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_state = (DIRAC_DECORR_STATE *)malloc(sizeof(DIRAC_DECORR_STATE))) == NULL) + if ( ( freq_domain_decorr_ap_state = (DIRAC_DECORR_STATE *) malloc( sizeof( DIRAC_DECORR_STATE ) ) ) == 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" ) ); } /*-----------------------------------------------------------------* * check input parameters *-----------------------------------------------------------------*/ - assert((num_freq_bands > 0) && "Error: Number of frequency bands <= 0!"); + assert( ( num_freq_bands > 0 ) && "Error: Number of frequency bands <= 0!" ); - if (synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD) + if ( synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { num_outputs_diff -= nchan_transport; } - assert((num_outputs_diff >= 0) && (num_outputs_diff <= DIRAC_MAX_NUM_DECORR_FILTERS) && "Error: Number of channels <= 0 or > DIRAC_MAX_NUM_DECORR_FILTERS"); + assert( ( num_outputs_diff >= 0 ) && ( num_outputs_diff <= DIRAC_MAX_NUM_DECORR_FILTERS ) && "Error: Number of channels <= 0 or > DIRAC_MAX_NUM_DECORR_FILTERS" ); /*-----------------------------------------------------------------* * set default parameters *-----------------------------------------------------------------*/ - if (synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD) + if ( synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { /*Decorrelation in SHD*/ freq_domain_decorr_ap_params->add_back_onsets_on = 0; - if (nchan_transport > 2) + if ( nchan_transport > 2 ) { freq_domain_decorr_ap_params->max_frequency = 2000; } else { - freq_domain_decorr_ap_params->max_frequency = (min(num_freq_bands, DIRAC_MAX_DECORR_CLDFB_BANDS_AMBI) * 24000) / CLDFB_NO_CHANNELS_MAX; + freq_domain_decorr_ap_params->max_frequency = ( min( num_freq_bands, DIRAC_MAX_DECORR_CLDFB_BANDS_AMBI ) * 24000 ) / CLDFB_NO_CHANNELS_MAX; } } - else if (synthesisConf == DIRAC_SYNTHESIS_COV_MC_LS) + else if ( synthesisConf == DIRAC_SYNTHESIS_COV_MC_LS ) { /*Decorrelation in LS channels for MC*/ freq_domain_decorr_ap_params->add_back_onsets_on = 1; - freq_domain_decorr_ap_params->max_frequency = (PARAM_MC_MAX_DECORR_CLDFB_BANDS * 24000) / CLDFB_NO_CHANNELS_MAX; + freq_domain_decorr_ap_params->max_frequency = ( PARAM_MC_MAX_DECORR_CLDFB_BANDS * 24000 ) / CLDFB_NO_CHANNELS_MAX; } else { /*Decorrelation in LS channels*/ freq_domain_decorr_ap_params->add_back_onsets_on = 1; - freq_domain_decorr_ap_params->max_frequency = (DIRAC_MAX_DECORR_CLDFB_BANDS * 24000) / CLDFB_NO_CHANNELS_MAX; + freq_domain_decorr_ap_params->max_frequency = ( DIRAC_MAX_DECORR_CLDFB_BANDS * 24000 ) / CLDFB_NO_CHANNELS_MAX; } freq_domain_decorr_ap_params->use_ducker = 1; - assert((freq_domain_decorr_ap_params->max_frequency >= 0) && (freq_domain_decorr_ap_params->max_frequency <= output_Fs / 2) && "Error: max_frequency invalid!"); + assert( ( freq_domain_decorr_ap_params->max_frequency >= 0 ) && ( freq_domain_decorr_ap_params->max_frequency <= output_Fs / 2 ) && "Error: max_frequency invalid!" ); /* compute maximum band for decorrelation */ - assert(frequency_axis != NULL); - for (k = num_freq_bands - 1; k > 0; --k) + assert( frequency_axis != NULL ); + for ( k = num_freq_bands - 1; k > 0; --k ) { freq_domain_decorr_ap_params->max_band_decorr = k + 1; /* outside "if" to avoid uninitialized variable */ - if (frequency_axis[k] < freq_domain_decorr_ap_params->max_frequency) + if ( frequency_axis[k] < freq_domain_decorr_ap_params->max_frequency ) { break; } @@ -180,70 +181,53 @@ ivas_error ivas_dirac_dec_decorr_open( * open sub-modules *-----------------------------------------------------------------*/ - /* open onset detection module */ -#ifdef IVAS_FLOAT_FIXED - IF (synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD) - { - /*Onset detector up to Nyquist and not only up to max_band_decorr*/ - IF ((error = ivas_dirac_dec_onset_detection_open_fx(num_protos_diff, num_freq_bands, num_freq_bands, &freq_domain_decorr_ap_params->h_onset_detection_power_params, &freq_domain_decorr_ap_state->h_onset_detection_power_state)) != IVAS_ERR_OK) - { - return error; - } - } - ELSE - { - if ((error = ivas_dirac_dec_onset_detection_open_fx(num_protos_diff, num_freq_bands, freq_domain_decorr_ap_params->max_band_decorr, &freq_domain_decorr_ap_params->h_onset_detection_power_params, &freq_domain_decorr_ap_state->h_onset_detection_power_state)) != IVAS_ERR_OK) - { - return error; - } - } -#else - if (synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD) + /* open onset detection module */ + if ( synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { /*Onset detector up to Nyquist and not only up to max_band_decorr*/ - if ((error = ivas_dirac_dec_onset_detection_open(num_protos_diff, num_freq_bands, num_freq_bands, &freq_domain_decorr_ap_params->h_onset_detection_power_params, &freq_domain_decorr_ap_state->h_onset_detection_power_state)) != IVAS_ERR_OK) + if ( ( error = ivas_dirac_dec_onset_detection_open( num_protos_diff, num_freq_bands, num_freq_bands, &freq_domain_decorr_ap_params->h_onset_detection_power_params, &freq_domain_decorr_ap_state->h_onset_detection_power_state ) ) != IVAS_ERR_OK ) { return error; } } else { - if ((error = ivas_dirac_dec_onset_detection_open(num_protos_diff, num_freq_bands, freq_domain_decorr_ap_params->max_band_decorr, &freq_domain_decorr_ap_params->h_onset_detection_power_params, &freq_domain_decorr_ap_state->h_onset_detection_power_state)) != IVAS_ERR_OK) + if ( ( error = ivas_dirac_dec_onset_detection_open( num_protos_diff, num_freq_bands, freq_domain_decorr_ap_params->max_band_decorr, &freq_domain_decorr_ap_params->h_onset_detection_power_params, &freq_domain_decorr_ap_state->h_onset_detection_power_state ) ) != IVAS_ERR_OK ) { return error; } } -#endif + /*-----------------------------------------------------------------* * prepare processing parameters *-----------------------------------------------------------------*/ - /* calculate decorrelation split bands */ + /* calculate decorrelation split bands */ split_freq_ptr = &split_frequencies_bands[0]; split_freq_ptr[0] = 0; - for (k = 1; k < DIRAC_DECORR_NUM_SPLIT_BANDS; k++) + for ( k = 1; k < DIRAC_DECORR_NUM_SPLIT_BANDS; k++ ) { - split_freq_ptr[k] = (int16_t)((float)CLDFB_NO_CHANNELS_MAX * ap_split_frequencies[k] + 0.5f) - 1; + split_freq_ptr[k] = (int16_t) ( (float) CLDFB_NO_CHANNELS_MAX * ap_split_frequencies[k] + 0.5f ) - 1; } split_band_index_start = 0; split_frequencies_bands[k] = 0; freq_domain_decorr_ap_params->num_split_frequency_bands = 0; - for (k = 1; k < DIRAC_DECORR_NUM_SPLIT_BANDS + 1; k++) + for ( k = 1; k < DIRAC_DECORR_NUM_SPLIT_BANDS + 1; k++ ) { freq_domain_decorr_ap_params->num_split_frequency_bands++; - if (split_frequencies_bands[k] >= freq_domain_decorr_ap_params->max_band_decorr) + if ( split_frequencies_bands[k] >= freq_domain_decorr_ap_params->max_band_decorr ) { split_frequencies_bands[k] = freq_domain_decorr_ap_params->max_band_decorr; break; } } - if ((freq_domain_decorr_ap_params->split_frequency_bands = (int16_t *)malloc(sizeof(int16_t) * (freq_domain_decorr_ap_params->num_split_frequency_bands + 1))) == NULL) + if ( ( freq_domain_decorr_ap_params->split_frequency_bands = (int16_t *) malloc( sizeof( int16_t ) * ( freq_domain_decorr_ap_params->num_split_frequency_bands + 1 ) ) ) == 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" ) ); } - mvs2s(&split_frequencies_bands[0], freq_domain_decorr_ap_params->split_frequency_bands, freq_domain_decorr_ap_params->num_split_frequency_bands + 1); + mvs2s( &split_frequencies_bands[0], freq_domain_decorr_ap_params->split_frequency_bands, freq_domain_decorr_ap_params->num_split_frequency_bands + 1 ); /* calc buffer size and allocate arrays */ freq_domain_decorr_ap_state->decorr_buffer = NULL; @@ -256,72 +240,59 @@ ivas_error ivas_dirac_dec_decorr_open( freq_domain_decorr_ap_params->pre_delay = NULL; freq_domain_decorr_ap_params->filter_length = NULL; -#ifdef IVAS_FLOAT_FIXED - freq_domain_decorr_ap_state->decorr_buffer_fx = NULL; -#endif - - 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 = (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); - -#ifdef IVAS_FLOAT_FIXED - 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) + 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 = (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")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); } - set32_fx(freq_domain_decorr_ap_state->decorr_buffer_fx, 0, 2 * buffer_size_decorr * num_outputs_diff * freq_domain_decorr_ap_params->max_band_decorr); - freq_domain_decorr_ap_state->q_decorr_buffer = Q31; -#endif + 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_params->filter_coeff_num_real = (float *)malloc(sizeof(float) * (ap_filter_length[split_band_index_start] + 1) * freq_domain_decorr_ap_params->max_band_decorr * num_outputs_diff)) == NULL) + if ( ( freq_domain_decorr_ap_params->filter_coeff_num_real = (float *) malloc( sizeof( float ) * ( ap_filter_length[split_band_index_start] + 1 ) * 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")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); } - if ((freq_domain_decorr_ap_params->filter_coeff_den_real = (float *)malloc(sizeof(float) * (ap_filter_length[split_band_index_start] + 1) * freq_domain_decorr_ap_params->max_band_decorr * num_outputs_diff)) == NULL) + if ( ( freq_domain_decorr_ap_params->filter_coeff_den_real = (float *) malloc( sizeof( float ) * ( ap_filter_length[split_band_index_start] + 1 ) * 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")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); } - if ((freq_domain_decorr_ap_params->phase_coeff_real = (float *)malloc(sizeof(float) * freq_domain_decorr_ap_params->max_band_decorr * num_outputs_diff)) == NULL) + if ( ( freq_domain_decorr_ap_params->phase_coeff_real = (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")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); } - if ((freq_domain_decorr_ap_params->phase_coeff_imag = (float *)malloc(sizeof(float) * freq_domain_decorr_ap_params->max_band_decorr * num_outputs_diff)) == NULL) + if ( ( freq_domain_decorr_ap_params->phase_coeff_imag = (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")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); } - 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) + 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")); + 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) + 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")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD decorrelator\n" ) ); } - if ((freq_domain_decorr_ap_params->pre_delay = (int16_t *)malloc(sizeof(int16_t) * freq_domain_decorr_ap_params->num_split_frequency_bands)) == NULL) + if ( ( freq_domain_decorr_ap_params->pre_delay = (int16_t *) malloc( sizeof( int16_t ) * 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 = (int16_t *)malloc(sizeof(int16_t) * freq_domain_decorr_ap_params->num_split_frequency_bands)) == NULL) + if ( ( freq_domain_decorr_ap_params->filter_length = (int16_t *) malloc( sizeof( int16_t ) * 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" ) ); } - 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); + 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 ); /* 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]; @@ -330,31 +301,20 @@ ivas_error ivas_dirac_dec_decorr_open( freq_domain_decorr_ap_params->filter_length[k] = 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 = k_in + m; cur_lattice_delta_phi = ap_lattice_delta_phi[l * DIRAC_MAX_DECORR_FILTER_LEN + ap_filter_length[k] - 1] * n; - static int count = 0; - count++; - freq_domain_decorr_ap_params->phase_coeff_real[l * freq_domain_decorr_ap_params->max_band_decorr + n] = cosf(cur_lattice_delta_phi); - freq_domain_decorr_ap_params->phase_coeff_imag[l * freq_domain_decorr_ap_params->max_band_decorr + n] = -sinf(cur_lattice_delta_phi); + freq_domain_decorr_ap_params->phase_coeff_real[l * freq_domain_decorr_ap_params->max_band_decorr + n] = cosf( cur_lattice_delta_phi ); + freq_domain_decorr_ap_params->phase_coeff_imag[l * freq_domain_decorr_ap_params->max_band_decorr + n] = -sinf( cur_lattice_delta_phi ); /* calculate phase offset */ -#ifdef IVAS_FLOAT_FIXED - Word16 lattice_coeffs_fx[2 * DIRAC_MAX_DECORR_FILTER_LEN]; - get_lattice_coeffs_fx(band_table_idx, l, lattice_coeffs_fx); - FOR(Word16 i = 0; i < ap_filter_length[band_table_idx]; i++) { - lattice_coeffs[i] = (float)lattice_coeffs_fx[i] / (1 << 15); - } -#else - get_lattice_coeffs(band_table_idx, l, lattice_coeffs); -#endif - + get_lattice_coeffs( band_table_idx, l, lattice_coeffs ); /* calcualte transfer function coefficients from the lattice coefficients */ - lattice2allpass(freq_domain_decorr_ap_params->filter_length[k], lattice_coeffs, &freq_domain_decorr_ap_params->filter_coeff_num_real[(k_in + m) * (freq_domain_decorr_ap_params->filter_length[0] * num_outputs_diff) + l * freq_domain_decorr_ap_params->filter_length[0]], &freq_domain_decorr_ap_params->filter_coeff_den_real[(k_in + m) * (freq_domain_decorr_ap_params->filter_length[0] * num_outputs_diff) + l * freq_domain_decorr_ap_params->filter_length[0]]); + lattice2allpass( freq_domain_decorr_ap_params->filter_length[k], lattice_coeffs, &freq_domain_decorr_ap_params->filter_coeff_num_real[( k_in + m ) * ( freq_domain_decorr_ap_params->filter_length[0] * num_outputs_diff ) + l * freq_domain_decorr_ap_params->filter_length[0]], &freq_domain_decorr_ap_params->filter_coeff_den_real[( k_in + m ) * ( freq_domain_decorr_ap_params->filter_length[0] * num_outputs_diff ) + l * freq_domain_decorr_ap_params->filter_length[0]] ); } } } @@ -365,8 +325,7 @@ ivas_error ivas_dirac_dec_decorr_open( return IVAS_ERR_OK; } - -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_dirac_dec_decorr_open_fx( DIRAC_DECORR_PARAMS **ph_freq_domain_decorr_ap_params, DIRAC_DECORR_STATE **ph_freq_domain_decorr_ap_state, @@ -533,10 +492,6 @@ ivas_error ivas_dirac_dec_decorr_open_fx( #if 1 /*float code to be cleaned up*/ freq_domain_decorr_ap_state->decorr_buffer = NULL; - freq_domain_decorr_ap_params->filter_coeff_num_real = NULL; - freq_domain_decorr_ap_params->filter_coeff_den_real = NULL; - freq_domain_decorr_ap_params->phase_coeff_real = NULL; - freq_domain_decorr_ap_params->phase_coeff_imag = 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; @@ -564,26 +519,6 @@ ivas_error ivas_dirac_dec_decorr_open_fx( } 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_params->filter_coeff_num_real = (float *) malloc( sizeof( float ) * ( ap_filter_length[split_band_index_start] + 1 ) * 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->filter_coeff_den_real = (float *) malloc( sizeof( float ) * ( ap_filter_length[split_band_index_start] + 1 ) * 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->phase_coeff_real = (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->phase_coeff_imag = (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->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" ) ); @@ -680,25 +615,13 @@ ivas_error ivas_dirac_dec_decorr_open_fx( freq_domain_decorr_ap_params->phase_coeff_real_fx[l * freq_domain_decorr_ap_params->max_band_decorr + n] = temp_a; freq_domain_decorr_ap_params->phase_coeff_imag_fx[l * freq_domain_decorr_ap_params->max_band_decorr + n] = temp_b; - /*To be cleaned up later*/ - freq_domain_decorr_ap_params->phase_coeff_real[l * freq_domain_decorr_ap_params->max_band_decorr + n] = fixedToFloat( freq_domain_decorr_ap_params->phase_coeff_real_fx[l * freq_domain_decorr_ap_params->max_band_decorr + n], Q14 ); - freq_domain_decorr_ap_params->phase_coeff_imag[l * freq_domain_decorr_ap_params->max_band_decorr + n] = fixedToFloat( freq_domain_decorr_ap_params->phase_coeff_imag_fx[l * freq_domain_decorr_ap_params->max_band_decorr + n], Q14 ); - /* calculate phase offset */ get_lattice_coeffs_fx( band_table_idx, l, lattice_coeffs_fx ); /* calcualte transfer function coefficients from the lattice coefficients */ Word16 a = ( k_in + m ) * ( freq_domain_decorr_ap_params->filter_length[0] * num_outputs_diff ) + l * freq_domain_decorr_ap_params->filter_length[0]; - Word16 filter_length = freq_domain_decorr_ap_params->filter_length[k]; lattice2allpass_fx( freq_domain_decorr_ap_params->filter_length[k], lattice_coeffs_fx, &freq_domain_decorr_ap_params->filter_coeff_num_real_fx[a], &freq_domain_decorr_ap_params->filter_coeff_den_real_fx[a] ); - - /*To be cleaned up later*/ - FOR( Word16 i = 0; i < filter_length; i++ ) - { - freq_domain_decorr_ap_params->filter_coeff_num_real[a + i] = fixedToFloat( freq_domain_decorr_ap_params->filter_coeff_num_real_fx[a + i], Q12 ); - freq_domain_decorr_ap_params->filter_coeff_den_real[a + i] = fixedToFloat( freq_domain_decorr_ap_params->filter_coeff_den_real_fx[a + i], Q12 ); - } } } } @@ -710,12 +633,15 @@ ivas_error ivas_dirac_dec_decorr_open_fx( return IVAS_ERR_OK; } #endif + + /*------------------------------------------------------------------------- * ivas_dirac_dec_decorr_process() * * *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_dirac_dec_decorr_process( const int16_t num_freq_bands, int16_t num_channels, @@ -992,8 +918,7 @@ void ivas_dirac_dec_decorr_process( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void ivas_dirac_dec_decorr_process_fx( const Word16 num_freq_bands, Word16 num_channels, @@ -1487,6 +1412,7 @@ void ivas_dirac_dec_decorr_process_fx( } #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec_decorr_close() * @@ -1595,34 +1521,6 @@ void ivas_dirac_dec_decorr_close_fx( (*ph_freq_domain_decorr_ap_params)->filter_length = NULL; } - /* free filter coeff param buffers */ - if ((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real != NULL) - { - free((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real); - (*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real = NULL; - } - - /* free pre-delay param buffer */ - if ((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real != NULL) - { - free((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real); - (*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real = NULL; - } - - /* free pre-delay param buffer */ - if ((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag != NULL) - { - free((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag); - (*ph_freq_domain_decorr_ap_params)->phase_coeff_imag = NULL; - } - - /* free pre-delay param buffer */ - if ((*ph_freq_domain_decorr_ap_params)->phase_coeff_real != NULL) - { - free((*ph_freq_domain_decorr_ap_params)->phase_coeff_real); - (*ph_freq_domain_decorr_ap_params)->phase_coeff_real = NULL; - } - /* free pre-delay param buffer */ if ((*ph_freq_domain_decorr_ap_params)->split_frequency_bands != NULL) { @@ -1631,12 +1529,14 @@ void ivas_dirac_dec_decorr_close_fx( } #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); @@ -1667,7 +1567,6 @@ void ivas_dirac_dec_decorr_close_fx( return; } #else - void ivas_dirac_dec_decorr_close( HANDLE_DIRAC_DECORR_PARAMS *ph_freq_domain_decorr_ap_params, HANDLE_DIRAC_DECORR_STATE *ph_freq_domain_decorr_ap_state ) @@ -1683,7 +1582,7 @@ void ivas_dirac_dec_decorr_close( return; } - if (*ph_freq_domain_decorr_ap_params == NULL || *ph_freq_domain_decorr_ap_state == NULL) + if ( *ph_freq_domain_decorr_ap_params == NULL || *ph_freq_domain_decorr_ap_state == NULL ) { return; } @@ -1692,17 +1591,17 @@ void ivas_dirac_dec_decorr_close( * 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; - if (dirac_onset_detection_state->onset_detector_1 != NULL) + if ( dirac_onset_detection_state->onset_detector_1 != NULL ) { - free(dirac_onset_detection_state->onset_detector_1); + free( dirac_onset_detection_state->onset_detector_1 ); dirac_onset_detection_state->onset_detector_1 = NULL; } - if (dirac_onset_detection_state->onset_detector_2 != NULL) + if ( dirac_onset_detection_state->onset_detector_2 != NULL ) { - free(dirac_onset_detection_state->onset_detector_2); + free( dirac_onset_detection_state->onset_detector_2 ); dirac_onset_detection_state->onset_detector_2 = NULL; } @@ -1710,87 +1609,88 @@ void ivas_dirac_dec_decorr_close( * memory deallocation *-----------------------------------------------------------------*/ - /* free decorrelation buffer */ - if ((*ph_freq_domain_decorr_ap_state)->decorr_buffer != NULL) + /* 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( ( *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) + 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( ( *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) + 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; + free( ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth ); + ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth = NULL; } /* free pre-delay param buffer */ - if ((*ph_freq_domain_decorr_ap_params)->pre_delay != NULL) + 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( ( *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) + 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( ( *ph_freq_domain_decorr_ap_params )->filter_length ); + ( *ph_freq_domain_decorr_ap_params )->filter_length = NULL; } /* free filter coeff param buffers */ - if ((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real != NULL) + if ( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real != NULL ) { - free((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real); - (*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real = NULL; + free( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real ); + ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real = NULL; } /* free pre-delay param buffer */ - if ((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real != NULL) + if ( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real != NULL ) { - free((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real); - (*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real = NULL; + free( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real ); + ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real = NULL; } /* free pre-delay param buffer */ - if ((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag != NULL) + if ( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag != NULL ) { - free((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag); - (*ph_freq_domain_decorr_ap_params)->phase_coeff_imag = NULL; + free( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag ); + ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag = NULL; } /* free pre-delay param buffer */ - if ((*ph_freq_domain_decorr_ap_params)->phase_coeff_real != NULL) + if ( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real != NULL ) { - free((*ph_freq_domain_decorr_ap_params)->phase_coeff_real); - (*ph_freq_domain_decorr_ap_params)->phase_coeff_real = NULL; + free( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real ); + ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real = NULL; } /* free pre-delay param buffer */ - if ((*ph_freq_domain_decorr_ap_params)->split_frequency_bands != NULL) + 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( ( *ph_freq_domain_decorr_ap_params )->split_frequency_bands ); + ( *ph_freq_domain_decorr_ap_params )->split_frequency_bands = NULL; } /* free pointers to state and parameter structs */ - free(*ph_freq_domain_decorr_ap_params); + free( *ph_freq_domain_decorr_ap_params ); *ph_freq_domain_decorr_ap_params = NULL; - free(*ph_freq_domain_decorr_ap_state); + free( *ph_freq_domain_decorr_ap_state ); *ph_freq_domain_decorr_ap_state = NULL; return; } - #endif // IVAS_FLOAT_FIXED + + /*------------------------------------------------------------------------- * Local functions *------------------------------------------------------------------------*/ @@ -1812,9 +1712,7 @@ static void get_lattice_coeffs( return; } -#endif - -#ifdef IVAS_FLOAT_FIXED +#else static void get_lattice_coeffs_fx( const Word16 band_index, const Word16 channel_index, @@ -1834,7 +1732,9 @@ static void get_lattice_coeffs_fx( } #endif + /* convert lattice filter coeffs to all pass transfer function coeffs */ +#ifndef IVAS_FLOAT_FIXED static void lattice2allpass( const int16_t filter_length, const float *lattice_coeffs, @@ -1878,98 +1778,56 @@ static void lattice2allpass( return; } - -#ifdef IVAS_FLOAT_FIXED +#else static void lattice2allpass_fx( const int16_t filter_length, const Word16 *lattice_coeffs_fx, Word16 *filter_coeffs_num_real_fx, - Word16 *filter_coeffs_den_real_fx) + Word16 *filter_coeffs_den_real_fx ) { Word16 i, p; - -#ifdef IVAS_FLOAT_FIXED + Word16 alpha_real_fx[2][DIRAC_MAX_DECORR_FILTER_LEN + 1]; Word16 *alpha_real_p_old_fx = &alpha_real_fx[0][0]; Word16 *alpha_real_p_fx = &alpha_real_fx[1][0]; Word16 *tmp_fx; -#else - float alpha_real[2][DIRAC_MAX_DECORR_FILTER_LEN + 1]; - float *alpha_real_p_old = &alpha_real[0][0]; - float *alpha_real_p = &alpha_real[1][0]; - float *tmp; -#endif - FOR (i = 0; i < 2; i++) + FOR( i = 0; i < 2; i++ ) { -#ifdef IVAS_FLOAT_FIXED - set16_fx(alpha_real_fx[i], 0, DIRAC_MAX_DECORR_FILTER_LEN + 1); -#else - set_f(alpha_real[i], 0.0f, DIRAC_MAX_DECORR_FILTER_LEN + 1); -#endif + set16_fx( alpha_real_fx[i], 0, DIRAC_MAX_DECORR_FILTER_LEN + 1 ); } - -#ifdef IVAS_FLOAT_FIXED + alpha_real_p_fx[0] = ONE_IN_Q12; - alpha_real_p_old_fx[0] = ONE_IN_Q12; move16(); + alpha_real_p_old_fx[0] = ONE_IN_Q12; move16(); -#else - alpha_real_p[0] = 1.0f; - alpha_real_p_old[0] = 1.0f; -#endif /* recursion */ - -#ifdef IVAS_FLOAT_FIXED Word16 lattice_alpha = 0; move16(); - FOR (p = 1; p < filter_length; p++) + FOR( p = 1; p < filter_length; p++ ) { - alpha_real_p_fx[p] = shr(lattice_coeffs_fx[(p - 1)], 3);//Q12 + alpha_real_p_fx[p] = shr( lattice_coeffs_fx[( p - 1 )], 3 ); /* Q12 */ - FOR (i = 1; i < p; i++) + FOR( i = 1; i < p; i++ ) { - lattice_alpha = mult(lattice_coeffs_fx[(p - 1)] , alpha_real_p_old_fx[p - i]);//Q12 - alpha_real_p_fx[i] = add(alpha_real_p_old_fx[i] , lattice_alpha);//Q12 + lattice_alpha = mult( lattice_coeffs_fx[( p - 1 )], alpha_real_p_old_fx[p - i] ); /* Q12 */ + alpha_real_p_fx[i] = add( alpha_real_p_old_fx[i], lattice_alpha ); /* Q12 */ + move16(); } /* switch pointers */ tmp_fx = alpha_real_p_old_fx; alpha_real_p_old_fx = alpha_real_p_fx; alpha_real_p_fx = tmp_fx; } -#else - for (p = 1; p < filter_length; p++) - { - alpha_real_p[p] = lattice_coeffs[(p - 1)]; - - for (i = 1; i < p; i++) - { - alpha_real_p[i] = alpha_real_p_old[i] + lattice_coeffs[(p - 1)] * alpha_real_p_old[p - i]; - } - /* switch pointers */ - tmp = alpha_real_p_old; - alpha_real_p_old = alpha_real_p; - alpha_real_p = tmp; - } -#endif - -#ifdef IVAS_FLOAT_FIXED - FOR (i = 0; i < filter_length; i++) + FOR( i = 0; i < filter_length; i++ ) { - filter_coeffs_den_real_fx[i] = alpha_real_p_old_fx[i]; - filter_coeffs_num_real_fx[i] = alpha_real_p_old_fx[filter_length - i - 1]; + filter_coeffs_den_real_fx[i] = alpha_real_p_old_fx[i]; /* Q12 */ move16(); + filter_coeffs_num_real_fx[i] = alpha_real_p_old_fx[filter_length - i - 1]; /* Q12 */ move16(); - }//Q12 -#else - for (i = 0; i < filter_length; i++) - { - filter_coeffs_den_real[i] = alpha_real_p_old[i]; - filter_coeffs_num_real[i] = alpha_real_p_old[filter_length - i - 1]; } -#endif return; } diff --git a/lib_rend/ivas_dirac_onsets_dec.c b/lib_rend/ivas_dirac_onsets_dec.c index 0f0eb51a4c88047f2798422a91db2633de205c00..ff9c0a57352ce41823ed4d4440a9caeb7fd178ec 100644 --- a/lib_rend/ivas_dirac_onsets_dec.c +++ b/lib_rend/ivas_dirac_onsets_dec.c @@ -44,12 +44,6 @@ #include "prot_fx1.h" #include "prot_fx2.h" -/*------------------------------------------------------------------------- - * ivas_dirac_dec_onset_detection_open() - * - * onset detection - *------------------------------------------------------------------------*/ - #ifdef IVAS_FLOAT_FIXED static Word16 BASOP_Util_Cmp_Mant32Exp_sat(Word32 a_m, Word16 a_e, Word32 b_m, Word16 b_e); Word16 BASOP_Util_Cmp_Mant32Exp_sat /*!< o: flag: result of comparison */ @@ -146,6 +140,14 @@ Word16 BASOP_Util_Cmp_Mant32Exp_sat /*!< o: flag: result of comparison */ } #endif + +/*------------------------------------------------------------------------- + * ivas_dirac_dec_onset_detection_open() + * + * onset detection + *------------------------------------------------------------------------*/ + +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_dirac_dec_onset_detection_open( const int16_t num_protos_diff, const int16_t num_freq_bands, @@ -159,28 +161,27 @@ ivas_error ivas_dirac_dec_onset_detection_open( /* check / set input parameters */ dirac_onset_detection_params->num_freq_bands = num_freq_bands; - assert(dirac_onset_detection_params->num_freq_bands > 0 && "Error: Number of frequency bands <= 0!"); + assert( dirac_onset_detection_params->num_freq_bands > 0 && "Error: Number of frequency bands <= 0!" ); dirac_onset_detection_params->max_band_decorr = max_band_decorr; /* memory allocation */ - IF((dirac_onset_detection_state->onset_detector_1 = (float *)malloc(sizeof(float) * num_protos_diff * dirac_onset_detection_params->max_band_decorr)) == NULL) + if ( ( dirac_onset_detection_state->onset_detector_1 = (float *) malloc( sizeof( float ) * num_protos_diff * dirac_onset_detection_params->max_band_decorr ) ) == NULL ) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for onset detection\n")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for onset detection\n" ) ); } - IF((dirac_onset_detection_state->onset_detector_2 = (float *)malloc(sizeof(float) * num_protos_diff * dirac_onset_detection_params->max_band_decorr)) == NULL) + if ( ( dirac_onset_detection_state->onset_detector_2 = (float *) malloc( sizeof( float ) * num_protos_diff * dirac_onset_detection_params->max_band_decorr ) ) == NULL ) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for onset detection\n")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for onset detection\n" ) ); } /* init to zero */ - set_zero(dirac_onset_detection_state->onset_detector_1, num_protos_diff * dirac_onset_detection_params->max_band_decorr); - set_zero(dirac_onset_detection_state->onset_detector_2, num_protos_diff * dirac_onset_detection_params->max_band_decorr); + set_zero( dirac_onset_detection_state->onset_detector_1, num_protos_diff * dirac_onset_detection_params->max_band_decorr ); + set_zero( dirac_onset_detection_state->onset_detector_2, num_protos_diff * dirac_onset_detection_params->max_band_decorr ); return IVAS_ERR_OK; } - -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_dirac_dec_onset_detection_open_fx( const Word16 num_protos_diff, const Word16 num_freq_bands, @@ -216,12 +217,15 @@ ivas_error ivas_dirac_dec_onset_detection_open_fx( return IVAS_ERR_OK; } #endif + + /*------------------------------------------------------------------------- * ivas_dirac_dec_onset_detection_process() * * *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_dirac_dec_onset_detection_process( const float *input_power_f, float *onset_filter, @@ -264,8 +268,7 @@ void ivas_dirac_dec_onset_detection_process( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void ivas_dirac_dec_onset_detection_process_fx( const Word32 *input_power_f, Word16 q_input_power, @@ -281,55 +284,62 @@ void ivas_dirac_dec_onset_detection_process_fx( Word32 *p_onset_detector_1_fx, *p_onset_detector_2_fx; Word16 e_scale; - //Scale_sig32(h_dirac_onset_detection_state.onset_detector_1_fx, num_protos_diff * h_dirac_onset_detection_params.max_band_decorr, -h_dirac_onset_detection_state.q_onset_detector); - //Scale_sig32(h_dirac_onset_detection_state.onset_detector_2_fx, num_protos_diff * h_dirac_onset_detection_params.max_band_decorr, -h_dirac_onset_detection_state.q_onset_detector); - //h_dirac_onset_detection_state.q_onset_detector = 0; - p_onset_detector_1_fx = h_dirac_onset_detection_state.onset_detector_1_fx;//Q0 - p_onset_detector_2_fx = h_dirac_onset_detection_state.onset_detector_2_fx;//Q0 + p_onset_detector_1_fx = h_dirac_onset_detection_state.onset_detector_1_fx; /* Q(q_onset_detector) */ + p_onset_detector_2_fx = h_dirac_onset_detection_state.onset_detector_2_fx; /* Q(q_onset_detector) */ FOR( ch_idx = 0; ch_idx < num_protos_diff; ch_idx++ ) { FOR( b = 0; b < h_dirac_onset_detection_params.max_band_decorr; b++ ) { /*detector 1: envelope max*/ - *p_onset_detector_1_fx = Mpy_32_16_1(*p_onset_detector_1_fx, DIRAC_ONSET_ALPHA_FX); //same Q0 - //Word16 comp_flag = BASOP_Util_Cmp_Mant32Exp_sat( *p_onset_detector_1_fx, 31 - q_p_onset_detector_1, *input_power_f, 31- q_input_power); - UNUSED_PARAM(q_input_power); - IF(GT_32(*p_onset_detector_1_fx, *input_power_f)) + *p_onset_detector_1_fx = Mpy_32_16_1( *p_onset_detector_1_fx, DIRAC_ONSET_ALPHA_FX ); /* Q(q_onset_detector) */ + UNUSED_PARAM( q_input_power ); + IF( GT_32( *p_onset_detector_1_fx, *input_power_f ) ) { - *p_onset_detector_1_fx = *p_onset_detector_1_fx; + *p_onset_detector_1_fx = *p_onset_detector_1_fx; + move32(); } ELSE { - *p_onset_detector_1_fx = *input_power_f; + *p_onset_detector_1_fx = *input_power_f; + move32(); } /*detector 2: envelope min*/ - *p_onset_detector_2_fx = L_add(Mpy_32_16_1( *p_onset_detector_2_fx,DIRAC_ONSET_BETA_FX ), Mpy_32_16_1(*p_onset_detector_1_fx,ONE_DIRAC_ONSET_BETA_FX)); - IF(LT_32(*p_onset_detector_2_fx, *p_onset_detector_1_fx)) - *p_onset_detector_2_fx = *p_onset_detector_2_fx; - ELSE - { - *p_onset_detector_2_fx = *p_onset_detector_1_fx; - } - - IF(EQ_32(*p_onset_detector_1_fx, 0)) - *p_onset_detector_1_fx = L_add(*p_onset_detector_1_fx, EPSILON_FX); + *p_onset_detector_2_fx = L_add( Mpy_32_16_1( *p_onset_detector_2_fx, DIRAC_ONSET_BETA_FX ), Mpy_32_16_1( *p_onset_detector_1_fx, ONE_DIRAC_ONSET_BETA_FX ) ); /* Q(q_onset_detector) */ + IF( LT_32( *p_onset_detector_2_fx, *p_onset_detector_1_fx ) ) + { + *p_onset_detector_2_fx = *p_onset_detector_2_fx; + move32(); + } + ELSE + { + *p_onset_detector_2_fx = *p_onset_detector_1_fx; + move32(); + } + + IF( EQ_32( *p_onset_detector_1_fx, 0 ) ) + { + + *p_onset_detector_1_fx = L_add( *p_onset_detector_1_fx, EPSILON_FX ); + } /*onset filter limited between 0 and 1*/ - tmp_fx = BASOP_Util_Divide3232_Scale(*p_onset_detector_2_fx, *p_onset_detector_1_fx, &e_scale); - tmp32_fx = L_mult0(tmp_fx, DIRAC_ONSET_GAIN_FX); - IF(LT_32(tmp32_fx, 0)) + tmp_fx = BASOP_Util_Divide3232_Scale( *p_onset_detector_2_fx, *p_onset_detector_1_fx, &e_scale ); + tmp32_fx = L_mult0( tmp_fx, DIRAC_ONSET_GAIN_FX ); + IF( LT_32( tmp32_fx, 0 ) ) { - tmp32_fx = 0; + tmp32_fx = 0; + move32(); } - Word16 comp_flag = BASOP_Util_Cmp_Mant32Exp_sat(tmp32_fx, e_scale + 4, ONE_IN_Q30, 1); - IF(EQ_16(comp_flag, 1) || EQ_16(comp_flag, 0)) - tmp32_fx = ONE_IN_Q31; + Word16 comp_flag = BASOP_Util_Cmp_Mant32Exp_sat( tmp32_fx, e_scale + 4, ONE_IN_Q30, 1 ); + IF( EQ_16( comp_flag, 1 ) || EQ_16( comp_flag, 0 ) ) + tmp32_fx = ONE_IN_Q31; ELSE { - tmp32_fx = L_shl(tmp32_fx, e_scale + 4); + tmp32_fx = L_shl( tmp32_fx, e_scale + 4 ); } onset_filter[b] = tmp32_fx; + move32(); input_power_f++; p_onset_detector_1_fx++; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index a24ade9d3da272322c146511c4924b3c5beaa298..a7ad619dd53da5d589ee48d12f7f09a86442b23a 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -114,6 +114,7 @@ static void normalizePanningGains( float *direct_response, const int16_t num_cha * * *------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED extern Word16 find_guarded_bits_fx(Word32 n); @@ -129,7 +130,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( int16_t idx, ch_idx; int16_t size; uint16_t num_diffuse_responses; - float temp_alpha_synthesis[CLDFB_NO_CHANNELS_MAX]; Word16 tmp_fx; Word16 temp_alpha_synthesis_fx[CLDFB_NO_CHANNELS_MAX]; @@ -143,7 +143,7 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( assert( hDirACRend->num_outputs_diff > 0 ); assert( hSpatParamRendCom->slot_size > 0 ); assert( hDirACRend->hOutSetup.is_loudspeaker_setup == 0 || hDirACRend->hOutSetup.is_loudspeaker_setup == 1 ); - assert( hDirACRend->diffuse_response_function != NULL ); + assert( hDirACRend->diffuse_response_function_fx != NULL ); IF ( hDirACRend->proto_signal_decorr_on ) { @@ -224,12 +224,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( } /* buffer length and interpolator */ - /*TODO : remove float code*/ - if ( ( dirac_output_synthesis_params->interpolator = (float *) malloc( JBM_CLDFB_SLOTS_IN_SUBFRAME * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - } - IF ((dirac_output_synthesis_params->interpolator_fx = (Word16 *)malloc(JBM_CLDFB_SLOTS_IN_SUBFRAME * sizeof(Word16))) == NULL) { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); @@ -375,17 +369,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { computeAlphaSynthesis_fx(temp_alpha_synthesis_fx, DIRAC_AVG_LENGTH_SYNTH_MS, DIRAC_ALPHA_MAX_Q15, &dirac_output_synthesis_params->numAlphas, hSpatParamRendCom->slot_size, hSpatParamRendCom->num_freq_bands, hDirACRend->frequency_axis_fx, output_Fs); - for (int k = 0; k < hSpatParamRendCom->num_freq_bands; k++) { - temp_alpha_synthesis[k] = fix16_to_float(temp_alpha_synthesis_fx[k], 15); - } - - /*TODO : remove float code*/ - if ( ( dirac_output_synthesis_params->alpha_synthesis = (float *) malloc( dirac_output_synthesis_params->numAlphas * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - } - mvr2r( temp_alpha_synthesis, dirac_output_synthesis_params->alpha_synthesis, dirac_output_synthesis_params->numAlphas ); - IF((dirac_output_synthesis_params->alpha_synthesis_fx = (Word16 *)malloc(dirac_output_synthesis_params->numAlphas * sizeof(Word16))) == NULL) { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); @@ -393,9 +376,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( Copy(temp_alpha_synthesis_fx, dirac_output_synthesis_params->alpha_synthesis_fx, dirac_output_synthesis_params->numAlphas); computeAlphaSynthesis_fx( temp_alpha_synthesis_fx, DIRAC_AVG_LENGTH_SYNTH_MS_FAST, DIRAC_ALPHA_MAX_FAST_Q15, &dirac_output_synthesis_params->numAlphasFast, hSpatParamRendCom->slot_size, hSpatParamRendCom->num_freq_bands , hDirACRend->frequency_axis_fx, output_Fs); - for (int k = 0; k < hSpatParamRendCom->num_freq_bands; k++) { - temp_alpha_synthesis[k] = fix16_to_float(temp_alpha_synthesis_fx[k], 15); - } IF ((dirac_output_synthesis_params->alpha_synthesis_fast_fx = (Word16 *)malloc(dirac_output_synthesis_params->numAlphasFast * sizeof(Word16))) == NULL) { @@ -416,13 +396,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( } set32_fx( dirac_output_synthesis_state->direction_smoothness_prev_fx, 0, hSpatParamRendCom->num_freq_bands ); - /*TODO : remove float code*/ - if ((dirac_output_synthesis_params->alpha_synthesis_fast = (float *)malloc(dirac_output_synthesis_params->numAlphasFast * sizeof(float))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); - } - mvr2r(temp_alpha_synthesis, dirac_output_synthesis_params->alpha_synthesis_fast, dirac_output_synthesis_params->numAlphasFast); - if ((dirac_output_synthesis_state->reference_power_smooth_prev = (float *)malloc(hSpatParamRendCom->num_freq_bands * sizeof(float))) == NULL) { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); @@ -436,8 +409,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( } ELSE { - dirac_output_synthesis_params->alpha_synthesis = NULL; - dirac_output_synthesis_params->alpha_synthesis_fast = NULL; dirac_output_synthesis_state->reference_power_smooth_prev = NULL; dirac_output_synthesis_state->direction_smoothness_prev = NULL; #ifdef IVAS_FLOAT_FIXED @@ -449,13 +420,9 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( } /* compute interpolator */ - FOR (idx = 1; idx <= JBM_CLDFB_SLOTS_IN_SUBFRAME; ++idx) + FOR( idx = 1; idx <= JBM_CLDFB_SLOTS_IN_SUBFRAME; ++idx ) { - dirac_output_synthesis_params->interpolator[idx - 1] = (float)idx / (float)JBM_CLDFB_SLOTS_IN_SUBFRAME; - Word16 tmp_exp = 0; - dirac_output_synthesis_params->interpolator_fx[idx - 1] = BASOP_Util_Divide1616_Scale(idx , JBM_CLDFB_SLOTS_IN_SUBFRAME, &tmp_exp); - /*TODO : Remove float code*/ - dirac_output_synthesis_params->interpolator[idx - 1] = me2f_16(dirac_output_synthesis_params->interpolator_fx[idx - 1] , tmp_exp); + dirac_output_synthesis_params->interpolator_fx[idx - 1] = div_s( idx, JBM_CLDFB_SLOTS_IN_SUBFRAME ); } /* prepare diffuse response function */ @@ -517,27 +484,19 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( Word16 exp_1 = 0, exp_2 = 0, tmp; tmp = BASOP_Util_Divide3232_Scale( diff_nrg_total_fx, diff_nrg_trans_fx, &exp_1 ); // (Q15 - exp_diff) dirac_output_synthesis_params->diffuse_compensation_factor_fx = L_shl( L_deposit_l( tmp ), add( Q12, exp_1 ) ); // Q27 - /*TODO : remove float code*/ - dirac_output_synthesis_params->diffuse_compensation_factor = fixedToFloat( dirac_output_synthesis_params->diffuse_compensation_factor_fx, Q27 ); tmp = BASOP_Util_Divide3232_Scale( diff_nrg_total_fx, diff_nrg_decorr_fx, &exp_2 ); // (Q15 - exp_diff) dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx = L_shl( L_deposit_l( tmp ), add( Q14, exp_2 ) ); // Q29 - /*TODO : remove float code*/ - dirac_output_synthesis_params->diffuse_compensation_factor_decorr = fixedToFloat( dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, Q29 ); } ELSE { dirac_output_synthesis_params->diffuse_compensation_factor_fx = 0; dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx = 0; - /*TODO : remove float code*/ - dirac_output_synthesis_params->diffuse_compensation_factor = 0.f; - dirac_output_synthesis_params->diffuse_compensation_factor_decorr = 0.f; } return IVAS_ERR_OK; } #else - ivas_error ivas_dirac_dec_output_synthesis_open( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ @@ -799,6 +758,8 @@ ivas_error ivas_dirac_dec_output_synthesis_open( return IVAS_ERR_OK; } #endif + + /*------------------------------------------------------------------------- * ivas_dirac_dec_output_synthesis_init() * @@ -1012,6 +973,7 @@ void ivas_dirac_dec_output_synthesis_init_fx( * Memory deallocation of Output synthesis sub-module *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_dirac_dec_output_synthesis_close( DIRAC_REND_HANDLE hDirACRend /* i/o: DirAC handle */ ) @@ -1105,8 +1067,7 @@ void ivas_dirac_dec_output_synthesis_close( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void ivas_dirac_dec_output_synthesis_close_fx( DIRAC_REND_HANDLE hDirACRend /* i/o: DirAC handle */ ) @@ -1119,25 +1080,6 @@ void ivas_dirac_dec_output_synthesis_close_fx( * memory deallocation *-----------------------------------------------------------------*/ - /* free interpolator */ - if ((dirac_output_synthesis_params)->interpolator != NULL) - { - free((dirac_output_synthesis_params)->interpolator); - (dirac_output_synthesis_params)->interpolator = NULL; - } - - /* free alpha */ - if ((dirac_output_synthesis_params)->alpha_synthesis != NULL) - { - free((dirac_output_synthesis_params)->alpha_synthesis); - (dirac_output_synthesis_params)->alpha_synthesis = NULL; - } - if ((dirac_output_synthesis_params)->alpha_synthesis_fast != NULL) - { - free((dirac_output_synthesis_params)->alpha_synthesis_fast); - (dirac_output_synthesis_params)->alpha_synthesis_fast = NULL; - } - if ((dirac_output_synthesis_state)->reference_power_smooth_prev != NULL) { free((dirac_output_synthesis_state)->reference_power_smooth_prev); @@ -1281,6 +1223,8 @@ void ivas_dirac_dec_output_synthesis_close_fx( return; } #endif + + /*------------------------------------------------------------------------- * ivas_dirac_dec_output_synthesis_process_slot() * diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 22d9049865430605039fb329151ff21343c54ef6..3210d47e7dba8133f4074dc33dbc33eff480e7f0 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -53,6 +53,7 @@ * Allocate and initialize DirAC parameters *-------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_dirac_allocate_parameters( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ const int16_t params_flag /* i : set of parameters flag */ @@ -183,8 +184,7 @@ ivas_error ivas_dirac_allocate_parameters( return IVAS_ERR_OK; } - -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_dirac_allocate_parameters_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ const Word16 params_flag /* i : set of parameters flag */ @@ -214,15 +214,6 @@ ivas_error ivas_dirac_allocate_parameters_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } - IF ( ( hSpatParamRendCom->spreadCoherence = (float **) malloc( hSpatParamRendCom->dirac_md_buffer_length * sizeof( float * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - - IF ( ( hSpatParamRendCom->surroundingCoherence = (float **) malloc( hSpatParamRendCom->dirac_md_buffer_length * sizeof( float * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } #ifdef IVAS_FLOAT_FIXED IF ( ( hSpatParamRendCom->diffuseness_vector_fx = (Word32 **) malloc( hSpatParamRendCom->dirac_md_buffer_length * sizeof( Word32 * ) ) ) == NULL ) { @@ -269,17 +260,6 @@ ivas_error ivas_dirac_allocate_parameters_fx( } set_f( hSpatParamRendCom->energy_ratio1[i], 0.0f, hSpatParamRendCom->num_freq_bands ); - IF ( ( hSpatParamRendCom->spreadCoherence[i] = (float *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - set_f( hSpatParamRendCom->spreadCoherence[i], 0.0f, hSpatParamRendCom->num_freq_bands ); - - IF ( ( hSpatParamRendCom->surroundingCoherence[i] = (float *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - set_f( hSpatParamRendCom->surroundingCoherence[i], 0.0f, hSpatParamRendCom->num_freq_bands ); #ifdef IVAS_FLOAT_FIXED IF ( ( hSpatParamRendCom->diffuseness_vector_fx[i] = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) { @@ -324,10 +304,6 @@ ivas_error ivas_dirac_allocate_parameters_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } - IF ( ( hSpatParamRendCom->spreadCoherence2 = (float **) malloc( hSpatParamRendCom->dirac_md_buffer_length * sizeof( float * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } #ifdef IVAS_FLOAT_FIXED IF ( ( hSpatParamRendCom->energy_ratio2_fx = (Word32 **) malloc( hSpatParamRendCom->dirac_md_buffer_length * sizeof( Word32 * ) ) ) == NULL ) { @@ -360,11 +336,6 @@ ivas_error ivas_dirac_allocate_parameters_fx( } set_f( hSpatParamRendCom->energy_ratio2[i], 0.0f, hSpatParamRendCom->num_freq_bands ); - IF ( ( hSpatParamRendCom->spreadCoherence2[i] = (float *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - set_f( hSpatParamRendCom->spreadCoherence2[i], 0.0f, hSpatParamRendCom->num_freq_bands ); #ifdef IVAS_FLOAT_FIXED IF ( ( hSpatParamRendCom->energy_ratio2_fx[i] = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) { @@ -385,11 +356,14 @@ ivas_error ivas_dirac_allocate_parameters_fx( } #endif + + /*------------------------------------------------------------------------- * ivas_spat_hSpatParamRendCom_config() * * *-------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED ivas_error ivas_spat_hSpatParamRendCom_config_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: IVAS decoder structure */ @@ -535,7 +509,6 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( hSpatParamRendCom->spreadCoherence2_fx = NULL; /*TODO: to remove float*/ hSpatParamRendCom->energy_ratio2 = NULL; - hSpatParamRendCom->spreadCoherence2 = NULL; } } @@ -684,6 +657,7 @@ ivas_error ivas_spat_hSpatParamRendCom_config( * *-------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_spat_hSpatParamRendCom_close( SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out ) { @@ -699,11 +673,11 @@ void ivas_spat_hSpatParamRendCom_close( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void ivas_spat_hSpatParamRendCom_close_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out) { + test(); IF (hSpatParamRendCom_out == NULL || *hSpatParamRendCom_out == NULL) { return; @@ -723,6 +697,7 @@ void ivas_spat_hSpatParamRendCom_close_fx( * * *-------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void ivas_dirac_rend_close_fx( DIRAC_REND_HANDLE *hDirACRend_out) @@ -752,13 +727,8 @@ void ivas_dirac_rend_close_fx( /* Params */ - /* free frequency axis buffer */ - IF (hDirACRend->frequency_axis != NULL) - { - free(hDirACRend->frequency_axis); - hDirACRend->frequency_axis = NULL; - } #ifdef IVAS_FLOAT_FIXED + /* free frequency axis buffer */ IF(hDirACRend->frequency_axis_fx != NULL) { free(hDirACRend->frequency_axis_fx); @@ -775,17 +745,6 @@ void ivas_dirac_rend_close_fx( hDirACRend->hoa_encoder_fx = NULL; } #endif - IF (hDirACRend->diffuse_response_function != NULL) - { - free(hDirACRend->diffuse_response_function); - hDirACRend->diffuse_response_function = NULL; - } - - IF (hDirACRend->hoa_encoder != NULL) - { - free(hDirACRend->hoa_encoder); - hDirACRend->hoa_encoder = NULL; - } #ifdef IVAS_FLOAT_FIXED IF (hDirACRend->hoa_encoder_fx != NULL) { @@ -966,6 +925,8 @@ void ivas_dirac_rend_close( return; } #endif + + /*------------------------------------------------------------------------- * ivas_dirac_deallocate_parameters() * @@ -1078,20 +1039,6 @@ void ivas_dirac_deallocate_parameters_fx( hSpatParamRendCom->diffuseness_vector_fx = NULL; } - if (hSpatParamRendCom->spreadCoherence != NULL) - { - for (i = 0; i < md_buffer_length; i++) - { - if (hSpatParamRendCom->spreadCoherence[i] != NULL) - { - free(hSpatParamRendCom->spreadCoherence[i]); - hSpatParamRendCom->spreadCoherence[i] = NULL; - } - } - free(hSpatParamRendCom->spreadCoherence); - hSpatParamRendCom->spreadCoherence = NULL; - } - if (hSpatParamRendCom->spreadCoherence_fx != NULL) { for (i = 0; i < md_buffer_length; i++) @@ -1106,20 +1053,6 @@ void ivas_dirac_deallocate_parameters_fx( hSpatParamRendCom->spreadCoherence_fx = NULL; } - if (hSpatParamRendCom->surroundingCoherence != NULL) - { - for (i = 0; i < md_buffer_length; i++) - { - if (hSpatParamRendCom->surroundingCoherence[i] != NULL) - { - free(hSpatParamRendCom->surroundingCoherence[i]); - hSpatParamRendCom->surroundingCoherence[i] = NULL; - } - } - free(hSpatParamRendCom->surroundingCoherence); - hSpatParamRendCom->surroundingCoherence = NULL; - } - if (hSpatParamRendCom->surroundingCoherence_fx != NULL) { for (i = 0; i < md_buffer_length; i++) @@ -1192,20 +1125,6 @@ void ivas_dirac_deallocate_parameters_fx( hSpatParamRendCom->energy_ratio2_fx = NULL; } - if (hSpatParamRendCom->spreadCoherence2 != NULL) - { - for (i = 0; i < md_buffer_length; i++) - { - if (hSpatParamRendCom->spreadCoherence2[i] != NULL) - { - free(hSpatParamRendCom->spreadCoherence2[i]); - hSpatParamRendCom->spreadCoherence2[i] = NULL; - } - } - free(hSpatParamRendCom->spreadCoherence2); - hSpatParamRendCom->spreadCoherence2 = NULL; - } - if (hSpatParamRendCom->spreadCoherence2_fx != NULL) { for (i = 0; i < md_buffer_length; i++) @@ -1223,8 +1142,7 @@ void ivas_dirac_deallocate_parameters_fx( return; } -#endif - +#else void ivas_dirac_deallocate_parameters( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ const int16_t params_flag /* i : set of parameters flag */ @@ -1390,6 +1308,7 @@ void ivas_dirac_deallocate_parameters( return; } +#endif /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 9f461a59011f04b9318c99f1cf603b503b2dd415..a37504cb9af48f4b5b6f0bff96a01eed1e512cb5 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -269,8 +269,6 @@ ivas_error ivas_td_binaural_open_unwrap_fx( IF( NE_16( ivas_format, MASA_ISM_FORMAT ) && NE_16( ivas_format, SBA_ISM_FORMAT ) ) { - // To be removed later - ( *hBinRendererTd )->HrFiltSet_p->latency_s_fx = floatToFixed( ( *hBinRendererTd )->HrFiltSet_p->latency_s, 31 ); *binaural_latency_ns = Mult_32_32( ( *hBinRendererTd )->HrFiltSet_p->latency_s_fx, 1000000000 ); } @@ -501,6 +499,7 @@ ivas_error ivas_td_binaural_open_unwrap( * * Close TD Object binaural renderer *---------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void ivas_td_binaural_close_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */ @@ -510,15 +509,18 @@ void ivas_td_binaural_close_fx( { return; } + free( ( *hBinRendererTd )->TdRend_MixSpatSpec_p ); free( ( *hBinRendererTd )->DirAtten_p ); + TDREND_MIX_Dealloc_fx( *hBinRendererTd ); + free( *hBinRendererTd ); *hBinRendererTd = NULL; + return; } -#endif // IVAS_FLOAT_FIXED - +#else void ivas_td_binaural_close( BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */ ) @@ -538,6 +540,7 @@ void ivas_td_binaural_close( return; } +#endif /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index 95a36a8db14b3369149a6a4cca18a80e9b0bc74b..76c146dd2004d9b2b251821a8bbfdbc9e32dcbd7 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -198,6 +198,7 @@ void TDREND_MIX_Dealloc_fx( ) { Word16 i; + /* Deallocate source list */ FOR ( i = 0; i < hBinRendererTd->NumOfSrcs; i++ ) { @@ -221,28 +222,6 @@ void TDREND_MIX_Dealloc_fx( } ELSE { -#if 1 - IF( hBinRendererTd->HrFiltSet_p->Elev_p != NULL ) - { - free( hBinRendererTd->HrFiltSet_p->Elev_p ); - hBinRendererTd->HrFiltSet_p->Elev_p = NULL; - } - IF( hBinRendererTd->HrFiltSet_p->Azim_p != NULL ) - { - free( hBinRendererTd->HrFiltSet_p->Azim_p ); - hBinRendererTd->HrFiltSet_p->Azim_p = NULL; - } - IF( hBinRendererTd->HrFiltSet_p->LeftFiltSet_p != NULL ) - { - free( hBinRendererTd->HrFiltSet_p->LeftFiltSet_p ); - hBinRendererTd->HrFiltSet_p->LeftFiltSet_p = NULL; - } - IF( hBinRendererTd->HrFiltSet_p->RightFiltSet_p != NULL ) - { - free( hBinRendererTd->HrFiltSet_p->RightFiltSet_p ); - hBinRendererTd->HrFiltSet_p->RightFiltSet_p = NULL; - } -#endif // 1 IF ( hBinRendererTd->HrFiltSet_p->Elev_p_fx != NULL ) { free( hBinRendererTd->HrFiltSet_p->Elev_p_fx); @@ -267,9 +246,10 @@ void TDREND_MIX_Dealloc_fx( free( hBinRendererTd->HrFiltSet_p ); hBinRendererTd->HrFiltSet_p = NULL; } + return; } -#endif // IVAS_FLOAT_FIXED +#else void TDREND_MIX_Dealloc( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle */ ) @@ -324,6 +304,7 @@ void TDREND_MIX_Dealloc( return; } +#endif /*-------------------------------------------------------------------* @@ -1025,10 +1006,9 @@ static ivas_error DefaultBSplineModel_fx( move16(); modelITD->azimBsShape_fx = defaultHRIR_rom_ITD_azimBsShape_fx; modelITD->elevBsShape_fx = defaultHRIR_rom_ITD_elevBsShape_fx; + HRTF_model_precalc( model ); -#if 1/*To be removed later : floating point initialization*/ - HrFiltSet_p->latency_s = defaultHRIR_rom_latency_s; -#endif + HrFiltSet_p->latency_s_fx = defaultHRIR_rom_latency_s_fx; move32(); HrFiltSet_p->SampleRate = output_Fs; diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.c b/lib_rend/ivas_rom_TdBinauralRenderer.c index 95d0e4514b554294ab25fdb077a89ea5d3450e2a..2bd48fa600f6b499763ff9698b83ac8048a4e826 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.c +++ b/lib_rend/ivas_rom_TdBinauralRenderer.c @@ -45,7 +45,7 @@ *------------------------------------------------------------------------*/ /* TD renderer default HRIR model */ const float defaultHRIR_rom_latency_s = 0.000020834f; -const Word32 defaultHRIR_rom_latency_s_fx = 44741;/*Q-31*/ +const Word32 defaultHRIR_rom_latency_s_fx = 44741; /* Q31 */ const int16_t defaultHRIR_rom_azimDim2[15] = { 1, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 1, }; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index bc48b7d3fffac5096eb1f6ad964a3e37f4b05ceb..4bae85cf657daabfe602613f6db279eecfcb6808 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -139,11 +139,12 @@ typedef struct dirac_onset_detection_params_structure typedef struct dirac_onset_detection_state_structure { +#ifndef IVAS_FLOAT_FIXED float *onset_detector_1; float *onset_detector_2; -#ifdef IVAS_FLOAT_FIXED - Word32 *onset_detector_1_fx; - Word32 *onset_detector_2_fx; +#else + Word32 *onset_detector_1_fx; /* Q(q_onset_detector) */ + Word32 *onset_detector_2_fx; /* Q(q_onset_detector) */ Word16 q_onset_detector; #endif @@ -157,17 +158,16 @@ typedef struct dirac_decorr_params_structure int16_t *pre_delay; int16_t *filter_length; +#ifndef IVAS_FLOAT_FIXED float *filter_coeff_num_real; float *filter_coeff_den_real; - float *phase_coeff_real; float *phase_coeff_imag; -#ifdef IVAS_FLOAT_FIXED - Word16 *filter_coeff_num_real_fx; - Word16 *filter_coeff_den_real_fx; - - Word16 *phase_coeff_real_fx; - Word16 *phase_coeff_imag_fx; +#else + Word16 *filter_coeff_num_real_fx; /* Q12 */ + Word16 *filter_coeff_den_real_fx; /* Q12 */ + Word16 *phase_coeff_real_fx; /* Q14 */ + Word16 *phase_coeff_imag_fx; /* Q14 */ #endif int16_t *split_frequency_bands; int16_t num_split_frequency_bands; @@ -228,13 +228,14 @@ typedef struct ivas_spatial_parametric_rend_common_data_structure Word32 **energy_ratio2_fx; #endif +#ifndef IVAS_FLOAT_FIXED float **spreadCoherence; float **spreadCoherence2; float **surroundingCoherence; -#ifdef IVAS_FLOAT_FIXED - Word16 **spreadCoherence_fx; - Word16 **spreadCoherence2_fx; - Word16 **surroundingCoherence_fx; +#else + Word16 **spreadCoherence_fx; /* Q15 */ + Word16 **spreadCoherence2_fx; /* Q15 */ + Word16 **surroundingCoherence_fx; /* Q15 */ #endif /* Metadata access indices and buffer size */ @@ -327,27 +328,31 @@ typedef struct dirac_output_synthesis_params_structure int16_t use_onset_filters; +#ifndef IVAS_FLOAT_FIXED float *interpolator; float *alpha_synthesis; float *alpha_synthesis_fast; -#ifdef IVAS_FLOAT_FIXED - Word16 *interpolator_fx; // Q15 - Word16 *alpha_synthesis_fx; - Word16 *alpha_synthesis_fast_fx; +#else + 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; - - float diffuse_compensation_factor; - float diffuse_compensation_factor_decorr; #ifdef IVAS_FLOAT_FIXED Word32 *proto_matrix_fx; Word16 proto_matrix_e; Word16 proto_matrix_len; - Word32 diffuse_compensation_factor_fx; // Q27 - Word32 diffuse_compensation_factor_decorr_fx; // Q29 +#endif + +#ifndef IVAS_FLOAT_FIXED + float diffuse_compensation_factor; + float diffuse_compensation_factor_decorr; +#else + Word32 diffuse_compensation_factor_fx; /* Q27 */ + Word32 diffuse_compensation_factor_decorr_fx; /* Q29 */ #endif } DIRAC_OUTPUT_SYNTHESIS_PARAMS; @@ -632,27 +637,24 @@ typedef struct ivas_dirac_rend_data_structure int16_t index_buffer_intensity; float *buffer_intensity_real[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; float *buffer_energy; - - float *frequency_axis; - float *diffuse_response_function; #ifdef IVAS_FLOAT_FIXED Word32 *buffer_intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; Word16 q_buffer_intensity_real[CLDFB_NO_CHANNELS_MAX]; Word32 *buffer_energy_fx; Word16 q_buffer_energy[CLDFB_NO_CHANNELS_MAX]; - Word16 *diffuse_response_function_fx; - Word16 diffuse_response_function_q; // Q15 - Word16 *frequency_axis_fx; - Word32 *hoa_encoder_fx; // Q29 - Word16 hoa_encoder_len; #endif - float *hoa_encoder; + #ifndef IVAS_FLOAT_FIXED + float *frequency_axis; + float *diffuse_response_function; + float *hoa_encoder; const float *hoa_decoder; #else - const Word32 *hoa_decoder; + Word16 *frequency_axis_fx; /* Q0 */ + Word16 *diffuse_response_function_fx; /* Q15 */ + Word32 *hoa_encoder_fx; /* Q29 */ + const Word32 *hoa_decoder; /* Q29 */ #endif - /*Decoder parameters */ /*Prototypes*/ int16_t num_outputs_dir; @@ -912,9 +914,10 @@ typedef struct ivas_dirac_dec_binaural_data_structure #endif uint16_t useTdDecorr; ivas_td_decorr_state_t *hTdDecorr; +#ifndef IVAS_FLOAT_FIXED float reqularizationFactor; -#ifdef IVAS_FLOAT_FIXED - Word16 reqularizationFactor_fx; +#else + Word16 reqularizationFactor_fx; /* Q14 */ #endif DIFFUSE_DISTRIBUTION_HANDLE hDiffuseDist; @@ -1063,17 +1066,18 @@ typedef struct ivas_orient_trk_state_t float centerAdaptationRate; float offCenterAdaptationRate; float adaptationAngle; - float alpha; -#endif - -#ifdef IVAS_FLOAT_FIXED +#else Word32 centerAdaptationRate_fx; /* Q31 */ Word32 offCenterAdaptationRate_fx; /* Q31 */ Word32 adaptationAngle_fx; /* Q29 */ #endif - Word32 alpha_fx; +#ifndef IVAS_FLOAT_FIXED + float alpha; +#else + Word32 alpha_fx; /* Q(Q_alpha) */ Word16 Q_alpha; +#endif IVAS_QUATERNION absAvgRot; /* average absolute orientation */ IVAS_QUATERNION refRot; /* reference orientation */ IVAS_QUATERNION trkRot; /* tracked rotation */ @@ -1727,30 +1731,40 @@ typedef struct TDREND_HRFILT_FiltSet_struct int32_t SampleRate; /* Sample rate of the HR filter */ int16_t NumPos; int16_t NumElev; +#ifndef IVAS_FLOAT_FIXED float Dist; float *ItdSet_p; +#else + Word32 Dist_fx; + Word32 *ItdSet_p_fx; +#endif int16_t FiltLength; +#ifndef IVAS_FLOAT_FIXED float *Azim_p; float *Elev_p; float *ItdSetNominal_p; float *LeftFiltSet_p; float *RightFiltSet_p; +#else + Word16 *Azim_p_fx; + Word16 *Elev_p_fx; + Word16 *ItdSetNominal_p_fx; + Word16 *LeftFiltSet_p_fx; + Word16 *RightFiltSet_p_fx; +#endif ModelParams_t ModelParams; ModelEval_t ModelEval; ModelParamsITD_t ModelParamsITD; TDREND_HRFILT_Method_t FilterMethod; /* HR filtering method */ +#ifndef IVAS_FLOAT_FIXED float latency_s; const float *lr_energy_and_iac[3]; /* left/right energy and interaural coherence for late reverb */ -#ifdef IVAS_FLOAT_FIXED - Word16 *Azim_p_fx; - Word16 *Elev_p_fx; - Word16 *LeftFiltSet_p_fx; - Word16 *RightFiltSet_p_fx; - Word32 *lr_energy_and_iac_dyn_fx[3]; + float *lr_energy_and_iac_dyn[3]; +#else + Word32 latency_s_fx; /* Q31 */ const Word32 *lr_energy_and_iac_fx[3]; /* left/right energy and interaural coherence for late reverb */ - Word32 latency_s_fx;/*Q-31*/ + Word32 *lr_energy_and_iac_dyn_fx[3]; #endif // IVAS_FLOAT_FIXED - float *lr_energy_and_iac_dyn[3]; } TDREND_HRFILT_FiltSet_t; @@ -1766,7 +1780,7 @@ typedef struct Word32 RefDist_fx; /* Q30 */ Word32 MaxDist_fx; /* Q27 */ Word32 RollOffFactor_fx; /* Q30 */ -#endif // IVAS_FLOAT_FIXED +#endif // IVAS_FLOAT_FIXED- } TDREND_DistAtten_t; @@ -2026,9 +2040,10 @@ typedef struct ivas_hrtfs_fastconv_struct #ifdef IVAS_FLOAT_FIXED Word32 FASTCONV_HOA3_latency_s_fx; Word32 FASTCONV_HRIR_latency_s_fx; -#endif +#else float FASTCONV_HOA3_latency_s; float FASTCONV_HRIR_latency_s; +#endif #ifdef IVAS_FLOAT_FIXED Word32 ***leftHRIRReal_HOA3_fx; @@ -2333,9 +2348,6 @@ typedef struct ivas_mcmasa_ana_data_structure Word32 prevDownmixEne_fx; Word32 prevEQ_fx; Word16 interpolator_fx[L_FRAME48k]; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; Word16 chnlToFoaMtx_e; Word16 prevMultiChEne_e; Word16 prevDownmixEne_e; @@ -2371,7 +2383,13 @@ typedef struct ivas_mcmasa_ana_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; +#ifndef IVAS_FLOAT_FIXED float energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; +#else + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; +#endif } MCMASA_ANA_DATA, *MCMASA_ANA_HANDLE; @@ -2476,8 +2494,9 @@ typedef struct ivas_dirac_ana_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; +#ifndef IVAS_FLOAT_FIXED float energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; -#ifdef IVAS_FLOAT_FIXED +#else Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -2523,8 +2542,9 @@ typedef struct ivas_masa_prerend_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; +#ifndef IVAS_FLOAT_FIXED float energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; -#ifdef IVAS_FLOAT_FIXED +#else Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES]; #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index eabff932b65889e92df9e3c469b18d2b72d2039f..92088eed9ebabc973d528fbb0ed132888a2f9f3d 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -5117,16 +5117,6 @@ static ivas_error setRendInputActiveMasa( #if 1 /*TODO: To be removed later(fixed to float)*/ IF( inputMasa->hMasaExtRend ) { - DIRAC_REND_HANDLE hDirACRend = inputMasa->hMasaExtRend->hDirACRend; - IF( hDirACRend ) - { - FOR( int i = 0; i < hDirACRend->num_outputs_dir; i++ ) - { - hDirACRend->diffuse_response_function[i] = fix16_to_float( hDirACRend->diffuse_response_function_fx[i], Q15 ); - } - IF( hDirACRend->hoa_encoder_fx ) - fixedToFloat_arrL( hDirACRend->hoa_encoder_fx, hDirACRend->hoa_encoder, Q29, hDirACRend->hoa_encoder_len ); - } IF( inputMasa->hMasaExtRend->hDiracDecBin ) fixedToFloat_arrL( inputMasa->hMasaExtRend->hDiracDecBin->earlyPartEneCorrection_fx, inputMasa->hMasaExtRend->hDiracDecBin->earlyPartEneCorrection, (Word16) Q28 /*1.0f Q28*/, (Word16) CLDFB_NO_CHANNELS_MAX ); } @@ -11714,8 +11704,6 @@ static void copyMasaMetadataToDiracRenderer_fx( hSpatParamRendCom->elevation[meta_write_index][bin] = (int16_t) meta->directional_meta[0].elevation[sf][band]; hSpatParamRendCom->energy_ratio1[meta_write_index][bin] = meta->directional_meta[0].energy_ratio[sf][band]; hSpatParamRendCom->diffuseness_vector[meta_write_index][bin] = 1.0f - meta->directional_meta[0].energy_ratio[sf][band]; - hSpatParamRendCom->spreadCoherence[meta_write_index][bin] = meta->directional_meta[0].spread_coherence[sf][band]; - hSpatParamRendCom->surroundingCoherence[meta_write_index][bin] = meta->common_meta.surround_coherence[sf][band]; #endif @@ -11735,7 +11723,6 @@ static void copyMasaMetadataToDiracRenderer_fx( hSpatParamRendCom->elevation2[meta_write_index][bin] = (int16_t) meta->directional_meta[1].elevation[sf][band]; hSpatParamRendCom->energy_ratio2[meta_write_index][bin] = meta->directional_meta[1].energy_ratio[sf][band]; hSpatParamRendCom->diffuseness_vector[meta_write_index][bin] -= meta->directional_meta[1].energy_ratio[sf][band]; - hSpatParamRendCom->spreadCoherence2[meta_write_index][bin] = meta->directional_meta[1].spread_coherence[sf][band]; #endif } @@ -13078,14 +13065,6 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( hDirACRend->panningConf = DIRAC_PANNING_HOA3; } -#if 1 /*TODO: To be removed later(floating buffer malloc and init)*/ - IF( ( hDirACRend->frequency_axis = (float *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - set_f( hDirACRend->frequency_axis, 0.0f, hSpatParamRendCom->num_freq_bands ); - -#endif IF( ( hDirACRend->frequency_axis_fx = (Word16 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); @@ -13243,12 +13222,6 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } -#if 1 /*TODO: To be removed later (Float buffer malloc)*/ - if ( ( hDirACRend->diffuse_response_function = (float *) malloc( sizeof( float ) * hDirACRend->num_outputs_dir ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } -#endif IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { @@ -13261,9 +13234,6 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( hDirACRend->hOutSetup, hDirACRend->hOutSetup.ambisonics_order, MASA_FORMAT, &hDirACRend->num_ele_spk_no_diffuse_rendering, IVAS_AUDIO_CONFIG_INVALID ); } -#if 1 /*TODO: To be removed later(after dependecny on float buffer hoa_encoder is removed)*/ - hDirACRend->hoa_encoder = NULL; -#endif hDirACRend->hoa_encoder_fx = NULL; IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) { @@ -13273,15 +13243,6 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } set32_fx( hDirACRend->hoa_encoder_fx, 0, nchan_out_woLFE * hDirACRend->num_outputs_diff ); - hDirACRend->hoa_encoder_len = imult1616( nchan_out_woLFE, hDirACRend->num_outputs_diff ); -#if 1 /*TODO: To be removed later(float buffer malloc and init)*/ - if ( ( hDirACRend->hoa_encoder = (float *) malloc( nchan_out_woLFE * hDirACRend->num_outputs_diff * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - - set_f( hDirACRend->hoa_encoder, 0.0f, nchan_out_woLFE * hDirACRend->num_outputs_diff ); -#endif compute_hoa_encoder_mtx_fx( ls_azimuth_fx, ls_elevation_fx, hDirACRend->hoa_encoder_fx, hDirACRend->num_outputs_diff, hDirACRend->hOutSetup.ambisonics_order ); } @@ -14450,7 +14411,11 @@ static void freeMasaExtRenderer( if ( hMasaExtRend->hSpatParamRendCom != NULL ) { +#ifdef IVAS_FLOAT_FIXED + ivas_spat_hSpatParamRendCom_close_fx( &hMasaExtRend->hSpatParamRendCom ); +#else ivas_spat_hSpatParamRendCom_close( &hMasaExtRend->hSpatParamRendCom ); +#endif // IVAS_FLOAT_FIXED } if ( hMasaExtRend->hDiracDecBin != NULL ) @@ -14558,7 +14523,6 @@ static void intermidiate_ext_dirac_render( for ( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[slot_idx]][i] = floatToFixed( hSpatParamRendCom->diffuseness_vector[hSpatParamRendCom->render_to_md_map[slot_idx]][i], Q30 ); - floatToFixed_arr(hSpatParamRendCom->surroundingCoherence[slot_idx], hSpatParamRendCom->surroundingCoherence_fx[slot_idx], Q15, hSpatParamRendCom->num_freq_bands ); } } for(slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++){ @@ -14566,15 +14530,11 @@ static void intermidiate_ext_dirac_render( { IF( EQ_16( hSpatParamRendCom->numParametricDirections, 2 ) ) { - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, Q15, hDirACRend->num_outputs_dir ); floatToFixed_arrL( hSpatParamRendCom->energy_ratio1[slot_idx], hSpatParamRendCom->energy_ratio1_fx[slot_idx], Q30, hSpatParamRendCom->num_freq_bands ); floatToFixed_arrL( hSpatParamRendCom->energy_ratio2[slot_idx], hSpatParamRendCom->energy_ratio2_fx[slot_idx], Q30, hSpatParamRendCom->num_freq_bands ); } hDirACRend->h_output_synthesis_psd_state.direct_responses_q = 30; 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 ) ); - floatToFixed_arr(hSpatParamRendCom->spreadCoherence[slot_idx], hSpatParamRendCom->spreadCoherence_fx[slot_idx], Q15, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr(hSpatParamRendCom->spreadCoherence2[slot_idx], hSpatParamRendCom->spreadCoherence2_fx[slot_idx], Q15, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, Q15, hDirACRend->num_outputs_dir ); floatToFixed_arrL( hSpatParamRendCom->energy_ratio1[slot_idx], hSpatParamRendCom->energy_ratio1_fx[slot_idx], Q30, hSpatParamRendCom->num_freq_bands ); floatToFixed_arrL( hSpatParamRendCom->energy_ratio2[slot_idx], hSpatParamRendCom->energy_ratio2_fx[slot_idx], Q30, hSpatParamRendCom->num_freq_bands ); } @@ -14592,9 +14552,6 @@ static void intermidiate_ext_dirac_render( { hDirACRend->h_output_synthesis_psd_state.direct_responses_q = 30; 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 ) ); - floatToFixed_arr(hSpatParamRendCom->spreadCoherence[slot_idx], hSpatParamRendCom->spreadCoherence_fx[slot_idx], Q15, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr(hSpatParamRendCom->spreadCoherence2[slot_idx], hSpatParamRendCom->spreadCoherence2_fx[slot_idx], Q15, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, Q15, hDirACRend->num_outputs_dir ); floatToFixed_arrL( hSpatParamRendCom->energy_ratio1[slot_idx], hSpatParamRendCom->energy_ratio1_fx[slot_idx], Q30, hSpatParamRendCom->num_freq_bands ); floatToFixed_arrL( hSpatParamRendCom->energy_ratio2[slot_idx], hSpatParamRendCom->energy_ratio2_fx[slot_idx], Q30, hSpatParamRendCom->num_freq_bands ); } @@ -14602,9 +14559,6 @@ static void intermidiate_ext_dirac_render( { hDirACRend->h_output_synthesis_psd_state.direct_responses_q = 30; 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 ) ); - floatToFixed_arr(hSpatParamRendCom->spreadCoherence[slot_idx], hSpatParamRendCom->spreadCoherence_fx[slot_idx], Q15, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr(hSpatParamRendCom->spreadCoherence2[slot_idx], hSpatParamRendCom->spreadCoherence2_fx[slot_idx], Q15, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, Q15, hDirACRend->num_outputs_dir ); floatToFixed_arrL( hSpatParamRendCom->energy_ratio1[slot_idx], hSpatParamRendCom->energy_ratio1_fx[slot_idx], Q30, hSpatParamRendCom->num_freq_bands ); floatToFixed_arrL( hSpatParamRendCom->energy_ratio2[slot_idx], hSpatParamRendCom->energy_ratio2_fx[slot_idx], Q30, hSpatParamRendCom->num_freq_bands ); } @@ -14614,9 +14568,6 @@ static void intermidiate_ext_dirac_render( { hDirACRend->h_output_synthesis_psd_state.direct_responses_q = 30; 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 ) ); - floatToFixed_arr(hSpatParamRendCom->spreadCoherence[slot_idx], hSpatParamRendCom->spreadCoherence_fx[slot_idx], Q15, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr(hSpatParamRendCom->spreadCoherence2[slot_idx], hSpatParamRendCom->spreadCoherence2_fx[slot_idx], Q15, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, Q15, hDirACRend->num_outputs_dir ); floatToFixed_arrL( hSpatParamRendCom->energy_ratio1[slot_idx], hSpatParamRendCom->energy_ratio1_fx[slot_idx], Q30, hSpatParamRendCom->num_freq_bands ); floatToFixed_arrL( hSpatParamRendCom->energy_ratio2[slot_idx], hSpatParamRendCom->energy_ratio2_fx[slot_idx], Q30, hSpatParamRendCom->num_freq_bands ); } @@ -14656,8 +14607,6 @@ static void intermidiate_ext_dirac_render( 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 ); } - hDirACRend->h_output_synthesis_psd_params.diffuse_compensation_factor_fx = floatToFixed( hDirACRend->h_output_synthesis_psd_params.diffuse_compensation_factor, Q27 ); // Q27 - 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, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_len ); @@ -14720,7 +14669,6 @@ static void intermidiate_ext_dirac_render( } } } - floatToFixed_arrL32( hDirACRend->hoa_encoder, hDirACRend->hoa_encoder_fx, Q29, hDirACRend->hoa_encoder_len ); 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); @@ -14771,7 +14719,6 @@ static void intermidiate_ext_dirac_render( } } - fixedToFloat_arr( hDirACRend->h_output_synthesis_psd_params.interpolator_fx, hDirACRend->h_output_synthesis_psd_params.interpolator, Q15, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); fixedToFloat_arrL(hDirACRend->stack_mem.onset_filter_fx, hDirACRend->stack_mem.onset_filter, Q30, hDirACRend->stack_mem.onset_filter_len ); if(DirAC_mem.reference_power) { diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index a6267035cdd2f694929f6a87b953d77ebfe845c0..8575ffd296d7270c788a203e64025cee5310930e 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -362,9 +362,16 @@ static ivas_error LoadBSplineBinary( ModelParams_t *model; int16_t i, tmp; - fread( &HrFiltSet_p->latency_s, sizeof( float ), 1, f_hrtf ); #ifdef IVAS_FLOAT_FIXED - HrFiltSet_p->latency_s_fx = float_to_fix( HrFiltSet_p->latency_s, Q31 ); + float f_tmp_latency_s; + float f_tmp_lr_energy_and_iac_dyn[LR_IAC_LENGTH_NR_FC]; +#endif + +#ifndef IVAS_FLOAT_FIXED + fread( &HrFiltSet_p->latency_s, sizeof( float ), 1, f_hrtf ); +#else + fread( &f_tmp_latency_s, sizeof( float ), 1, f_hrtf ); + HrFiltSet_p->latency_s_fx = float_to_fix( f_tmp_latency_s, Q31 ); #endif // IVAS_FLOAT_FIXED model = &( HrFiltSet_p->ModelParams ); @@ -568,15 +575,21 @@ static ivas_error LoadBSplineBinary( /* left/right energy and interaural coherence for late reverb */ for ( i = 0; i < 3; i++ ) { +#ifndef IVAS_FLOAT_FIXED HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); fread( HrFiltSet_p->lr_energy_and_iac_dyn[i], sizeof( const float ), LR_IAC_LENGTH_NR_FC, f_hrtf ); HrFiltSet_p->lr_energy_and_iac[i] = (const float *) HrFiltSet_p->lr_energy_and_iac_dyn[i]; -#ifdef IVAS_FLOAT_FIXED +#else + fread( f_tmp_lr_energy_and_iac_dyn, sizeof( const float ), LR_IAC_LENGTH_NR_FC, f_hrtf ); HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); IF( i == 2 ) - floatToFixed_arr32( HrFiltSet_p->lr_energy_and_iac_dyn[i], HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q27, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + { + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q27, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + } ELSE - floatToFixed_arr32( HrFiltSet_p->lr_energy_and_iac_dyn[i], HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ + { + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ + } HrFiltSet_p->lr_energy_and_iac_fx[i] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[i]; #endif // IVAS_FLOAT_FIXED } @@ -905,8 +918,9 @@ ivas_error dealloc_HRTF_binary( for ( i = 0; i < 3; i++ ) { +#ifndef IVAS_FLOAT_FIXED free( hHrtf->lr_energy_and_iac_dyn[i] ); -#ifdef IVAS_FLOAT_FIXED +#else free( hHrtf->lr_energy_and_iac_dyn_fx[i] ); #endif // IVAS_FLOAT_FIXED }