diff --git a/apps/renderer.c b/apps/renderer.c index bafeec725a15ec43f098b528366779da6b75273a..af75bcb68c3d9db064f248cdea8258f6d30094e3 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1549,7 +1549,11 @@ int main( { if ( args.delayCompensationEnabled ) { +#ifdef IVAS_FLOAT_FIXED + IF( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples, &delayTimeScale ) != IVAS_ERR_OK ) +#else if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples, &delayTimeScale ) != IVAS_ERR_OK ) +#endif // IVAS_FLOAT_FIXED { fprintf( stderr, "\nUnable to get delay of renderer!\n" ); exit( -1 ); diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index a5b76f8d46d80a95ef601c812eb7443cfcca0a5c..0444bac6579400e0e0f089684c6458cea31f0dd5 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -6170,7 +6170,7 @@ void ivas_clear_band_coeff_idx( /*----------------------------------------------------------------------------------* * MASA prototypes *----------------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_masa_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); @@ -6178,6 +6178,7 @@ ivas_error ivas_masa_dec_open( void ivas_masa_dec_close( MASA_DECODER_HANDLE *hMasa /* i/o: MASA metadata structure */ ); +#endif ivas_error ivas_masa_decode( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ @@ -6828,7 +6829,15 @@ void ivas_mono_stereo_downmix_mcmasa( float *output_f[], /* i/o: synthesized core-coder transport channels/mono or stereo output */ int16_t output_frame /* i : output frame length per channel */ ); - +#ifdef IVAS_FLOAT_FIXED +void ivas_lfe_synth_with_filters_fx( + MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, /* i/o: LFE synthesis structure for McMASA */ + Word32 *data_f[], /* o : output signals */ + const Word16 output_frame, /* i : output frame length per channel */ + const Word16 separateChannelIndex, /* i : separate channel index */ + const Word16 lfeChannelIndex /* i : LFE channel index */ +); +#else void ivas_lfe_synth_with_filters( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, /* i/o: LFE synthesis structure for McMASA */ float *data_f[], /* o : output signals */ @@ -6836,7 +6845,7 @@ void ivas_lfe_synth_with_filters( const int16_t separateChannelIndex, /* i : separate channel index */ const int16_t lfeChannelIndex /* i : LFE channel index */ ); - +#endif /*----------------------------------------------------------------------------------* * LFE encoder low pass filter prototypes diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index e360e599edd24f6e5505d82eb37d0fb10639fc98..80c0d9d1acfa4393391590eb7382fcc6510f6d64 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -2309,12 +2309,6 @@ void ivas_binaural_add_LFE_fx( Word32 *output_fx[] /* o : synthesized core-coder transport channels/DirAC output */ ) { -#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - IF( st_ivas->hCrendWrapper != NULL ) - { - st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx = (Word16)(st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe * ( ONE_IN_Q14 )); - } -#endif Word16 render_lfe, idx_lfe; Word16 gain_fx; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 2594011d3ebdc5b6ce0427c43c17cb92e6fe1597..18ca3e140b5dae30dff933a649f1fe2f6125ca80 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3626,6 +3626,7 @@ void ivas_dirac_dec_render_sf_fx( Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; set_zero_fx(surCohRatio_fx, CLDFB_NO_CHANNELS_MAX); Word16 q_cldfb, q_temp_cldfb = 0; + Word16 proto_length = 0; //Word32 proto_frame_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; Word32 proto_direct_buffer_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; @@ -3750,15 +3751,6 @@ void ivas_dirac_dec_render_sf_fx( floatToFixed_arrL32( st_ivas->cldfbAnaDec[1]->cldfb_state, st_ivas->cldfbAnaDec[1]->cldfb_state_fx, Q11, ( st_ivas->cldfbAnaDec[1]->p_filter_length - st_ivas->cldfbAnaDec[1]->no_channels ) ); } - IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && !hDirACRend->hOutSetup.separateChannelEnabled && !( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && EQ_16( hDirACRend->hOutSetup.num_lfe, 0 ) ) ) - { - st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth_fx = floatToFixed_32( st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth, st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth_q ); - st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth_fx = floatToFixed_32( st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth, st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth_q ); - f2me( st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth, &st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_fx, &st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_q ); - st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_q = sub( 31, st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_q ); - st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_fx = floatToFixed_32( st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth, st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_q ); - } - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); @@ -4325,10 +4317,6 @@ void ivas_dirac_dec_render_sf_fx( } fixedToFloat_arrL32( Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS - 1][slot_idx], Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1][slot_idx], Q6, CLDFB_NO_CHANNELS_MAX ); fixedToFloat_arrL32( Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS - 1][slot_idx], Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1][slot_idx], Q6, CLDFB_NO_CHANNELS_MAX ); - st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth = fixedToFloat_32( st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth_fx, st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth_q ); - st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth = fixedToFloat_32( st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth_fx, st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth_q ); - st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth = me2f( st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_fx, sub( 31, st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_q ) ); - st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth = fixedToFloat_32( st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_fx, st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_q ); } IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) @@ -4353,6 +4341,7 @@ void ivas_dirac_dec_render_sf_fx( fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 4, hSpatParamRendCom->num_freq_bands ) ); fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); + proto_length = i_mult(6, hSpatParamRendCom->num_freq_bands); fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); IF( hDirACRend->masa_stereo_type_detect ) { @@ -4371,6 +4360,7 @@ void ivas_dirac_dec_render_sf_fx( fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); fixedToFloat_arrL32( &proto_direct_buffer_f_fx[offset], &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f[offset], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); + proto_length = i_mult(2, i_mult(hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff)); fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); BREAK; case 2: @@ -4389,12 +4379,14 @@ void ivas_dirac_dec_render_sf_fx( } } fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); + proto_length = i_mult(6, hSpatParamRendCom->num_freq_bands); fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); BREAK; case 1: fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands ); fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ) ); + proto_length = i_mult(2, i_mult(hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff)); fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); BREAK; } @@ -4942,12 +4934,32 @@ void ivas_dirac_dec_render_sf_fx( /*-----------------------------------------------------------------* * frequency domain decorrelation *-----------------------------------------------------------------*/ - + Word16 scale = 0, temp_len = 0; if ( hDirACRend->proto_signal_decorr_on == 1 ) { /* decorrelate prototype frame */ if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { +#ifdef IVAS_FLOAT_FIXED + ivas_dirac_dec_decorr_process_fx(hSpatParamRendCom->num_freq_bands, + hDirACRend->num_outputs_diff, + hDirACRend->num_protos_diff, + hDirACRend->synthesisConf, + nchan_transport, + &proto_diffuse_buffer_f_fx [slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff], + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, + hDirACRend->num_protos_diff, + hDirACRend->proto_index_diff, + &proto_diffuse_buffer_f_fx[slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * min(4, nchan_transport)], + &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, + onset_filter_fx, + hDirACRend->h_freq_domain_decorr_ap_params, + hDirACRend->h_freq_domain_decorr_ap_state); + + + fixedToFloat_arrL(onset_filter_fx, onset_filter, Q31, hSpatParamRendCom->num_freq_bands ); + +#else ivas_dirac_dec_decorr_process( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff, hDirACRend->num_protos_diff, @@ -4960,6 +4972,7 @@ void ivas_dirac_dec_render_sf_fx( onset_filter, hDirACRend->h_freq_domain_decorr_ap_params, hDirACRend->h_freq_domain_decorr_ap_state ); +#endif v_multc( onset_filter, 0.25f, onset_filter, hSpatParamRendCom->num_freq_bands ); v_add( onset_filter, onset_filter_subframe, onset_filter_subframe, hSpatParamRendCom->num_freq_bands ); @@ -4970,8 +4983,31 @@ void ivas_dirac_dec_render_sf_fx( p_onset_filter_fx = onset_filter_subframe_fx; #endif } - else + ELSE { +#ifdef IVAS_FLOAT_FIXED + scale = L_norm_arr(hDirACRend->proto_frame_f_fx, proto_length); + Scale_sig32(hDirACRend->proto_frame_f_fx, proto_length, scale); + hDirACRend->proto_frame_f_q = add(hDirACRend->proto_frame_f_q, scale); + ivas_dirac_dec_decorr_process_fx(hSpatParamRendCom->num_freq_bands, + hDirACRend->num_outputs_diff, + hDirACRend->num_protos_diff, + hDirACRend->synthesisConf, + nchan_transport, + hDirACRend->proto_frame_f_fx, + hDirACRend->proto_frame_f_q, + hDirACRend->num_protos_diff, + hDirACRend->proto_index_diff, + DirAC_mem.frame_dec_f_fx, + &DirAC_mem.frame_dec_f_q, + onset_filter_fx, + hDirACRend->h_freq_domain_decorr_ap_params, + hDirACRend->h_freq_domain_decorr_ap_state); + + temp_len = DirAC_mem.frame_dec_f_len; + fixedToFloat_arrL(onset_filter_fx, onset_filter, Q31, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff); + me2f_buf(DirAC_mem.frame_dec_f_fx, 31- DirAC_mem.frame_dec_f_q , DirAC_mem.frame_dec_f , temp_len); +#else ivas_dirac_dec_decorr_process( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff, hDirACRend->num_protos_diff, @@ -4984,9 +5020,11 @@ void ivas_dirac_dec_render_sf_fx( onset_filter, hDirACRend->h_freq_domain_decorr_ap_params, hDirACRend->h_freq_domain_decorr_ap_state ); +#endif hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f; p_onset_filter = onset_filter; + #ifdef IVAS_FLOAT_FIXED hDirACRend->proto_frame_dec_f_fx = DirAC_mem.frame_dec_f_fx; hDirACRend->proto_frame_dec_f_q = DirAC_mem.frame_dec_f_q; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index a4b34f908ad698394aeb5dea78bd91aaaeedff90..e558dda691fb39949b22fd4dbabf3493bc0a82a5 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -1161,7 +1161,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( Word32 mixing_matrix_smooth_fx[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; Word16 mixing_matrix_smooth_e; Word32 mixing_matrix_res_smooth_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - Word16 mixing_matrix_res_smooth_e; + Word16 mixing_matrix_res_smooth_e = 0; Word32 mixing_matrix_buffer_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; Word16 mixing_matrix_buffer_e; Word32 input_f_real_fx[PARAM_MC_MAX_TRANSPORT_CHANS]; @@ -1172,8 +1172,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( Word16 output_f_imag_e; Word32 diff_f_real_fx[MAX_CICP_CHANNELS]; Word32 diff_f_imag_fx[MAX_CICP_CHANNELS]; - Word16 diff_f_real_e; - Word16 diff_f_imag_e; set_zero_fx( input_f_real_fx, PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero_fx( input_f_imag_fx, PARAM_MC_MAX_TRANSPORT_CHANS ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index c27587e1b3872938a7162dbe4c7d401d0231e6f7..80173b9fa36c912dbe9f308f74891d195b98931b 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -72,15 +72,6 @@ ivas_error ivas_dec_setup( { #ifdef IVAS_FLOAT_FIXED/*TODO:To be removed later*/ RENDER_CONFIG_DATA *hRendCfg = st_ivas->hRenderConfig; - HRTFS_CREND_HANDLE hSetOfHRTF = st_ivas->hSetOfHRTF; - IF( hSetOfHRTF ) - { - hSetOfHRTF->hHRTF_brir_combined->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_brir_combined->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_foa->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_foa->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_combined->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_combined->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_hoa3->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_hoa3->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_hoa2->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_hoa2->latency_s, 31 ); - } IF( hRendCfg ) { hRendCfg->roomAcoustics.acousticPreDelay_fx = floatToFixed( hRendCfg->roomAcoustics.acousticPreDelay, 27 ); @@ -875,14 +866,6 @@ ivas_error ivas_dec_setup( st->total_brate = ACELP_8k00; /* only temporary initialization - this is needed for get_next_indice() in the frame following NO_DATA frame */ } -#ifdef IVAS_FLOAT_FIXED/*Cleanup changes: fixed to float*/ - IF( st_ivas->hCrendWrapper != NULL ) - { - st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); - st_ivas->hCrendWrapper->hHrtfCrend->latency_s = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->latency_s_fx, 31 ); - fixedToFloat_arr( st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight_fx, st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); - } -#endif return error; } @@ -2257,10 +2240,81 @@ ivas_error ivas_init_decoder_fx( } ELSE IF ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { +#ifdef IVAS_FLOAT_FIXED +#if 1 /*Cleanup changes: float to fixed */ + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + Word16 num_src; + FOR( i = 0; i < 4; i++ ) + { + st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16)floatToFixed( st_ivas->hRenderConfig->directivity[i * 3], 6 ); + st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16)floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 1], 6 ); + st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16)floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 2], 15 ); + } +#endif + IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ) != IVAS_ERR_OK ) + { + return error; + } +#if 1 // Cleanup changes for ivas_td_binaural_open: fixed to float + st_ivas->hBinRendererTd->Gain = 1.0f; /*1.0f Q15*/ + fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Pos_fx, st_ivas->hBinRendererTd->Listener_p->Pos, st_ivas->hBinRendererTd->Listener_p->Pos_q, 3 ); + fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Vel_fx, st_ivas->hBinRendererTd->Listener_p->Vel, Q30, 3 ); + fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Front_fx, st_ivas->hBinRendererTd->Listener_p->Front, Q30, 3 ); + fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Up_fx, st_ivas->hBinRendererTd->Listener_p->Up, Q30, 3 ); + fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Right_fx, st_ivas->hBinRendererTd->Listener_p->Right, Q30, 3 ); + TDREND_DirAtten_t *DirAtten_p = st_ivas->hBinRendererTd->DirAtten_p; + DirAtten_p->ConeInnerAngle = fix_to_float( DirAtten_p->ConeInnerAngle_fx, Q22 ); + DirAtten_p->ConeOuterAngle = fix_to_float( DirAtten_p->ConeOuterAngle_fx, Q22 ); + DirAtten_p->ConeOuterGain = fix_to_float( DirAtten_p->ConeOuterGain_fx, Q30 ); + Word16 nchan_rend = num_src; + IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_rend--; /* Skip LFE channel -- added to the others */ + } + FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) + { + TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; + IF( Src_p->SrcSpatial_p != NULL ) + { + Src_p->SrcSpatial_p->DirAtten.ConeInnerAngle = 360.0f; + Src_p->SrcSpatial_p->DirAtten.ConeOuterAngle = 360.0f; + Src_p->SrcSpatial_p->DirAtten.ConeOuterGain = 1.0f; + FOR( Word16 nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) + { + fixedToFloat_arrL( Src_p->SrcSpatial_p->Pos_p_fx + nC * 3, Src_p->SrcSpatial_p->Pos_p + nC * 3, Q31, 3 ); + fixedToFloat_arrL( Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, Q30, 3 ); + } + } + FOR( Word16 nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) + { + Src_p->SrcRend_p->SrcGainMin_p[nC] = 0.0f; + Src_p->SrcRend_p->SrcGainMax_p[nC] = 1.0f; + } + set_f( Src_p->mem_itd, 0.0f, ITD_MEM_LEN ); + set_f( Src_p->mem_hrf_left, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1 ); + set_f( Src_p->mem_hrf_right, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1 ); + set_f( Src_p->hrf_left_prev, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH ); + set_f( Src_p->hrf_right_prev, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH ); + Src_p->hrf_left_prev[0] = 1; + Src_p->hrf_right_prev[0] = 1; + Src_p->azim_prev = 0.0f; + Src_p->elev_prev = 0.0f; + Src_p->Gain = 1.0f; + Src_p->prevGain = 1.0f; + TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; + fixedToFloat_arrL( SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, Q31, 3 ); + fixedToFloat_arrL( SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, Q30, 3 ); + SrcSpatial_p->DirAtten.ConeInnerAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeInnerAngle_fx, Q22 ); + SrcSpatial_p->DirAtten.ConeOuterAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterAngle_fx, Q22 ); + SrcSpatial_p->DirAtten.ConeOuterGain = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterGain_fx, Q30 ); + } +#endif +#else IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } +#endif IF ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { @@ -2310,14 +2364,6 @@ ivas_error ivas_init_decoder_fx( return error; } -#if 1 /*Cleanup changes: fixed to float*/ - IF(st_ivas->hCrendWrapper!=NULL && st_ivas->hCrendWrapper->hHrtfCrend != NULL ) - { - st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); - st_ivas->hCrendWrapper->hHrtfCrend->latency_s = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->latency_s_fx, 31 ); - fixedToFloat_arr( st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight_fx, st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); - } -#endif st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; IF ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 95f26554dfc4a2f9f84b1b0b92d6fb659efb5113..2bc91f30dc87d779cc146cb4e7c169d65c0e13cd 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -1028,7 +1028,7 @@ ivas_error ivas_ism_metadata_dec_fx( pitch_fx = ism_dequant_meta_fx( idx_angle2, ism_elevation_borders_fx, (Word32)(ISM_Q_STEP * (1<<22)), (Word32)(ISM_Q_STEP_BORDER * (1<<22)), 1 << ISM_ELEVATION_NBITS ); idx_radius = decode_radius_fx( st0, &hIsmMetaData->last_radius_idx, &flag_abs_radius ); - radius_fx = usdequant_fx( idx_radius, (Word16)(ISM_RADIUS_MIN * (1 << 9)) , (Word16)(ISM_RADIUS_DELTA * (1 << 9)) ); + radius_fx = usdequant_fx( idx_radius, (Word16)(ISM_RADIUS_MIN * (1 << 9)) , (Word16)(ISM_RADIUS_DELTA * (1 << (9 - 1))) ); IF ( *ism_extmeta_active == 1 ) { hIsmMetaData->yaw_fx = yaw_fx; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 2e860b00df2d92a6803c84354b0365085ec943a6..08bcdc2fe7d547752426e693b95eb7589a9d4291 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -314,15 +314,6 @@ ivas_error ivas_jbm_dec_tc( st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; #ifdef IVAS_FLOAT_FIXED - // Float to fix conversion starts here. - IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) - { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j] = float_to_fix16( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j], Q14 ); - } - } - // Float to fix conversion ends here. IF( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) @@ -350,13 +341,6 @@ ivas_error ivas_jbm_dec_tc( } } st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); - IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) - { - for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j] = fix16_to_float( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j], Q14 ); - } - } IF( st_ivas->hSpatParamRendCom != NULL ) { FOR( i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++ ) @@ -829,13 +813,6 @@ ivas_error ivas_jbm_dec_tc( ELSE tmp_nchan_ism = st_ivas->nchan_ism; ///////////////////////////////////// Float to fix conversion starts here. /////////////////////////////////// - IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) - { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j] = float_to_fix16( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j], Q14 ); - } - } FOR( n = 0; n < tmp_nchan_ism; n++ ) { @@ -936,13 +913,6 @@ ivas_error ivas_jbm_dec_tc( } } st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); - IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) - { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j] = fix16_to_float( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j], Q14 ); - } - } IF( st_ivas->hSpatParamRendCom != NULL ) { FOR( i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++ ) @@ -2004,15 +1974,6 @@ ivas_error ivas_jbm_dec_tc( /* read McMASA parameters from the bitstream */ #ifdef IVAS_FLOAT_FIXED - // Float to fix conversion starts here. - IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) - { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j] = float_to_fix16( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j], Q14 ); - } - } - // Float to fix conversion ends here. IF( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { @@ -2039,13 +2000,6 @@ ivas_error ivas_jbm_dec_tc( } } st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); - IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) - { - for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j] = fix16_to_float( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j], Q14 ); - } - } IF( st_ivas->hSpatParamRendCom != NULL ) { FOR( i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++ ) @@ -2088,28 +2042,18 @@ ivas_error ivas_jbm_dec_tc( return error; } #endif // IVAS_FLOAT_FIXED -#if 1 - FOR( i = 0; i < 12; i++ ) - { - fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, output_frame ); - } /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */ IF( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) { - ivas_lfe_synth_with_filters( st_ivas->hMasa->hMasaLfeSynth, p_output, output_frame, n, LFE_CHANNEL ); + ivas_lfe_synth_with_filters_fx( st_ivas->hMasa->hMasaLfeSynth, p_output_fx, output_frame, n, LFE_CHANNEL ); } ELSE IF( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ - delay_signal_float( p_output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); - } - FOR( i = 0; i < 12; i++ ) - { - floatToFixed_arrL( p_output[i], p_output_fx[i], Q11, output_frame ); + delay_signal_fx(p_output_fx[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); } -#endif } ELSE { diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index 279749caafd4a5fefec52871fb9069910bbc5138..1fc1c04f4177d9a21ca5e81a630aed8005d3a4b4 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -211,10 +211,13 @@ static Word16 d_lev_dur_fx( Word32 buf_fx[TCXLTP_LTP_ORDER]; Word16 rc_q_fx[TCXLTP_LTP_ORDER]; Word32 *rc_fx; /* reflection coefficients 0,...,m-1 */ - Word32 temp1, temp2, err_fx, at_fx, s, a_tmp; + Word32 temp1, temp2, err_fx, at_fx, s; Word16 temp_q1, temp_q2, s_q_fx, err_q_fx, exp1, exp2; Word64 s_fx; + s_q_fx = 0; + move16(); + rc_fx = &buf_fx[0]; rc_fx[0] = BASOP_Util_Divide3232_Scale_cadence( -r_fx[1], r_fx[0], &temp_q2 ); move32(); diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 2aba53751fe63522bb38ce50738badba7c43caf5..b37dd203fee31fc22e281f99ea623356e30084ef 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -83,9 +83,9 @@ static void restore_lowbitrate_masa( IVAS_QMETADATA_HANDLE hQMetaData, const int static void restore_lowbitrate_masa_fx( IVAS_QMETADATA_HANDLE hQMetaData, const Word16 low_bitrate_mode, const Word16 numCodingBands ); #endif +#ifndef IVAS_FLOAT_FIXED static ivas_error init_lfe_synth_data( Decoder_Struct *st_ivas, MASA_DECODER_HANDLE hMasa ); - -#ifdef IVAS_FLOAT_FIXED +#else static ivas_error init_lfe_synth_data_fx( Decoder_Struct *st_ivas, MASA_DECODER_HANDLE hMasa ); #endif @@ -93,9 +93,10 @@ static void compute_foa_cov_matrix( float foaCov[FOA_CHANNELS][FOA_CHANNELS], fl #ifdef IVAS_FLOAT_FIXED static void compute_foa_cov_matrix_fx(Word32 foaCov_fx[FOA_CHANNELS][FOA_CHANNELS], Word32 inCov_fx[FOA_CHANNELS][FOA_CHANNELS], Word32 mixMtx_fx[FOA_CHANNELS][FOA_CHANNELS]); #endif -static int16_t decode_lfe_to_total_energy_ratio( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, uint16_t *bitstream, int16_t *index, const int32_t ivas_total_brate ); -#ifdef IVAS_FLOAT_FIXED +#ifndef IVAS_FLOAT_FIXED +static int16_t decode_lfe_to_total_energy_ratio( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, uint16_t *bitstream, int16_t *index, const int32_t ivas_total_brate ); +#else static Word16 decode_lfe_to_total_energy_ratio_fx( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, uint16_t *bitstream, int16_t *index, const int32_t ivas_total_brate ); #endif @@ -327,27 +328,11 @@ ivas_error ivas_masa_decode( if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { -#ifdef IVAS_FLOAT_FIXED - for ( int j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j] = float_to_fix16( hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j], Q14 ); - } - *nb_bits_read = add( *nb_bits_read, decode_lfe_to_total_energy_ratio_fx( hMasa->hMasaLfeSynth, st->bit_stream, &st->next_bit_pos, ivas_total_brate ) ); - for ( int j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j] = fix16_to_float( hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j], Q14 ); - } -#else *nb_bits_read += decode_lfe_to_total_energy_ratio( hMasa->hMasaLfeSynth, st->bit_stream, &st->next_bit_pos, ivas_total_brate ); -#endif } /* Once we know incoming configuration, we can config decoder further based on bitrate etc. */ -#ifdef IVAS_FLOAT_FIXED - IF ( ( error = ivas_masa_dec_config_fx( st_ivas ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_masa_dec_config( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -379,40 +364,9 @@ ivas_error ivas_masa_decode( { if ( st_ivas->hDirAC != NULL ) { -#ifdef IVAS_FLOAT_FIXED - *nb_bits_read += ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos, - st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ); - FOR(Word32 dir = 0; dir < MAX_PARAM_SPATIAL_SUBFRAMES; dir++) - { - FOR(Word16 sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; ++sf) - { - Word16 meta_write_index = (add(st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, sf)) % st_ivas->hSpatParamRendCom->dirac_md_buffer_length; - FOR(Word32 b = 0; b < MASA_FREQUENCY_BANDS; ++b) - { - st_ivas->hMasaIsmData->energy_ratio_ism[dir][meta_write_index][b] = fix_to_float(st_ivas->hMasaIsmData->energy_ratio_ism_fx[dir][meta_write_index][b], Q30); - } - } - } - FOR(Word32 n = 0; n < st_ivas->nchan_ism; n++) - { - st_ivas->hMasaIsmData->q_azimuth_old_fx[n] = float_to_fix(st_ivas->hMasaIsmData->q_azimuth_old[n], Q22); - } - - //FOR(Word32 k = 0; k < (nblocks != 1 ? nblocks : MAX_PARAM_SPATIAL_SUBFRAMES); k++) - //FOR(Word32 k = 0; k < ( hQMetaData->q_direction->cfg.nblocks != 1 ? hQMetaData->q_direction->cfg.nblocks : MAX_PARAM_SPATIAL_SUBFRAMES); k++) - FOR(Word32 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++) - { - //FOR(Word32 j = 0; j < (hQMetaData->q_direction->cfg.nbands != 1 ? hQMetaData->q_direction->cfg.nbands : MASA_FREQUENCY_BANDS); j++) - FOR(Word32 j = 0; j < MASA_FREQUENCY_BANDS; j++) - { - st_ivas->hMasaIsmData->masa_to_total_energy_ratio[k][j] = fix_to_float(st_ivas->hMasaIsmData->masa_to_total_energy_ratio_fx[k][j], Q30); - } - } - -#else *nb_bits_read += ivas_decode_masaism_metadata( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos, st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ); -#endif + for ( obj = 0; obj <= st_ivas->nchan_ism; obj++ ) { if ( st_ivas->hMasaIsmData->idx_separated_ism == obj ) @@ -431,38 +385,8 @@ ivas_error ivas_masa_decode( } else { -#ifdef IVAS_FLOAT_FIXED - *nb_bits_read += ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos, - st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); - FOR(Word32 dir = 0; dir < MAX_PARAM_SPATIAL_SUBFRAMES; dir++) - { - FOR(Word32 sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; ++sf) - { - FOR(Word32 b = 0; b < MASA_FREQUENCY_BANDS; ++b) - { - st_ivas->hMasaIsmData->energy_ratio_ism[dir][sf][b] = fix_to_float(st_ivas->hMasaIsmData->energy_ratio_ism_fx[dir][sf][b], Q30); - } - } - } - FOR(Word32 n = 0; n < st_ivas->nchan_ism; n++) - { - st_ivas->hMasaIsmData->q_azimuth_old_fx[n] = float_to_fix(st_ivas->hMasaIsmData->q_azimuth_old[n], Q22); - } - - //FOR(Word32 k = 0; k < (nblocks != 1 ? nblocks : MAX_PARAM_SPATIAL_SUBFRAMES); k++) - //FOR(Word32 k = 0; k < ( hQMetaData->q_direction->cfg.nblocks != 1 ? hQMetaData->q_direction->cfg.nblocks : MAX_PARAM_SPATIAL_SUBFRAMES); k++) - FOR(Word32 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++) - { - //FOR(Word32 j = 0; j < (hQMetaData->q_direction->cfg.nbands != 1 ? hQMetaData->q_direction->cfg.nbands : MASA_FREQUENCY_BANDS); j++) - FOR(Word32 j = 0; j < MASA_FREQUENCY_BANDS; j++) - { - st_ivas->hMasaIsmData->masa_to_total_energy_ratio[k][j] = fix_to_float(st_ivas->hMasaIsmData->masa_to_total_energy_ratio_fx[k][j], Q30); - } - } -#else *nb_bits_read += ivas_decode_masaism_metadata( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos, st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); -#endif } } } @@ -472,23 +396,7 @@ ivas_error ivas_masa_decode( { masa_total_brate = calculate_cpe_brate_MASA_ISM( st_ivas->ism_mode, ivas_total_brate, st_ivas->nchan_ism ); } -#ifdef IVAS_FLOAT_FIXED - // To do remove this code - for ( int d = 0; d < hQMetaData->no_directions; d++ ) - { - IVAS_QDIRECTION *q_direction; - q_direction = &hQMetaData->q_direction[d]; - int nbands = hQMetaData->q_direction[0].cfg.nbands; - FOR( Word16 j = 0; j < nbands; j++ ) - { - FOR( Word16 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - q_direction->band_data[j].elevation_fx[k] = (Word32) ( q_direction->band_data[j].elevation[k] * ( 1 << 22 ) ); - q_direction->band_data[j].azimuth_fx[k] = (Word32) ( q_direction->band_data[j].azimuth[k] * ( 1 << 22 ) ); - } - } - } -#endif + if ( masa_total_brate >= IVAS_384k ) { if ( masa_total_brate >= IVAS_512k ) @@ -504,53 +412,17 @@ ivas_error ivas_masa_decode( { *nb_bits_read += ivas_qmetadata_dec_decode( hQMetaData, st->bit_stream, &st->next_bit_pos, 0 ); } -#ifdef IVAS_FLOAT_FIXED - // To do remove this code - for ( int d = 0; d < hQMetaData->no_directions; d++ ) - { - IVAS_QDIRECTION *q_direction; - q_direction = &hQMetaData->q_direction[d]; - int nbands = hQMetaData->q_direction[0].cfg.nbands; - FOR( Word16 j = 0; j < nbands; j++ ) - { - FOR( Word16 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - q_direction->band_data[j].elevation[k] = ( (float) q_direction->band_data[j].elevation_fx[k] / ( 1 << 22 ) ); - q_direction->band_data[j].azimuth[k] = ( (float) q_direction->band_data[j].azimuth_fx[k] / ( 1 << 22 ) ); - q_direction->band_data[j].energy_ratio[k] = ( (float) q_direction->band_data[j].energy_ratio_fx[k] / ( 1 << 30 ) ); - } - } - } -#endif if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) { /* Modify spatial metadata based on the MASA-to-total energy ratios */ -#ifdef IVAS_FLOAT_FIXED - ivas_omasa_modify_masa_energy_ratios_fx( hQMetaData, st_ivas->hMasaIsmData->masa_to_total_energy_ratio_fx ); - for (int k = 0; k < hQMetaData->no_directions; k++) - { - for (int j = 0; j < hQMetaData->q_direction[0].cfg.nbands; j++) - { - for (int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES; m++) - { - hQMetaData->q_direction[k].band_data[j].energy_ratio[m] = fix_to_float(hQMetaData->q_direction[k].band_data[j].energy_ratio_fx[m], Q30); - } - } - } -#else ivas_omasa_modify_masa_energy_ratios( hQMetaData, st_ivas->hMasaIsmData->masa_to_total_energy_ratio ); -#endif } /* Get direction decoding quality. EC 1 and 2 are handled by the default value. */ if ( hQMetaData->ec_flag == 2 ) { -#ifndef IVAS_FLOAT_FIXED hMasa->data.dir_decode_quality = hQMetaData->dir_comp_ratio; -#else - hMasa->data.dir_decode_quality = (float)hQMetaData->dir_comp_ratio_fx/(1<<15); -#endif } hMasa->config.coherencePresent = !hQMetaData->all_coherence_zero; @@ -575,20 +447,12 @@ ivas_error ivas_masa_decode( if ( hQMetaData->q_direction == NULL ) { /* replicate ivas_masa_dec_config() in case that first good received frame is SID frame */ -#ifdef IVAS_FLOAT_FIXED - IF ( ( error = ivas_masa_dec_config_fx( st_ivas ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_masa_dec_config( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } -#ifdef IVAS_FLOAT_FIXED - ivas_masa_set_elements_fx( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, st_ivas->ivas_format, st_ivas->ism_mode, 0 ); -#else ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, st_ivas->ivas_format, st_ivas->ism_mode, 0 ); -#endif hQMetaData->metadata_max_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC; @@ -614,43 +478,7 @@ ivas_error ivas_masa_decode( } tmp_elem_mode = -1; -#ifdef IVAS_FLOAT_FIXED - for (int d = 0; d < hQMetaData->no_directions; d++) - { - IVAS_QDIRECTION *q_direction; - q_direction = &hQMetaData->q_direction[d]; - int nbands = hQMetaData->q_direction[0].cfg.nbands; - FOR(Word16 j = 0; j < nbands; j++) - { - FOR(Word16 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++) - { - q_direction->band_data[j].elevation_fx[k] = (Word32)(q_direction->band_data[j].elevation[k] * (1 << 22)); - q_direction->band_data[j].azimuth_fx[k] = (Word32)(q_direction->band_data[j].azimuth[k] * (1 << 22)); - q_direction->band_data[j].energy_ratio_fx[k] = (Word32)(q_direction->band_data[j].energy_ratio[k] * (1 << 30)); - } - } - } -#endif *nb_bits_read += ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), st_ivas->nchan_transport, &tmp_elem_mode, ivas_format ); -#ifdef IVAS_FLOAT_FIXED - for (int d = 0; d < hQMetaData->no_directions; d++) - { - IVAS_QDIRECTION *q_direction; - q_direction = &hQMetaData->q_direction[d]; - int nbands = hQMetaData->q_direction[0].cfg.nbands; - FOR(Word16 j = 0; j < nbands; j++) - { - FOR(Word16 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++) - { - - q_direction->band_data[j].elevation[k] = ((float)q_direction->band_data[j].elevation_fx[k] / (1 << 22)); - q_direction->band_data[j].azimuth[k] = ((float)q_direction->band_data[j].azimuth_fx[k] / (1 << 22)); - q_direction->band_data[j].energy_ratio[k] = ((float)q_direction->band_data[j].energy_ratio_fx[k] / (1 << 30)); - - } - } - } -#endif if ( st_ivas->nchan_transport == 2 ) { assert( st_ivas->nCPE > 0 ); @@ -662,11 +490,7 @@ ivas_error ivas_masa_decode( { if ( hQMetaData->q_direction == NULL ) { -#ifdef IVAS_FLOAT_FIXED - IF ( ( error = ivas_masa_dec_config_fx( st_ivas ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_masa_dec_config( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -676,68 +500,14 @@ ivas_error ivas_masa_decode( if ( st_ivas->hDirAC != NULL ) { dirac_bs_md_write_idx = st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx; /* Store the write-index for this frame */ - -#ifdef IVAS_FLOAT_FIXED - for (int d = 0; d < hQMetaData->no_directions; d++) - { - IVAS_QDIRECTION *q_direction; - q_direction = &hQMetaData->q_direction[d]; - int nbands = hQMetaData->q_direction[0].cfg.nbands; - //int nblocks = hQMetaData->q_direction[0].cfg.nblocks; - FOR(Word16 j = 0; j < nbands; j++) - { - FOR(Word16 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++) - { - q_direction->band_data[j].elevation_fx[k] = (Word32)(q_direction->band_data[j].elevation[k] * (1 << 22)); - q_direction->band_data[j].azimuth_fx[k] = (Word32)(q_direction->band_data[j].azimuth[k] * (1 << 22)); - q_direction->band_data[j].energy_ratio_fx[k] = (Word32)(q_direction->band_data[j].energy_ratio[k] * (1 << 30)); - } - } - } - - for ( i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++) { - for ( int j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++) { - st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j] = float_to_fix(st_ivas->hSpatParamRendCom->diffuseness_vector[i][j], 30); - st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j] = float_to_fix(st_ivas->hSpatParamRendCom->energy_ratio1[i][j], 30); - IF(hQMetaData->no_directions == 2) - { - st_ivas->hSpatParamRendCom->energy_ratio2_fx[i][j] = float_to_fix(st_ivas->hSpatParamRendCom->energy_ratio2[i][j], 30); - st_ivas->hSpatParamRendCom->spreadCoherence2_fx[i][j] = float_to_fix16(st_ivas->hSpatParamRendCom->spreadCoherence2[i][j], 15); - } - 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); - } - } - - ivas_qmetadata_to_dirac_fx(hQMetaData, st_ivas->hDirAC, hMasa, st_ivas->hSpatParamRendCom, ivas_total_brate, ivas_format, 0, 0); - - for ( i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++) { - for ( int j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++) { - st_ivas->hSpatParamRendCom->diffuseness_vector[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j], 30); - st_ivas->hSpatParamRendCom->energy_ratio1[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j], 30); - IF(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); - } - } -#else - ivas_qmetadata_to_dirac( hQMetaData, st_ivas->hDirAC, hMasa, st_ivas->hSpatParamRendCom, ivas_total_brate, ivas_format, 0, 0); -#endif + ivas_qmetadata_to_dirac( hQMetaData, st_ivas->hDirAC, hMasa, st_ivas->hSpatParamRendCom, ivas_total_brate, ivas_format, 0, 0 ); } if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { if ( hQMetaData->q_direction == NULL ) { -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_masa_dec_config_fx( st_ivas ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_masa_dec_config( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1453,7 +1223,7 @@ ivas_error ivas_masa_decode_fx( * * *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_masa_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) @@ -1560,7 +1330,7 @@ ivas_error ivas_masa_dec_open( return error; } -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_masa_dec_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) @@ -1685,7 +1455,7 @@ ivas_error ivas_masa_dec_open_fx( * * close MASA decoder *-----------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void ivas_masa_dec_close( MASA_DECODER_HANDLE *hMasa_out /* i/o: MASA metadata structure */ ) @@ -1744,7 +1514,7 @@ void ivas_masa_dec_close( return; } -#ifdef IVAS_FLOAT_FIXED +#else void ivas_masa_dec_close_fx( MASA_DECODER_HANDLE *hMasa_out /* i/o: MASA metadata structure */ ) @@ -1773,28 +1543,6 @@ void ivas_masa_dec_close_fx( IF ( hMasa->hMasaLfeSynth != NULL ) { -#if 1 /* TODO: Remove float free */ - IF ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer != NULL ) - { - free( hMasa->hMasaLfeSynth->lfeSynthRingBuffer ); - hMasa->hMasaLfeSynth->lfeSynthRingBuffer = NULL; - } - IF ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer2 != NULL ) - { - free( hMasa->hMasaLfeSynth->lfeSynthRingBuffer2 ); - hMasa->hMasaLfeSynth->lfeSynthRingBuffer2 = NULL; - } - IF ( hMasa->hMasaLfeSynth->delayBuffer_syncLp != NULL ) - { - free( hMasa->hMasaLfeSynth->delayBuffer_syncLp ); - hMasa->hMasaLfeSynth->delayBuffer_syncLp = NULL; - } - IF ( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC != NULL ) - { - free( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC ); - hMasa->hMasaLfeSynth->delayBuffer_syncDirAC = NULL; - } -#endif IF ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx != NULL ) { free( hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx ); @@ -2419,6 +2167,7 @@ static void restore_lowbitrate_masa_fx( #endif +#ifndef IVAS_FLOAT_FIXED static ivas_error init_lfe_synth_data( Decoder_Struct *st_ivas, /* i : IVAS decoder struct */ MASA_DECODER_HANDLE hMasa /* i/o: MASA decoder structure */ @@ -2534,8 +2283,7 @@ static ivas_error init_lfe_synth_data( return IVAS_ERR_OK; } - -#ifdef IVAS_FLOAT_FIXED +#else static ivas_error init_lfe_synth_data_fx( Decoder_Struct *st_ivas, /* i : IVAS decoder struct */ MASA_DECODER_HANDLE hMasa /* i/o: MASA decoder structure */ @@ -2554,13 +2302,6 @@ static ivas_error init_lfe_synth_data_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); } -#if 1 /* TODO: remove float code. */ - hMasa->hMasaLfeSynth->transportEneSmooth = 0.0f; - hMasa->hMasaLfeSynth->protoLfeEneSmooth = 0.0f; - hMasa->hMasaLfeSynth->targetEneLfeSmooth = 0.0f; - hMasa->hMasaLfeSynth->targetEneTransSmooth = 0.0f; -#endif - hMasa->hMasaLfeSynth->transportEneSmooth_fx = 0; move32(); hMasa->hMasaLfeSynth->transportEneSmooth_q = Q31; @@ -2578,9 +2319,6 @@ static ivas_error init_lfe_synth_data_fx( hMasa->hMasaLfeSynth->targetEneTransSmooth_q = Q31; move16(); -#if 1 /* TODO: remove float code. */ - set_zero( hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio, MAX_PARAM_SPATIAL_SUBFRAMES ); -#endif set16_fx( hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); hMasa->hMasaLfeSynth->lfeGainPrevIndex = 0; move16(); @@ -2605,25 +2343,15 @@ static ivas_error init_lfe_synth_data_fx( tmp = BASOP_Util_Divide3232_Scale(output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &tmp_e); bufferSize = shr(tmp, sub(15, tmp_e)); // Q0 -#if 1 /* TODO: remove float code. */ - IF ( ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer = ( float * )malloc( bufferSize * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); - } - set_zero( hMasa->hMasaLfeSynth->lfeSynthRingBuffer, bufferSize ); -#endif - IF ( ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx = ( Word16 * )malloc( bufferSize * sizeof( Word16 ) ) ) == NULL) + IF ( ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx = ( Word32 * )malloc( bufferSize * sizeof( Word32 ) ) ) == NULL) { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n")); } - set16_fx( hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx, 0, bufferSize ); + set32_fx( hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx, 0, bufferSize ); hMasa->hMasaLfeSynth->ringBufferLoPointer = 0; move16(); hMasa->hMasaLfeSynth->ringBufferHiPointer = shr(bufferSize, 1); -#if 1 /* TODO: remove float code. */ - hMasa->hMasaLfeSynth->lowpassSum = 0.0f; -#endif hMasa->hMasaLfeSynth->lowpassSum_fx = 0; move16(); hMasa->hMasaLfeSynth->ringBufferSize = bufferSize; @@ -2633,70 +2361,43 @@ static ivas_error init_lfe_synth_data_fx( * Moving average lowpass filter with the crossover of 240 Hz. */ bufferSize = shr( bufferSize, 1 ); -#if 1 /* TODO: remove float code. */ - IF ( ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer2 = (float *) malloc( bufferSize * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); - } - set_zero( hMasa->hMasaLfeSynth->lfeSynthRingBuffer2, bufferSize ); -#endif - IF ( ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer2_fx = (Word16 *) malloc( bufferSize * sizeof( Word16 ) ) ) == NULL ) + IF ( ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer2_fx = (Word32 *) malloc( bufferSize * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); } - set16_fx( hMasa->hMasaLfeSynth->lfeSynthRingBuffer2_fx, 0, bufferSize ); + set32_fx( hMasa->hMasaLfeSynth->lfeSynthRingBuffer2_fx, 0, bufferSize ); hMasa->hMasaLfeSynth->ringBufferLoPointer2 = 0; -#if 1 /* TODO: remove float code. */ - hMasa->hMasaLfeSynth->lowpassSum2 = 0.0f; -#endif - hMasa->hMasaLfeSynth->lowpassSum2_fx = 0; move16(); + hMasa->hMasaLfeSynth->lowpassSum2_fx = 0; + move32(); hMasa->hMasaLfeSynth->ringBufferSize2 = bufferSize; move16(); /* Delay buffer for matching the delay of the lowpass filter */ bufferSize = shr(bufferSize, 1); /* The delay of the moving average lowpass filter is bufferSize / 2 */ -#if 1 /* TODO: remove float code. */ - IF ( ( hMasa->hMasaLfeSynth->delayBuffer_syncLp = (float *) malloc( bufferSize * sizeof( float ) ) ) == NULL ) + IF ( ( hMasa->hMasaLfeSynth->delayBuffer_syncLp_fx = (Word32 *) malloc( bufferSize * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); } - set_zero( hMasa->hMasaLfeSynth->delayBuffer_syncLp, bufferSize ); -#endif - IF ( ( hMasa->hMasaLfeSynth->delayBuffer_syncLp_fx = (Word16 *) malloc( bufferSize * sizeof( Word16 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); - } - set16_fx( hMasa->hMasaLfeSynth->delayBuffer_syncLp_fx, 0, bufferSize ); + set32_fx( hMasa->hMasaLfeSynth->delayBuffer_syncLp_fx, 0, bufferSize ); hMasa->hMasaLfeSynth->delayBuffer_syncLp_size = bufferSize; move16(); /* Delay buffer for syncing with DirAC rendering */ bufferSize = sub(sub(NS2SA( output_Fs, IVAS_FB_DEC_DELAY_NS ), shr(hMasa->hMasaLfeSynth->ringBufferSize, 1)), shr(hMasa->hMasaLfeSynth->ringBufferSize2, 1)); -#if 1 /* TODO: remove float code. */ - IF ( ( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC = (float *) malloc( bufferSize * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); - } - set_zero( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, bufferSize ); -#endif - IF ( ( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx = (Word16 *) malloc( bufferSize * sizeof( Word16 ) ) ) == NULL ) + IF ( ( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx = (Word32 *) malloc( bufferSize * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); } - set16_fx( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, 0, bufferSize ); + set32_fx( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, 0, bufferSize ); hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size = bufferSize; move16(); /* Interpolation between slots */ -#if 1 /* TODO: remove float code. */ - hMasa->hMasaLfeSynth->lfeGainPrev = 0.0f; - hMasa->hMasaLfeSynth->transportGainPrev = 1.0f; -#endif hMasa->hMasaLfeSynth->lfeGainPrev_fx = 0; move16(); - hMasa->hMasaLfeSynth->transportGainPrev_fx = ONE_IN_Q14; + hMasa->hMasaLfeSynth->transportGainPrev_fx = ONE_IN_Q15; move16(); tmp = BASOP_Util_Divide3232_Scale(output_Fs, FRAMES_PER_SEC * CLDFB_NO_COL_MAX, &tmp_e); @@ -2705,10 +2406,6 @@ static ivas_error init_lfe_synth_data_fx( FOR ( i = 0; i < slot_size; i++ ) { hMasa->hMasaLfeSynth->interpolator_fx[i] = div_s( add( i, 1 ), slot_size ); -#if 1 - /* TODO: remove float code */ - hMasa->hMasaLfeSynth->interpolator[i] = fix16_to_float(hMasa->hMasaLfeSynth->interpolator_fx[i], Q15); -#endif } } ELSE IF ( st_ivas->hOutSetup.separateChannelEnabled && EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && EQ_16(st_ivas->hOutSetup.num_lfe, 0) ) @@ -2717,38 +2414,20 @@ static ivas_error init_lfe_synth_data_fx( /* Delay buffer for syncing with DirAC rendering */ bufferSize = NS2SA( output_Fs, IVAS_FB_DEC_DELAY_NS ); -#if 1 /* TODO: remove float code. */ - if ( ( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC = (float *) malloc( bufferSize * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); - } - set_zero( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, bufferSize ); -#endif - IF ( ( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx = (Word16 *) malloc( bufferSize * sizeof( Word16 ) ) ) == NULL ) + IF ( ( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx = (Word32 *) malloc( bufferSize * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); } - set16_fx( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, 0, bufferSize ); + set32_fx( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, 0, bufferSize ); hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size = bufferSize; move16(); -#if 1 /* TODO: remove float code. */ - hMasa->hMasaLfeSynth->lfeSynthRingBuffer = NULL; - hMasa->hMasaLfeSynth->lfeSynthRingBuffer2 = NULL; - hMasa->hMasaLfeSynth->delayBuffer_syncLp = NULL; -#endif hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx = NULL; hMasa->hMasaLfeSynth->lfeSynthRingBuffer2_fx = NULL; hMasa->hMasaLfeSynth->delayBuffer_syncLp_fx = NULL; } ELSE { -#if 1 /* TODO: remove float code. */ - hMasa->hMasaLfeSynth->lfeSynthRingBuffer = NULL; - hMasa->hMasaLfeSynth->lfeSynthRingBuffer2 = NULL; - hMasa->hMasaLfeSynth->delayBuffer_syncLp = NULL; - hMasa->hMasaLfeSynth->delayBuffer_syncDirAC = NULL; -#endif hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx = NULL; hMasa->hMasaLfeSynth->lfeSynthRingBuffer2_fx = NULL; hMasa->hMasaLfeSynth->delayBuffer_syncLp_fx = NULL; @@ -2759,7 +2438,9 @@ static ivas_error init_lfe_synth_data_fx( } #endif + /*! r: Number of bits read */ +#ifndef IVAS_FLOAT_FIXED static int16_t decode_lfe_to_total_energy_ratio( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, /* i/o: McMASA LFE structure */ uint16_t *bitstream, /* i : bitstream */ @@ -2875,8 +2556,7 @@ static int16_t decode_lfe_to_total_energy_ratio( return lfeBitsRead; } - -#ifdef IVAS_FLOAT_FIXED +#else static Word16 decode_lfe_to_total_energy_ratio_fx( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, /* i/o: McMASA LFE structure */ UWord16 *bitstream, /* i : bitstream */ diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index aae13ac70b52b1032e6698662f97a53e383af7ab..313c478d515386727fb81e79fe411254493351ab 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1602,6 +1602,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( /* init onsetDetectionPower */ set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx, len ); set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx, len ); + hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.q_onset_detector = Q31; #if 1/*To be removed later*/ set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1, len ); set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2, len ); @@ -3599,8 +3600,7 @@ void ivas_param_mc_dec_render( } } - Word16 length = nchan_transport; - FOR (Word16 i = 0; i < 16 * nchan_transport * hParamMC->num_freq_bands; i++) + FOR ( i = 0; i < 16 * nchan_transport * hParamMC->num_freq_bands; i++) { st_ivas->hParamMC->Cldfb_RealBuffer_tc_fx[i] = floatToFixed(st_ivas->hParamMC->Cldfb_RealBuffer_tc[i], 6); @@ -4330,6 +4330,7 @@ static void ivas_param_mc_dec_init_fx( /* init onsetDetectionPower */ set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx, len ); set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx, len ); + hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.q_onset_detector = Q31; #if 1/*Floating point intialization: to be removed later*/ set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1, len ); set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2, len ); @@ -4488,8 +4489,6 @@ static void param_mc_protoSignalComputation_fx( Word32 *p_real_buffer_fx; // Q12 Word32 *p_imag_buffer_fx; // Q12 - Word16 proto_frame_f_q[ MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS * 120]; - set32_fx(proto_frame_f_fx, 0, 2 * num_freq_bands * diff_proto_info->num_protos_diff); @@ -4511,8 +4510,6 @@ static void param_mc_protoSignalComputation_fx( p_real_buffer_fx = &RealBuffer_fx[source_ch_idx * num_freq_bands]; p_imag_buffer_fx = &ImagBuffer_fx[source_ch_idx * num_freq_bands]; - Word16 i = shl(imult1616(proto_ch_idx, num_freq_bands), 1); - move16(); FOR (band = 0; band < num_freq_bands; band++) { diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 9242d0672747e08a387d203893032a54c41723c9..f7094db3daa347ff0644106c60351c4167fc985f 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -8104,7 +8104,6 @@ static Word16 read_surround_coherence_hr_fx( IVAS_QDIRECTION *q_direction; Word16 min_index; Word16 d, idx; - Word32 int_error_ratio_surr; coding_subbands = hQMetaData->q_direction[0].cfg.nbands; q_direction = hQMetaData->q_direction; @@ -8196,7 +8195,7 @@ static Word16 read_surround_coherence_hr_fx( { IF( GT_16( no_cv_vec[j], 1 ) ) { - hQMetaData->surcoh_band_data[j].sur_coherence_index = L_add( (Word32) idx_sur_coh[j], L_deposit_l( min_index ) ); + hQMetaData->surcoh_band_data[j].sur_coherence_index = (UWord16) L_add( (Word32) idx_sur_coh[j], L_deposit_l( min_index ) ); hQMetaData->surcoh_band_data[j].surround_coherence[sf] = sur_coherence_cb_masa[idx_cb_sur_coh_masa[idx_ER[j]] * MASA_MAX_NO_CV_SUR_COH + hQMetaData->surcoh_band_data[j].sur_coherence_index]; } ELSE diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 6a5c50f8d9182d8ba5653722ae9d264f4b2fce7c..91db00884f7f52ceb045ca1e0c671f19f9783905 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -68,10 +68,6 @@ ivas_error ivas_hrtf_init( return IVAS_ERR_WRONG_PARAMS; } -#if 1 /*To be removed later: Floating point initialization*/ - hHrtf->latency_s = 0; - hHrtf->gain_lfe = 0; -#endif hHrtf->latency_s_fx = 0; hHrtf->gain_lfe_fx = 0; hHrtf->max_num_ir = 0; @@ -85,17 +81,10 @@ ivas_error ivas_hrtf_init( FOR ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) { -#if 1 /*To be removed later: Floating point initialization*/ - hHrtf->inv_diffuse_weight[i] = 0; -#endif hHrtf->inv_diffuse_weight_fx[i] = 0; move16(); FOR ( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#if 1 /*To be removed later: Floating point memory allocation*/ - hHrtf->pOut_to_bin_re[i][j] = NULL; - hHrtf->pOut_to_bin_im[i][j] = NULL; -#endif hHrtf->num_iterations[i][j] = 0; move16(); hHrtf->pIndex_frequency_max[i][j] = NULL; @@ -106,10 +95,6 @@ ivas_error ivas_hrtf_init( FOR ( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#if 1 /*To be removed later: Floating point memory allocations*/ - hHrtf->pOut_to_bin_diffuse_re[j] = NULL; - hHrtf->pOut_to_bin_diffuse_im[j] = NULL; -#endif hHrtf->num_iterations_diffuse[j] = 0; move16(); hHrtf->pIndex_frequency_max_diffuse[j] = NULL; @@ -340,10 +325,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[j]; -#if 1 // To be removed later:Floating pointer initialization - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz[j]; -#endif // 1 + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz_fx[j]; } @@ -351,10 +333,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[j]; -#if 1 // To be removed later:Floating pointer initialization - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz[j]; -#endif + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz_fx[j]; } @@ -388,10 +367,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[j]; -#if 1 /*To be removed later: Floating pointer intializations*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz[j]; -#endif + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz_fx[j]; } @@ -399,10 +375,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[j]; -#if 1 /*To be removed later: Floating pointer intializations*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz[j]; -#endif + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz_fx[j]; } @@ -436,10 +409,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[j]; -#if 1 /*To be removed later: Floating pointer intializations*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz[j]; -#endif + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz_fx[j]; } @@ -447,10 +417,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[j]; -#if 1 /*To be removed later: Floating pointer intializations*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz[j]; -#endif + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz_fx[j]; } @@ -511,10 +478,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_48kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[tmp][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_48kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_48kHz[tmp][j]; -#endif + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_Combined_BRIR_coeff_re_48kHz_fx[tmp][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_Combined_BRIR_coeff_im_48kHz_fx[tmp][j]; } @@ -522,10 +486,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_48kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[tmp][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_48kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_48kHz[tmp][j]; -#endif + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_Combined_HRIR_coeff_re_48kHz_fx[tmp][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_Combined_HRIR_coeff_im_48kHz_fx[tmp][j]; } @@ -553,10 +514,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_32kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[tmp][j]; -#if 1 /*To be removed later: Floating pointer intializations*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_32kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_32kHz[tmp][j]; -#endif + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_Combined_BRIR_coeff_re_32kHz_fx[tmp][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_Combined_BRIR_coeff_im_32kHz_fx[tmp][j]; } @@ -564,10 +522,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_32kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[tmp][j]; -#if 1 /*To be removed later: Floating pointer intializations*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_32kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_32kHz[tmp][j]; -#endif + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_Combined_HRIR_coeff_re_32kHz_fx[tmp][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_Combined_HRIR_coeff_im_32kHz_fx[tmp][j]; } @@ -595,10 +550,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_16kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[tmp][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_16kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_16kHz[tmp][j]; -#endif + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_Combined_BRIR_coeff_re_16kHz_fx[tmp][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_Combined_BRIR_coeff_im_16kHz_fx[tmp][j]; } @@ -606,10 +558,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_16kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[tmp][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_16kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_16kHz[tmp][j]; -#endif + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_Combined_HRIR_coeff_re_16kHz_fx[tmp][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_Combined_HRIR_coeff_im_16kHz_fx[tmp][j]; } @@ -647,10 +596,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_48kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_48kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_48kHz[i][j]; -#endif + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_HOA3_HRIR_coeff_re_48kHz_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_HOA3_HRIR_coeff_im_48kHz_fx[i][j]; move32(); @@ -663,10 +609,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz[j]; -#endif + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz_fx[j]; move32(); @@ -693,10 +636,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_32kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_32kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_32kHz[i][j]; -#endif + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_HOA3_HRIR_coeff_re_32kHz_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_HOA3_HRIR_coeff_im_32kHz_fx[i][j]; move32(); @@ -710,10 +650,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz[j]; -#endif + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz_fx[j]; move32(); @@ -740,10 +677,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_16kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_16kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_16kHz[i][j]; -#endif + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_HOA3_HRIR_coeff_re_16kHz_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_HOA3_HRIR_coeff_im_16kHz_fx[i][j]; move32(); @@ -757,10 +691,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz[j]; -#endif + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz_fx[j]; move32(); @@ -794,10 +725,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_48kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA2_HRIR_coeff_re_48kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA2_HRIR_coeff_im_48kHz[i][j]; -#endif // 1 + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_HOA2_HRIR_coeff_re_48kHz_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_HOA2_HRIR_coeff_im_48kHz_fx[i][j]; move32(); @@ -810,10 +738,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz[j]; -#endif // 1 + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz_fx[j]; move32(); @@ -840,10 +765,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_32kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA2_HRIR_coeff_re_32kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA2_HRIR_coeff_im_32kHz[i][j]; -#endif // 1 + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_HOA2_HRIR_coeff_re_32kHz_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_HOA2_HRIR_coeff_im_32kHz_fx[i][j]; move32(); @@ -857,10 +779,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz[j]; -#endif // 1 + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz_fx[j]; move32(); @@ -887,10 +806,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_16kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA2_HRIR_coeff_re_16kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA2_HRIR_coeff_im_16kHz[i][j]; -#endif // 1 + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_HOA2_HRIR_coeff_re_16kHz_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_HOA2_HRIR_coeff_im_16kHz_fx[i][j]; move32(); @@ -904,10 +820,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz[j]; -#endif // 1 + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz_fx[j]; move32(); @@ -941,10 +854,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_48kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_FOA_HRIR_coeff_re_48kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_FOA_HRIR_coeff_im_48kHz[i][j]; -#endif // 1 + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_FOA_HRIR_coeff_re_48kHz_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_FOA_HRIR_coeff_im_48kHz_fx[i][j]; move32(); @@ -957,10 +867,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz[j]; -#endif // 1 + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz_fx[j]; move32(); @@ -987,10 +894,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_32kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_FOA_HRIR_coeff_re_32kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_FOA_HRIR_coeff_im_32kHz[i][j]; -#endif // 1 + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_FOA_HRIR_coeff_re_32kHz_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_FOA_HRIR_coeff_im_32kHz_fx[i][j]; move32(); @@ -1004,10 +908,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz[j]; -#endif // 1 + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz_fx[j]; move32(); @@ -1034,10 +935,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_16kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = CRendBin_FOA_HRIR_coeff_re_16kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_FOA_HRIR_coeff_im_16kHz[i][j]; -#endif // 1 + hHrtf->pOut_to_bin_re_fx[i][j] = CRendBin_FOA_HRIR_coeff_re_16kHz_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = CRendBin_FOA_HRIR_coeff_im_16kHz_fx[i][j]; move32(); @@ -1051,10 +949,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[j]; hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz[j]; -#endif // 1 + hHrtf->pOut_to_bin_diffuse_re_fx[j] = CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz_fx[j]; move32(); @@ -1108,10 +1003,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_brir_combined->num_iterations_diffuse[j]; hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_brir_combined->pIndex_frequency_max_diffuse[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_diffuse_re[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_diffuse_im[j]; -#endif // 1 + hHrtf->pOut_to_bin_diffuse_re_fx[j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_diffuse_re_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_diffuse_im_fx[j]; } @@ -1119,10 +1011,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_hrir_combined->num_iterations_diffuse[j]; hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_hrir_combined->pIndex_frequency_max_diffuse[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_diffuse_re[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_diffuse_im[j]; -#endif // 1 + hHrtf->pOut_to_bin_diffuse_re_fx[j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_diffuse_re_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_diffuse_im_fx[j]; } @@ -1176,10 +1065,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_brir_combined->num_iterations[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_brir_combined->pIndex_frequency_max[tmp][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_re[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_im[tmp][j]; -#endif // 1 + hHrtf->pOut_to_bin_re_fx[i][j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_re_fx[tmp][j]; hHrtf->pOut_to_bin_im_fx[i][j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_im_fx[tmp][j]; } @@ -1187,10 +1073,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_combined->num_iterations[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pIndex_frequency_max[tmp][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_re[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_im[tmp][j]; -#endif // 1 + hHrtf->pOut_to_bin_re_fx[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_re_fx[tmp][j]; hHrtf->pOut_to_bin_im_fx[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_im_fx[tmp][j]; } @@ -1221,10 +1104,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->num_iterations[i][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->pIndex_frequency_max[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_re[i][j]; - hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_im[i][j]; -#endif // 1 + hHrtf->pOut_to_bin_re_fx[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_re_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_im_fx[i][j]; move32(); @@ -1237,10 +1117,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_hrir_hoa3->num_iterations_diffuse[j]; hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_hrir_hoa3->pIndex_frequency_max_diffuse[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_diffuse_re[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_diffuse_im[j]; -#endif // 1 + hHrtf->pOut_to_bin_diffuse_re_fx[j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_diffuse_re_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_diffuse_im_fx[j]; move32(); @@ -1267,10 +1144,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->num_iterations[i][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->pIndex_frequency_max[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_re[i][j]; - hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_im[i][j]; -#endif + hHrtf->pOut_to_bin_re_fx[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_re_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_im_fx[i][j]; move32(); @@ -1283,10 +1157,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_hrir_hoa2->num_iterations_diffuse[j]; hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_hrir_hoa2->pIndex_frequency_max_diffuse[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_diffuse_re[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_diffuse_im[j]; -#endif + hHrtf->pOut_to_bin_diffuse_re_fx[j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_diffuse_re_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_diffuse_im_fx[j]; move32(); @@ -1313,10 +1184,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_foa->num_iterations[i][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_foa->pIndex_frequency_max[i][j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_re[i][j]; - hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_im[i][j]; -#endif + hHrtf->pOut_to_bin_re_fx[i][j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_re_fx[i][j]; hHrtf->pOut_to_bin_im_fx[i][j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_im_fx[i][j]; move32(); @@ -1329,10 +1197,7 @@ static ivas_error ivas_rend_initCrend_fx( { hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_hrir_foa->num_iterations_diffuse[j]; hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_hrir_foa->pIndex_frequency_max_diffuse[j]; -#if 1 /*To be removed later: Floating pointer initialization*/ - hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_diffuse_re[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_diffuse_im[j]; -#endif + hHrtf->pOut_to_bin_diffuse_re_fx[j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_diffuse_re_fx[j]; hHrtf->pOut_to_bin_diffuse_im_fx[j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_diffuse_im_fx[j]; move32(); @@ -1353,7 +1218,7 @@ static ivas_error ivas_rend_initCrend_fx( return IVAS_ERR_OK; } -#endif +#else /*------------------------------------------------------------------------- * initCrend_from_rom() * @@ -2094,7 +1959,7 @@ static ivas_error ivas_rend_initCrend( return IVAS_ERR_OK; } - +#endif /*------------------------------------------------------------------------- * ivas_shoebox_data_init() * @@ -2568,36 +2433,21 @@ ivas_error ivas_rend_initCrendWrapper( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer handle" ); } -#if 1//To be removed later:floating pointer initialization - hCrend->lfe_delay_line = NULL; -#endif hCrend->lfe_delay_line_fx = NULL; FOR ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) { -#if 1//To be removed later:floating pointer initialization - hCrend->freq_buffer_re[i] = NULL; - hCrend->freq_buffer_im[i] = NULL; -#endif hCrend->freq_buffer_re_fx[i] = NULL; hCrend->freq_buffer_im_fx[i] = NULL; } FOR ( i = 0; i < BINAURAL_CHANNELS; i++ ) { -#if 1//To be removed later:floating pointer initialization - hCrend->prev_out_buffer[i] = NULL; -#endif hCrend->prev_out_buffer_fx[i] = NULL; } #if 1 - hCrend->freq_buffer_re_diffuse = NULL; - hCrend->freq_buffer_im_diffuse = NULL; hCrend->hTrack = NULL; - hCrend->m_fYaw = 0; - hCrend->m_fPitch = 0; - hCrend->m_fRoll = 0; #endif hCrend->freq_buffer_re_diffuse_fx = NULL; hCrend->freq_buffer_im_diffuse_fx = NULL; @@ -2731,19 +2581,6 @@ ivas_error ivas_rend_openCrend( FOR ( i = 0; i < hHrtf->max_num_ir; i++ ) { -#if 1/*TODO: Floating point memory allocation:To be removed later*/ - IF ( ( hCrend->freq_buffer_re[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero( hCrend->freq_buffer_re[i], max_total_ir_len ); - IF ( ( hCrend->freq_buffer_im[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero( hCrend->freq_buffer_im[i], max_total_ir_len ); -#endif - IF ( ( hCrend->freq_buffer_re_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); @@ -2758,13 +2595,6 @@ ivas_error ivas_rend_openCrend( FOR ( i = 0; i < BINAURAL_CHANNELS; i++ ) { -#if 1/*TODO: Floating point memory allocation:To be removed later*/ - IF ( ( hCrend->prev_out_buffer[i] = (float *) malloc( sizeof( float ) * subframe_length ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero( hCrend->prev_out_buffer[i], subframe_length ); -#endif IF ( ( hCrend->prev_out_buffer_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * subframe_length ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); @@ -2776,18 +2606,6 @@ ivas_error ivas_rend_openCrend( IF ( GT_16(max_total_ir_len , 0) ) { -#if 1/*TODO: Floating point memory allocation:To be removed later*/ - if ( ( hCrend->freq_buffer_re_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero( hCrend->freq_buffer_re_diffuse, max_total_ir_len ); - if ( ( hCrend->freq_buffer_im_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero( hCrend->freq_buffer_im_diffuse, max_total_ir_len ); -#endif // IF ( ( hCrend->freq_buffer_re_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); @@ -2801,10 +2619,6 @@ ivas_error ivas_rend_openCrend( } ELSE { -#if 1/*TODO: Floating point memory allocation:To be removed later*/ - hCrend->freq_buffer_re_diffuse = NULL; - hCrend->freq_buffer_im_diffuse = NULL; -#endif // hCrend->freq_buffer_re_diffuse_fx = NULL; hCrend->freq_buffer_im_diffuse_fx = NULL; } @@ -2812,13 +2626,6 @@ ivas_error ivas_rend_openCrend( max_total_ir_len = add(extract_l(L_shr(L_add(L_shl(Mult_32_32(hHrtf->latency_s_fx , output_Fs),1) , 1) ,1)) , subframe_length);/*(int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;*/ IF ( GT_16(max_total_ir_len , 0) ) { -#if 1/*TODO: Floating point memory allocation:To be removed later*/ - IF ( ( hCrend->lfe_delay_line = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero( hCrend->lfe_delay_line, max_total_ir_len ); -#endif IF ( ( hCrend->lfe_delay_line_fx = (Word32 *) malloc( sizeof(Word32) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); @@ -2827,9 +2634,6 @@ ivas_error ivas_rend_openCrend( } ELSE { -#if 1/*TODO: Floating point memory allocation:To be removed later*/ - hCrend->lfe_delay_line = NULL; -#endif hCrend->lfe_delay_line_fx = NULL; } @@ -2918,16 +2722,6 @@ void ivas_rend_closeCrend( { for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) { - if ( hCrend->freq_buffer_re[i] != NULL ) - { - free( hCrend->freq_buffer_re[i] ); - hCrend->freq_buffer_re[i] = NULL; - } - if ( hCrend->freq_buffer_im[i] != NULL ) - { - free( hCrend->freq_buffer_im[i] ); - hCrend->freq_buffer_im[i] = NULL; - } if ( hCrend->freq_buffer_re_fx[i] != NULL ) { free( hCrend->freq_buffer_re_fx[i] ); @@ -2942,11 +2736,6 @@ void ivas_rend_closeCrend( for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { - if ( hCrend->prev_out_buffer[i] != NULL ) - { - free( hCrend->prev_out_buffer[i] ); - hCrend->prev_out_buffer[i] = NULL; - } if ( hCrend->prev_out_buffer_fx[i] != NULL ) { free( hCrend->prev_out_buffer_fx[i] ); @@ -2961,11 +2750,6 @@ void ivas_rend_closeCrend( hCrend->lfe_delay_line_fx = NULL; } #endif - if ( hCrend->lfe_delay_line != NULL ) - { - free( hCrend->lfe_delay_line ); - hCrend->lfe_delay_line = NULL; - } if ( hCrend->lfe_delay_line_fx != NULL ) { @@ -2973,17 +2757,6 @@ void ivas_rend_closeCrend( hCrend->lfe_delay_line_fx = NULL; } - if ( hCrend->freq_buffer_re_diffuse != NULL ) - { - free( hCrend->freq_buffer_re_diffuse ); - hCrend->freq_buffer_re_diffuse = NULL; - } - - if ( hCrend->freq_buffer_im_diffuse != NULL ) - { - free( hCrend->freq_buffer_im_diffuse ); - hCrend->freq_buffer_im_diffuse = NULL; - } if ( hCrend->freq_buffer_re_diffuse_fx != NULL ) { free( hCrend->freq_buffer_re_diffuse_fx ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 9968120a27afb7bc13cb02720b1e614a4e045403..79ba4ba4d7972db991dd00e8cc054babc868dcb5 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -4950,8 +4950,8 @@ static void ivas_masa_ext_rend_parambin_internal( FOR( slot = 0; slot < 4; slot++ ) FOR( Word16 ind = 0; ind < 60; ind++ ) { - Cldfb_RealBuffer_in_fx[cha][slot][ind] = float_to_fix( Cldfb_RealBuffer_in[cha][slot][ind], Q6 ); - Cldfb_ImagBuffer_in_fx[cha][slot][ind] = float_to_fix( Cldfb_ImagBuffer_in[cha][slot][ind], Q6 ); + Cldfb_RealBuffer_in_fx[cha][slot][ind] = floatToFixed( Cldfb_RealBuffer_in[cha][slot][ind], Q6 ); + Cldfb_ImagBuffer_in_fx[cha][slot][ind] = floatToFixed( Cldfb_ImagBuffer_in[cha][slot][ind], Q6 ); } ivas_dirac_dec_binaural_process_output_fx(hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat); diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c index ce125f9a11e5ff5e4f56b89d165b9c48faafd08e..b1e24ca062f1582ecaf80a1d532790aaf2ab3391 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -254,6 +254,10 @@ 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) { buffer_size_decorr = (ap_pre_delay[split_band_index_start] + ap_filter_length[split_band_index_start]); @@ -263,6 +267,15 @@ ivas_error ivas_dirac_dec_decorr_open( } 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) + { + 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 + 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")); diff --git a/lib_rend/ivas_dirac_onsets_dec.c b/lib_rend/ivas_dirac_onsets_dec.c index 9a9dfe43d5f008bc2343aabda3f2b1d6dc1af53f..b9f8ddee99d164ee0bbdf9c07979caf610b7e9a3 100644 --- a/lib_rend/ivas_dirac_onsets_dec.c +++ b/lib_rend/ivas_dirac_onsets_dec.c @@ -203,6 +203,7 @@ ivas_error ivas_dirac_dec_onset_detection_open( /* init to zero */ set32_fx(dirac_onset_detection_state->onset_detector_1_fx, 0, num_protos_diff * dirac_onset_detection_params->max_band_decorr); set32_fx(dirac_onset_detection_state->onset_detector_2_fx, 0, num_protos_diff * dirac_onset_detection_params->max_band_decorr); + dirac_onset_detection_state->q_onset_detector = Q31; #endif /*to be cleand up*/ IF((dirac_onset_detection_state->onset_detector_1 = (float *)malloc(sizeof(float) * num_protos_diff * dirac_onset_detection_params->max_band_decorr)) == NULL) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 43a0cb5e8ace7f558626b95a5242cd1cf3e30f95..ca6c7b02fe3b6cde45ffd3093e65006272f243c5 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1618,8 +1618,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word16 diff_start_band; DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params; DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state; - Word16 q_onset; - h_dirac_output_synthesis_params = &( hDirACRend->h_output_synthesis_psd_params ); h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state ); @@ -1703,8 +1701,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( hSpatParamRendCom->diffuseness_vector_fx[md_idx], h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor_fx, - h_dirac_output_synthesis_state->direct_power_factor_q, - h_dirac_output_synthesis_state->diffuse_power_factor_q); + &h_dirac_output_synthesis_state->direct_power_factor_q, + &h_dirac_output_synthesis_state->diffuse_power_factor_q); } } ELSE IF ( EQ_16(dec_param_estim, TRUE )) @@ -1769,11 +1767,11 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( FOR ( ch_idx = 0; ch_idx < s_min( 4, nchan_transport ); ch_idx++ ) { - Word16 k, temp = 0; + Word16 k; IF ( NE_16(ch_idx, 0 )) { - Word32 a, b, c; - Word16 b_exp, sqr_exp, q_diff_aab, q_diff_c; + Word32 a, c; + Word16 b, b_exp, sqr_exp, q_diff_aab, q_diff_c; Word32 mpy_a_a_b, mpy_diff_c, mpy_diff_aab; Word32 sqr_inp, sqr; @@ -3674,7 +3672,6 @@ static void ivas_dirac_dec_get_response_split_order_fx( tmp = BASOP_util_atan2( dv_r_1, dv_r_0, 0 ); // Q13 index_azimuth = shr( mult( tmp, _180_OVER_PI_Q9 ), 7 ); // Q0; - IF(EQ_16(index_azimuth, -180)) { tmp = 0; move16(); @@ -5146,7 +5143,183 @@ void ivas_dirac_dec_compute_power_factors_fx( * * *------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_lfe_synth_with_filters_fx( + MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, /* i/o: LFE synthesis structure for McMASA */ + Word32 *data_fx[], /* o : output signals (Q11) */ + const Word16 output_frame, /* i : output frame length per channel */ + const Word16 separateChannelIndex, /* i : separate channel index */ + const Word16 lfeChannelIndex /* i : LFE channel index */ +) +{ + Word16 lowpassCoef_fx; + Word16 lowpassCoef_fx_exp; + Word16 i, j; + Word32 lowPassSignal_fx[L_FRAME48k]; + Word32 highPassSignal_fx[L_FRAME48k]; + int16_t slot_index; + int16_t subframe_index; + int16_t slotSize; + Word32 transportEne_fx, targetEneLfe_fx, targetEneTrans_fx; + int16_t mrange[2]; + Word16 lfeGain_fx; + Word16 lfeGain_fx_exp; + Word16 transportGain_fx; + Word16 transportGain_fx_exp; + int16_t delay; + + /* Delay the separated channel to sync the LFE synthesis with the DirAC rendering */ + delay = hMasaLfeSynth->delayBuffer_syncDirAC_size; + move16(); + delay_signal_fx( data_fx[separateChannelIndex], output_frame, hMasaLfeSynth->delayBuffer_syncDirAC_fx, delay ); + + /* Filterbank for dividing the separated channel to LFE frequencies and higher frequencies */ + lowpassCoef_fx_exp = 15; + move16(); + lowpassCoef_fx = Inv16( hMasaLfeSynth->ringBufferSize, &lowpassCoef_fx_exp ); + FOR( i = 0; i < output_frame; i++ ) + { + hMasaLfeSynth->lowpassSum_fx = L_add( hMasaLfeSynth->lowpassSum_fx, L_shl( Mpy_32_16_1( L_sub( data_fx[separateChannelIndex][i], hMasaLfeSynth->lfeSynthRingBuffer_fx[hMasaLfeSynth->ringBufferLoPointer] ), lowpassCoef_fx ), lowpassCoef_fx_exp ) ); // Q11 + lowPassSignal_fx[i] = hMasaLfeSynth->lowpassSum_fx; // Q11 + move32(); + highPassSignal_fx[i] = L_sub( hMasaLfeSynth->lfeSynthRingBuffer_fx[hMasaLfeSynth->ringBufferHiPointer], lowPassSignal_fx[i] ); // Q11 + move32(); + hMasaLfeSynth->lfeSynthRingBuffer_fx[hMasaLfeSynth->ringBufferLoPointer] = data_fx[separateChannelIndex][i]; // Q11 + move32(); + + hMasaLfeSynth->ringBufferLoPointer--; + IF( LT_16( hMasaLfeSynth->ringBufferLoPointer, 0 ) ) + { + hMasaLfeSynth->ringBufferLoPointer = sub( hMasaLfeSynth->ringBufferSize, 1 ); + } + + hMasaLfeSynth->ringBufferHiPointer--; + IF( LT_16( hMasaLfeSynth->ringBufferHiPointer, 0 ) ) + { + hMasaLfeSynth->ringBufferHiPointer = sub( hMasaLfeSynth->ringBufferSize, 1 ); + } + } + + /* Synthesize the LFE signal */ + slotSize = shr_r( output_frame, 4 ); // output_frame / CLDFB_NO_COL_MAX + FOR( slot_index = 0; slot_index < CLDFB_NO_COL_MAX; slot_index++ ) + { + subframe_index = shr( slot_index, 4 ); + + mrange[0] = i_mult( slot_index, slotSize ); + move16(); + mrange[1] = i_mult( add( slot_index, 1 ), slotSize ); + move16(); + + transportEne_fx = 0; + move32(); + Word64 W_tmp = 0; + move64(); + FOR( i = mrange[0]; i < mrange[1]; i++ ) + { + W_tmp = W_add( W_tmp, W_mult0_32_32( lowPassSignal_fx[i], lowPassSignal_fx[i] ) ); // Q22 + } + + Word16 tmp_shift = W_norm( W_tmp ); + move16(); + + W_tmp = W_shl( W_tmp, tmp_shift ); + move64(); + + Word16 tmp_q = Q22 + tmp_shift - 32; + move16(); + Word16 tmp_exp; + + transportEne_fx = W_extract_h( W_tmp ); /* Q22 + tmp_shift - 32 */ + targetEneLfe_fx = W_extract_l( W_shr( W_mult0_32_32( transportEne_fx, hMasaLfeSynth->lfeToTotalEnergyRatio_fx[subframe_index] ), Q14 ) ); /* Q22 + tmp_shift - 32 */ + targetEneTrans_fx = W_extract_l( W_shr( W_mult0_32_32( transportEne_fx, s_max( sub( ONE_IN_Q14, hMasaLfeSynth->lfeToTotalEnergyRatio_fx[subframe_index] ), 168 ) ), Q14 ) ); /* Q22 + tmp_shift - 32 */ + + hMasaLfeSynth->transportEneSmooth_fx = Mpy_32_16_1( hMasaLfeSynth->transportEneSmooth_fx, MCMASA_LFE_SYNTH_ALPHA_Q15 ); /* transportEneSmooth_q */ + hMasaLfeSynth->targetEneLfeSmooth_fx = Mpy_32_16_1( hMasaLfeSynth->targetEneLfeSmooth_fx, MCMASA_LFE_SYNTH_ALPHA_Q15 ); /* targetEneLfeSmooth_q */ + hMasaLfeSynth->targetEneTransSmooth_fx = Mpy_32_16_1( hMasaLfeSynth->targetEneTransSmooth_fx, MCMASA_LFE_SYNTH_ALPHA_Q15 ); /* targetEneTransSmooth_q */ + hMasaLfeSynth->transportEneSmooth_fx = BASOP_Util_Add_Mant32Exp( hMasaLfeSynth->transportEneSmooth_fx, ( Q31 - hMasaLfeSynth->transportEneSmooth_q ), transportEne_fx, ( Q31 - tmp_q ), &tmp_exp ); /* Q31 - tmp_exp */ + hMasaLfeSynth->transportEneSmooth_q = sub( Q31, tmp_exp ); + hMasaLfeSynth->targetEneLfeSmooth_fx = BASOP_Util_Add_Mant32Exp( hMasaLfeSynth->targetEneLfeSmooth_fx, ( Q31 - hMasaLfeSynth->targetEneLfeSmooth_q ), targetEneLfe_fx, ( Q31 - tmp_q ), &tmp_exp ); /* Q31 - tmp_exp */ + hMasaLfeSynth->targetEneLfeSmooth_q = sub( Q31, tmp_exp ); + hMasaLfeSynth->targetEneTransSmooth_fx = BASOP_Util_Add_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, ( Q31 - hMasaLfeSynth->targetEneTransSmooth_q ), targetEneTrans_fx, ( Q31 - tmp_q ), &tmp_exp ); /* Q31 - tmp_exp */ + hMasaLfeSynth->targetEneTransSmooth_q = sub( Q31, tmp_exp ); + + IF( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneLfeSmooth_fx, ( Q31 - hMasaLfeSynth->targetEneLfeSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, ( Q31 - hMasaLfeSynth->transportEneSmooth_q ) ) == 1 ) + { + lfeGain_fx = MAX_16; + move16(); + } + ELSE + { + lfeGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneLfeSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &lfeGain_fx_exp ); + lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); + lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); + lfeGain_fx = shl_r( lfeGain_fx, lfeGain_fx_exp ); // Q15 + } + IF( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, ( Q31 - hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, ( Q31 - hMasaLfeSynth->transportEneSmooth_q ) ) == 1 ) + { + transportGain_fx = MAX_16; + move16(); + } + ELSE + { + transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); + transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); + transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); + transportGain_fx = shl_r( transportGain_fx, transportGain_fx_exp ); // Q15 + } + j = 0; + FOR( i = mrange[0]; i < mrange[1]; i++ ) + { + Word32 L_tmp1 = L_mult( transportGain_fx, hMasaLfeSynth->interpolator_fx[j] ); // Q31 + Word32 L_tmp2 = L_mult( hMasaLfeSynth->transportGainPrev_fx, sub( MAX_16, hMasaLfeSynth->interpolator_fx[j] ) ); // Q31 + data_fx[separateChannelIndex][i] = L_add( Mpy_32_32( L_add( L_tmp1, L_tmp2 ), lowPassSignal_fx[i] ), highPassSignal_fx[i] ); + move32(); + Word32 L_tmp3 = L_mult( lfeGain_fx, hMasaLfeSynth->interpolator_fx[j] ); // Q31 + Word32 L_tmp4 = L_mult( hMasaLfeSynth->lfeGainPrev_fx, sub( MAX_16, hMasaLfeSynth->interpolator_fx[j] ) ); + data_fx[lfeChannelIndex][i] = Mpy_32_32( L_add( L_tmp3, L_tmp4 ), lowPassSignal_fx[i] ); + move32(); + j++; + } + + hMasaLfeSynth->lfeGainPrev_fx = lfeGain_fx; + move16(); + hMasaLfeSynth->transportGainPrev_fx = transportGain_fx; + move16(); + } + + /* Lowpass filter for removing remaining mid and high frequencies from the LFE signal */ + lowpassCoef_fx_exp = 15; + move16(); + lowpassCoef_fx = Inv16( hMasaLfeSynth->ringBufferSize2, &lowpassCoef_fx_exp ); + FOR( i = 0; i < output_frame; i++ ) + { + hMasaLfeSynth->lowpassSum2_fx = L_add( hMasaLfeSynth->lowpassSum2_fx, + L_shl_r( L_sub( Mpy_32_16_1( data_fx[lfeChannelIndex][i], lowpassCoef_fx ), + Mpy_32_16_1( hMasaLfeSynth->lfeSynthRingBuffer2_fx[hMasaLfeSynth->ringBufferLoPointer2], lowpassCoef_fx ) ), + lowpassCoef_fx_exp ) ); + hMasaLfeSynth->lfeSynthRingBuffer2_fx[hMasaLfeSynth->ringBufferLoPointer2] = data_fx[lfeChannelIndex][i]; + move32(); + + hMasaLfeSynth->ringBufferLoPointer2--; + IF( LT_16( hMasaLfeSynth->ringBufferLoPointer2, 0 ) ) + { + hMasaLfeSynth->ringBufferLoPointer2 = sub( hMasaLfeSynth->ringBufferSize2, 1 ); + } + + data_fx[lfeChannelIndex][i] = hMasaLfeSynth->lowpassSum2_fx; + move32(); + } + + /* Delay the separated channel to match the delay of the lowpass filter */ + delay = hMasaLfeSynth->delayBuffer_syncLp_size; + move16(); + delay_signal_fx( data_fx[separateChannelIndex], output_frame, hMasaLfeSynth->delayBuffer_syncLp_fx, delay ); + + return; +} +#else void ivas_lfe_synth_with_filters( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, /* i/o: LFE synthesis structure for McMASA */ float *data_f[], /* o : output signals */ @@ -5255,7 +5428,7 @@ void ivas_lfe_synth_with_filters( return; } - +#endif /*------------------------------------------------------------------------- * Local functions diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 85ef5378c280a0b0e8e73027ffa5ddfcfb5870d0..3e2acd87330ba30d4dea6f838e0a87fd79d92f18 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -5815,7 +5815,7 @@ static void ivas_masa_ext_dirac_render_sf( return; } -#ifdef IVAS_FLOAT_FIXED +#ifdef IVAS_FLOAT_FIXED_u //Currently disabled static void ivas_masa_ext_dirac_render_sf_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: IVAS decoder structure */ Word32 *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ @@ -5986,9 +5986,9 @@ static void ivas_masa_ext_dirac_render_sf_fx( { protoSignalComputation_shd_fx( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, + &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, + &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, reference_power, q_reference_power, slot_idx, nchan_transport, hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, @@ -6255,7 +6255,7 @@ void ivas_masa_ext_dirac_render( return; } -#ifdef IVAS_FLOAT_FIXED +#ifdef IVAS_FLOAT_FIXED_u //Currently disabled void ivas_masa_ext_dirac_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ Word32 *output_f[], /* i/o: input/output signals in time domain */ diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index b570c8216c8ead52897a47dd5f877da4525f09bb..0cbdbdb7fd5076b9310b7e65d3bed3df84dc99c7 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -1182,7 +1182,6 @@ ivas_error ivas_orient_trk_SetReferenceVector_fx( IVAS_VECTOR3 acousticFrontVector, ivasForwardVector; IVAS_VECTOR3 listenerPosLevel, refPosLevel; Word32 acousticFrontVectorLength; - Word16 acousticFrontVector_q; IF( pOTR == NULL ) { diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index ece1d6785ac1339a05192042066c048550eb8477..807dce497528019ce91f9c0b7ad5e45ddea4b1fa 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -450,7 +450,7 @@ typedef struct dirac_output_synthesis_state_structure Word16 q_cy_cross_dir_smooth_prev; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ Word16 q_cy_auto_diff_smooth_prev; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ - const Word16 *onset_filter_fx; + const Word32 *onset_filter_fx; /* Temporal smoothing memories */ Word16 *reference_power_smooth_prev_fx; @@ -527,68 +527,77 @@ typedef struct /* McMASA LFE synthesis structure */ typedef struct ivas_mcmasa_lfe_synth_struct { +#ifndef IVAS_FLOAT_FIXED float lfeToTotalEnergyRatio[MAX_PARAM_SPATIAL_SUBFRAMES]; -#ifdef IVAS_FLOAT_FIXED - Word16 lfeToTotalEnergyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; // Q14 +#else + Word16 lfeToTotalEnergyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Q14 */ #endif int16_t lfeGainPrevIndex; +#ifndef IVAS_FLOAT_FIXED float transportEneSmooth; float protoLfeEneSmooth; float targetEneLfeSmooth; float targetEneTransSmooth; -#ifdef IVAS_FLOAT_FIXED - Word32 transportEneSmooth_fx; +#else + Word32 transportEneSmooth_fx; /* transportEneSmooth_q */ Word16 transportEneSmooth_q; - Word32 protoLfeEneSmooth_fx; + Word32 protoLfeEneSmooth_fx; /* protoLfeEneSmooth_q */ Word16 protoLfeEneSmooth_q; - Word32 targetEneLfeSmooth_fx; + Word32 targetEneLfeSmooth_fx; /* targetEneLfeSmooth_q */ Word16 targetEneLfeSmooth_q; - Word32 targetEneTransSmooth_fx; + Word32 targetEneTransSmooth_fx; /* targetEneTransSmooth_q */ Word16 targetEneTransSmooth_q; #endif +#ifndef IVAS_FLOAT_FIXED float *lfeSynthRingBuffer; -#ifdef IVAS_FLOAT_FIXED - Word16 *lfeSynthRingBuffer_fx; +#else + Word32 *lfeSynthRingBuffer_fx; /* Q11 */ #endif int16_t ringBufferLoPointer; int16_t ringBufferHiPointer; +#ifndef IVAS_FLOAT_FIXED float lowpassSum; -#ifdef IVAS_FLOAT_FIXED - Word16 lowpassSum_fx; +#else + Word32 lowpassSum_fx; /* Q11 */ #endif int16_t ringBufferSize; +#ifndef IVAS_FLOAT_FIXED float *lfeSynthRingBuffer2; -#ifdef IVAS_FLOAT_FIXED - Word16 *lfeSynthRingBuffer2_fx; +#else + Word32 *lfeSynthRingBuffer2_fx; /* Q11 */ #endif int16_t ringBufferLoPointer2; +#ifndef IVAS_FLOAT_FIXED float lowpassSum2; -#ifdef IVAS_FLOAT_FIXED - Word16 lowpassSum2_fx; +#else + Word32 lowpassSum2_fx; /* Q11 */ #endif int16_t ringBufferSize2; +#ifndef IVAS_FLOAT_FIXED float *delayBuffer_syncLp; -#ifdef IVAS_FLOAT_FIXED - Word16 *delayBuffer_syncLp_fx; +#else + Word32 *delayBuffer_syncLp_fx; /* Q11 */ #endif int16_t delayBuffer_syncLp_size; +#ifndef IVAS_FLOAT_FIXED float *delayBuffer_syncDirAC; -#ifdef IVAS_FLOAT_FIXED - Word16 *delayBuffer_syncDirAC_fx; +#else + Word32 *delayBuffer_syncDirAC_fx; /* Q11 */ #endif int16_t delayBuffer_syncDirAC_size; +#ifndef IVAS_FLOAT_FIXED float lfeGainPrev; float transportGainPrev; float interpolator[CLDFB_NO_CHANNELS_MAX]; -#ifdef IVAS_FLOAT_FIXED - Word16 lfeGainPrev_fx; - Word16 transportGainPrev_fx; /* Q14 */ - Word16 interpolator_fx[CLDFB_NO_CHANNELS_MAX]; /* Q15 */ +#else + Word16 lfeGainPrev_fx; /* Q15 */ + Word16 transportGainPrev_fx; /* Q15 */ + Word16 interpolator_fx[CLDFB_NO_CHANNELS_MAX]; /* Q15 */ #endif } MCMASA_LFE_SYNTH_DATA, *MCMASA_LFE_SYNTH_DATA_HANDLE; @@ -1824,15 +1833,10 @@ typedef struct #ifdef IVAS_FLOAT_FIXED typedef struct ivas_hrtfs_structure { - float *pOut_to_bin_re[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; Word32 *pOut_to_bin_re_fx[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; - float *pOut_to_bin_im[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; Word32 *pOut_to_bin_im_fx[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; - float *pOut_to_bin_diffuse_re[BINAURAL_CHANNELS]; Word32 *pOut_to_bin_diffuse_re_fx[BINAURAL_CHANNELS]; - float *pOut_to_bin_diffuse_im[BINAURAL_CHANNELS]; Word32 *pOut_to_bin_diffuse_im_fx[BINAURAL_CHANNELS]; - float latency_s; UWord16 num_iterations[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; UWord16 num_iterations_diffuse[BINAURAL_CHANNELS]; UWord16 *pIndex_frequency_max[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; @@ -1840,14 +1844,9 @@ typedef struct ivas_hrtfs_structure UWord16 index_frequency_max_diffuse; Word16 max_num_ir; Word16 max_num_iterations; - float inv_diffuse_weight[MAX_INTERN_CHANNELS]; /* inverse diffuse weights array, access one inverse weight by pInvDiffuseWeight[channel] */ Word16 inv_diffuse_weight_fx[MAX_INTERN_CHANNELS]; /* inverse diffuse weights array, access one inverse weight by pInvDiffuseWeight[channel] */ - float gain_lfe; - -#ifdef IVAS_FLOAT_FIXED Word32 latency_s_fx; Word16 gain_lfe_fx; -#endif } HRTFS_DATA, *HRTFS_HANDLE; #else typedef struct ivas_hrtfs_structure @@ -1873,26 +1872,15 @@ typedef struct ivas_hrtfs_structure /* Main Crend structure */ typedef struct ivas_crend_state_t { - float *freq_buffer_re[MAX_INTERN_CHANNELS]; Word32 *freq_buffer_re_fx[MAX_INTERN_CHANNELS]; - float *freq_buffer_im[MAX_INTERN_CHANNELS]; Word32 *freq_buffer_im_fx[MAX_INTERN_CHANNELS]; - float *freq_buffer_re_diffuse; Word32 *freq_buffer_re_diffuse_fx; - float *freq_buffer_im_diffuse; Word32 *freq_buffer_im_diffuse_fx; - float *prev_out_buffer[BINAURAL_CHANNELS]; Word32 *prev_out_buffer_fx[BINAURAL_CHANNELS]; - float *lfe_delay_line; Word32 *lfe_delay_line_fx; -#ifdef IVAS_FLOAT_FIXED Word32 m_fYaw_fx; Word32 m_fPitch_fx; Word32 m_fRoll_fx; -#endif // IVAS_FLOAT_FIXED - float m_fYaw; - float m_fPitch; - float m_fRoll; ivas_orient_trk_state_t *hTrack; REVERB_HANDLE hReverb; Word16 delay_line_rw_index; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index c49d837e5b8e22130b7c45dfd11283727aa3c7f6..5f5f80b40bad351263447166cceec0773f5ce9ef 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1519,7 +1519,7 @@ static ivas_error getMcConfigValues_fx( return IVAS_ERR_OK; } -#endif +#else static ivas_error getMcConfigValues( AUDIO_CONFIG inConfig, const LSSETUP_CUSTOM_STRUCT *pInCustomLs, @@ -1585,7 +1585,7 @@ static ivas_error getMcConfigValues( return IVAS_ERR_OK; } - +#endif #ifdef IVAS_FLOAT_FIXED static ivas_error initEfap( EFAP_WRAPPER *pEfapWrapper, @@ -2358,14 +2358,6 @@ static ivas_error setRendInputActiveIsm( { return error; } -#ifdef IVAS_FLOAT_FIXED /*Cleanup changes: fixed to float*/ - IF(inputIsm->crendWrapper && inputIsm->crendWrapper->hHrtfCrend != NULL ) - { - inputIsm->crendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( inputIsm->crendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); - inputIsm->crendWrapper->hHrtfCrend->latency_s = fixedToFloat( inputIsm->crendWrapper->hHrtfCrend->latency_s_fx, 31 ); - fixedToFloat_arr( inputIsm->crendWrapper->hHrtfCrend->inv_diffuse_weight_fx, inputIsm->crendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); - } -#endif } else if ( outConfig == IVAS_AUDIO_CONFIG_MASA1 || outConfig == IVAS_AUDIO_CONFIG_MASA2 ) { @@ -2539,7 +2531,7 @@ static void fillIdentityPanMatrix_fx( return; } -#endif +#else /* Note: this only sets non-zero elements, call setZeroPanMatrix() to init first. */ static void fillIdentityPanMatrix( pan_matrix panMatrix ) @@ -2553,7 +2545,7 @@ static void fillIdentityPanMatrix( return; } - +#endif #ifdef IVAS_FLOAT_FIXED static ivas_error initMcPanGainsWithIdentMatrix( input_mc *inputMc ) @@ -3881,15 +3873,6 @@ static ivas_error initMcBinauralRendering( { return error; } -#ifdef IVAS_FLOAT_FIXED /*Cleanup changes: fixed to float*/ - IF(inputMc->crendWrapper && inputMc->crendWrapper->hHrtfCrend != NULL ) - - { - inputMc->crendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( inputMc->crendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); - inputMc->crendWrapper->hHrtfCrend->latency_s = fixedToFloat( inputMc->crendWrapper->hHrtfCrend->latency_s_fx, 31 ); - fixedToFloat_arr( inputMc->crendWrapper->hHrtfCrend->inv_diffuse_weight_fx, inputMc->crendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); - } -#endif } /* Initialise the EFAP handle for rotation on input layout */ @@ -4562,14 +4545,6 @@ static ivas_error updateSbaPanGains( return error; } -#if 1 /*Cleanup changes: fixed to float*/ - IF( inputSba->crendWrapper != NULL && inputSba->crendWrapper->hHrtfCrend != NULL) - { - inputSba->crendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( inputSba->crendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); - inputSba->crendWrapper->hHrtfCrend->latency_s = fixedToFloat( inputSba->crendWrapper->hHrtfCrend->latency_s_fx, 31 ); - fixedToFloat_arr( inputSba->crendWrapper->hHrtfCrend->inv_diffuse_weight_fx, inputSba->crendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); - } -#endif return IVAS_ERR_OK; } #else @@ -6449,7 +6424,7 @@ ivas_error IVAS_REND_GetNumAllObjects( * * *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED ivas_error IVAS_REND_GetDelay( IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ int16_t *nSamples, /* o : Renderer delay in samples */ @@ -6519,6 +6494,81 @@ ivas_error IVAS_REND_GetDelay( return IVAS_ERR_OK; } +#else +ivas_error IVAS_REND_GetDelay_fx( + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ + Word16 *nSamples, /* o : Renderer delay in samples */ + Word32 *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ +) +{ + /* TODO tmu : this function only returns the maximum delay across all inputs + * Ideally each input has its own delay buffer and everything is aligned (binaural and LFE filtering delays are nonuniform) + */ + Word16 i; + Word32 latency_ns; + Word32 max_latency_ns; + + Word32 timescale_by_ns[7] = { 0, 17180, 34360, 0, 68719, 0, 103079 }; + + /* Validate function arguments */ + IF ( hIvasRend == NULL || nSamples == NULL || timeScale == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *timeScale = hIvasRend->sampleRateOut; + assert( *timeScale == 8000 || *timeScale == 16000 || *timeScale == 32000 || *timeScale == 48000 ); + *nSamples = 0; + max_latency_ns = 0; + + /* Compute the maximum delay across all inputs */ + FOR ( i = 0; i < RENDERER_MAX_ISM_INPUTS; i++ ) + { + IF ( NE_32(hIvasRend->inputsIsm[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID )) + { + latency_ns = L_max( ( hIvasRend->inputsIsm[i].crendWrapper != NULL ) ? hIvasRend->inputsIsm[i].crendWrapper->binaural_latency_ns : 0, + hIvasRend->inputsIsm[i].tdRendWrapper.binaural_latency_ns ); + max_latency_ns = L_max( max_latency_ns, latency_ns ); + } + } + + FOR ( i = 0; i < RENDERER_MAX_MC_INPUTS; i++ ) + { + IF ( NE_32(hIvasRend->inputsMc[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID )) + { + latency_ns = L_max( ( hIvasRend->inputsMc[i].crendWrapper != NULL ) ? hIvasRend->inputsMc[i].crendWrapper->binaural_latency_ns : 0, + hIvasRend->inputsMc[i].tdRendWrapper.binaural_latency_ns ); + max_latency_ns = L_max( max_latency_ns, latency_ns ); + } + } + + FOR ( i = 0; i < RENDERER_MAX_SBA_INPUTS; i++ ) + { + IF ( NE_32(hIvasRend->inputsSba[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID )) + { + { + latency_ns = ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ? hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns : 0; + max_latency_ns = L_max( max_latency_ns, latency_ns ); + } + } + } + + + FOR ( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ ) + { + IF ( NE_32(hIvasRend->inputsMasa[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID )) + { + latency_ns = (Word32) ( IVAS_FB_DEC_DELAY_NS ); + max_latency_ns = L_max( max_latency_ns, latency_ns ); + } + } + + //*nSamples = (Word16) roundf( (float) max_latency_ns * *timeScale / 1000000000.f ); + *nSamples = extract_l( Mpy_32_32_r( max_latency_ns, timescale_by_ns[*timeScale / 8000] ) ); + + return IVAS_ERR_OK; +} +#endif #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* @@ -11075,21 +11125,25 @@ static ivas_error getSamplesInternal( FOR ( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ ) { - numMasaInputs += hIvasRend->inputsMasa[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID ? 0 : 1; + //numMasaInputs += hIvasRend->inputsMasa[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID ? 0 : 1; + numMasaInputs = EQ_32( L_add( numMasaInputs, hIvasRend->inputsMasa[i].base.inConfig ), IVAS_AUDIO_CONFIG_INVALID ) ? 0 : 1; } FOR ( i = 0; i < RENDERER_MAX_MC_INPUTS; i++ ) { - numOtherInputs += hIvasRend->inputsMc[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID ? 0 : 1; + //numOtherInputs += hIvasRend->inputsMc[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID ? 0 : 1; + numOtherInputs = EQ_32( L_add( numOtherInputs, hIvasRend->inputsMc[i].base.inConfig ), IVAS_AUDIO_CONFIG_INVALID ) ? 0 : 1; } FOR ( i = 0; i < RENDERER_MAX_SBA_INPUTS; i++ ) { - numOtherInputs += hIvasRend->inputsSba[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID ? 0 : 1; + //numOtherInputs += hIvasRend->inputsSba[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID ? 0 : 1; + numOtherInputs = EQ_32( L_add( numOtherInputs, hIvasRend->inputsSba[i].base.inConfig ), IVAS_AUDIO_CONFIG_INVALID ) ? 0 : 1; } /* For ISM, we check only first as all ISMs are handled together via OMASA when merging to MASA. */ - numOtherInputs += hIvasRend->inputsIsm[0].base.inConfig == IVAS_AUDIO_CONFIG_INVALID ? 0 : 1; + //numOtherInputs += hIvasRend->inputsIsm[0].base.inConfig == IVAS_AUDIO_CONFIG_INVALID ? 0 : 1; + numOtherInputs = EQ_32( L_add( numOtherInputs, hIvasRend->inputsIsm[0].base.inConfig ), IVAS_AUDIO_CONFIG_INVALID ) ? 0 : 1; test(); IF ( EQ_16(numMasaInputs , 0) || EQ_16(numOtherInputs , 0) ) { diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 1353922151a57f6a67185ccf0ccb4228c7ec2e64..9f5695c488605b07ebe14faef457556b810b5c82 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -230,6 +230,13 @@ ivas_error IVAS_REND_GetDelay( int16_t *nSamples, /* o : Renderer delay in samples */ int32_t *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ ); +#ifdef IVAS_FLOAT_FIXED +ivas_error IVAS_REND_GetDelay_fx( + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ + Word16 *nSamples, /* o : Renderer delay in samples */ + Word32 *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ +); +#endif // IVAS_FLOAT_FIXED /* Functions to be called during rendering */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 29bd4a8b080477c528347910ce10cbfd141de9a3..f35783a9b3c04c4a9e084ee0fc8a3219774072b6 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -918,8 +918,7 @@ static ivas_error create_HRTF_from_rawdata( uint16_t max_total_num_fsamp_per_iteration, max_total_num_fsamp_per_iteration_diff; uint32_t mem_size; char *hrtf_data_rptr; - float *pOut_to_bin_wptr; - //Word32 *pOut_to_bin_wptr_fx; + Word32 *pOut_to_bin_wptr_fx; ivas_error error; if ( *hHRTF == NULL ) @@ -942,31 +941,32 @@ static ivas_error create_HRTF_from_rawdata( hrtf_data_rptr = hrtf_data; /* latency_s */ - ( *hHRTF )->latency_s = *( (float *) ( hrtf_data_rptr ) ); + //( *hHRTF )->latency_s = *( (float *) ( hrtf_data_rptr ) ); + ( *hHRTF )->latency_s_fx = (Word32) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q31 ); hrtf_data_rptr += sizeof( float ); /* max_num_ir */ - ( *hHRTF )->max_num_ir = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + ( *hHRTF )->max_num_ir = *( (UWord16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( UWord16 ); /* BINAURAL_CHANNELS */ - if ( BINAURAL_CHANNELS != *( (int16_t *) ( hrtf_data_rptr ) ) ) + if ( BINAURAL_CHANNELS != *( (Word16 *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file format not compliant (BINAURAL_CHANNELS)" ); } - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += sizeof( UWord16 ); /* max_num_iterations */ - ( *hHRTF )->max_num_iterations = *( (int16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( int16_t ); + ( *hHRTF )->max_num_iterations = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); /* num_iterations */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { - ( *hHRTF )->num_iterations[i][j] = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + ( *hHRTF )->num_iterations[i][j] = *( (UWord16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( UWord16 ); } } @@ -975,8 +975,8 @@ static ivas_error create_HRTF_from_rawdata( { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { - mem_size = ( *hHRTF )->max_num_iterations * sizeof( uint16_t ); - ( *hHRTF )->pIndex_frequency_max[i][j] = (uint16_t *) malloc( mem_size ); + mem_size = ( *hHRTF )->max_num_iterations * sizeof( UWord16 ); + ( *hHRTF )->pIndex_frequency_max[i][j] = (UWord16 *) malloc( mem_size ); if ( ( *hHRTF )->pIndex_frequency_max[i][j] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max" ); @@ -987,23 +987,23 @@ static ivas_error create_HRTF_from_rawdata( } /* max_num_iterations_diffuse */ - max_num_iterations_diffuse = *( (int16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( int16_t ); + max_num_iterations_diffuse = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); if ( max_num_iterations_diffuse != 0 ) { /* num_iterations_diffuse */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { - ( *hHRTF )->num_iterations_diffuse[j] = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + ( *hHRTF )->num_iterations_diffuse[j] = *( (UWord16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( UWord16 ); } /* pIndex_frequency_max_diffuse (the size depends on num_iterations_diffuse) */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { - mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t ); - ( *hHRTF )->pIndex_frequency_max_diffuse[j] = (uint16_t *) malloc( mem_size ); + mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( UWord16 ); + ( *hHRTF )->pIndex_frequency_max_diffuse[j] = (UWord16 *) malloc( mem_size ); if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max_diffuse" ); @@ -1014,20 +1014,20 @@ static ivas_error create_HRTF_from_rawdata( } /* index_frequency_max_diffuse */ - ( *hHRTF )->index_frequency_max_diffuse = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + ( *hHRTF )->index_frequency_max_diffuse = *( (UWord16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( UWord16 ); /* inv_diffuse_weight */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { - ( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) ); + //( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) ); ( *hHRTF )->inv_diffuse_weight_fx[i] = ( Word16 ) (* ( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15); hrtf_data_rptr += sizeof( float ); } /* max_total_num_fsamp_per_iteration */ - max_total_num_fsamp_per_iteration = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + max_total_num_fsamp_per_iteration = *( (UWord16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( UWord16 ); /* coeff_re (the size depends on pIndex_frequency_max) */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) @@ -1035,12 +1035,6 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); - ( *hHRTF )->pOut_to_bin_re[i][j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_re[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_re" ); - } - memset( ( *hHRTF )->pOut_to_bin_re[i][j], 0x00, mem_size ); ( *hHRTF )->pOut_to_bin_re_fx[i][j] = (Word32 *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_re_fx[i][j] == NULL ) { @@ -1048,81 +1042,60 @@ static ivas_error create_HRTF_from_rawdata( } memset( ( *hHRTF )->pOut_to_bin_re_fx[i][j], 0x00, mem_size ); - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_re[i][j]; - // pOut_to_bin_wptr_fx = ( *hHRTF )->pOut_to_bin_re_fx[i][j]; + pOut_to_bin_wptr_fx = ( *hHRTF )->pOut_to_bin_re_fx[i][j]; for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - /* for ( Word16 l = 0; l < mem_size ;l++) + //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for ( Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max[i][j][k]; l++ ) { - pOut_to_bin_wptr_fx[l] = hrtf_data_rptr[l] * ONE_IN_Q29; - }*/ - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max[i][j][k]; - // pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max[i][j][k]; + float *tmp, temp_buf[1]; + tmp = temp_buf; + memcpy( tmp, hrtf_data_rptr, sizeof( float ) ); + pOut_to_bin_wptr_fx[l] = (Word32) ( (float) hrtf_data_rptr[l] * ONE_IN_Q29 ); + pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); + hrtf_data_rptr += sizeof( float ); + } + //hrtf_data_rptr += mem_size; + pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max[i][j][k]; } - /*for ( k = 0; k < 240; k++ ) - { - ( *hHRTF )->pOut_to_bin_re_fx[i][j][k] = ( *hHRTF )->pOut_to_bin_re[i][j][k] * ONE_IN_Q29; - }*/ } } mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - for ( k = 0; (UWord32) k < mem_size / 4; k++ ) - { - ( *hHRTF )->pOut_to_bin_re_fx[i][j][k] =(Word32) (( *hHRTF )->pOut_to_bin_re[i][j][k] * ONE_IN_Q29); - } - } - - - } + /* coeff_im (the size depends on pIndex_frequency_max) */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); - ( *hHRTF )->pOut_to_bin_im[i][j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_im[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_im" ); - } - memset( ( *hHRTF )->pOut_to_bin_im[i][j], 0x00, mem_size ); ( *hHRTF )->pOut_to_bin_im_fx[i][j] = (Word32 *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_im_fx[i][j] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_im" ); } memset( ( *hHRTF )->pOut_to_bin_im_fx[i][j], 0x00, mem_size ); - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_im[i][j]; + pOut_to_bin_wptr_fx = ( *hHRTF )->pOut_to_bin_im_fx[i][j]; for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max[i][j][k]; + //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for (Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max[i][j][k]; l++) + { + float *tmp, temp_buf[1]; + tmp = temp_buf; + memcpy( tmp, hrtf_data_rptr, sizeof( float ) ); + pOut_to_bin_wptr_fx[l] = (Word32) ( (float) hrtf_data_rptr[l] * ONE_IN_Q29 ); + pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); + hrtf_data_rptr += sizeof( float ); + } + //hrtf_data_rptr += mem_size; + pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max[i][j][k]; } } } mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - for ( k = 0; (UWord32) k < mem_size / 4; k++ ) - { - // ( *hHRTF )->pOut_to_bin_re_fx[i][j][k] = ( *hHRTF )->pOut_to_bin_re[i][j][k] * ONE_IN_Q29; - ( *hHRTF )->pOut_to_bin_im_fx[i][j][k] = (Word32) (( *hHRTF )->pOut_to_bin_im[i][j][k] * ONE_IN_Q29); - } - } - - - } + /* max_total_num_fsamp_per_iteration_diff */ max_total_num_fsamp_per_iteration_diff = *( (uint16_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( uint16_t ); @@ -1133,12 +1106,6 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); - ( *hHRTF )->pOut_to_bin_diffuse_re[j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_re" ); - } - memset( ( *hHRTF )->pOut_to_bin_diffuse_re[j], 0x00, mem_size ); ( *hHRTF )->pOut_to_bin_diffuse_re_fx[j] = (Word32 *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_diffuse_re_fx[j] == NULL ) @@ -1146,34 +1113,30 @@ static ivas_error create_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_re" ); } memset( ( *hHRTF )->pOut_to_bin_diffuse_re_fx[j], 0x00, mem_size ); - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_re[j]; + pOut_to_bin_wptr_fx = ( *hHRTF )->pOut_to_bin_diffuse_re_fx[j]; for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; + //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for (Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max_diffuse[j][k]; l++) + { + float *tmp, temp_buf[1]; + tmp = temp_buf; + memcpy( tmp, hrtf_data_rptr, sizeof( float ) ); + pOut_to_bin_wptr_fx[l] = (Word32) ( (float) hrtf_data_rptr[l] * ONE_IN_Q29 ); + pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); + hrtf_data_rptr += sizeof( float ); + } + //hrtf_data_rptr += mem_size; + pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; } } mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - for ( k = 0; (UWord32) k < mem_size / 4; k++ ) - { - ( *hHRTF )->pOut_to_bin_diffuse_re_fx[j][k] = (Word32) (( *hHRTF )->pOut_to_bin_diffuse_re[j][k] * ONE_IN_Q31); - // ( *hHRTF )->pOut_to_bin_diffuse_im_fx[j][k] = ( *hHRTF )->pOut_to_bin_diffuse_im[j][k] * ONE_IN_Q31; - } - } + /* coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); - ( *hHRTF )->pOut_to_bin_diffuse_im[j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_im" ); - } - memset( ( *hHRTF )->pOut_to_bin_diffuse_im[j], 0x00, mem_size ); ( *hHRTF )->pOut_to_bin_diffuse_im_fx[j] = (Word32 *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_diffuse_im_fx[j] == NULL ) @@ -1181,25 +1144,25 @@ static ivas_error create_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_im" ); } memset( ( *hHRTF )->pOut_to_bin_diffuse_im_fx[j], 0x00, mem_size ); - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_im[j]; + pOut_to_bin_wptr_fx = ( *hHRTF )->pOut_to_bin_diffuse_im_fx[j]; for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; + //memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); + for ( Word16 l = 0; l < (*hHRTF)->pIndex_frequency_max_diffuse[j][k]; l++ ) + { + float *tmp, temp_buf[1]; + tmp = temp_buf; + memcpy( tmp, hrtf_data_rptr, sizeof( float ) ); + pOut_to_bin_wptr_fx[l] = (Word32) ( (float) hrtf_data_rptr[l] * ONE_IN_Q29 ); + pOut_to_bin_wptr_fx[l] = (Word32) ( *tmp * ONE_IN_Q29 ); + hrtf_data_rptr += sizeof( float ); + } + //hrtf_data_rptr += mem_size; + pOut_to_bin_wptr_fx += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; } } mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - for ( k = 0; (UWord32) k < mem_size / 4; k++ ) - { - //( *hHRTF )->pOut_to_bin_diffuse_re_fx[j][k] = ( *hHRTF )->pOut_to_bin_diffuse_re[j][k] * ONE_IN_Q31; - ( *hHRTF )->pOut_to_bin_diffuse_im_fx[j][k] = (Word32) (( *hHRTF )->pOut_to_bin_diffuse_im[j][k] * ONE_IN_Q31); - } - } - } return IVAS_ERR_OK; @@ -2079,14 +2042,6 @@ static ivas_error destroy_HRTF( { free( ( *hHRTF )->pIndex_frequency_max[i][j] ); } - if ( ( *hHRTF )->pOut_to_bin_re[i][j] != NULL ) - { - free( ( *hHRTF )->pOut_to_bin_re[i][j] ); - } - if ( ( *hHRTF )->pOut_to_bin_im[i][j] != NULL ) - { - free( ( *hHRTF )->pOut_to_bin_im[i][j] ); - } if ( ( *hHRTF )->pOut_to_bin_re_fx[i][j] != NULL ) { free( ( *hHRTF )->pOut_to_bin_re_fx[i][j] ); @@ -2103,14 +2058,6 @@ static ivas_error destroy_HRTF( { free( ( *hHRTF )->pIndex_frequency_max_diffuse[j] ); } - if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] != NULL ) - { - free( ( *hHRTF )->pOut_to_bin_diffuse_re[j] ); - } - if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] != NULL ) - { - free( ( *hHRTF )->pOut_to_bin_diffuse_im[j] ); - } if ( ( *hHRTF )->pOut_to_bin_diffuse_re_fx[j] != NULL ) { free( ( *hHRTF )->pOut_to_bin_diffuse_re_fx[j] ); diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index b52e9acf4adc320b999a18fe6099e25478c21067..cd548002a16cade53038cc6c315a6371e2c03a9a 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -35,6 +35,9 @@ #include #include #include "prot.h" +#ifdef IVAS_FLOAT_FIXED +#include "prot_fx2.h" +#endif struct RotFileReader @@ -124,11 +127,24 @@ ivas_error HeadRotationFileReading( pQuaternion->x = x; pQuaternion->y = y; pQuaternion->z = z; +#ifdef IVAS_FLOAT_FIXED + pQuaternion->w_fx = floatToFixed_32(w, Q31); + pQuaternion->x_fx = floatToFixed_32(x, Q31); + pQuaternion->y_fx = floatToFixed_32(y, Q31); + pQuaternion->z_fx = floatToFixed_32(z, Q31); + pQuaternion->q_fact = Q31; +#endif if ( pPos != NULL ) { pPos->x = posx; pPos->y = posy; pPos->z = posz; +#ifdef IVAS_FLOAT_FIXED + pPos->x_fx = floatToFixed_32(posx, Q25); + pPos->y_fx = floatToFixed_32(posy, Q25); + pPos->z_fx = floatToFixed_32(posz, Q25); + pPos->q_fact = Q25; +#endif } return IVAS_ERR_OK;