From 14b77bd3a5e1158ec44a69cb0deed414a5edb8a6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 7 Feb 2023 17:26:41 +0100 Subject: [PATCH 01/40] - move lib_rend related declarations from ivast_prot.h to ivas_lib_rend_internal.h - VE2AT comments --- lib_com/ivas_prot.h | 510 +----------------------- lib_dec/ivas_rom_dec.h | 4 +- lib_rend/ivas_allrad_dec.c | 5 +- lib_rend/ivas_binauralRenderer.c | 3 +- lib_rend/ivas_binaural_reverb.c | 7 +- lib_rend/ivas_crend.c | 1 + lib_rend/ivas_hrtf.c | 11 +- lib_rend/ivas_lib_rend_internal.h | 524 ++++++++++++++++++++++++- lib_rend/ivas_ls_custom_dec.c | 2 +- lib_rend/ivas_objectRenderer.c | 26 +- lib_rend/ivas_objectRenderer_hrFilt.c | 5 +- lib_rend/ivas_objectRenderer_mix.c | 1 + lib_rend/ivas_objectRenderer_sources.c | 3 +- lib_rend/ivas_reverb.c | 1 + lib_rend/ivas_reverb_fft_filter.c | 1 + lib_rend/ivas_reverb_filter_design.c | 1 + lib_rend/ivas_reverb_utils.c | 5 +- lib_rend/ivas_rom_rend.c | 2 +- lib_rend/ivas_rom_rend.h | 12 +- lib_rend/ivas_rotation.c | 9 +- lib_rend/ivas_sba_rendering.c | 15 +- lib_rend/ivas_stat_rend.h | 7 +- lib_rend/lib_rend.h | 2 +- lib_util/hrtf_file_reader.c | 9 +- 24 files changed, 603 insertions(+), 563 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6f4d27d5e8..7a3f0a2c78 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3182,6 +3182,7 @@ void ivas_sba_getTCs( const int16_t input_frame /* i : frame length */ ); +// VE2AT: move to ivas_lib_rend_internal.h ? ivas_error ivas_sba_linear_renderer( float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ @@ -3211,19 +3212,13 @@ void ivas_sba_dirac_stereo_smooth_parameters( STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: encoder DFT stereo handle */ ); +// VE2AT: move to ivas_lib_rend_internal.h ? ivas_error ivas_sba_get_hoa_dec_matrix( const IVAS_OUTPUT_SETUP hOutSetup, /* i : target output setup */ float **hoa_dec_mtx, /* o : ALLRAD decoder matrix */ const int16_t ambisonics_order /* i : Ambisonics order */ ); -void ivas_sba_mtx_mult( - float output_f[][L_FRAME48k], /* i/o: synthesized core-corder transport channels/DirAC output */ - const int16_t output_frame, /* i : frame length per channel */ - const int16_t nchan_in, /* i : Number of ambisonic channels */ - const IVAS_OUTPUT_SETUP output_setup, /* i : Output configuration */ - const float *mtx_hoa_decoder /* o : HOA decoding matrix */ -); /*----------------------------------------------------------------------------------* * DirAC prototypes @@ -3332,7 +3327,7 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ ); #endif - +// VE2AT: move to lib_rend ? void ivas_dirac_dec_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ @@ -4646,24 +4641,12 @@ void ivas_HRTF_parambin_binary_close( ); #endif +// VE2AT: move to ivas_lib_rend_internal.h ?? void QuatToRotMat( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ); -void Quat2Euler( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float *yaw, /* o : yaw */ - float *pitch, /* o : pitch */ - float *roll /* o : roll */ -); - -void SHrotmatgen( - float SHrotmat[SBA_NHARM_HOA3][SBA_NHARM_HOA3], /* o : SHD rotation matrix */ - float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t order /* i : ambisonics order */ -); - void rotateAziEle( float azi_in, /* i : output elevation */ float ele_in, /* i : input elevation */ @@ -4685,39 +4668,6 @@ ivas_error ivas_headTrack_open( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ ); -void rotateFrame_shd( - HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ - float output[][L_FRAME48k], /* i/o: unrotated HOA3 signal buffer in TD */ - const int16_t subframe_len, /* i : subframe length per channel */ - const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ - const int16_t subframe_idx /* i : subframe index */ -); - -void rotateFrame_sd( - HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ - float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */ - const int16_t subframe_len, /* i : subframe length per channel */ - const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ - const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ - const int16_t subframe_idx /* i : subframe index */ -); - -void rotateFrame_shd_cldfb( - float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */ - float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ - float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t nInChannels, /* i : number of channels */ - const int16_t shd_rot_max_order /* i : split-order rotation method */ -); - -void rotateFrame_sd_cldfb( - HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ - float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */ - float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ - const IVAS_OUTPUT_SETUP_HANDLE hOutputSetup, /* i : output format setup number of channels */ - const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ - const int16_t nb_band /* i : number of CLDFB bands to process */ -); /*----------------------------------------------------------------------------------* @@ -4749,15 +4699,6 @@ void ivas_mc2sba( const float gain_lfe /* i : gain for LFE, 0=ignore LFE */ ); -void ivas_sba2mc_cldfb( - IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */ - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part */ - const int16_t nb_channels_out, /* i : nb of output channels */ - const int16_t nb_bands, /* i : nb of CLDFB bands to process */ - const float *hoa_dec_mtx /* i : HOA decoding mtx */ -); - void ivas_ism2sba( float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ @@ -5081,11 +5022,6 @@ void ivas_HRTF_binary_close( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); -void DefaultBSplineModel( - TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */ - const int32_t output_Fs /* i : Output sampling rate */ -); - ivas_error ivas_td_binaural_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); @@ -5100,25 +5036,6 @@ void ObjRenderIVASFrame( const int16_t output_frame /* i : output frame length */ ); -void BSplineModelEvalAlloc( - ModelParams_t *model, /* i : Model parameters */ - ModelEval_t *modelEval /* i/o: Model evaluation structure */ -); - -/* ----- Object renderer - hrfilt ----- */ - -void GetFilterFromAngle( - TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* i/o: HR filter set structure */ - const float Elev, /* i : Elevation, degrees */ - float Azim, /* i : Azimuth, degrees */ - float *LeftFilter, /* o : Left HR filter */ - float *RightFilter, /* o : Right HR filter */ - int16_t *itd /* o : ITD value */ -); - -void HRTF_model_precalc( - ModelParams_t *model /* i/o: HRTF Model parameters */ -); void BSplineModelEvalDealloc( ModelParams_t *model, /* i : Model parameters */ @@ -5126,164 +5043,6 @@ void BSplineModelEvalDealloc( ); - -ivas_error TDREND_REND_RenderSourceHRFilt( - TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */ - const float *hrf_left_delta, /* i: Left filter interpolation delta */ - const float *hrf_right_delta, /* i: Right filter interpolation delta */ - const int16_t intp_count, /* i: Interpolation count */ - float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */ - const int16_t subframe_length /* i : Subframe length in use */ -); - -/* ----- Object renderer - sources ----- */ - -ivas_error TDREND_MIX_SRC_SetPos( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float *Vec_p /* i : Position vector */ -); - -ivas_error TDREND_MIX_SRC_SetDir( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float *Vec_p /* i : Direction vector */ -); - -ivas_error TDREND_MIX_SRC_SetDirAtten( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */ -); - -ivas_error TDREND_MIX_SRC_SetPlayState( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const TDREND_PlayStatus_t PlayStatus /* i : Play state */ -); - -void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ - TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - float *hrf_left_prev, /* o: Left filter */ - float *hrf_right_prev, /* o: Right filter */ - float *hrf_left_delta, /* o: Left filter interpolation delta */ - float *hrf_right_delta, /* o: Right filter interpolation delta */ - int16_t *intp_count, /* o: Interpolation count */ - int16_t *filterlength, /* o: Length of filters */ - int16_t *itd, /* o: ITD value */ - float *Gain, /* o: Gain value */ - TDREND_SRC_t *Src_p, - const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ -); - -ivas_error TDREND_SRC_Alloc( - TDREND_SRC_t **Src_pp /* i/o: Source */ -); - -void TDREND_SRC_Dealloc( - TDREND_SRC_t *Src_p /* i/o: Source to deallocate */ -); - -void TDREND_SRC_Init( - TDREND_SRC_t *Src_p, /* i/o: Source to initialize */ - const TDREND_PosType_t PosType /* i : Position type specifier */ -); - -/* ----- Object renderer - vec ----- */ - -void TDREND_SPATIAL_VecInit( - float *Pos_p, /* o : Output vector */ - const float PosX, /* i : X value */ - const float PosY, /* i : Y value */ - const float PosZ /* i : Z value */ -); - -/*! r: Euclidian norm value */ -float TDREND_SPATIAL_VecNorm( - const float *Vec_p /* i : Vector for norm calculation */ -); - -void TDREND_SPATIAL_VecNormalize( - const float *Vec_p, /* i : Input vector */ - float *VecNorm_p /* o : Output vector */ -); - -void TDREND_SPATIAL_VecMapToNewCoordSystem( - const float *Vec_p, /* i : Input vector */ - const float *TranslVec_p, /* i : Translation vector */ - const float *DirVec_p, /* i : Direction vector */ - const float *UpVec_p, /* i : Up vector */ - const float *RightVec_p, /* i : Right vector */ - float *MappedVec_p /* o : Transformed vector */ -); - -/*! r: Flag if the orientation has been updated */ -int16_t TDREND_SPATIAL_EvalOrthonormOrient( - float *FrontVecON_p, /* o : Normalized front vector */ - float *UpVecON_p, /* o : Normalized up vector */ - float *RightVecON_p, /* o : Normalized right vector */ - const float *FrontVec_p, /* i : Input front vector */ - const float *UpVec_p /* i : Input up vector */ -); - -/* ----- Object renderer - mix ----- */ - -ivas_error TDREND_MIX_AddSrc( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - int16_t *SrcInd, /* o : Source index */ - const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */ -); - -ivas_error TDREND_MIX_SetDistAttenModel( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const TDREND_DistAttenModel_t DistAttenModel /* i : Distance attenuation model */ -); - -void TDREND_MIX_LIST_SetPos( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const float *Pos_p /* i : Listener's position */ -); - -ivas_error TDREND_MIX_LIST_SetOrient( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const float *FrontVec_p, /* i : Listener's orientation front vector */ - const float *UpVec_p /* i : Listener's orientation up vector */ -); - -void TDREND_MIX_Dealloc( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle */ -); - -ivas_error TDREND_MIX_Init( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HRTF data (initialized in case of NULL) */ - const TDREND_MixSpatSpec_t *MixSpatSpec_p, /* i : Mixer spatial specification */ - const int32_t output_Fs /* i : Output sampling rate */ -); - - /* ----- Object renderer - sfx ----- */ - -void TDREND_Apply_ITD( - float *input, /* i: Input SCE subframe to be time adjusted */ - float *out_left, /* o: Output left channels with ITD applied */ - float *out_right, /* o: Output right channels with ITD applied */ - int16_t *previtd, /*i/o: Previous ITD value */ - const int16_t itd, /* i: Current subframe ITD value */ - float *mem_itd, /*i/o: ITD buffer memory */ - const int16_t length /* i: Subframe length */ -); - -void TDREND_firfilt( - float *signal, /* i/o: Input signal / Filtered signal */ - float *filter, /* i/o: FIR filter */ - const float *filter_delta, /* i : FIR filter delta */ - const int16_t intp_count, /* i : interpolation count */ - float *mem, /* i/o: filter memory */ - const int16_t subframe_length, /* i : Length of signal */ - const int16_t filterlength /* i : Filter length */ -); /*----------------------------------------------------------------------------------* * Filter-bank (FB) Mixer *----------------------------------------------------------------------------------*/ @@ -5410,26 +5169,10 @@ ivas_error ivas_crend_process( ); #else - -IVAS_REND_AudioConfigType getAudioConfigType( - const IVAS_REND_AudioConfig config ); - -ivas_error getAudioConfigNumChannels( - const IVAS_REND_AudioConfig config, - int16_t *numChannels ); - +// VE2AT: declaration here in Codec but definition in Rend IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( - AUDIO_CONFIG config ); - -ivas_error ivas_rend_initCrend( - CREND_WRAPPER *pCrend, - const IVAS_REND_AudioConfig inConfig, - const IVAS_REND_AudioConfig outConfig, - RENDER_CONFIG_DATA *hRendCfg, -#ifdef HRTF_BINARY_FILE - HRTFS_CREND_HANDLE hSetOfHRTF, -#endif - const int32_t output_Fs ); + AUDIO_CONFIG config +); ivas_error ivas_rend_openCrend( CREND_WRAPPER_HANDLE *pCrend, @@ -5440,7 +5183,8 @@ ivas_error ivas_rend_openCrend( #ifdef HRTF_BINARY_FILE HRTFS_CREND_HANDLE hSetOfHRTF, #endif - const int32_t output_Fs ); + const int32_t output_Fs +); #ifdef FIX_197_CREND_INTERFACE void ivas_rend_closeCrend( @@ -5458,7 +5202,8 @@ ivas_error ivas_rend_crendProcess( IVAS_OUTPUT_SETUP_HANDLE hIntSetup, EFAP_HANDLE hEFAPdata, float output[][L_FRAME48k], /* i/o: input/output audio channels */ - const int32_t output_Fs ); + const int32_t output_Fs +); #endif /*----------------------------------------------------------------------------------* @@ -5479,239 +5224,6 @@ ivas_error ivas_render_config_init_from_rom( ); -/*----------------------------------------------------------------------------------* - * Reverberator - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_reverb_open( - REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ - const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ - const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ - RENDER_CONFIG_DATA *pConfig, /* i : Reverb configuration */ - const int32_t output_Fs /* i : output sampling rate */ -); - -void ivas_reverb_close( - REVERB_HANDLE *hReverb /* i/o: Reverberator handle */ -); - -ivas_error ivas_reverb_process( - REVERB_HANDLE hReverb, /* i/o: reverb state */ - const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ - const int16_t mix_signals, /* i : add reverb to output signal */ - float pcm_in[][L_FRAME48k], /* i : the PCM audio to apply reverb on */ - float pcm_out[][L_FRAME48k], /* o : the PCM audio with reverb applied */ - const int16_t i_ts -); - -void ivas_rev_delay_line_init( - ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */ - float *memory_buffer, /* i : the memory buffer to use for the delay line */ - const uint16_t delay, /* i : the delay */ - const uint16_t maxdelay /* i : maximum delay to be supported */ -); - -/* !r: sample gotten out of delay line, and amplified by set gain */ -float ivas_rev_delay_line_get_sample( - ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ -); - -void ivas_rev_delay_line_feed_sample( - ivas_rev_delay_line_t *pDelay, /* i : the delay line */ - float input /* i : the sample to feed */ -); - -void ivas_rev_delay_line_get_sample_blk( - ivas_rev_delay_line_t *pDelay, /* i : the delay line */ - const uint16_t blk_size, /* i : number of samples in the data block */ - float *output /* i/o: amples gotten out of delay line, and amplified by set gainin */ -); - -void ivas_rev_delay_line_feed_sample_blk( - ivas_rev_delay_line_t *pDelay, /* i/o: the delay line */ - const uint16_t blk_size, /* i : number of samples in the input data block */ - float *input /* i : the samples to feed */ -); - -void ivas_reverb_iir_filt_init( - ivas_rev_iir_filter_t *iirFilter, /* o : IIR filter */ - const uint16_t maxTaps /* i : maximum number of filter taps */ -); - -void ivas_reverb_iir_filt_set( - ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ - uint16_t nr_taps, /* i : number of IIR filter taps */ - const float *coefA, /* i : A filter coefficients to set */ - const float *coefB /* i : the B filter coefficients to set */ -); - -void ivas_reverb_iir_filt_2taps_feed_blk( - ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ - const uint16_t blk_size, /* i : size */ - const float *input, /* i : input buffer */ - float *output /* i : output buffer */ -); - -uint16_t int_log2( - uint32_t powerOf2 -); - -int16_t ivas_reverb_t2f_f2t_init( - ivas_reverb_t2f_f2t_t *t2f_f2t, - const int16_t fft_size, - const int16_t block_size -); - -void ivas_reverb_t2f_f2t_ClearHistory( - ivas_reverb_t2f_f2t_t *t2f_f2t -); - -void ivas_reverb_t2f_f2t_in( - ivas_reverb_t2f_f2t_t *t2f_f2t, - float *input_L, - float *input_R, float *buffer_L, - float *buffer_R -); - -void ivas_reverb_t2f_f2t_out( - ivas_reverb_t2f_f2t_t *t2f_f2t, - float *buffer_L, - float *buffer_R, - float *output_L, - float *output_R -); - -int16_t ivas_reverb_fft_filter_init( - ivas_reverb_fft_filter_t *fft_filter, - const int16_t fft_size -); - -void ivas_reverb_fft_filter_ComplexMul( - ivas_reverb_fft_filter_t *fft_filter, - float *buffer -); - -void ivas_reverb_fft_filter_CrossMix( - float *buffer0, - float *buffer1, - const int16_t fft_size -); - -void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( - rv_fftwf_type_complex *spectrum, - float *fft_real, - const int16_t fft_size -); - -void ivas_reverb_define_window_fft( - float *pWindow, - const int16_t transitionStart, - const int16_t transitionLength, - const int16_t spectrumLength -); - -int16_t ivas_reverb_calc_color_filters( - const float *pTargetL, - const float *pTargetR, - const float *pWindow, - const int16_t fft_size, - const float delay, - rv_fftwf_type_complex *pBeqL, - rv_fftwf_type_complex *pBeqR -); - -int16_t ivas_reverb_calc_correl_filters( - const float *pTargetICC, - const float *pWindow, - const int16_t fft_size, - const float delay, - rv_fftwf_type_complex *pU, - rv_fftwf_type_complex *pV -); - -void ivas_reverb_calc_color_levels( - const int32_t output_Fs, - const int16_t freq_count, - const int16_t loop_count, - const float *pFc, - const float *pAcoustic_dsr, - const float *pHrtf_avg_pwr_L, - const float *pHrtf_avg_pwr_R, - const int16_t *pLoop_delays, - const float *pT60_filter_coeff, - float *pTarget_color_L, - float *pTarget_color_R -); - -void ivas_reverb_prepare_cldfb_params( - ivas_roomAcoustics_t *pInput_params, -#ifdef HRTF_BINARY_FILE - const HRTFS_FASTCONV_HANDLE hHrtfFastConv, -#endif - const AUDIO_CONFIG input_audio_config, - const int16_t use_brir, - const int32_t output_Fs, - float *pOutput_t60, - float *pOutput_ene ); - -void ivas_reverb_interpolate_acoustic_data( - const int16_t input_table_size, - const float *pInput_fc, - const float *pInput_t60, - const float *pInput_dsrR, - const int16_t output_table_size, - const float *pOutput_fc, - float *pOutput_t60, - float *pOutput_dsr -); - -void ivas_reverb_get_hrtf_set_properties( - float **ppHrtf_set_L_re, - float **ppHrtf_set_L_im, - float **ppHrtf_set_R_re, - float **ppHrtf_set_R_im, - const AUDIO_CONFIG input_audio_config, - const int16_t hrtf_count, - const int16_t in_freq_count, - const int16_t out_freq_count, - float *pOut_avg_pwr_L, - float *pOut_avg_pwr_R, - float *pOut_i_a_coherence -); - - -/*----------------------------------------------------------------------------------* - * Orientation tracking - *----------------------------------------------------------------------------------*/ - -void ivas_orient_trk_Init( - ivas_orient_trk_state_t *pOTR -); - -ivas_error ivas_orient_trk_SetTrackingType( - ivas_orient_trk_state_t *pOTR, - OTR_TRACKING_T trackingType -); - -ivas_error ivas_orient_trk_SetAbsoluteOrientation( - ivas_orient_trk_state_t *pOTR, - float yaw, - float pitch, - float roll -); - -ivas_error ivas_orient_trk_Process( - ivas_orient_trk_state_t *pOTR -); - -ivas_error ivas_orient_trk_GetTrackedOrientation( - ivas_orient_trk_state_t *pOTR, - float *yaw, - float *pitch, - float *roll -); - - /* clang-format on */ #endif /* IVAS_PROT_H */ diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index 00995b1ebc..dd88f2ebe1 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -115,9 +115,9 @@ extern const int16_t sba_map_tc[8]; *----------------------------------------------------------------------------------*/ /* Downmix matrices */ -extern const float ls_conversion_cicpX_mono[12][1]; +extern const float ls_conversion_cicpX_mono[12][1]; // VE2AT: it is declared also in ivas_rom_rend.h extern const float ls_conversion_cicpX_stereo[12][2]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[]; +extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[]; // VE2AT: remove from here - it is declared in ivas_rom_rend.h extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp6[]; extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp12[]; extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp6[]; diff --git a/lib_rend/ivas_allrad_dec.c b/lib_rend/ivas_allrad_dec.c index ada7c2c6d1..3e8bcc179c 100644 --- a/lib_rend/ivas_allrad_dec.c +++ b/lib_rend/ivas_allrad_dec.c @@ -33,12 +33,11 @@ #include #include #include -#include -#include +//#include #include "options.h" #include "prot.h" #include "ivas_prot.h" -#include "ivas_stat_dec.h" +//#include "ivas_stat_dec.h" #include "ivas_rom_rend.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_binauralRenderer.c b/lib_rend/ivas_binauralRenderer.c index d0eaa6407c..1b3fce126b 100644 --- a/lib_rend/ivas_binauralRenderer.c +++ b/lib_rend/ivas_binauralRenderer.c @@ -33,8 +33,9 @@ #include #include "options.h" #include -#include "ivas_prot.h" #include "prot.h" +#include "ivas_prot.h" +#include "ivas_lib_rend_internal.h" #include "cnst.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_binaural_reverb.c b/lib_rend/ivas_binaural_reverb.c index 3d4c9d6fe2..673b3d2389 100644 --- a/lib_rend/ivas_binaural_reverb.c +++ b/lib_rend/ivas_binaural_reverb.c @@ -33,10 +33,11 @@ #include #include "options.h" #include -#include "ivas_prot.h" #include "prot.h" -#include "ivas_rom_com.h" -#include "ivas_rom_binauralRenderer.h" +//#include "ivas_prot.h" +#include "ivas_lib_rend_internal.h" +//#include "ivas_rom_com.h" +//#include "ivas_rom_binauralRenderer.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index cf29f0c988..582bca8122 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -34,6 +34,7 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_lib_rend_internal.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "ivas_stat_dec.h" diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index ba5f02da63..c284cce8d3 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -34,9 +34,10 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" -#include "lib_dec.h" -#include "string.h" -#include "assert.h" +#include "ivas_lib_rend_internal.h" +//#include "lib_dec.h" +//#include "string.h" +//#include "assert.h" #include "ivas_rom_TdBinauralRenderer.h" #include "ivas_error.h" #include "wmc_auto.h" @@ -56,7 +57,7 @@ * Allocate the B Spline HR Filter model. --------------------------------------------------------------------*/ -void BSplineModelEvalAlloc( +static void BSplineModelEvalAlloc( ModelParams_t *model, /* i : Model parameters */ ModelEval_t *modelEval /* i/o: Model evaluation structure */ ) @@ -266,7 +267,7 @@ void ivas_HRTF_binary_close( * * Allocate HRTF binary handle *-----------------------------------------------------------------------*/ - +//VE2AT: move to lib_dec ivas_error ivas_HRTF_CRend_binary_open( HRTFS_CREND **hSetOfHRTF ) { diff --git a/lib_rend/ivas_lib_rend_internal.h b/lib_rend/ivas_lib_rend_internal.h index 4d36ecf7f0..6ea62875b0 100644 --- a/lib_rend/ivas_lib_rend_internal.h +++ b/lib_rend/ivas_lib_rend_internal.h @@ -30,16 +30,46 @@ *******************************************************************************************************/ +// VE2AT: rename this file to ivas_prot_rend.h to follow the logic with "ivas_stat_rend.h" ? +#ifndef IVAS_LIB_REND_INTERNALS_H +#define IVAS_LIB_REND_INTERNALS_H + +#include +#include "options.h" #include "ivas_error.h" #ifdef FIX_197_CREND_INTERFACE #include "ivas_stat_rend.h" #else #include "lib_rend.h" #endif -#include "ivas_stat_dec.h" +//#include "ivas_stat_dec.h" + +/* clang-format off */ + + +/*----------------------------------------------------------------------------------* + * General renderer declarations + *----------------------------------------------------------------------------------*/ + +IVAS_REND_AudioConfigType getAudioConfigType( + const IVAS_REND_AudioConfig config +); + +ivas_error getAudioConfigNumChannels( + const IVAS_REND_AudioConfig config, + int16_t *numChannels +); + +ivas_error ivas_rend_initCrend( + CREND_WRAPPER *pCrend, + const IVAS_REND_AudioConfig inConfig, + const IVAS_REND_AudioConfig outConfig, + RENDER_CONFIG_DATA *hRendCfg, +#ifdef HRTF_BINARY_FILE + HRTFS_CREND_HANDLE hSetOfHRTF, +#endif + const int32_t output_Fs ); -#ifndef IVAS_LIB_REND_INTERNALS_H -#define IVAS_LIB_REND_INTERNALS_H #ifndef FIX_197_CREND_INTERFACE typedef struct @@ -113,6 +143,21 @@ ivas_error ivas_rend_crendConvolver( const int16_t i_ts ); #endif + +void ivas_sba2mc_cldfb( + IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */ + float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part */ + float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part */ + const int16_t nb_channels_out, /* i : nb of output channels */ + const int16_t nb_bands, /* i : nb of CLDFB bands to process */ + const float *hoa_dec_mtx /* i : HOA decoding mtx */ +); + + +/*----------------------------------------------------------------------------------* + * TD object renderer + *----------------------------------------------------------------------------------*/ + ivas_error ivas_rend_TDObjRenderFrame( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const IVAS_REND_AudioConfig inConfig, /* i : Input audio configuration */ @@ -127,6 +172,477 @@ ivas_error ivas_rend_TDObjRendOpen( TDREND_WRAPPER *pTDRend, const IVAS_REND_AudioConfig inConfig, LSSETUP_CUSTOM_STRUCT *customLsInput, - const int32_t output_Fs ); + const int32_t output_Fs +); + +void DefaultBSplineModel( + TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */ + const int32_t output_Fs /* i : Output sampling rate */ +); + +/* ----- Object renderer - hrfilt ----- */ + +void GetFilterFromAngle( + TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* i/o: HR filter set structure */ + const float Elev, /* i : Elevation, degrees */ + float Azim, /* i : Azimuth, degrees */ + float *LeftFilter, /* o : Left HR filter */ + float *RightFilter, /* o : Right HR filter */ + int16_t *itd /* o : ITD value */ +); + +void HRTF_model_precalc( + ModelParams_t *model /* i/o: HRTF Model parameters */ +); + +ivas_error TDREND_REND_RenderSourceHRFilt( + TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */ + const float *hrf_left_delta, /* i: Left filter interpolation delta */ + const float *hrf_right_delta, /* i: Right filter interpolation delta */ + const int16_t intp_count, /* i: Interpolation count */ + float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */ + const int16_t subframe_length /* i : Subframe length in use */ +); + +/* ----- Object renderer - sources ----- */ + +ivas_error TDREND_MIX_SRC_SetPos( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float *Vec_p /* i : Position vector */ +); + +ivas_error TDREND_MIX_SRC_SetDir( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float *Vec_p /* i : Direction vector */ +); + +ivas_error TDREND_MIX_SRC_SetDirAtten( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */ +); + +ivas_error TDREND_MIX_SRC_SetPlayState( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const TDREND_PlayStatus_t PlayStatus /* i : Play state */ +); + +void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ + TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ + float *hrf_left_prev, /* o: Left filter */ + float *hrf_right_prev, /* o: Right filter */ + float *hrf_left_delta, /* o: Left filter interpolation delta */ + float *hrf_right_delta, /* o: Right filter interpolation delta */ + int16_t *intp_count, /* o: Interpolation count */ + int16_t *filterlength, /* o: Length of filters */ + int16_t *itd, /* o: ITD value */ + float *Gain, /* o: Gain value */ + TDREND_SRC_t *Src_p, + const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ +); + +ivas_error TDREND_SRC_Alloc( + TDREND_SRC_t **Src_pp /* i/o: Source */ +); + +void TDREND_SRC_Dealloc( + TDREND_SRC_t *Src_p /* i/o: Source to deallocate */ +); + +void TDREND_SRC_Init( + TDREND_SRC_t *Src_p, /* i/o: Source to initialize */ + const TDREND_PosType_t PosType /* i : Position type specifier */ +); + +/* ----- Object renderer - vec ----- */ + +void TDREND_SPATIAL_VecInit( + float *Pos_p, /* o : Output vector */ + const float PosX, /* i : X value */ + const float PosY, /* i : Y value */ + const float PosZ /* i : Z value */ +); + +/*! r: Euclidian norm value */ +float TDREND_SPATIAL_VecNorm( + const float *Vec_p /* i : Vector for norm calculation */ +); + +void TDREND_SPATIAL_VecNormalize( + const float *Vec_p, /* i : Input vector */ + float *VecNorm_p /* o : Output vector */ +); + +void TDREND_SPATIAL_VecMapToNewCoordSystem( + const float *Vec_p, /* i : Input vector */ + const float *TranslVec_p, /* i : Translation vector */ + const float *DirVec_p, /* i : Direction vector */ + const float *UpVec_p, /* i : Up vector */ + const float *RightVec_p, /* i : Right vector */ + float *MappedVec_p /* o : Transformed vector */ +); + +/*! r: Flag if the orientation has been updated */ +int16_t TDREND_SPATIAL_EvalOrthonormOrient( + float *FrontVecON_p, /* o : Normalized front vector */ + float *UpVecON_p, /* o : Normalized up vector */ + float *RightVecON_p, /* o : Normalized right vector */ + const float *FrontVec_p, /* i : Input front vector */ + const float *UpVec_p /* i : Input up vector */ +); + +/* ----- Object renderer - mix ----- */ + +ivas_error TDREND_MIX_AddSrc( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + int16_t *SrcInd, /* o : Source index */ + const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */ +); + +ivas_error TDREND_MIX_SetDistAttenModel( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const TDREND_DistAttenModel_t DistAttenModel /* i : Distance attenuation model */ +); + +void TDREND_MIX_LIST_SetPos( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const float *Pos_p /* i : Listener's position */ +); + +ivas_error TDREND_MIX_LIST_SetOrient( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const float *FrontVec_p, /* i : Listener's orientation front vector */ + const float *UpVec_p /* i : Listener's orientation up vector */ +); + +void TDREND_MIX_Dealloc( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle */ +); + +ivas_error TDREND_MIX_Init( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HRTF data (initialized in case of NULL) */ + const TDREND_MixSpatSpec_t *MixSpatSpec_p, /* i : Mixer spatial specification */ + const int32_t output_Fs /* i : Output sampling rate */ +); + + /* ----- Object renderer - sfx ----- */ + +void TDREND_Apply_ITD( + float *input, /* i: Input SCE subframe to be time adjusted */ + float *out_left, /* o: Output left channels with ITD applied */ + float *out_right, /* o: Output right channels with ITD applied */ + int16_t *previtd, /*i/o: Previous ITD value */ + const int16_t itd, /* i: Current subframe ITD value */ + float *mem_itd, /*i/o: ITD buffer memory */ + const int16_t length /* i: Subframe length */ +); + +void TDREND_firfilt( + float *signal, /* i/o: Input signal / Filtered signal */ + float *filter, /* i/o: FIR filter */ + const float *filter_delta, /* i : FIR filter delta */ + const int16_t intp_count, /* i : interpolation count */ + float *mem, /* i/o: filter memory */ + const int16_t subframe_length, /* i : Length of signal */ + const int16_t filterlength /* i : Filter length */ +); + + +/*----------------------------------------------------------------------------------* + * Crend renderer + *----------------------------------------------------------------------------------*/ + + + +/*----------------------------------------------------------------------------------* + * Reverberator + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_reverb_open( + REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ + const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ + const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ + RENDER_CONFIG_DATA *pConfig, /* i : Reverb configuration */ + const int32_t output_Fs /* i : output sampling rate */ +); + +void ivas_reverb_close( + REVERB_HANDLE *hReverb /* i/o: Reverberator handle */ +); + +ivas_error ivas_reverb_process( + REVERB_HANDLE hReverb, /* i/o: reverb state */ + const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ + const int16_t mix_signals, /* i : add reverb to output signal */ + float pcm_in[][L_FRAME48k], /* i : the PCM audio to apply reverb on */ + float pcm_out[][L_FRAME48k], /* o : the PCM audio with reverb applied */ + const int16_t i_ts +); + +void ivas_rev_delay_line_init( + ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */ + float *memory_buffer, /* i : the memory buffer to use for the delay line */ + const uint16_t delay, /* i : the delay */ + const uint16_t maxdelay /* i : maximum delay to be supported */ +); + +/* !r: sample gotten out of delay line, and amplified by set gain */ +float ivas_rev_delay_line_get_sample( + ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ +); + +void ivas_rev_delay_line_feed_sample( + ivas_rev_delay_line_t *pDelay, /* i : the delay line */ + float input /* i : the sample to feed */ +); + +void ivas_rev_delay_line_get_sample_blk( + ivas_rev_delay_line_t *pDelay, /* i : the delay line */ + const uint16_t blk_size, /* i : number of samples in the data block */ + float *output /* i/o: amples gotten out of delay line, and amplified by set gainin */ +); + +void ivas_rev_delay_line_feed_sample_blk( + ivas_rev_delay_line_t *pDelay, /* i/o: the delay line */ + const uint16_t blk_size, /* i : number of samples in the input data block */ + float *input /* i : the samples to feed */ +); + +void ivas_reverb_iir_filt_init( + ivas_rev_iir_filter_t *iirFilter, /* o : IIR filter */ + const uint16_t maxTaps /* i : maximum number of filter taps */ +); + +void ivas_reverb_iir_filt_set( + ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ + uint16_t nr_taps, /* i : number of IIR filter taps */ + const float *coefA, /* i : A filter coefficients to set */ + const float *coefB /* i : the B filter coefficients to set */ +); + +void ivas_reverb_iir_filt_2taps_feed_blk( + ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ + const uint16_t blk_size, /* i : size */ + const float *input, /* i : input buffer */ + float *output /* i : output buffer */ +); + +uint16_t int_log2( + uint32_t powerOf2 +); + +int16_t ivas_reverb_t2f_f2t_init( + ivas_reverb_t2f_f2t_t *t2f_f2t, + const int16_t fft_size, + const int16_t block_size +); + +void ivas_reverb_t2f_f2t_ClearHistory( + ivas_reverb_t2f_f2t_t *t2f_f2t +); + +void ivas_reverb_t2f_f2t_in( + ivas_reverb_t2f_f2t_t *t2f_f2t, + float *input_L, + float *input_R, float *buffer_L, + float *buffer_R +); + +void ivas_reverb_t2f_f2t_out( + ivas_reverb_t2f_f2t_t *t2f_f2t, + float *buffer_L, + float *buffer_R, + float *output_L, + float *output_R +); + +int16_t ivas_reverb_fft_filter_init( + ivas_reverb_fft_filter_t *fft_filter, + const int16_t fft_size +); + +void ivas_reverb_fft_filter_ComplexMul( + ivas_reverb_fft_filter_t *fft_filter, + float *buffer +); + +void ivas_reverb_fft_filter_CrossMix( + float *buffer0, + float *buffer1, + const int16_t fft_size +); + +void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( + rv_fftwf_type_complex *spectrum, + float *fft_real, + const int16_t fft_size +); + +void ivas_reverb_define_window_fft( + float *pWindow, + const int16_t transitionStart, + const int16_t transitionLength, + const int16_t spectrumLength +); + +int16_t ivas_reverb_calc_color_filters( + const float *pTargetL, + const float *pTargetR, + const float *pWindow, + const int16_t fft_size, + const float delay, + rv_fftwf_type_complex *pBeqL, + rv_fftwf_type_complex *pBeqR +); + +int16_t ivas_reverb_calc_correl_filters( + const float *pTargetICC, + const float *pWindow, + const int16_t fft_size, + const float delay, + rv_fftwf_type_complex *pU, + rv_fftwf_type_complex *pV +); + +void ivas_reverb_calc_color_levels( + const int32_t output_Fs, + const int16_t freq_count, + const int16_t loop_count, + const float *pFc, + const float *pAcoustic_dsr, + const float *pHrtf_avg_pwr_L, + const float *pHrtf_avg_pwr_R, + const int16_t *pLoop_delays, + const float *pT60_filter_coeff, + float *pTarget_color_L, + float *pTarget_color_R +); + +void ivas_reverb_prepare_cldfb_params( + ivas_roomAcoustics_t *pInput_params, +#ifdef HRTF_BINARY_FILE + const HRTFS_FASTCONV_HANDLE hHrtfFastConv, +#endif + const AUDIO_CONFIG input_audio_config, + const int16_t use_brir, + const int32_t output_Fs, + float *pOutput_t60, + float *pOutput_ene ); + +void ivas_reverb_interpolate_acoustic_data( + const int16_t input_table_size, + const float *pInput_fc, + const float *pInput_t60, + const float *pInput_dsrR, + const int16_t output_table_size, + const float *pOutput_fc, + float *pOutput_t60, + float *pOutput_dsr +); + +void ivas_reverb_get_hrtf_set_properties( + float **ppHrtf_set_L_re, + float **ppHrtf_set_L_im, + float **ppHrtf_set_R_re, + float **ppHrtf_set_R_im, + const AUDIO_CONFIG input_audio_config, + const int16_t hrtf_count, + const int16_t in_freq_count, + const int16_t out_freq_count, + float *pOut_avg_pwr_L, + float *pOut_avg_pwr_R, + float *pOut_i_a_coherence +); + + +/*---------------------------------------------------------------------------------* + * Binaural Renderer Prototypes + *-----------------------------------------------------------------------------------*/ + +void Quat2Euler( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ +); + +void SHrotmatgen( + float SHrotmat[SBA_NHARM_HOA3][SBA_NHARM_HOA3], /* o : SHD rotation matrix */ + float Rmat[3][3], /* i : real-space rotation matrix */ + const int16_t order /* i : ambisonics order */ +); + +void rotateFrame_shd( + HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ + float output[][L_FRAME48k], /* i/o: unrotated HOA3 signal buffer in TD */ + const int16_t subframe_len, /* i : subframe length per channel */ + const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ + const int16_t subframe_idx /* i : subframe index */ +); + +void rotateFrame_sd( + HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ + float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */ + const int16_t subframe_len, /* i : subframe length per channel */ + const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ + const int16_t subframe_idx /* i : subframe index */ +); + +void rotateFrame_shd_cldfb( + float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */ + float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ + float Rmat[3][3], /* i : real-space rotation matrix */ + const int16_t nInChannels, /* i : number of channels */ + const int16_t shd_rot_max_order /* i : split-order rotation method */ +); + +void rotateFrame_sd_cldfb( + HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ + float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */ + float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ + const IVAS_OUTPUT_SETUP_HANDLE hOutputSetup, /* i : output format setup number of channels */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ + const int16_t nb_band /* i : number of CLDFB bands to process */ +); + + +/*----------------------------------------------------------------------------------* + * Orientation tracking + *----------------------------------------------------------------------------------*/ + +void ivas_orient_trk_Init( + ivas_orient_trk_state_t *pOTR +); + +ivas_error ivas_orient_trk_SetTrackingType( + ivas_orient_trk_state_t *pOTR, + OTR_TRACKING_T trackingType +); + +ivas_error ivas_orient_trk_SetAbsoluteOrientation( + ivas_orient_trk_state_t *pOTR, + float yaw, + float pitch, + float roll +); + +ivas_error ivas_orient_trk_Process( + ivas_orient_trk_state_t *pOTR +); + +ivas_error ivas_orient_trk_GetTrackedOrientation( + ivas_orient_trk_state_t *pOTR, + float *yaw, + float *pitch, + float *roll +); +/* clang-format on */ #endif diff --git a/lib_rend/ivas_ls_custom_dec.c b/lib_rend/ivas_ls_custom_dec.c index 0e3a4d9801..286798f878 100644 --- a/lib_rend/ivas_ls_custom_dec.c +++ b/lib_rend/ivas_ls_custom_dec.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ - +// VE2AT: move this file to lib_dec #include #include "options.h" #include "ivas_prot.h" diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 7c8173e222..bc6bd01f6e 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -34,14 +34,14 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_lib_rend_internal.h" #include -#include "wmc_auto.h" #include "ivas_rom_com.h" -#include "lib_rend.h" -#include "ivas_lib_rend_internal.h" +//#include "lib_rend.h" // VE2AT: remove it from this file? #ifdef DEBUGGING #include "debug.h" #endif +#include "wmc_auto.h" /*---------------------------------------------------------------------* @@ -49,17 +49,13 @@ *---------------------------------------------------------------------*/ static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, float output[][L_FRAME48k], const int16_t subframe_length, const int16_t subframe_idx ); + static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd ); -static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, - const int16_t headRotEnabled, - const IVAS_QUATERNION *headPosition ); -static void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, - const int16_t numSources, - const int16_t lfe_idx, - const IVAS_FORMAT in_format, - const ISM_METADATA_HANDLE *hIsmMetaData, - float output[][L_FRAME48k] ); +static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t headRotEnabled, const IVAS_QUATERNION *headPosition ); + +static void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t numSources, const int16_t lfe_idx, const IVAS_FORMAT in_format, const ISM_METADATA_HANDLE *hIsmMetaData, float output[][L_FRAME48k] ); + /*---------------------------------------------------------------------* * ivas_td_binaural_open() @@ -228,7 +224,7 @@ void ivas_td_binaural_close( * Receives the current frames for the object streams, updates metadata * and renders the current frame. *---------------------------------------------------------------------*/ - +// VE2AT: shopuld be defined in lib_dec void ObjRenderIVASFrame( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ @@ -494,7 +490,7 @@ static void TDREND_Update_listener_orientation( return; } - +// VE2AT: should be defined in lib_dec ivas_error ivas_rend_TDObjRendOpen( TDREND_WRAPPER *pTDRend, IVAS_REND_AudioConfig inConfig, @@ -636,7 +632,7 @@ ivas_error ivas_rend_TDObjRendOpen( } /*---------------------------------------------------------------------* - * ObjRenderIVASFrame() + * ivas_rend_TDObjRenderFrame() * * Receives the current frames for the object streams, updates metadata * and renders the current frame. diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index 206cd40e1e..ad52c2529a 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -35,10 +35,11 @@ #include "options.h" #include "prot.h" #include -#include "ivas_prot.h" +//#include "ivas_prot.h" +#include "ivas_lib_rend_internal.h" #include "ivas_rom_rend.h" #include "ivas_cnst.h" -#include "ivas_rom_TdBinauralRenderer.h" +//#include "ivas_rom_TdBinauralRenderer.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index 456bd4cd33..96f1c8b423 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -34,6 +34,7 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_lib_rend_internal.h" #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index e56516d454..5a323a5d3d 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -33,8 +33,9 @@ #include #include "options.h" #include -#include "ivas_prot.h" #include "prot.h" +//#include "ivas_prot.h" +#include "ivas_lib_rend_internal.h" #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 09e4822341..6bc8db5c2c 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -34,6 +34,7 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_lib_rend_internal.h" #include "ivas_cnst.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c index 2c6a77ec2b..7b2ff45e1e 100644 --- a/lib_rend/ivas_reverb_fft_filter.c +++ b/lib_rend/ivas_reverb_fft_filter.c @@ -38,6 +38,7 @@ #endif #include #include "prot.h" +#include "ivas_lib_rend_internal.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c index 80044e3e65..2e2f456350 100644 --- a/lib_rend/ivas_reverb_filter_design.c +++ b/lib_rend/ivas_reverb_filter_design.c @@ -33,6 +33,7 @@ #include #include "options.h" #include "ivas_prot.h" +#include "ivas_lib_rend_internal.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index 20a3e2ac47..de28766e13 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -33,8 +33,9 @@ #include #include "options.h" #include "prot.h" -#include "ivas_prot.h" -#include "ivas_rom_binauralRenderer.h" +//#include "ivas_prot.h" +#include "ivas_lib_rend_internal.h" +//#include "ivas_rom_binauralRenderer.h" #include "ivas_rom_rend.h" #include #ifdef DEBUGGING diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index 2a68d832e0..828dc0eac8 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -43,7 +43,7 @@ * FASTCONV and PARAMETRIC binaural renderer ROM tables *----------------------------------------------------------------------------------*/ -const float dmxmtx[BINAURAL_CHANNELS][11] = +const float dmxmtx[BINAURAL_CHANNELS][11] = // VE2AT: rename, otherwise could be confusing with hReverb->dmxmtx[][] { { 1.0f, 0.0f, 0.70709997f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.70709997f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }, diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index cba0fffb1b..e2b0b16ba3 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -57,10 +57,10 @@ extern const int16_t channelIndex_CICP19[11]; * TD ISM Object renderer *----------------------------------------------------------------------------------*/ -extern const int16_t TDREND_SRC_REND_MaxTargetTimes[IVAS_NUM_SUPPORTED_FS]; -extern const int16_t TDREND_SRC_REND_MaxBlockLengths[IVAS_NUM_SUPPORTED_FS]; -extern const int16_t TDREND_MaxITD[IVAS_NUM_SUPPORTED_FS]; -extern const float TDREND_MaxITD_Incr[IVAS_NUM_SUPPORTED_FS]; +extern const int16_t TDREND_SRC_REND_MaxTargetTimes[IVAS_NUM_SUPPORTED_FS]; // VE2AT: not used +extern const int16_t TDREND_SRC_REND_MaxBlockLengths[IVAS_NUM_SUPPORTED_FS]; // VE2AT: not used +extern const int16_t TDREND_MaxITD[IVAS_NUM_SUPPORTED_FS]; // VE2AT: not used +extern const float TDREND_MaxITD_Incr[IVAS_NUM_SUPPORTED_FS]; // VE2AT: not used extern const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS]; @@ -96,10 +96,10 @@ extern const float ivas_reverb_default_DSR[]; * Renderer SBA & MC enc/dec matrices *----------------------------------------------------------------------------------*/ -extern const float hoa_dec_mtx_CICP1[16]; +extern const float hoa_dec_mtx_CICP1[16]; // VE2AT: not used extern const float ls_azimuth_CICP1[1]; extern const float ls_elevation_CICP1[1]; -extern const uint32_t ls_LFE_last_idx_CICP1[1]; +extern const uint32_t ls_LFE_last_idx_CICP1[1]; // VE2AT: not used extern const uint32_t ls_LFE_last_idx_CICP2[2]; extern const uint32_t ls_LFE_last_idx_CICP6[6]; extern const uint32_t ls_LFE_last_idx_CICP12[8]; diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index ff9eeebf2f..4860b40c79 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -37,9 +37,10 @@ #include "cnst.h" #include "prot.h" #include "ivas_prot.h" -#include "ivas_cnst.h" -#include "ivas_rom_com.h" -#include "ivas_rom_dec.h" +#include "ivas_lib_rend_internal.h" +//#include "ivas_cnst.h" +//#include "ivas_rom_com.h" +//#include "ivas_rom_dec.h" #ifdef DEBUGGING #include "debug.h" #endif @@ -51,7 +52,7 @@ * * Allocate and initialize Head-Tracking handle *-----------------------------------------------------------------------*/ - +// VE2AT: should be moved to lib_dec ivas_error ivas_headTrack_open( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ ) diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index 3167929517..d71edf724a 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -47,6 +47,7 @@ * Local function prototypes *-----------------------------------------------------------------------*/ +static void ivas_sba_mtx_mult( float output_f[][L_FRAME48k], const int16_t output_frame, const int16_t nchan_in, const IVAS_OUTPUT_SETUP output_setup, const float *mtx_hoa_decoder ); #ifdef DEBUG_MODE_DIRAC static void debug_mode_dirac( float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], const int16_t nchan_transport, const int16_t output_frame ); @@ -58,7 +59,7 @@ static void debug_mode_dirac( float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], con * * MC signals transformed into SBA in TD domain *-------------------------------------------------------------------------*/ - +// VE2AT: should be defined in lib_dec void ivas_mc2sba( IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ float buffer_td[][L_FRAME48k], /* i/o: MC signals (on input) and the HOA3 (on output) */ @@ -213,7 +214,7 @@ void ivas_sba2mc_cldfb( * * Get TCs from Ambisonics signal in ACN *-------------------------------------------------------------------*/ - +// VE2AT: should be defined in lib_dec int16_t ivas_sba_remapTCs( float sba_data[][L_FRAME48k], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ @@ -276,7 +277,7 @@ int16_t ivas_sba_remapTCs( * * ISM transformed into SBA in TD domain. *-------------------------------------------------------------------------*/ - +// VE2AT: should be defined in lib_dec void ivas_ism2sba( float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ @@ -427,7 +428,7 @@ ivas_error ivas_sba_linear_renderer( * HOA decoding with LFE insertion *-------------------------------------------------------------------*/ -void ivas_sba_mtx_mult( +static void ivas_sba_mtx_mult( float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ const int16_t nchan_in, /* i : Number of ambisonic channels */ @@ -486,7 +487,7 @@ void ivas_sba_mtx_mult( * * SBA upmix & rendering *-------------------------------------------------------------------*/ - +// VE2AT: should be defined in lib_dec void ivas_sba_upmixer_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ float output[][L_FRAME48k], /* i/o: transport/output audio channels */ @@ -530,7 +531,7 @@ void ivas_sba_upmixer_renderer( * * Determine SBA mixing matrices *-------------------------------------------------------------------*/ - +// VE2AT: should be defined in lib_dec void ivas_sba_mix_matrix_determiner( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ float output[][L_FRAME48k], /* i/o: transport/output audio channels */ @@ -591,7 +592,7 @@ void ivas_sba_mix_matrix_determiner( * * Render prototype audio signals using SBA mixing matrices *-------------------------------------------------------------------*/ - +// VE2AT: should be defined in lib_dec void ivas_sba_prototype_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 975656dffb..055c4bf6ab 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -41,7 +41,7 @@ #include "common_api_types.h" // VE2AT: don't we want to avoid this include in the library? I admit that the rules hefre are not 100% clear to me but introducing it just for IVAS_QUATERNION is not necessry I think #endif -#define MAX_SPEAKERS 12 /* Max number of speakers (including LFE) in a channel-based config */ +#define MAX_SPEAKERS 12 /* Max number of speakers (including LFE) in a channel-based config */ // VE2AT: not used #ifdef FIX_197_CREND_INTERFACE @@ -188,6 +188,7 @@ typedef struct ivas_binaural_reverb_struct } REVERB_STRUCT, *REVERB_STRUCT_HANDLE; +// VE2AT: this should be ivas_stat_dec.h /* AGC structure */ typedef struct ivas_agc_dec_chan_state_t { @@ -204,6 +205,7 @@ typedef struct ivas_agc_dec_state_t } ivas_agc_dec_state_t; +// VE2AT: this should be ivas_stat_dec.h /* TD decorr */ typedef struct ivas_td_decorr_APD_filt_state_t { @@ -226,6 +228,7 @@ typedef struct ivas_td_decorr_state_t } ivas_td_decorr_state_t; +// VE2AT: this should be ivas_stat_dec.h /* Parametric binaural data structure */ typedef struct ivas_dirac_dec_binaural_data_structure { @@ -984,7 +987,7 @@ typedef struct ivas_hrtfs_parambin_struct /*----------------------------------------------------------------------------------* * LFE decoder structure *----------------------------------------------------------------------------------*/ - +// VE2AT: this should be ivas_stat_dec.h typedef struct ivas_lfe_dec_data_structure { ivas_filters_process_state_t filter_state; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index b2ca45c70c..dfb839d7fa 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -142,7 +142,7 @@ typedef uint16_t IVAS_REND_InputId; #else -AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( +AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( // VE2AT: move to ivas_lib_rend_internal.h? IVAS_REND_AudioConfig config ); #endif diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 97b33b7fd1..dde9d04f71 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -33,13 +33,14 @@ #include "hrtf_file_reader.h" #include #include -#include "prot.h" // VE: !!!!! -#include "ivas_prot.h" // VE: !!!!! - +#include "prot.h" // VE: !!!!! +//#include "ivas_prot.h" // VE: !!!!! +#include "ivas_lib_rend_internal.h" #ifdef HRTF_BINARY_FILE -#include "lib_dec.h" +//#include "lib_dec.h" #endif + struct hrtfFileReader { FILE *file; -- GitLab From b4c67ae96a1ddced664fa918947944443c6a07ec Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 7 Feb 2023 18:01:59 +0100 Subject: [PATCH 02/40] address few VE2AT comments --- lib_com/ivas_prot.h | 12 ---- lib_dec/ivas_dirac_dec_binaural_functions.c | 4 +- lib_dec/ivas_ism_renderer.c | 13 +++- lib_dec/ivas_mono_dmx_renderer.c | 7 +- lib_dec/ivas_out_setup_conversion.c | 2 +- lib_dec/ivas_rom_dec.c | 2 +- lib_dec/ivas_rom_dec.h | 16 ----- lib_dec/ivas_vbap.c | 2 +- lib_rend/ivas_binaural_reverb.c | 4 +- lib_rend/ivas_crend.c | 2 +- lib_rend/ivas_hrtf.c | 4 +- lib_rend/ivas_lib_rend_internal.h | 13 +--- lib_rend/lib_rend.c | 80 +++++++++++++++++++-- lib_rend/lib_rend.h | 2 - 14 files changed, 106 insertions(+), 57 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 7a3f0a2c78..fdac1c72d6 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3353,18 +3353,6 @@ void ivas_binaural_reverb_close( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ ); -void ivas_binaural_reverb_setReverbTimes( - REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ - const int32_t output_Fs, /* i : sampling_rate */ - const float *revTimes, /* i : reverberation times T60 for each CLDFB bin in seconds */ - const float *revEnes /* i : spectrum for reverberated sound at each CLDFB bin */ -); - -void ivas_binaural_reverb_setPreDelay( - REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ - const int16_t delaySamples /* i : reverb pre-delay in CLDFB slots */ -); - void ivas_binaural_reverb_processFrame( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const int16_t numInChannels, /* i : num input channels to be processed */ diff --git a/lib_dec/ivas_dirac_dec_binaural_functions.c b/lib_dec/ivas_dirac_dec_binaural_functions.c index 7cdd0cc127..a9c400cdde 100644 --- a/lib_dec/ivas_dirac_dec_binaural_functions.c +++ b/lib_dec/ivas_dirac_dec_binaural_functions.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: move to lib_rend ? + #include #include "options.h" #include @@ -37,7 +37,7 @@ #include "prot.h" #include "ivas_prot.h" #include "ivas_cnst.h" -#include "ivas_rom_binauralRenderer.h" // VE2AT: what about to put these includes ust into ivas_rom_rend.c ? +#include "ivas_rom_binauralRenderer.h" #include "ivas_rom_dec.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 462fedfdc6..39e4cffba5 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: move to lib_rend ? + #include #include "options.h" #include "ivas_cnst.h" @@ -186,6 +186,7 @@ void ivas_ism_render( st_ivas->hIsmRendererData->prev_gains[i][j] = gains[i][j]; } } + /* Move to output skipping LFE */ for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ ) { @@ -195,9 +196,17 @@ void ivas_ism_render( } mvr2r( tmp_output_f[j], output_f[j2], output_frame ); } + return; } + +/*-------------------------------------------------------------------------* + * ivas_ism_get_stereo_gains() + * + * + *-------------------------------------------------------------------------*/ + void ivas_ism_get_stereo_gains( const float azimuth, /* i : object azimuth */ const float elevation, /* i : object elevation */ @@ -235,4 +244,6 @@ void ivas_ism_get_stereo_gains( *left_gain = sqrtf( A3 ); *right_gain = sqrtf( 1.0f - A3 ); } + + return; } diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 4932e71d51..d4dcb7ac73 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: move to lib_rend ? + #include #include "options.h" #include @@ -124,10 +124,11 @@ void ivas_mono_downmix_render_passive( return; } + /*------------------------------------------------------------------------- * ivas_mono_stereo_downmix_mcmasa() * - * Downmix process + * Downmix process in McMASA *------------------------------------------------------------------------*/ void ivas_mono_stereo_downmix_mcmasa( @@ -165,4 +166,6 @@ void ivas_mono_stereo_downmix_mcmasa( /* Move to output */ mvr2r( dmx_tmp, output_f[0], output_frame ); } + + return; } diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 0e553b4759..179e7d021b 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: move to lib_rend ? + #include #include #include "options.h" diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 04e3461e99..50ddf18839 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -516,7 +516,7 @@ const int16_t sba_map_tc[8] = /*----------------------------------------------------------------------------------* * FASTCONV and PARAMETRIC binaural renderer ROM tables *----------------------------------------------------------------------------------*/ -// VE2AT: move to in ivas_rom_dec ? + const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = { 3.0903f, 2.0053f, 1.0860f, 0.8072f, 0.7079f diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index dd88f2ebe1..eccdd5eb15 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -117,22 +117,6 @@ extern const int16_t sba_map_tc[8]; /* Downmix matrices */ extern const float ls_conversion_cicpX_mono[12][1]; // VE2AT: it is declared also in ivas_rom_rend.h extern const float ls_conversion_cicpX_stereo[12][2]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[]; // VE2AT: remove from here - it is declared in ivas_rom_rend.h -extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp6[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp12[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp6[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp14[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp6[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp12[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp14[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp16[]; - -/* Upmix matrices */ -extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp14[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp16[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp19[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp19[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp19[]; /* Mapping table of input config : output config with corresponding matrix */ extern const LS_CONVERSION_MAPPING ls_conversion_mapping[]; diff --git a/lib_dec/ivas_vbap.c b/lib_dec/ivas_vbap.c index e0deb652dc..cdd96210fa 100644 --- a/lib_dec/ivas_vbap.c +++ b/lib_dec/ivas_vbap.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: move to lib_rend ? + #include #include "options.h" #include diff --git a/lib_rend/ivas_binaural_reverb.c b/lib_rend/ivas_binaural_reverb.c index 673b3d2389..b045a8dccb 100644 --- a/lib_rend/ivas_binaural_reverb.c +++ b/lib_rend/ivas_binaural_reverb.c @@ -240,7 +240,7 @@ static uint16_t binRend_rand( * *------------------------------------------------------------------------*/ -void ivas_binaural_reverb_setPreDelay( +static void ivas_binaural_reverb_setPreDelay( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const int16_t delaySamples /* i : reverb pre-delay in CLDFB slots */ ) @@ -271,7 +271,7 @@ void ivas_binaural_reverb_setPreDelay( * *------------------------------------------------------------------------*/ -void ivas_binaural_reverb_setReverbTimes( +static void ivas_binaural_reverb_setReverbTimes( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const int32_t output_Fs, /* i : sampling_rate */ const float *revTimes, /* i : reverberation times T60 for each CLDFB bin in seconds */ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 582bca8122..56973d4665 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1467,7 +1467,7 @@ ivas_error ivas_crend_process( * Allocate and initialize crend renderer handle *------------------------------------------------------------------------*/ -ivas_error ivas_rend_initCrend( +static ivas_error ivas_rend_initCrend( CREND_WRAPPER *pCrend, const IVAS_REND_AudioConfig inConfig, const IVAS_REND_AudioConfig outConfig, diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index c284cce8d3..bde05431f9 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -29,12 +29,12 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ - +// VE2AT: move this file to lib_dec #include #include "options.h" #include "prot.h" #include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_lib_rend_internal.h" // VE2AT: remove it //#include "lib_dec.h" //#include "string.h" //#include "assert.h" diff --git a/lib_rend/ivas_lib_rend_internal.h b/lib_rend/ivas_lib_rend_internal.h index 6ea62875b0..2aee734939 100644 --- a/lib_rend/ivas_lib_rend_internal.h +++ b/lib_rend/ivas_lib_rend_internal.h @@ -60,16 +60,9 @@ ivas_error getAudioConfigNumChannels( int16_t *numChannels ); -ivas_error ivas_rend_initCrend( - CREND_WRAPPER *pCrend, - const IVAS_REND_AudioConfig inConfig, - const IVAS_REND_AudioConfig outConfig, - RENDER_CONFIG_DATA *hRendCfg, -#ifdef HRTF_BINARY_FILE - HRTFS_CREND_HANDLE hSetOfHRTF, -#endif - const int32_t output_Fs ); - +AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( + const IVAS_REND_AudioConfig config +); #ifndef FIX_197_CREND_INTERFACE typedef struct diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index c3b3ef07c2..4663ca7e2c 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -263,8 +263,6 @@ static void accumulate2dArrayToBuffer( * limitRendererOutput() * * In-place saturation control for multichannel buffers with adaptive release time - * - * *-------------------------------------------------------------------*/ /*! r: number of clipped output samples */ @@ -312,6 +310,13 @@ static int32_t limitRendererOutput( return numClipping; } + +/*-------------------------------------------------------------------* + * getIvasAudioConfigFromRendAudioConfig() + * + * + *-------------------------------------------------------------------*/ + #ifdef FIX_197_CREND_INTERFACE AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( #else @@ -360,6 +365,13 @@ static AUDIO_CONFIG rendAudioConfigToIvasAudioConfig( // VE2AT: similar is defin return AUDIO_CONFIG_INVALID; } + +/*-------------------------------------------------------------------* + * validateOutputAudioConfig() + * + * + *-------------------------------------------------------------------*/ + static ivas_error validateOutputAudioConfig( IVAS_REND_AudioConfig outConfig ) { @@ -386,13 +398,27 @@ static ivas_error validateOutputAudioConfig( return IVAS_ERR_INVALID_OUTPUT_FORMAT; } + +/*-------------------------------------------------------------------* + * getAudioConfigType() + * + * + *-------------------------------------------------------------------*/ + IVAS_REND_AudioConfigType getAudioConfigType( IVAS_REND_AudioConfig config ) { /* By definition, config type is the second byte (from LSB) of IVAS_REND_AudioConfig enum. */ - return ( config & 0xFF00 ) >> 8; // VE2AT: MSVC returns warning C4244: 'return': conversion from 'int' to 'IVAS_REND_InputId', possible loss of data + return ( config & 0xFF00 ) >> 8; } + +/*-------------------------------------------------------------------* + * validateOutputSampleRate() + * + * + *-------------------------------------------------------------------*/ + static ivas_error validateOutputSampleRate( const int32_t sampleRate, const IVAS_REND_AudioConfig outConfig ) @@ -416,6 +442,13 @@ static ivas_error validateOutputSampleRate( return IVAS_ERR_INVALID_SAMPLING_RATE; } + +/*-------------------------------------------------------------------* + * getAudioConfigNumChannels() + * + * + *-------------------------------------------------------------------*/ + ivas_error getAudioConfigNumChannels( const IVAS_REND_AudioConfig config, int16_t *numChannels ) @@ -462,9 +495,16 @@ ivas_error getAudioConfigNumChannels( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * getRendAudioConfigFromIvasAudioConfig() + * + * + *-------------------------------------------------------------------*/ + #ifdef FIX_197_CREND_INTERFACE IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( - AUDIO_CONFIG config ) + const AUDIO_CONFIG config ) #else AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( IVAS_REND_AudioConfig config ) @@ -533,6 +573,11 @@ AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( #endif } + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ + static ivas_error initLimiter( IVAS_LIMITER_HANDLE *phLimiter, const int16_t numChannels, @@ -5139,6 +5184,13 @@ static ivas_error renderActiveInputsMasa( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_GetSamples() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetSamples( IVAS_REND_HANDLE hIvasRend, IVAS_REND_AudioBuffer outAudio ) @@ -5205,6 +5257,13 @@ ivas_error IVAS_REND_GetSamples( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_Close() + * + * + *-------------------------------------------------------------------*/ + void IVAS_REND_Close( IVAS_REND_HANDLE *phIvasRend ) { @@ -5256,6 +5315,12 @@ void IVAS_REND_Close( } #ifdef DEBUGGING +/*-------------------------------------------------------------------* + * IVAS_REND_GetNoCLipping() + * + * + *-------------------------------------------------------------------*/ + int32_t IVAS_REND_GetNoCLipping( IVAS_REND_CONST_HANDLE hIvasRend ) { @@ -5274,6 +5339,13 @@ int32_t IVAS_REND_GetCntFramesLimited( } #endif + +/*-------------------------------------------------------------------* + * ivas_rend_initEfap() + * + * + *-------------------------------------------------------------------*/ + #ifdef FIX_197_CREND_INTERFACE ivas_error ivas_rend_initEfap( AUDIO_CONFIG outConfig, diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index dfb839d7fa..00a3dc0cc4 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -142,8 +142,6 @@ typedef uint16_t IVAS_REND_InputId; #else -AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( // VE2AT: move to ivas_lib_rend_internal.h? - IVAS_REND_AudioConfig config ); #endif -- GitLab From 9ef90cc2a7fcbe80d791407fd40828c26012ff2e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 7 Feb 2023 18:13:54 +0100 Subject: [PATCH 03/40] - ROM tables - move of few functions --- lib_rend/ivas_binauralRenderer.c | 2 +- lib_rend/ivas_hrtf.c | 177 --------------------------- lib_rend/ivas_lib_rend_internal.h | 5 - lib_rend/ivas_objectRenderer_mix.c | 186 +++++++++++++++++++++++++++++ lib_rend/ivas_rom_rend.c | 25 +--- lib_rend/ivas_rom_rend.h | 7 +- 6 files changed, 189 insertions(+), 213 deletions(-) diff --git a/lib_rend/ivas_binauralRenderer.c b/lib_rend/ivas_binauralRenderer.c index 1b3fce126b..d697fc3956 100644 --- a/lib_rend/ivas_binauralRenderer.c +++ b/lib_rend/ivas_binauralRenderer.c @@ -752,7 +752,7 @@ ivas_error ivas_binRenderer_open( { for ( k = 0; k < hBinRenderer->nInChannels; k++ ) { - hBinRenderer->hReverb->dmxmtx[chIdx][k] = dmxmtx[chIdx][k]; + hBinRenderer->hReverb->dmxmtx[chIdx][k] = dmxmtx_table[chIdx][k]; } } } diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index bde05431f9..4b44d52764 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -43,183 +43,6 @@ #include "wmc_auto.h" -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f ) -#define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f ) - - -/*-------------------------------------------------------------------* - * BSplineModelEvalAlloc() - * - * Allocate the B Spline HR Filter model. - --------------------------------------------------------------------*/ - -static void BSplineModelEvalAlloc( - ModelParams_t *model, /* i : Model parameters */ - ModelEval_t *modelEval /* i/o: Model evaluation structure */ -) -{ - modelEval->hrfModL = (float *) malloc( model->K * sizeof( float ) ); - modelEval->hrfModR = (float *) malloc( model->K * sizeof( float ) ); - - return; -} - - -/*-------------------------------------------------------------------* - * DefaultBSplineModel() - * - * Init default HRTF model - --------------------------------------------------------------------*/ - -void DefaultBSplineModel( - TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */ - const int32_t output_Fs /* i : Output sampling rate */ -) -{ - ModelParams_t *model; - ModelParamsITD_t *modelITD; - int16_t i, j; - - HrFiltSet_p->FilterMethod = TDREND_HRFILT_Method_BSplineModel; - model = &( HrFiltSet_p->ModelParams ); - modelITD = &( HrFiltSet_p->ModelParamsITD ); - - /* Set ROM flag for correct deallocation */ - model->modelROM = TRUE; - - /* int16_t parameters */ - model->UseItdModel = 1; - model->SplineDegree = 4; - model->elevDim2 = 20; - model->elevDim3 = 18; - model->AlphaN = 578; - model->num_unique_azim_splines = 1; - model->elevSegSamples = 3; - model->elevBsLen[0] = 4; - model->elevBsLen[1] = 7; - model->elevBsLen[2] = 10; - model->elevBsLen[3] = 7; - model->elevBsStart[0] = 0; - model->elevBsStart[1] = 4; - model->elevBsStart[2] = 11; - model->elevBsStart[3] = 21; - - model->azimDim2 = orange53_rom_azimDim2; - model->azimDim3 = orange53_rom_azimDim3; - model->azim_start_idx = orange53_rom_azim_start_idx; - model->azimSegSamples = orange53_rom_azimSegSamples; - model->azimShapeIdx = orange53_rom_azimShapeIdx; - model->azimShapeSampFactor = orange53_rom_azimShapeSampFactor; - - /* float parameters */ - model->elevKSeq = (const float *) orange53_rom_elevKSeq; - model->elevBsShape = (const float *) orange53_rom_elevBsShape; - - model->azimBsShape = (const float **) malloc( model->num_unique_azim_splines * sizeof( float * ) ); - model->azimBsShape[0] = (const float *) orange53_rom_azimBsShape; - model->azimKSeq = (float **) malloc( 18 * sizeof( float * ) ); - model->azimKSeq[0] = (float *) malloc( 2 * sizeof( float * ) ); - model->azimKSeq[17] = (float *) malloc( 2 * sizeof( float * ) ); - model->azimKSeq[0][0] = 0.0f; - model->azimKSeq[17][0] = 0.0f; - model->azimKSeq[0][1] = 360.0f; - model->azimKSeq[17][1] = 360.0f; - - for ( i = 1; i < 17; i++ ) - { - model->azimKSeq[i] = (float *) malloc( model->azimDim2[i] * sizeof( float * ) ); /* azimDim2[i] = 91, i=2..15 */ - for ( j = 0; j < model->azimDim2[i]; j++ ) - { - model->azimKSeq[i][j] = (float) orange53_rom_azimSegSamples[0] * j; - } - } - - switch ( output_Fs ) - { - case 48000: - model->AlphaL = (const float *) orange53_rom_AlphaL48; - model->AlphaR = (const float *) orange53_rom_AlphaR48; - model->EL = (const float *) orange53_rom_EL48; - model->ER = (const float *) orange53_rom_ER48; - model->K = 128; - if ( HrFiltSet_p->ModelParams.UseItdModel ) - { - modelITD->resamp_factor = 1.0f; - } - break; - case 32000: - model->AlphaL = (const float *) orange53_rom_AlphaL32; - model->AlphaR = (const float *) orange53_rom_AlphaR32; - model->EL = (const float *) orange53_rom_EL32; - model->ER = (const float *) orange53_rom_ER32; - model->K = 86; - if ( HrFiltSet_p->ModelParams.UseItdModel ) - { - modelITD->resamp_factor = RESAMPLE_FACTOR_32_48; - } - break; - case 16000: - model->AlphaL = (const float *) orange53_rom_AlphaL16; - model->AlphaR = (const float *) orange53_rom_AlphaR16; - model->EL = (const float *) orange53_rom_EL16; - model->ER = (const float *) orange53_rom_ER16; - model->K = 43; - if ( HrFiltSet_p->ModelParams.UseItdModel ) - { - modelITD->resamp_factor = RESAMPLE_FACTOR_16_48; - } - break; - default: - break; - } - - modelITD->N = 4; - modelITD->elevDim2 = 20; - modelITD->elevDim3 = 18; - modelITD->azimDim2 = 41; - modelITD->azimDim3 = 41; - modelITD->elevSegSamples = 3; - modelITD->elevBsLen[0] = 4; - modelITD->elevBsLen[1] = 7; - modelITD->elevBsLen[2] = 10; - modelITD->elevBsLen[3] = 7; - modelITD->elevBsStart[0] = 0; - modelITD->elevBsStart[1] = 4; - modelITD->elevBsStart[2] = 11; - modelITD->elevBsStart[3] = 21; - - modelITD->elevKSeq = model->elevKSeq; - - modelITD->azimBsLen[0] = 11; - modelITD->azimBsLen[1] = 21; - modelITD->azimBsLen[2] = 31; - modelITD->azimBsLen[3] = 21; - modelITD->azimBsStart[0] = 0; - modelITD->azimBsStart[1] = 11; - modelITD->azimBsStart[2] = 32; - modelITD->azimBsStart[3] = 63; - - modelITD->azimSegSamples = 10; - - modelITD->azimKSeq = orange53_rom_ITD_azimKSeq; - modelITD->W = (const float *) orange53_rom_ITD_W; - modelITD->azimBsShape = (const float *) orange53_rom_ITD_azimBsShape; - modelITD->elevBsShape = (const float *) orange53_rom_ITD_elevBsShape; - - HRTF_model_precalc( model ); - - HrFiltSet_p->SampleRate = output_Fs; - HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; - BSplineModelEvalAlloc( &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval ); - - return; -} - - /*-----------------------------------------------------------------------* * ivas_HRTF_binary_open() * diff --git a/lib_rend/ivas_lib_rend_internal.h b/lib_rend/ivas_lib_rend_internal.h index 2aee734939..6c533d4b16 100644 --- a/lib_rend/ivas_lib_rend_internal.h +++ b/lib_rend/ivas_lib_rend_internal.h @@ -168,11 +168,6 @@ ivas_error ivas_rend_TDObjRendOpen( const int32_t output_Fs ); -void DefaultBSplineModel( - TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */ - const int32_t output_Fs /* i : Output sampling rate */ -); - /* ----- Object renderer - hrfilt ----- */ void GetFilterFromAngle( diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index 96f1c8b423..19c050b454 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -35,12 +35,28 @@ #include "prot.h" #include "ivas_prot.h" #include "ivas_lib_rend_internal.h" +#include "ivas_rom_TdBinauralRenderer.h" #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" #endif +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +#define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f ) +#define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f ) + + +/*------------------------------------------------------------------------- + * Local functions + *-------------------------------------------------------------------------*/ + +static void DefaultBSplineModel( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, const int32_t output_Fs ); + + /*-------------------------------------------------------------------* * TDREND_MIX_LIST_SetPos() * @@ -317,3 +333,173 @@ ivas_error TDREND_MIX_AddSrc( return error; } + + +/*-------------------------------------------------------------------* + * BSplineModelEvalAlloc() + * + * Allocate the B Spline HR Filter model. + --------------------------------------------------------------------*/ + +static void BSplineModelEvalAlloc( + ModelParams_t *model, /* i : Model parameters */ + ModelEval_t *modelEval /* i/o: Model evaluation structure */ +) +{ + modelEval->hrfModL = (float *) malloc( model->K * sizeof( float ) ); + modelEval->hrfModR = (float *) malloc( model->K * sizeof( float ) ); + + return; +} + + +/*-------------------------------------------------------------------* + * DefaultBSplineModel() + * + * Init default HRTF model + --------------------------------------------------------------------*/ + +static void DefaultBSplineModel( + TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */ + const int32_t output_Fs /* i : Output sampling rate */ +) +{ + ModelParams_t *model; + ModelParamsITD_t *modelITD; + int16_t i, j; + + HrFiltSet_p->FilterMethod = TDREND_HRFILT_Method_BSplineModel; + model = &( HrFiltSet_p->ModelParams ); + modelITD = &( HrFiltSet_p->ModelParamsITD ); + + /* Set ROM flag for correct deallocation */ + model->modelROM = TRUE; + + /* int16_t parameters */ + model->UseItdModel = 1; + model->SplineDegree = 4; + model->elevDim2 = 20; + model->elevDim3 = 18; + model->AlphaN = 578; + model->num_unique_azim_splines = 1; + model->elevSegSamples = 3; + model->elevBsLen[0] = 4; + model->elevBsLen[1] = 7; + model->elevBsLen[2] = 10; + model->elevBsLen[3] = 7; + model->elevBsStart[0] = 0; + model->elevBsStart[1] = 4; + model->elevBsStart[2] = 11; + model->elevBsStart[3] = 21; + + model->azimDim2 = orange53_rom_azimDim2; + model->azimDim3 = orange53_rom_azimDim3; + model->azim_start_idx = orange53_rom_azim_start_idx; + model->azimSegSamples = orange53_rom_azimSegSamples; + model->azimShapeIdx = orange53_rom_azimShapeIdx; + model->azimShapeSampFactor = orange53_rom_azimShapeSampFactor; + + /* float parameters */ + model->elevKSeq = (const float *) orange53_rom_elevKSeq; + model->elevBsShape = (const float *) orange53_rom_elevBsShape; + + model->azimBsShape = (const float **) malloc( model->num_unique_azim_splines * sizeof( float * ) ); + model->azimBsShape[0] = (const float *) orange53_rom_azimBsShape; + model->azimKSeq = (float **) malloc( 18 * sizeof( float * ) ); + model->azimKSeq[0] = (float *) malloc( 2 * sizeof( float * ) ); + model->azimKSeq[17] = (float *) malloc( 2 * sizeof( float * ) ); + model->azimKSeq[0][0] = 0.0f; + model->azimKSeq[17][0] = 0.0f; + model->azimKSeq[0][1] = 360.0f; + model->azimKSeq[17][1] = 360.0f; + + for ( i = 1; i < 17; i++ ) + { + model->azimKSeq[i] = (float *) malloc( model->azimDim2[i] * sizeof( float * ) ); /* azimDim2[i] = 91, i=2..15 */ + for ( j = 0; j < model->azimDim2[i]; j++ ) + { + model->azimKSeq[i][j] = (float) orange53_rom_azimSegSamples[0] * j; + } + } + + switch ( output_Fs ) + { + case 48000: + model->AlphaL = (const float *) orange53_rom_AlphaL48; + model->AlphaR = (const float *) orange53_rom_AlphaR48; + model->EL = (const float *) orange53_rom_EL48; + model->ER = (const float *) orange53_rom_ER48; + model->K = 128; + if ( HrFiltSet_p->ModelParams.UseItdModel ) + { + modelITD->resamp_factor = 1.0f; + } + break; + case 32000: + model->AlphaL = (const float *) orange53_rom_AlphaL32; + model->AlphaR = (const float *) orange53_rom_AlphaR32; + model->EL = (const float *) orange53_rom_EL32; + model->ER = (const float *) orange53_rom_ER32; + model->K = 86; + if ( HrFiltSet_p->ModelParams.UseItdModel ) + { + modelITD->resamp_factor = RESAMPLE_FACTOR_32_48; + } + break; + case 16000: + model->AlphaL = (const float *) orange53_rom_AlphaL16; + model->AlphaR = (const float *) orange53_rom_AlphaR16; + model->EL = (const float *) orange53_rom_EL16; + model->ER = (const float *) orange53_rom_ER16; + model->K = 43; + if ( HrFiltSet_p->ModelParams.UseItdModel ) + { + modelITD->resamp_factor = RESAMPLE_FACTOR_16_48; + } + break; + default: + break; + } + + modelITD->N = 4; + modelITD->elevDim2 = 20; + modelITD->elevDim3 = 18; + modelITD->azimDim2 = 41; + modelITD->azimDim3 = 41; + modelITD->elevSegSamples = 3; + modelITD->elevBsLen[0] = 4; + modelITD->elevBsLen[1] = 7; + modelITD->elevBsLen[2] = 10; + modelITD->elevBsLen[3] = 7; + modelITD->elevBsStart[0] = 0; + modelITD->elevBsStart[1] = 4; + modelITD->elevBsStart[2] = 11; + modelITD->elevBsStart[3] = 21; + + modelITD->elevKSeq = model->elevKSeq; + + modelITD->azimBsLen[0] = 11; + modelITD->azimBsLen[1] = 21; + modelITD->azimBsLen[2] = 31; + modelITD->azimBsLen[3] = 21; + modelITD->azimBsStart[0] = 0; + modelITD->azimBsStart[1] = 11; + modelITD->azimBsStart[2] = 32; + modelITD->azimBsStart[3] = 63; + + modelITD->azimSegSamples = 10; + + modelITD->azimKSeq = orange53_rom_ITD_azimKSeq; + modelITD->W = (const float *) orange53_rom_ITD_W; + modelITD->azimBsShape = (const float *) orange53_rom_ITD_azimBsShape; + modelITD->elevBsShape = (const float *) orange53_rom_ITD_elevBsShape; + + HRTF_model_precalc( model ); + + HrFiltSet_p->SampleRate = output_Fs; + HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; + + BSplineModelEvalAlloc( &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval ); + + return; +} diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index 828dc0eac8..b3f2685a45 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -43,7 +43,7 @@ * FASTCONV and PARAMETRIC binaural renderer ROM tables *----------------------------------------------------------------------------------*/ -const float dmxmtx[BINAURAL_CHANNELS][11] = // VE2AT: rename, otherwise could be confusing with hReverb->dmxmtx[][] +const float dmxmtx_table[BINAURAL_CHANNELS][11] = { { 1.0f, 0.0f, 0.70709997f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.70709997f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }, @@ -76,29 +76,6 @@ const int16_t channelIndex_CICP19[11] = { 0, 1, 2, 3, 4, 7, 8, 9, 10, 13, 14 }; * TD ISm binaural renderer ROM tables *----------------------------------------------------------------------------------*/ - /* The maximum target times set to 100 msec. */ -const int16_t TDREND_SRC_REND_MaxTargetTimes[IVAS_NUM_SUPPORTED_FS] = -{ - 1600, 3200, 4800 /* Corresponds to 16kHz, 32kHz, 48kHz */ -}; - -/* The maximum lengths of the blocks internally in the effect. Corresponds to 6 msec. This means also that */ -/* if the length of the input block is just above 6 msec, the block will be divided into two 3 msec blocks. */ -const int16_t TDREND_SRC_REND_MaxBlockLengths[IVAS_NUM_SUPPORTED_FS] = -{ - 96, 192, 288 /* Corresponds to 16kHz, 32kHz, 48kHz */ -}; - -const int16_t TDREND_MaxITD[IVAS_NUM_SUPPORTED_FS] = -{ - 111, 222, 333 /* Corresponds to 16kHz, 32kHz, 48kHz */ -}; - -const float TDREND_MaxITD_Incr[IVAS_NUM_SUPPORTED_FS] = -{ - 0.0925f, 0.1850f, 0.2775f /* Corresponds to 16kHz, 32kHz, 48kHz, e.g. ( ( 2 * MaxITD ) / ( 0.05 * 48000 ) ) */ -}; - const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS] = { 13, 12, 11 diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index e2b0b16ba3..13de27a963 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -45,7 +45,7 @@ * FASTCONV and PARAMETRIC binaural renderer ROM tables *----------------------------------------------------------------------------------*/ -extern const float dmxmtx[BINAURAL_CHANNELS][11]; +extern const float dmxmtx_table[BINAURAL_CHANNELS][11]; extern const int16_t channelIndex_CICP6[5]; extern const int16_t channelIndex_CICP12[7]; @@ -57,11 +57,6 @@ extern const int16_t channelIndex_CICP19[11]; * TD ISM Object renderer *----------------------------------------------------------------------------------*/ -extern const int16_t TDREND_SRC_REND_MaxTargetTimes[IVAS_NUM_SUPPORTED_FS]; // VE2AT: not used -extern const int16_t TDREND_SRC_REND_MaxBlockLengths[IVAS_NUM_SUPPORTED_FS]; // VE2AT: not used -extern const int16_t TDREND_MaxITD[IVAS_NUM_SUPPORTED_FS]; // VE2AT: not used -extern const float TDREND_MaxITD_Incr[IVAS_NUM_SUPPORTED_FS]; // VE2AT: not used - extern const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS]; extern const float SincTable[321]; -- GitLab From 064fed5f9f0c51493c1bb21801f442b64923ea52 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 7 Feb 2023 18:23:50 +0100 Subject: [PATCH 04/40] - remove unused ROM tables - remove outdated VE2AT comments --- lib_rend/ivas_hrtf.c | 4 ++-- lib_rend/ivas_rom_rend.c | 17 ----------------- lib_rend/ivas_rom_rend.h | 9 +-------- lib_rend/ivas_stat_rend.h | 4 +--- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index 4b44d52764..3cf0280ccc 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -34,7 +34,7 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" // VE2AT: remove it +//#include "ivas_lib_rend_internal.h" //#include "lib_dec.h" //#include "string.h" //#include "assert.h" @@ -90,7 +90,7 @@ void ivas_HRTF_binary_close( * * Allocate HRTF binary handle *-----------------------------------------------------------------------*/ -//VE2AT: move to lib_dec + ivas_error ivas_HRTF_CRend_binary_open( HRTFS_CREND **hSetOfHRTF ) { diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index b3f2685a45..5aa3578e28 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -310,25 +310,8 @@ const float ivas_reverb_default_DSR[IVAS_REVERB_DEFAULT_N_BANDS] = /* CICP1 - Mono */ const float ls_azimuth_CICP1[1] = { 0.0f }; const float ls_elevation_CICP1[1] = { 0.0f }; -const uint32_t ls_LFE_last_idx_CICP1[1] = { 0 }; -/* CICP2 - Stereo */ -const uint32_t ls_LFE_last_idx_CICP2[2] = { 0, 1 }; -/* CICP6 - 5.1 */ -const uint32_t ls_LFE_last_idx_CICP6[6] = { 0, 1, 2, 4, 5, 3 }; - -/* CICP12 - 7.1 */ -const uint32_t ls_LFE_last_idx_CICP12[8] = { 0, 1, 2, 4, 5, 6, 7, 3 }; - -/* CICP14 - 5.1.2 */ -const uint32_t ls_LFE_last_idx_CICP14[8] = { 0, 1, 2, 4, 5, 6, 7, 3 }; - -/* CICP16 - 5.1.4 */ -const uint32_t ls_LFE_last_idx_CICP16[10] = { 0, 1, 2, 4, 5, 6, 7, 8, 9, 3 }; - -/* CICP19 - 7.1.4 */ -const uint32_t ls_LFE_last_idx_CICP19[12] = { 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 3 }; /*----------------------------------------------------------------------------------* * LS Renderer ROM tables diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 13de27a963..b18caa02dc 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -91,16 +91,9 @@ extern const float ivas_reverb_default_DSR[]; * Renderer SBA & MC enc/dec matrices *----------------------------------------------------------------------------------*/ -extern const float hoa_dec_mtx_CICP1[16]; // VE2AT: not used extern const float ls_azimuth_CICP1[1]; extern const float ls_elevation_CICP1[1]; -extern const uint32_t ls_LFE_last_idx_CICP1[1]; // VE2AT: not used -extern const uint32_t ls_LFE_last_idx_CICP2[2]; -extern const uint32_t ls_LFE_last_idx_CICP6[6]; -extern const uint32_t ls_LFE_last_idx_CICP12[8]; -extern const uint32_t ls_LFE_last_idx_CICP14[8]; -extern const uint32_t ls_LFE_last_idx_CICP16[10]; -extern const uint32_t ls_LFE_last_idx_CICP19[12]; + /*----------------------------------------------------------------------------------* * LS Configuration Converter ROM tables diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 055c4bf6ab..e819fc9b42 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -38,11 +38,9 @@ #include "cnst.h" #include "ivas_cnst.h" #include "ivas_stat_com.h" -#include "common_api_types.h" // VE2AT: don't we want to avoid this include in the library? I admit that the rules hefre are not 100% clear to me but introducing it just for IVAS_QUATERNION is not necessry I think +#include "common_api_types.h" #endif -#define MAX_SPEAKERS 12 /* Max number of speakers (including LFE) in a channel-based config */ // VE2AT: not used - #ifdef FIX_197_CREND_INTERFACE -- GitLab From fb1bec0ca749f223cd45511cae2046a1a91c3044 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Feb 2023 09:38:02 +0100 Subject: [PATCH 05/40] - rename ivas_lib_rend_internal.h to ivas_prot_rend.h - add MSVC filters for lib_rend --- Workspace_msvc/lib_rend.vcxproj | 2 +- lib_com/ivas_prot.h | 6 +++--- lib_rend/ivas_binauralRenderer.c | 2 +- lib_rend/ivas_binaural_reverb.c | 2 +- lib_rend/ivas_crend.c | 2 +- lib_rend/ivas_hrtf.c | 2 +- lib_rend/ivas_objectRenderer.c | 2 +- lib_rend/ivas_objectRenderer_hrFilt.c | 2 +- lib_rend/ivas_objectRenderer_mix.c | 2 +- lib_rend/ivas_objectRenderer_sources.c | 2 +- lib_rend/{ivas_lib_rend_internal.h => ivas_prot_rend.h} | 0 lib_rend/ivas_reverb.c | 2 +- lib_rend/ivas_reverb_fft_filter.c | 2 +- lib_rend/ivas_reverb_filter_design.c | 2 +- lib_rend/ivas_reverb_utils.c | 2 +- lib_rend/ivas_rotation.c | 2 +- lib_rend/lib_rend.c | 2 +- lib_util/hrtf_file_reader.c | 6 +++--- 18 files changed, 21 insertions(+), 21 deletions(-) rename lib_rend/{ivas_lib_rend_internal.h => ivas_prot_rend.h} (100%) diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index c3a1268694..7087dd5993 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -229,7 +229,7 @@ - + diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index fdac1c72d6..e2fdba1ae5 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3182,7 +3182,7 @@ void ivas_sba_getTCs( const int16_t input_frame /* i : frame length */ ); -// VE2AT: move to ivas_lib_rend_internal.h ? +// VE2AT: move to ivas_prot_rend.h ? ivas_error ivas_sba_linear_renderer( float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ @@ -3212,7 +3212,7 @@ void ivas_sba_dirac_stereo_smooth_parameters( STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: encoder DFT stereo handle */ ); -// VE2AT: move to ivas_lib_rend_internal.h ? +// VE2AT: move to ivas_prot_rend.h ? ivas_error ivas_sba_get_hoa_dec_matrix( const IVAS_OUTPUT_SETUP hOutSetup, /* i : target output setup */ float **hoa_dec_mtx, /* o : ALLRAD decoder matrix */ @@ -4629,7 +4629,7 @@ void ivas_HRTF_parambin_binary_close( ); #endif -// VE2AT: move to ivas_lib_rend_internal.h ?? +// VE2AT: move to ivas_prot_rend.h ?? void QuatToRotMat( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ diff --git a/lib_rend/ivas_binauralRenderer.c b/lib_rend/ivas_binauralRenderer.c index d697fc3956..7cfd88f9af 100644 --- a/lib_rend/ivas_binauralRenderer.c +++ b/lib_rend/ivas_binauralRenderer.c @@ -35,7 +35,7 @@ #include #include "prot.h" #include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" #include "cnst.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_binaural_reverb.c b/lib_rend/ivas_binaural_reverb.c index b045a8dccb..4b3968d9ad 100644 --- a/lib_rend/ivas_binaural_reverb.c +++ b/lib_rend/ivas_binaural_reverb.c @@ -35,7 +35,7 @@ #include #include "prot.h" //#include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" //#include "ivas_rom_com.h" //#include "ivas_rom_binauralRenderer.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 56973d4665..b83fb8dcd0 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -34,7 +34,7 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "ivas_stat_dec.h" diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index 3cf0280ccc..ffbad961cc 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -34,7 +34,7 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" -//#include "ivas_lib_rend_internal.h" +//#include "ivas_prot_rend.h" //#include "lib_dec.h" //#include "string.h" //#include "assert.h" diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index bc6bd01f6e..f65eb07f29 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -34,7 +34,7 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" //#include "lib_rend.h" // VE2AT: remove it from this file? diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index ad52c2529a..b1402c8340 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -36,7 +36,7 @@ #include "prot.h" #include //#include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "ivas_cnst.h" //#include "ivas_rom_TdBinauralRenderer.h" diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index 19c050b454..7f088d6cd1 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -34,7 +34,7 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" #include "ivas_rom_TdBinauralRenderer.h" #include "wmc_auto.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 5a323a5d3d..ee2dfe484f 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -35,7 +35,7 @@ #include #include "prot.h" //#include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_lib_rend_internal.h b/lib_rend/ivas_prot_rend.h similarity index 100% rename from lib_rend/ivas_lib_rend_internal.h rename to lib_rend/ivas_prot_rend.h diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 6bc8db5c2c..412e4d7068 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -34,7 +34,7 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" #include "ivas_cnst.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c index 7b2ff45e1e..8555d7d502 100644 --- a/lib_rend/ivas_reverb_fft_filter.c +++ b/lib_rend/ivas_reverb_fft_filter.c @@ -38,7 +38,7 @@ #endif #include #include "prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c index 2e2f456350..097f06e515 100644 --- a/lib_rend/ivas_reverb_filter_design.c +++ b/lib_rend/ivas_reverb_filter_design.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index de28766e13..c4d7f7d49e 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -34,7 +34,7 @@ #include "options.h" #include "prot.h" //#include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" //#include "ivas_rom_binauralRenderer.h" #include "ivas_rom_rend.h" #include diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 4860b40c79..a96091e229 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -37,7 +37,7 @@ #include "cnst.h" #include "prot.h" #include "ivas_prot.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" //#include "ivas_cnst.h" //#include "ivas_rom_com.h" //#include "ivas_rom_dec.h" diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 4663ca7e2c..1e06bc8696 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -37,7 +37,7 @@ #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "ivas_rom_rend.h" -#include "ivas_lib_rend_internal.h" +#include "ivas_prot_rend.h" #ifdef FIX_197_CREND_INTERFACE #include "lib_rend.h" #endif diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index dde9d04f71..abdde9e8a1 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -33,9 +33,9 @@ #include "hrtf_file_reader.h" #include #include -#include "prot.h" // VE: !!!!! -//#include "ivas_prot.h" // VE: !!!!! -#include "ivas_lib_rend_internal.h" +#include "prot.h" +//#include "ivas_prot.h" +#include "ivas_prot_rend.h" #ifdef HRTF_BINARY_FILE //#include "lib_dec.h" #endif -- GitLab From 077febab25fca8835172c1cb56df50ea5f8464a6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Feb 2023 09:52:10 +0100 Subject: [PATCH 06/40] - move and rename "lib_rend/ivas_binauralRenderer.c" to "lib_dec/ivas_binRenderer_internal.c" - ivas_headTrack_open() to lib_dec --- Workspace_msvc/lib_dec.vcxproj | 1 + Workspace_msvc/lib_dec.vcxproj.filters | 3 ++ Workspace_msvc/lib_rend.vcxproj | 1 - .../ivas_binRenderer_internal.c | 0 lib_rend/ivas_hrtf.c | 42 ++++++++++++++++--- lib_rend/ivas_rotation.c | 35 ---------------- 6 files changed, 40 insertions(+), 42 deletions(-) rename lib_rend/ivas_binauralRenderer.c => lib_dec/ivas_binRenderer_internal.c (100%) diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 773dafc2c5..f8034a0595 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -264,6 +264,7 @@ + diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index 4dcff8d503..376a19c0c6 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -503,6 +503,9 @@ dec_ivas_c + + dec_ivas_c + diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 7087dd5993..c64828d57c 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -199,7 +199,6 @@ - diff --git a/lib_rend/ivas_binauralRenderer.c b/lib_dec/ivas_binRenderer_internal.c similarity index 100% rename from lib_rend/ivas_binauralRenderer.c rename to lib_dec/ivas_binRenderer_internal.c diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index ffbad961cc..5e6c63f17c 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -29,16 +29,11 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: move this file to lib_dec + #include #include "options.h" #include "prot.h" #include "ivas_prot.h" -//#include "ivas_prot_rend.h" -//#include "lib_dec.h" -//#include "string.h" -//#include "assert.h" -#include "ivas_rom_TdBinauralRenderer.h" #include "ivas_error.h" #include "wmc_auto.h" @@ -210,3 +205,38 @@ void ivas_HRTF_parambin_binary_close( return; } #endif + + +/*-----------------------------------------------------------------------* + * ivas_headTrack_open() + * + * Allocate and initialize Head-Tracking handle + *-----------------------------------------------------------------------*/ + +ivas_error ivas_headTrack_open( + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ +) +{ + int16_t i; + + /* Allocate Head-Tracking handle */ + if ( ( *hHeadTrackData = (HEAD_TRACK_DATA_HANDLE) malloc( sizeof( HEAD_TRACK_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for head-tracking memory\n" ) ); + } + + /* Initialization */ + ( *hHeadTrackData )->num_quaternions = 0; + ( *hHeadTrackData )->lrSwitchInterpVal = 0.0f; + ( *hHeadTrackData )->lrSwitchedCurrent = 0; + ( *hHeadTrackData )->lrSwitchedNext = 0; + + /* Initialise Rmat_prev to I, Rmat will be computed later */ + for ( i = 0; i < 3; i++ ) + { + set_zero( ( *hHeadTrackData )->Rmat_prev[i], 3 ); + ( *hHeadTrackData )->Rmat_prev[i][i] = 1.0f; + } + + return IVAS_ERR_OK; +} diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index a96091e229..8bdf5b5eb2 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -47,41 +47,6 @@ #include "wmc_auto.h" -/*-----------------------------------------------------------------------* - * ivas_headTrack_open() - * - * Allocate and initialize Head-Tracking handle - *-----------------------------------------------------------------------*/ -// VE2AT: should be moved to lib_dec -ivas_error ivas_headTrack_open( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ -) -{ - int16_t i; - - /* Allocate Head-Tracking handle */ - if ( ( *hHeadTrackData = (HEAD_TRACK_DATA_HANDLE) malloc( sizeof( HEAD_TRACK_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for head-tracking memory\n" ) ); - } - - /* Initialization */ - ( *hHeadTrackData )->num_quaternions = 0; - ( *hHeadTrackData )->lrSwitchInterpVal = 0.0f; - ( *hHeadTrackData )->lrSwitchedCurrent = 0; - ( *hHeadTrackData )->lrSwitchedNext = 0; - - /* Initialise Rmat_prev to I, Rmat will be computed later */ - for ( i = 0; i < 3; i++ ) - { - set_zero( ( *hHeadTrackData )->Rmat_prev[i], 3 ); - ( *hHeadTrackData )->Rmat_prev[i][i] = 1.0f; - } - - return IVAS_ERR_OK; -} - - /*---------------------------------------------------------------------------------- * QuatToRotMat() * -- GitLab From e031c86f1abc23bd905fc09c793658d47fa33a0f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Feb 2023 10:20:50 +0100 Subject: [PATCH 07/40] move functions to appropriate libraries --- Workspace_msvc/lib_dec.vcxproj | 3 +- Workspace_msvc/lib_dec.vcxproj.filters | 9 +- Workspace_msvc/lib_rend.vcxproj | 2 +- lib_com/ivas_prot.h | 9 +- lib_dec/ivas_dec.c | 1 + lib_dec/ivas_init_dec.c | 1 + lib_dec/ivas_ism_param_dec.c | 1 + lib_dec/ivas_mct_dec.c | 1 + lib_dec/ivas_out_setup_conversion.c | 8 +- lib_dec/ivas_output_config.c | 451 ++++++++++++++++++ .../ivas_reverb_internal.c | 0 lib_dec/ivas_rom_dec.h | 11 - .../ivas_dirac_dec_binaural_functions.c | 0 lib_rend/ivas_output_init.c | 372 +-------------- lib_rend/ivas_prot_rend.h | 10 +- lib_rend/lib_rend.c | 78 --- 16 files changed, 481 insertions(+), 476 deletions(-) create mode 100644 lib_dec/ivas_output_config.c rename lib_rend/ivas_binaural_reverb.c => lib_dec/ivas_reverb_internal.c (100%) rename {lib_dec => lib_rend}/ivas_dirac_dec_binaural_functions.c (100%) diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index f8034a0595..cd454b8be8 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -272,7 +272,6 @@ - @@ -291,12 +290,14 @@ + + diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index 376a19c0c6..5ca5c16138 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -13,9 +13,6 @@ dec_ivas_c - - dec_ivas_c - dec_ivas_c @@ -506,6 +503,12 @@ dec_ivas_c + + dec_ivas_c + + + dec_ivas_c + diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index c64828d57c..b597ee8fcb 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -197,9 +197,9 @@ + - diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index e2fdba1ae5..5eb77df64f 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4577,6 +4577,11 @@ void ivas_output_init( const AUDIO_CONFIG output_config /* i : output audio configuration */ ); +// VE2AT: rename it +IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( + AUDIO_CONFIG config +); + /*---------------------------------------------------------------------------------* * Binaural Renderer Prototypes @@ -5157,10 +5162,6 @@ ivas_error ivas_crend_process( ); #else -// VE2AT: declaration here in Codec but definition in Rend -IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( - AUDIO_CONFIG config -); ivas_error ivas_rend_openCrend( CREND_WRAPPER_HANDLE *pCrend, diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index e4a08b0540..fc44363745 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -37,6 +37,7 @@ #include "rom_com.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 763c83dc39..f2c32a63af 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -33,6 +33,7 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "lib_dec.h" diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 2b6d0b6876..dde0f70d56 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -35,6 +35,7 @@ #include #include "options.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "prot.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 7b2fa2982c..1089f6c2f2 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -39,6 +39,7 @@ #include "rom_com.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 179e7d021b..cc6688732a 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -30,18 +30,18 @@ *******************************************************************************************************/ -#include #include #include "options.h" #include -#include "ivas_prot.h" +#include #include "prot.h" +#include "ivas_prot.h" +#include "ivas_rom_com.h" +#include "ivas_rom_rend.h" #ifdef DEBUGGING #include "debug.h" #endif #include "wmc_auto.h" -#include "ivas_rom_com.h" -#include "ivas_rom_dec.h" /*----------------------------------------------------------------------------------* diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c new file mode 100644 index 0000000000..1f0350633a --- /dev/null +++ b/lib_dec/ivas_output_config.c @@ -0,0 +1,451 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "ivas_cnst.h" +#include "ivas_prot.h" +//#include "prot.h" +#include "ivas_stat_dec.h" +//#include "ivas_rom_dec.h" +//#include "ivas_rom_com.h" +#ifdef DEBUGGING +#include "debug.h" +#include +#endif +#include "wmc_auto.h" + + +/*-------------------------------------------------------------------------* + * ivas_renderer_select() + * + * Select and configure IVAS renderer parameters + *-------------------------------------------------------------------------*/ + +void ivas_renderer_select( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + RENDERER_TYPE *renderer_type; + AUDIO_CONFIG *internal_config; + AUDIO_CONFIG output_config; + AUDIO_CONFIG transport_config; + + int16_t nchan_internal; + + renderer_type = &( st_ivas->renderer_type ); + internal_config = &( st_ivas->intern_config ); + output_config = st_ivas->hDecoderConfig->output_config; + transport_config = st_ivas->transport_config; + + /* disabled rendering by default */ + *renderer_type = RENDERER_DISABLE; + + /*-----------------------------------------------------------------* + * Binaural rendering configurations + *-----------------------------------------------------------------*/ + + if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + { + st_ivas->hHeadTrackData->shd_rot_max_order = -1; + } + + if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM ) + { + if ( st_ivas->ivas_format == ISM_FORMAT ) + { + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + if ( output_config == AUDIO_CONFIG_BINAURAL ) + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC; + } + else + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; + } + } + else /* ISM_MODE_DISC */ + { + if ( output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hRenderConfig->roomAcoustics.use_brir == 0 ) + { +#ifdef DEBUGGING + if ( st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER ) + { + *renderer_type = RENDERER_BINAURAL_FASTCONV; + *internal_config = AUDIO_CONFIG_HOA3; /* Render ISM to HOA3 before binauralization*/ + } + else + { + *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + *internal_config = AUDIO_CONFIG_BINAURAL; + } +#else + *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + *internal_config = AUDIO_CONFIG_BINAURAL; +#endif + } + else + { + *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; +#if defined( DEBUGGING ) + if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) + { + *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; + } +#endif + *internal_config = AUDIO_CONFIG_7_1_4; + } + } + } + else if ( st_ivas->ivas_format == MASA_FORMAT || ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->nchan_transport <= 2 ) ) + { + *internal_config = output_config; + if ( output_config == AUDIO_CONFIG_BINAURAL ) + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC; + } + else + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; + } + } + else if ( st_ivas->ivas_format == SBA_FORMAT ) + { + *internal_config = AUDIO_CONFIG_HOA3; + + if ( output_config == AUDIO_CONFIG_BINAURAL ) + { + *renderer_type = RENDERER_BINAURAL_FASTCONV; + } + else + { + *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; + } + + if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + { + + nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); + if ( nchan_internal == 2 ) + { + st_ivas->hHeadTrackData->shd_rot_max_order = 1; + } + else if ( nchan_internal == 4 || nchan_internal == 3 ) + { + st_ivas->hHeadTrackData->shd_rot_max_order = 0; + } + else if ( nchan_internal == 6 || nchan_internal == 5 ) + { + st_ivas->hHeadTrackData->shd_rot_max_order = 2; + } + else if ( nchan_internal == 8 || nchan_internal == 7 ) + { + st_ivas->hHeadTrackData->shd_rot_max_order = 3; + } + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + *internal_config = output_config; + if ( output_config == AUDIO_CONFIG_BINAURAL ) + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC; + } + else + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; + } + } + else + { + *internal_config = transport_config; + if ( output_config == AUDIO_CONFIG_BINAURAL ) + { +#ifdef DEBUGGING + if ( ( ( ( st_ivas->transport_config == AUDIO_CONFIG_5_1 || st_ivas->transport_config == AUDIO_CONFIG_7_1 ) && st_ivas->hDecoderConfig->Opt_Headrotation ) || ( st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) ) && ( st_ivas->mc_mode == MC_MODE_MCT ) && !( st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER ) ) +#else + if ( ( st_ivas->transport_config == AUDIO_CONFIG_5_1 || st_ivas->transport_config == AUDIO_CONFIG_7_1 ) && st_ivas->hDecoderConfig->Opt_Headrotation && ( st_ivas->mc_mode == MC_MODE_MCT ) ) +#endif + { + *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + } + else + { + if ( st_ivas->mc_mode == MC_MODE_MCT ) + { + *renderer_type = RENDERER_BINAURAL_MIXER_CONV; + } + else + { + *renderer_type = RENDERER_BINAURAL_FASTCONV; + } + +#ifdef DEBUGGING + if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_CREND ) + { + *renderer_type = RENDERER_BINAURAL_MIXER_CONV; + } + else if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) + { + *renderer_type = RENDERER_BINAURAL_FASTCONV; + } +#endif + if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + { + /* force HOA3 domain for rotation*/ + *internal_config = AUDIO_CONFIG_HOA3; + } + } + } + else /* AUDIO_CONFIG_BINAURAL_ROOM */ + { + if ( st_ivas->mc_mode == MC_MODE_MCT ) + { + *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; + } + else + { + *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; + } +#ifdef DEBUGGING + if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_CREND ) + { + *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; + } + else if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) + { + *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; + } +#endif + } + } + } + } + + /*-----------------------------------------------------------------* + * Non-binaural rendering configurations + *-----------------------------------------------------------------*/ + + else if ( st_ivas->ivas_format == STEREO_FORMAT ) + { + if ( output_config != AUDIO_CONFIG_STEREO && output_config != AUDIO_CONFIG_MONO ) + { + *renderer_type = RENDERER_MC; + } + } + else if ( st_ivas->ivas_format == ISM_FORMAT ) + { + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + *renderer_type = RENDERER_PARAM_ISM; + if ( output_config == AUDIO_CONFIG_MONO ) + { + *renderer_type = RENDERER_MONO_DOWNMIX; + } + else if ( output_config == AUDIO_CONFIG_STEREO ) + { + *renderer_type = RENDERER_DISABLE; + } + else if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + *internal_config = AUDIO_CONFIG_7_1_4; + } + } + else /* ISM_MODE_DISC */ + { + *renderer_type = RENDERER_TD_PANNING; + if ( output_config == AUDIO_CONFIG_MONO ) + { + *renderer_type = RENDERER_MONO_DOWNMIX; + } + else if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + } + else if ( output_config == AUDIO_CONFIG_EXTERNAL ) + { + *renderer_type = RENDERER_DISABLE; + } + } + } + else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT ) + { + *renderer_type = RENDERER_DIRAC; + + if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR && + ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM ) ) + { + if ( output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_FOA ) + { + *internal_config = output_config; + } + else if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) + { + *internal_config = AUDIO_CONFIG_FOA; + } + else + { + *internal_config = AUDIO_CONFIG_HOA3; + } + st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC; + } + else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || + ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_STEREO && st_ivas->nchan_transport == 1 ) ) + { + *renderer_type = RENDERER_DISABLE; + } + else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 ) ) + { + *renderer_type = RENDERER_DISABLE; + } + else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_STEREO ) + { + *renderer_type = RENDERER_STEREO_PARAMETRIC; + } + else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) + { + *renderer_type = RENDERER_DISABLE; + } + else if ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_MONO ) + { + *renderer_type = RENDERER_SBA_LINEAR_DEC; + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + *internal_config = transport_config; + if ( st_ivas->mc_mode == MC_MODE_MCT && *internal_config != output_config ) + { + if ( output_config != AUDIO_CONFIG_FOA && output_config != AUDIO_CONFIG_HOA2 && output_config != AUDIO_CONFIG_HOA3 ) + { + *renderer_type = RENDERER_MC; + } + else + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + } + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + } + else + { + *renderer_type = RENDERER_MC_PARAMMC; + } + } + else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + *internal_config = output_config; + /* No rendering for 1TC to Mono or Stereo and 2TC to Stereo */ + if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) + { + if ( st_ivas->nchan_transport == 1 ) + { + *renderer_type = RENDERER_DISABLE; + } + else if ( output_config == AUDIO_CONFIG_STEREO && st_ivas->nchan_transport == 2 && !st_ivas->hOutSetup.separateChannelEnabled ) + { + *renderer_type = RENDERER_DISABLE; + } + else + { + *renderer_type = RENDERER_MCMASA_MONO_STEREO; + } + } + else + { + *renderer_type = RENDERER_DIRAC; + if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + *internal_config = transport_config; + } + else if ( transport_config == AUDIO_CONFIG_5_1 && ( output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_5_1_4 ) ) + { + *internal_config = transport_config; + } + } + } + } + + return; +} + + +/*-------------------------------------------------------------------* + * getRendAudioConfigFromIvasAudioConfig() + * + * + *-------------------------------------------------------------------*/ + +IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( + const AUDIO_CONFIG config ) +{ + switch ( config ) + { + case AUDIO_CONFIG_MONO: + return IVAS_REND_AUDIO_CONFIG_MONO; + case AUDIO_CONFIG_STEREO: + return IVAS_REND_AUDIO_CONFIG_STEREO; + case AUDIO_CONFIG_BINAURAL: + return IVAS_REND_AUDIO_CONFIG_BINAURAL; + case AUDIO_CONFIG_BINAURAL_ROOM: + return IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM; + case AUDIO_CONFIG_5_1: + return IVAS_REND_AUDIO_CONFIG_5_1; + case AUDIO_CONFIG_7_1: + return IVAS_REND_AUDIO_CONFIG_7_1; + case AUDIO_CONFIG_5_1_2: + return IVAS_REND_AUDIO_CONFIG_5_1_2; + case AUDIO_CONFIG_5_1_4: + return IVAS_REND_AUDIO_CONFIG_5_1_4; + case AUDIO_CONFIG_7_1_4: + return IVAS_REND_AUDIO_CONFIG_7_1_4; + case AUDIO_CONFIG_FOA: + return IVAS_REND_AUDIO_CONFIG_FOA; + case AUDIO_CONFIG_HOA2: + return IVAS_REND_AUDIO_CONFIG_HOA2; + case AUDIO_CONFIG_HOA3: + return IVAS_REND_AUDIO_CONFIG_HOA3; + default: + break; + } + + return IVAS_REND_AUDIO_CONFIG_UNKNOWN; +} diff --git a/lib_rend/ivas_binaural_reverb.c b/lib_dec/ivas_reverb_internal.c similarity index 100% rename from lib_rend/ivas_binaural_reverb.c rename to lib_dec/ivas_reverb_internal.c diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index eccdd5eb15..37302a25e5 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -110,17 +110,6 @@ extern const float ap_split_frequencies[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]; extern const int16_t sba_map_tc[8]; -/*----------------------------------------------------------------------------------* - * LS Configuration Converter ROM tables - *----------------------------------------------------------------------------------*/ - -/* Downmix matrices */ -extern const float ls_conversion_cicpX_mono[12][1]; // VE2AT: it is declared also in ivas_rom_rend.h -extern const float ls_conversion_cicpX_stereo[12][2]; - -/* Mapping table of input config : output config with corresponding matrix */ -extern const LS_CONVERSION_MAPPING ls_conversion_mapping[]; - /*----------------------------------------------------------------------------------* * FASTCONV and PARAMETRIC binaural renderer ROM tables diff --git a/lib_dec/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c similarity index 100% rename from lib_dec/ivas_dirac_dec_binaural_functions.c rename to lib_rend/ivas_dirac_dec_binaural_functions.c diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 2dfaa6da68..970e6a54cb 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -29,15 +29,14 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: keep in lib_rend or move to lib_dec ? -#include +// VE2AT: move these low-level fucntions to lib_com? #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" +//#include "ivas_prot.h" #include "prot.h" -#include "ivas_stat_dec.h" -#include "ivas_rom_dec.h" +//#include "ivas_stat_dec.h" +//#include "ivas_rom_dec.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" @@ -246,366 +245,3 @@ void ivas_output_init( return; } - - -/*-------------------------------------------------------------------------* - * ivas_renderer_select() - * - * Select and configure IVAS renderer parameters - *-------------------------------------------------------------------------*/ - -void ivas_renderer_select( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - RENDERER_TYPE *renderer_type; - AUDIO_CONFIG *internal_config; - AUDIO_CONFIG output_config; - AUDIO_CONFIG transport_config; - - int16_t nchan_internal; - - renderer_type = &( st_ivas->renderer_type ); - internal_config = &( st_ivas->intern_config ); - output_config = st_ivas->hDecoderConfig->output_config; - transport_config = st_ivas->transport_config; - - /* disabled rendering by default */ - *renderer_type = RENDERER_DISABLE; - - /*-----------------------------------------------------------------* - * Binaural rendering configurations - *-----------------------------------------------------------------*/ - - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) - { - st_ivas->hHeadTrackData->shd_rot_max_order = -1; - } - - if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM ) - { - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) - { - if ( output_config == AUDIO_CONFIG_BINAURAL ) - { - *renderer_type = RENDERER_BINAURAL_PARAMETRIC; - } - else - { - *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; - } - } - else /* ISM_MODE_DISC */ - { - if ( output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hRenderConfig->roomAcoustics.use_brir == 0 ) - { -#ifdef DEBUGGING - if ( st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER ) - { - *renderer_type = RENDERER_BINAURAL_FASTCONV; - *internal_config = AUDIO_CONFIG_HOA3; /* Render ISM to HOA3 before binauralization*/ - } - else - { - *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; - *internal_config = AUDIO_CONFIG_BINAURAL; - } -#else - *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; - *internal_config = AUDIO_CONFIG_BINAURAL; -#endif - } - else - { - *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; -#if defined( DEBUGGING ) - if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) - { - *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; - } -#endif - *internal_config = AUDIO_CONFIG_7_1_4; - } - } - } - else if ( st_ivas->ivas_format == MASA_FORMAT || ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->nchan_transport <= 2 ) ) - { - *internal_config = output_config; - if ( output_config == AUDIO_CONFIG_BINAURAL ) - { - *renderer_type = RENDERER_BINAURAL_PARAMETRIC; - } - else - { - *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; - } - } - else if ( st_ivas->ivas_format == SBA_FORMAT ) - { - *internal_config = AUDIO_CONFIG_HOA3; - - if ( output_config == AUDIO_CONFIG_BINAURAL ) - { - *renderer_type = RENDERER_BINAURAL_FASTCONV; - } - else - { - *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; - } - - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) - { - - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); - if ( nchan_internal == 2 ) - { - st_ivas->hHeadTrackData->shd_rot_max_order = 1; - } - else if ( nchan_internal == 4 || nchan_internal == 3 ) - { - st_ivas->hHeadTrackData->shd_rot_max_order = 0; - } - else if ( nchan_internal == 6 || nchan_internal == 5 ) - { - st_ivas->hHeadTrackData->shd_rot_max_order = 2; - } - else if ( nchan_internal == 8 || nchan_internal == 7 ) - { - st_ivas->hHeadTrackData->shd_rot_max_order = 3; - } - } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - if ( st_ivas->mc_mode == MC_MODE_MCMASA ) - { - *internal_config = output_config; - if ( output_config == AUDIO_CONFIG_BINAURAL ) - { - *renderer_type = RENDERER_BINAURAL_PARAMETRIC; - } - else - { - *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; - } - } - else - { - *internal_config = transport_config; - if ( output_config == AUDIO_CONFIG_BINAURAL ) - { -#ifdef DEBUGGING - if ( ( ( ( st_ivas->transport_config == AUDIO_CONFIG_5_1 || st_ivas->transport_config == AUDIO_CONFIG_7_1 ) && st_ivas->hDecoderConfig->Opt_Headrotation ) || ( st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) ) && ( st_ivas->mc_mode == MC_MODE_MCT ) && !( st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER ) ) -#else - if ( ( st_ivas->transport_config == AUDIO_CONFIG_5_1 || st_ivas->transport_config == AUDIO_CONFIG_7_1 ) && st_ivas->hDecoderConfig->Opt_Headrotation && ( st_ivas->mc_mode == MC_MODE_MCT ) ) -#endif - { - *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; - } - else - { - if ( st_ivas->mc_mode == MC_MODE_MCT ) - { - *renderer_type = RENDERER_BINAURAL_MIXER_CONV; - } - else - { - *renderer_type = RENDERER_BINAURAL_FASTCONV; - } - -#ifdef DEBUGGING - if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_CREND ) - { - *renderer_type = RENDERER_BINAURAL_MIXER_CONV; - } - else if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) - { - *renderer_type = RENDERER_BINAURAL_FASTCONV; - } -#endif - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) - { - /* force HOA3 domain for rotation*/ - *internal_config = AUDIO_CONFIG_HOA3; - } - } - } - else /* AUDIO_CONFIG_BINAURAL_ROOM */ - { - if ( st_ivas->mc_mode == MC_MODE_MCT ) - { - *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; - } - else - { - *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; - } -#ifdef DEBUGGING - if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_CREND ) - { - *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; - } - else if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) - { - *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; - } -#endif - } - } - } - } - - /*-----------------------------------------------------------------* - * Non-binaural rendering configurations - *-----------------------------------------------------------------*/ - - else if ( st_ivas->ivas_format == STEREO_FORMAT ) - { - if ( output_config != AUDIO_CONFIG_STEREO && output_config != AUDIO_CONFIG_MONO ) - { - *renderer_type = RENDERER_MC; - } - } - else if ( st_ivas->ivas_format == ISM_FORMAT ) - { - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) - { - *renderer_type = RENDERER_PARAM_ISM; - if ( output_config == AUDIO_CONFIG_MONO ) - { - *renderer_type = RENDERER_MONO_DOWNMIX; - } - else if ( output_config == AUDIO_CONFIG_STEREO ) - { - *renderer_type = RENDERER_DISABLE; - } - else if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) - { - *renderer_type = RENDERER_SBA_LINEAR_ENC; - *internal_config = AUDIO_CONFIG_7_1_4; - } - } - else /* ISM_MODE_DISC */ - { - *renderer_type = RENDERER_TD_PANNING; - if ( output_config == AUDIO_CONFIG_MONO ) - { - *renderer_type = RENDERER_MONO_DOWNMIX; - } - else if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) - { - *renderer_type = RENDERER_SBA_LINEAR_ENC; - } - else if ( output_config == AUDIO_CONFIG_EXTERNAL ) - { - *renderer_type = RENDERER_DISABLE; - } - } - } - else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT ) - { - *renderer_type = RENDERER_DIRAC; - - if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR && - ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM ) ) - { - if ( output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_FOA ) - { - *internal_config = output_config; - } - else if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) - { - *internal_config = AUDIO_CONFIG_FOA; - } - else - { - *internal_config = AUDIO_CONFIG_HOA3; - } - st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC; - } - else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || - ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_STEREO && st_ivas->nchan_transport == 1 ) ) - { - *renderer_type = RENDERER_DISABLE; - } - else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 ) ) - { - *renderer_type = RENDERER_DISABLE; - } - else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_STEREO ) - { - *renderer_type = RENDERER_STEREO_PARAMETRIC; - } - else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) - { - *renderer_type = RENDERER_DISABLE; - } - else if ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_MONO ) - { - *renderer_type = RENDERER_SBA_LINEAR_DEC; - } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - *internal_config = transport_config; - if ( st_ivas->mc_mode == MC_MODE_MCT && *internal_config != output_config ) - { - if ( output_config != AUDIO_CONFIG_FOA && output_config != AUDIO_CONFIG_HOA2 && output_config != AUDIO_CONFIG_HOA3 ) - { - *renderer_type = RENDERER_MC; - } - else - { - *renderer_type = RENDERER_SBA_LINEAR_ENC; - } - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) - { - if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) - { - *renderer_type = RENDERER_SBA_LINEAR_ENC; - } - else - { - *renderer_type = RENDERER_MC_PARAMMC; - } - } - else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) - { - *internal_config = output_config; - /* No rendering for 1TC to Mono or Stereo and 2TC to Stereo */ - if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) - { - if ( st_ivas->nchan_transport == 1 ) - { - *renderer_type = RENDERER_DISABLE; - } - else if ( output_config == AUDIO_CONFIG_STEREO && st_ivas->nchan_transport == 2 && !st_ivas->hOutSetup.separateChannelEnabled ) - { - *renderer_type = RENDERER_DISABLE; - } - else - { - *renderer_type = RENDERER_MCMASA_MONO_STEREO; - } - } - else - { - *renderer_type = RENDERER_DIRAC; - if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) - { - *renderer_type = RENDERER_SBA_LINEAR_ENC; - *internal_config = transport_config; - } - else if ( transport_config == AUDIO_CONFIG_5_1 && ( output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_5_1_4 ) ) - { - *internal_config = transport_config; - } - } - } - } - - return; -} diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 6c533d4b16..a5a4606e92 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -30,9 +30,8 @@ *******************************************************************************************************/ -// VE2AT: rename this file to ivas_prot_rend.h to follow the logic with "ivas_stat_rend.h" ? -#ifndef IVAS_LIB_REND_INTERNALS_H -#define IVAS_LIB_REND_INTERNALS_H +#ifndef IVAS_PROT_REND_H +#define IVAS_PROT_REND_H #include #include "options.h" @@ -42,10 +41,9 @@ #else #include "lib_rend.h" #endif -//#include "ivas_stat_dec.h" -/* clang-format off */ +/* clang-format off */ /*----------------------------------------------------------------------------------* * General renderer declarations @@ -633,4 +631,4 @@ ivas_error ivas_orient_trk_GetTrackedOrientation( ); /* clang-format on */ -#endif +#endif /* IVAS_PROT_REND_H */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 1e06bc8696..634c260934 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -496,84 +496,6 @@ ivas_error getAudioConfigNumChannels( } -/*-------------------------------------------------------------------* - * getRendAudioConfigFromIvasAudioConfig() - * - * - *-------------------------------------------------------------------*/ - -#ifdef FIX_197_CREND_INTERFACE -IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( - const AUDIO_CONFIG config ) -#else -AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( - IVAS_REND_AudioConfig config ) -#endif -{ - switch ( config ) - { -#ifdef FIX_197_CREND_INTERFACE - case AUDIO_CONFIG_MONO: - return IVAS_REND_AUDIO_CONFIG_MONO; - case AUDIO_CONFIG_STEREO: - return IVAS_REND_AUDIO_CONFIG_STEREO; - case AUDIO_CONFIG_BINAURAL: - return IVAS_REND_AUDIO_CONFIG_BINAURAL; - case AUDIO_CONFIG_BINAURAL_ROOM: - return IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM; - case AUDIO_CONFIG_5_1: - return IVAS_REND_AUDIO_CONFIG_5_1; - case AUDIO_CONFIG_7_1: - return IVAS_REND_AUDIO_CONFIG_7_1; - case AUDIO_CONFIG_5_1_2: - return IVAS_REND_AUDIO_CONFIG_5_1_2; - case AUDIO_CONFIG_5_1_4: - return IVAS_REND_AUDIO_CONFIG_5_1_4; - case AUDIO_CONFIG_7_1_4: - return IVAS_REND_AUDIO_CONFIG_7_1_4; - case AUDIO_CONFIG_FOA: - return IVAS_REND_AUDIO_CONFIG_FOA; - case AUDIO_CONFIG_HOA2: - return IVAS_REND_AUDIO_CONFIG_HOA2; - case AUDIO_CONFIG_HOA3: - return IVAS_REND_AUDIO_CONFIG_HOA3; - default: - break; - } - return IVAS_REND_AUDIO_CONFIG_UNKNOWN; -#else - case IVAS_REND_AUDIO_CONFIG_MONO: - return AUDIO_CONFIG_MONO; - case IVAS_REND_AUDIO_CONFIG_STEREO: - return AUDIO_CONFIG_STEREO; - case IVAS_REND_AUDIO_CONFIG_BINAURAL: - return AUDIO_CONFIG_BINAURAL; - case IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM: - return AUDIO_CONFIG_BINAURAL_ROOM; - case IVAS_REND_AUDIO_CONFIG_5_1: - return AUDIO_CONFIG_5_1; - case IVAS_REND_AUDIO_CONFIG_7_1: - return AUDIO_CONFIG_7_1; - case IVAS_REND_AUDIO_CONFIG_5_1_2: - return AUDIO_CONFIG_5_1_2; - case IVAS_REND_AUDIO_CONFIG_5_1_4: - return AUDIO_CONFIG_5_1_4; - case IVAS_REND_AUDIO_CONFIG_7_1_4: - return AUDIO_CONFIG_7_1_4; - case IVAS_REND_AUDIO_CONFIG_FOA: - return AUDIO_CONFIG_FOA; - case IVAS_REND_AUDIO_CONFIG_HOA2: - return AUDIO_CONFIG_HOA2; - case IVAS_REND_AUDIO_CONFIG_HOA3: - return AUDIO_CONFIG_HOA3; - default: - break; - } - return AUDIO_CONFIG_INVALID; -#endif -} - - /*-------------------------------------------------------------------* * Local functions *-------------------------------------------------------------------*/ -- GitLab From 5d3161fea18ff066b7a8d0301a28d8f4f420530a Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Feb 2023 11:28:04 +0100 Subject: [PATCH 08/40] move functions to appropriate libraries --- Workspace_msvc/lib_dec.vcxproj | 5 +- Workspace_msvc/lib_dec.vcxproj.filters | 13 +- Workspace_msvc/lib_rend.vcxproj | 2 - lib_com/ivas_prot.h | 212 ++----- lib_dec/ivas_dirac_dec.c | 72 ++- {lib_rend => lib_dec}/ivas_hrtf.c | 81 ++- lib_dec/ivas_ism_renderer.c | 3 +- {lib_rend => lib_dec}/ivas_ls_custom_dec.c | 2 +- lib_dec/ivas_mc_param_dec.c | 3 +- lib_dec/ivas_mcmasa_dec.c | 1 + lib_dec/ivas_reverb_internal.c | 570 ------------------- lib_dec/ivas_sba_dec.c | 1 + lib_dec/ivas_sba_rendering_internal.c | 483 ++++++++++++++++ lib_rend/ivas_crend.c | 73 --- lib_rend/ivas_dirac_dec_binaural_functions.c | 1 + lib_rend/ivas_objectRenderer.c | 228 +------- lib_rend/ivas_prot_rend.h | 184 +++++- lib_rend/ivas_reverb.c | 527 +++++++++++++++++ lib_rend/ivas_rotation.c | 45 -- lib_rend/ivas_sba_rendering.c | 434 +------------- lib_rend/lib_rend.c | 5 +- 21 files changed, 1387 insertions(+), 1558 deletions(-) rename {lib_rend => lib_dec}/ivas_hrtf.c (77%) rename {lib_rend => lib_dec}/ivas_ls_custom_dec.c (98%) delete mode 100644 lib_dec/ivas_reverb_internal.c create mode 100644 lib_dec/ivas_sba_rendering_internal.c diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index cd454b8be8..59b00db3bf 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -276,12 +276,14 @@ + + @@ -290,6 +292,7 @@ + @@ -297,10 +300,10 @@ - + diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index 5ca5c16138..d6fc1dcbbf 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -503,10 +503,19 @@ dec_ivas_c - + dec_ivas_c - + + dec_ivas_c + + + dec_ivas_c + + + dec_ivas_c + + dec_ivas_c diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index b597ee8fcb..e7efa18f8a 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -202,9 +202,7 @@ - - diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 5eb77df64f..61d6afdda7 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3182,16 +3182,6 @@ void ivas_sba_getTCs( const int16_t input_frame /* i : frame length */ ); -// VE2AT: move to ivas_prot_rend.h ? -ivas_error ivas_sba_linear_renderer( - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nchan_in, /* i : number of input ambisonics channels */ - const AUDIO_CONFIG output_config, /* i : output audio configuration */ - const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */ - const float hoa_dec_mtx[] /* i : HOA decoding mtx */ -); - int16_t ivas_sba_remapTCs( float sba_data[][L_FRAME48k], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ @@ -3212,11 +3202,13 @@ void ivas_sba_dirac_stereo_smooth_parameters( STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: encoder DFT stereo handle */ ); -// VE2AT: move to ivas_prot_rend.h ? -ivas_error ivas_sba_get_hoa_dec_matrix( - const IVAS_OUTPUT_SETUP hOutSetup, /* i : target output setup */ - float **hoa_dec_mtx, /* o : ALLRAD decoder matrix */ - const int16_t ambisonics_order /* i : Ambisonics order */ +void ivas_sba2mc_cldfb( + IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */ + float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part */ + float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part */ + const int16_t nb_channels_out, /* i : nb of output channels */ + const int16_t nb_bands, /* i : nb of CLDFB bands to process */ + const float *hoa_dec_mtx /* i : HOA decoding mtx */ ); @@ -3307,61 +3299,6 @@ void ivas_dirac_dec( const int16_t i_sf ); -#ifdef HRTF_BINARY_FILE -ivas_error ivas_dirac_dec_init_binaural_data( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : HRTF structure for rendering */ -); -#else -ivas_error ivas_dirac_dec_init_binaural_data( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); -#endif - -void ivas_dirac_dec_close_binaural_data( - DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ -); - -#ifdef HRTF_BINARY_FILE -ivas_error ivas_dirac_dec_binaural_copy_hrtfs( - HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ -); -#endif -// VE2AT: move to lib_rend ? -void ivas_dirac_dec_binaural( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport /* i : number of transport channels */ -); - -ivas_error ivas_binaural_reverb_open( - REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ - const int16_t numBins, /* i : number of CLDFB bins */ - const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ - ivas_roomAcoustics_t *roomAcoustics, /* i/o: room acoustics parameters */ - const AUDIO_CONFIG output_config, /* i : output audio configuration */ - const int32_t sampling_rate, /* i : sampling rate */ - const RENDERER_TYPE renderer_type /* i : renderer type */ -#ifdef HRTF_BINARY_FILE - , - const HRTFS_FASTCONV_HANDLE hHrtfFastConv, /* i : FastConv HRTF handle */ - const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ -#endif -); - -void ivas_binaural_reverb_close( - REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ -); - -void ivas_binaural_reverb_processFrame( - REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ - const int16_t numInChannels, /* i : num input channels to be processed */ - float inReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real */ - float inImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ - float outReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ - float outImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data imag */ - const uint8_t offsetSamplesIO /* i : number of offset samples */ -); void computeDiffuseness_mdft( float **buffer_intensity[DIRAC_NUM_DIMS], @@ -3848,14 +3785,6 @@ void ivas_sba_mix_matrix_determiner( const int16_t output_frame /* i : output frame length */ ); -void ivas_sba_prototype_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ - const int16_t firstSubframe, /* i : First subframe to map */ - const int16_t nSubframes /* i : Number of subframes to map */ -); - /* AGC */ /*! r: AGC enable flag */ int16_t ivas_agc_enc_get_flag( @@ -4577,6 +4506,7 @@ void ivas_output_init( const AUDIO_CONFIG output_config /* i : output audio configuration */ ); +// VE2AT: this fucntion is used in lib_rend at one place - the fucntion ivas_rend_initEfap() is however not used; wh // VE2AT: rename it IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( AUDIO_CONFIG config @@ -4617,45 +4547,9 @@ void ivas_binaural_add_LFE( ); #ifdef HRTF_BINARY_FILE -ivas_error ivas_HRTF_fastconv_binary_open( - HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ -); - -void ivas_HRTF_fastconv_binary_close( - HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ -); - -ivas_error ivas_HRTF_parambin_binary_open( - HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ -); -void ivas_HRTF_parambin_binary_close( - HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ -); #endif -// VE2AT: move to ivas_prot_rend.h ?? -void QuatToRotMat( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ -); - -void rotateAziEle( - float azi_in, /* i : output elevation */ - float ele_in, /* i : input elevation */ - int16_t *azi, /* o : rotated azimuth */ - int16_t *ele, /* o : rotated elevation */ - float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t isPlanar /* i : is roation planar and elevation meaningless? */ -); - -void rotateAziEle_DirAC( - int16_t *azi, /* i/o: array of azimuth values */ - int16_t *ele, /* i/o: array of elevation values */ - const int16_t band1, /* i : bands to work on (lower limit) */ - const int16_t band2, /* i : bands to work on (upper bound) */ - const float *p_Rmat /* i : pointer to real-space rotation matrix */ -); ivas_error ivas_headTrack_open( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ @@ -5007,21 +4901,10 @@ void ivas_filter_process( * TD Binaural Object renderer *----------------------------------------------------------------------------------*/ -ivas_error ivas_HRTF_binary_open( - TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ -); - -void ivas_HRTF_binary_close( - TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ -); - ivas_error ivas_td_binaural_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -void ivas_td_binaural_close( - BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */ -); void ObjRenderIVASFrame( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -5030,10 +4913,7 @@ void ObjRenderIVASFrame( ); -void BSplineModelEvalDealloc( - ModelParams_t *model, /* i : Model parameters */ - ModelEval_t *modelEval /* i : Model evaluation structure */ -); + /*----------------------------------------------------------------------------------* @@ -5111,10 +4991,35 @@ int16_t ivas_get_num_bands_from_bw_idx( ); + /*----------------------------------------------------------------------------------* - * Crend renderer + * HRTF *----------------------------------------------------------------------------------*/ +ivas_error ivas_HRTF_binary_open( + TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ +); + +void ivas_HRTF_binary_close( + TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ +); + +ivas_error ivas_HRTF_fastconv_binary_open( + HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ +); + +void ivas_HRTF_fastconv_binary_close( + HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ +); + +ivas_error ivas_HRTF_parambin_binary_open( + HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ +); + +void ivas_HRTF_parambin_binary_close( + HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ +); + #ifdef HRTF_BINARY_FILE ivas_error ivas_HRTF_CRend_binary_open( @@ -5163,55 +5068,8 @@ ivas_error ivas_crend_process( #else -ivas_error ivas_rend_openCrend( - CREND_WRAPPER_HANDLE *pCrend, - const IVAS_REND_AudioConfig inConfig, - const IVAS_REND_AudioConfig outConfig, - RENDER_CONFIG_DATA *hRendCfg, - int16_t Opt_Headrotation, -#ifdef HRTF_BINARY_FILE - HRTFS_CREND_HANDLE hSetOfHRTF, -#endif - const int32_t output_Fs -); - -#ifdef FIX_197_CREND_INTERFACE -void ivas_rend_closeCrend( -#else -ivas_error ivas_rend_closeCrend( -#endif - CREND_WRAPPER_HANDLE *pCrend ); - -ivas_error ivas_rend_crendProcess( - const CREND_WRAPPER *pCrend, - const IVAS_REND_AudioConfig inConfig, - const IVAS_REND_AudioConfig outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - float output[][L_FRAME48k], /* i/o: input/output audio channels */ - const int32_t output_Fs -); #endif -/*----------------------------------------------------------------------------------* - * Renderer configuration - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_render_config_open( - RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ -); - -void ivas_render_config_close( - RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ -); - -ivas_error ivas_render_config_init_from_rom( - RENDER_CONFIG_HANDLE *hRenderConfig, /* i/o: Renderer config handle */ - const int16_t room_flag_on /* i : room effect on/off flag */ -); - /* clang-format on */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 557af7a497..f3090415ae 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -37,6 +37,7 @@ #include "cnst.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" @@ -49,33 +50,16 @@ /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ + static void ivas_dirac_alloc_mem( DIRAC_DEC_HANDLE hDirAC, const RENDERER_TYPE renderer_type, DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem ); static void ivas_dirac_free_mem( DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem ); -static void initDiffuseResponses( - float *diffuse_response_function, - const int16_t num_channels, - AUDIO_CONFIG output_config, - IVAS_OUTPUT_SETUP hOutSetup, - const int16_t ambisonics_order, - const IVAS_FORMAT ivas_format, - int16_t *num_ele_spk_no_diffuse_rendering, - AUDIO_CONFIG transport_config ); +static void initDiffuseResponses( float *diffuse_response_function, const int16_t num_channels, AUDIO_CONFIG output_config, IVAS_OUTPUT_SETUP hOutSetup, const int16_t ambisonics_order, const IVAS_FORMAT ivas_format, int16_t *num_ele_spk_no_diffuse_rendering, AUDIO_CONFIG transport_config ); static void computeIntensityVector_dec( float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], const int16_t num_frequency_bands, float *intensity_real_x, float *intensity_real_y, float *intensity_real_z ); -static void protoSignalComputation_shd( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float *proto_direct_buffer_f, - float *proto_diffuse_buffer_f, - float *reference_power, - const int16_t slot_index, - const int16_t num_inputs, - const int16_t num_outputs_diff, - const int16_t num_freq_bands, - float *p_Rmat ); +static void protoSignalComputation_shd( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float *proto_direct_buffer_f, float *proto_diffuse_buffer_f, float *reference_power, const int16_t slot_index, const int16_t num_inputs, const int16_t num_outputs_diff, const int16_t num_freq_bands, float *p_Rmat ); static void protoSignalComputation1( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float *proto_frame_f, float *proto_direct_buffer_f, float *reference_power, float *proto_power_smooth, const int16_t slot_index, const int16_t num_outputs_diff, const int16_t num_freq_bands ); @@ -85,7 +69,6 @@ static void protoSignalComputation4( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRA static void ivas_dirac_dec_compute_diffuse_proto( DIRAC_DEC_HANDLE hDirAC, const int16_t slot_idx ); - static void computeDirectionAngles( float *intensity_real_x, float *intensity_real_y, float *intensity_real_z, const int16_t num_frequency_bands, int16_t *azimuth, int16_t *elevation ); static void ivas_masa_init_stereotype_detection( MASA_STEREO_TYPE_DETECT *stereo_type_detect ); @@ -94,6 +77,8 @@ static void ivas_masa_stereotype_detection( MASA_STEREO_TYPE_DETECT *stereo_type static void ivas_lfe_synth_with_cldfb( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float RealBufferLfe[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBufferLfe[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], const int16_t slot_index, const int16_t subframe_index, const int16_t nchan_transport ); +static void rotateAziEle_DirAC( int16_t *azi, int16_t *ele, const int16_t band1, const int16_t band2, const float *p_Rmat ); + /*------------------------------------------------------------------------- * ivas_dirac_dec_open() @@ -3617,3 +3602,48 @@ static void ivas_lfe_synth_with_cldfb( return; } + + +/*------------------------------------------------------------------------- + * rotateAziEle_DirAC() + * + * Apply rotation to DirAC DOAs + *------------------------------------------------------------------------*/ + +static void rotateAziEle_DirAC( + int16_t *azi, /* i/o: array of azimuth values */ + int16_t *ele, /* i/o: array of elevation values */ + const int16_t band1, /* i : bands to work on (lower limit) */ + const int16_t band2, /* i : bands to work on (upper bound) */ + const float *p_Rmat /* i : pointer to real-space rotation matrix */ +) +{ + int16_t b; + float dv_0, dv_1, dv_2; + float dv_r_0, dv_r_1, dv_r_2; + float w; + + push_wmops( "rotateAziEle_DirAC" ); + + for ( b = band1; b < band2; b++ ) + { + + /*Conversion spherical to cartesian coordinates*/ + w = cosf( ele[b] * PI_OVER_180 ); + dv_0 = w * cosf( azi[b] * PI_OVER_180 ); + dv_1 = w * sinf( azi[b] * PI_OVER_180 ); + dv_2 = sinf( ele[b] * PI_OVER_180 ); + + dv_r_0 = p_Rmat[0] * dv_0 + p_Rmat[1] * dv_1 + p_Rmat[2] * dv_2; + dv_r_1 = p_Rmat[3] * dv_0 + p_Rmat[4] * dv_1 + p_Rmat[5] * dv_2; + dv_r_2 = p_Rmat[6] * dv_0 + p_Rmat[7] * dv_1 + p_Rmat[8] * dv_2; + + /*Conversion spherical to cartesian coordinates*/ + azi[b] = (int16_t) ( atan2f( dv_r_1, dv_r_0 ) * _180_OVER_PI ); + ele[b] = (int16_t) ( atan2f( dv_r_2, sqrtf( dv_r_0 * dv_r_0 + dv_r_1 * dv_r_1 ) ) * _180_OVER_PI ); + } + + pop_wmops(); + + return; +} diff --git a/lib_rend/ivas_hrtf.c b/lib_dec/ivas_hrtf.c similarity index 77% rename from lib_rend/ivas_hrtf.c rename to lib_dec/ivas_hrtf.c index 5e6c63f17c..338de7e14b 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_dec/ivas_hrtf.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ - +//VE2AT: this file functions are called from lib_dec only; is it expected? #include #include "options.h" #include "prot.h" @@ -103,6 +103,7 @@ ivas_error ivas_HRTF_CRend_binary_open( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * ivas_HRTF_CRend_binary_close() * @@ -126,6 +127,84 @@ void ivas_HRTF_CRend_binary_close( } #endif + +/*---------------------------------------------------------------------* + * destroy_HRTF() + * + * Destroy the HRTF CRend handle + *---------------------------------------------------------------------*/ + +static ivas_error destroy_HRTF( + HRTFS_HANDLE *hHRTF /* i/o: HRTF CRend handle */ +) +{ + uint16_t i, j; + + if ( *hHRTF != NULL && hHRTF != NULL ) + { + for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + { + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL ) + { + 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] ); + } + } + } + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL ) + { + 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] ); + } + } + + free( *hHRTF ); + *hHRTF = NULL; + } + + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * destroy_SetOfHRTF() + * + * Destroy the HRTF data set. + *---------------------------------------------------------------------*/ + +ivas_error destroy_SetOfHRTF( + HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ +) +{ + if ( hSetOfHRTF != NULL ) + { + destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_combined ) ); + destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_hoa3 ) ); + destroy_HRTF( &( hSetOfHRTF->hHRTF_brir_combined ) ); + } + + return IVAS_ERR_OK; +} + + #ifdef HRTF_BINARY_FILE /*-----------------------------------------------------------------------* * ivas_HRTF_fastconv_binary_open() diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 39e4cffba5..00052f1667 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -33,8 +33,9 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot.h" +#include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_rend/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c similarity index 98% rename from lib_rend/ivas_ls_custom_dec.c rename to lib_dec/ivas_ls_custom_dec.c index 286798f878..16d8ae286b 100644 --- a/lib_rend/ivas_ls_custom_dec.c +++ b/lib_dec/ivas_ls_custom_dec.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: move this file to lib_dec +// VE2AT: this file functions are called from lib_dec only; is it expected? #include #include "options.h" #include "ivas_prot.h" diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 41ba3e53c7..541fa3b7c6 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1547,8 +1547,7 @@ void ivas_param_mc_dec( if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { - ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hHeadTrackData, - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hHeadTrackData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); } else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) { diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index 3af2ea2c3b..50fcf3a2bd 100644 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -34,6 +34,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. #include #include "ivas_cnst.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "prot.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_dec/ivas_reverb_internal.c b/lib_dec/ivas_reverb_internal.c deleted file mode 100644 index 4b3968d9ad..0000000000 --- a/lib_dec/ivas_reverb_internal.c +++ /dev/null @@ -1,570 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include "options.h" -#include -#include "prot.h" -//#include "ivas_prot.h" -#include "ivas_prot_rend.h" -//#include "ivas_rom_com.h" -//#include "ivas_rom_binauralRenderer.h" -#ifdef DEBUGGING -#include "debug.h" -#endif -#include "wmc_auto.h" - - -/* The reverberator structure implemented here is described in detail in: - * Vilkamo, J., Neugebauer, B., & Plogsties, J. (2012). Sparse frequency-domain reverberator. - * Journal of the Audio Engineering Society, 59(12), 936-943. */ - -/*------------------------------------------------------------------------- - * Local constants - *------------------------------------------------------------------------*/ - -#define BIN_REND_RANDOM_SEED 1 /* random seed for generating reverb decorrelators */ - -#define CLDFB_SLOTS_PER_SECOND 800 /* Used for initializing reverb */ - -/*------------------------------------------------------------------------- - * ivas_binaural_reverb_processFrame() - * - * Compute the reverberation - room effect - *------------------------------------------------------------------------*/ - -void ivas_binaural_reverb_processFrame( - REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ - const int16_t numInChannels, /* i : num inputs to be processed */ - float inReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real, Comment: This change swaps two first dimensions as first dimension is not constant. */ - float inImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ - float outReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ - float outImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data imag */ - const uint8_t offsetSamplesIO /* i : number of offset samples */ -) -{ - /* Declare the required variables */ - int16_t idx, bin, ch, sample, invertSampleIndex, tapIdx, *phaseShiftTypePr; - float **tapRealPr, **tapImagPr; - - /* 1) Rotate the data in the loop buffer of the reverberator. - * Notice that the audio at the loop buffers is at time-inverted order - * for convolution purposes later on. */ - for ( bin = 0; bin < hReverb->numBins; bin++ ) - { - /* Move the data forwards by blockSize (i.e. by the frame size of 16 CLDFB slots) */ - mvr2r( hReverb->loopBufReal[bin], hReverb->loopBufReal[bin] + hReverb->blockSize, hReverb->loopBufLength[bin] ); - mvr2r( hReverb->loopBufImag[bin], hReverb->loopBufImag[bin] + hReverb->blockSize, hReverb->loopBufLength[bin] ); - - /* Add the data from the end of the loop to the beginning, with an attenuation factor - * according to RT60. This procedure generates an IIR decaying response. The response - * is decorrelated later on. */ - v_multc( hReverb->loopBufReal[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor[bin], hReverb->loopBufReal[bin], hReverb->blockSize ); - v_multc( hReverb->loopBufImag[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor[bin], hReverb->loopBufImag[bin], hReverb->blockSize ); - } - - /* 2) Apply the determined pre-delay to the input audio, and add the delayed audio to the loop. */ - idx = hReverb->preDelayBufferIndex; - for ( sample = 0; sample < hReverb->blockSize; sample++ ) - { - uint16_t sampleWithOffset; - sampleWithOffset = sample + offsetSamplesIO; - invertSampleIndex = hReverb->blockSize - sample - 1; - for ( bin = 0; bin < hReverb->numBins; bin++ ) - { - /* Add from pre-delay buffer a sample to the loop buffer, in a time-inverted order. - * Also apply the spectral gains determined for the reverberation */ - hReverb->loopBufReal[bin][invertSampleIndex] += hReverb->preDelayBufferReal[idx][bin] * hReverb->reverbEqGains[bin]; - hReverb->loopBufImag[bin][invertSampleIndex] += hReverb->preDelayBufferImag[idx][bin] * hReverb->reverbEqGains[bin]; - hReverb->preDelayBufferReal[idx][bin] = 0.0f; - hReverb->preDelayBufferImag[idx][bin] = 0.0f; - } - - /* Add every second input channel as is to the pre-delay buffer, and every second input channel with - * 90 degrees phase shift to reduce energy imbalances between coherent and incoherent sounds */ - for ( ch = 0; ch < numInChannels; ch++ ) - { - if ( ch % 2 ) - { - v_add( hReverb->preDelayBufferReal[idx], inReal[ch][sampleWithOffset], hReverb->preDelayBufferReal[idx], hReverb->numBins ); - v_add( hReverb->preDelayBufferImag[idx], inImag[ch][sampleWithOffset], hReverb->preDelayBufferImag[idx], hReverb->numBins ); - } - else - { - v_sub( hReverb->preDelayBufferReal[idx], inImag[ch][sampleWithOffset], hReverb->preDelayBufferReal[idx], hReverb->numBins ); - v_add( hReverb->preDelayBufferImag[idx], inReal[ch][sampleWithOffset], hReverb->preDelayBufferImag[idx], hReverb->numBins ); - } - } - idx = ( idx + 1 ) % hReverb->preDelayBufferLength; - } - hReverb->preDelayBufferIndex = idx; - - /* 3) Perform the filtering/decorrelating, using complex and sparse FIR filtering */ - for ( bin = 0; bin < hReverb->numBins; bin++ ) - { - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - /* These tap pointers have been determined to point to the loop buffer at sparse locations */ - tapRealPr = hReverb->tapPointersReal[bin][ch]; - tapImagPr = hReverb->tapPointersImag[bin][ch]; - phaseShiftTypePr = hReverb->tapPhaseShiftType[bin][ch]; - - /* Flush output */ - set_f( hReverb->outputBufferReal[bin][ch], 0.0f, hReverb->blockSize ); - set_f( hReverb->outputBufferImag[bin][ch], 0.0f, hReverb->blockSize ); - - /* Add from temporally decaying sparse tap locations the audio to the output. */ - for ( tapIdx = 0; tapIdx < hReverb->taps[bin][ch]; tapIdx++ ) - { - switch ( phaseShiftTypePr[tapIdx] ) - { - case 0: /* 0 degrees phase */ - v_add( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); - v_add( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); - break; - case 1: /* 90 degrees phase */ - v_sub( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); - v_add( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); - break; - case 2: /* 180 degrees phase */ - v_sub( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); - v_sub( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); - break; - default: /* 270 degrees phase */ - v_add( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); - v_sub( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); - break; - } - } - } - - /* Generate diffuse field binaural coherence by mixing the incoherent reverberated channels with pre-defined gains */ - if ( bin <= hReverb->highestBinauralCoherenceBin ) - { - if ( hReverb->useBinauralCoherence ) - { - for ( sample = 0; sample < hReverb->blockSize; sample++ ) - { - float leftRe, rightRe, leftIm, rightIm; - - leftRe = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferReal[bin][0][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferReal[bin][1][sample]; - rightRe = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferReal[bin][1][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferReal[bin][0][sample]; - leftIm = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferImag[bin][0][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferImag[bin][1][sample]; - rightIm = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferImag[bin][1][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferImag[bin][0][sample]; - - hReverb->outputBufferReal[bin][0][sample] = leftRe; - hReverb->outputBufferReal[bin][1][sample] = rightRe; - hReverb->outputBufferImag[bin][0][sample] = leftIm; - hReverb->outputBufferImag[bin][1][sample] = rightIm; - } - } - } - } - - /* 4) Write data to output */ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - for ( sample = 0; sample < hReverb->blockSize; sample++ ) - { - uint16_t sampleWithOffset; - - sampleWithOffset = sample + offsetSamplesIO; - /* Audio was in the temporally inverted order for convolution, re-invert audio to output */ - invertSampleIndex = hReverb->blockSize - sample - 1; - - for ( bin = 0; bin < hReverb->numBins; bin++ ) - { - outReal[ch][sampleWithOffset][bin] = hReverb->outputBufferReal[bin][ch][invertSampleIndex]; - outImag[ch][sampleWithOffset][bin] = hReverb->outputBufferImag[bin][ch][invertSampleIndex]; - } - for ( ; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) - { - outReal[ch][sampleWithOffset][bin] = 0.0f; - outImag[ch][sampleWithOffset][bin] = 0.0f; - } - } - } - - return; -} - - -/*------------------------------------------------------------------------- - * binRend_rand() - * - * - *------------------------------------------------------------------------*/ - -static uint16_t binRend_rand( - REVERB_STRUCT_HANDLE hReverb /* i/o: binaural reverb handle */ -) -{ - hReverb->binRend_RandNext = hReverb->binRend_RandNext * 1103515245 + 12345; - - return (uint16_t) ( hReverb->binRend_RandNext / 65536 ) % 32768; -} - - -/*------------------------------------------------------------------------- - * ivas_binaural_reverb_setPreDelay() - * - * - *------------------------------------------------------------------------*/ - -static void ivas_binaural_reverb_setPreDelay( - REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ - const int16_t delaySamples /* i : reverb pre-delay in CLDFB slots */ -) -{ - if ( delaySamples < 1 ) - { - hReverb->preDelayBufferLength = 1; - - return; - } - - if ( delaySamples > REVERB_PREDELAY_MAX ) - { - hReverb->preDelayBufferLength = REVERB_PREDELAY_MAX; - - return; - } - - hReverb->preDelayBufferLength = delaySamples; - - return; -} - - -/*------------------------------------------------------------------------- - * ivas_binaural_reverb_setReverbTimes() - * - * - *------------------------------------------------------------------------*/ - -static void ivas_binaural_reverb_setReverbTimes( - REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ - const int32_t output_Fs, /* i : sampling_rate */ - const float *revTimes, /* i : reverberation times T60 for each CLDFB bin in seconds */ - const float *revEnes /* i : spectrum for reverberated sound at each CLDFB bin */ -) -{ - int16_t bin, ch, tap, sample; - float binCenterFreq, diffuseFieldICC, tmpVal, attenuationFactorPerSample; - float intendedEnergy, actualizedEnergy, energyBuildup, currentEnergy, attenuationFactorPerSampleSq; - - hReverb->binRend_RandNext = (uint16_t) BIN_REND_RANDOM_SEED; - hReverb->highestBinauralCoherenceBin = 0; - for ( bin = 0; bin < hReverb->numBins; bin++ ) - { - /* Determine the diffuse field binaural coherence */ - binCenterFreq = ( (float) bin + 0.5f ) / ( (float) hReverb->numBins ) * ( (float) output_Fs ) / 2.0f; - if ( bin == 0 ) - { - diffuseFieldICC = 1.0f; - } - else if ( binCenterFreq < 2700.0f ) - { - diffuseFieldICC = sinf( EVS_PI * binCenterFreq / 550.0f + 1e-20f ) / ( EVS_PI * binCenterFreq / 550.0f + 1e-20f ) * ( 1.0f - binCenterFreq / 2700.0f ); - hReverb->highestBinauralCoherenceBin = bin; - } - else - { - diffuseFieldICC = 0.0f; - } - - /* Mixing gains to generate a diffuse-binaural sound based on incoherent sound */ - tmpVal = ( 1.0f - sqrtf( 1.0f - powf( diffuseFieldICC, 2.0 ) ) ) / 2.0f; - if ( diffuseFieldICC > 0 ) - { - hReverb->binauralCoherenceCrossmixGains[bin] = sqrtf( fabsf( tmpVal ) ); - } - else - { - hReverb->binauralCoherenceCrossmixGains[bin] = -sqrtf( fabsf( tmpVal ) ); - } - hReverb->binauralCoherenceDirectGains[bin] = sqrtf( 1.0f - fabsf( tmpVal ) ); - - /* Determine attenuation factor that generates the appropriate energy decay according to reverberation time */ - attenuationFactorPerSample = powf( 10.0f, -3.0f * ( 1.0f / ( (float) CLDFB_SLOTS_PER_SECOND * revTimes[bin] ) ) ); - hReverb->loopAttenuationFactor[bin] = powf( attenuationFactorPerSample, hReverb->loopBufLength[bin] ); - attenuationFactorPerSampleSq = attenuationFactorPerSample * attenuationFactorPerSample; - - /* Design sparse decorrelation filters. The decorrelation filters, due to random procedures involved, - * may affect the spectrum of the output. The spectral effect is therefore monitored and compensated for. */ - intendedEnergy = 0.0f; - actualizedEnergy = 0.0f; - - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - energyBuildup = 0.0f; - currentEnergy = 1.0f; - tap = 0; - - for ( sample = 0; sample < hReverb->loopBufLength[bin]; sample++ ) - { - intendedEnergy += currentEnergy; - - /* The randomization at the energy build up affects where the sparse taps are located */ - energyBuildup += currentEnergy + 0.1f * ( (float) binRend_rand( hReverb ) / PCM16_TO_FLT_FAC - 0.5f ); - - if ( energyBuildup >= 1.0f ) /* A new filter tap is added at this condition */ - { - /* Four efficient phase operations: n*pi/2, n=0,1,2,3 */ - hReverb->tapPhaseShiftType[bin][ch][tap] = (int16_t) ( binRend_rand( hReverb ) % 4 ); - /* Set the tapPointer to point to the determined sample at the loop buffer */ - hReverb->tapPointersReal[bin][ch][tap] = &( hReverb->loopBufReal[bin][sample] ); - hReverb->tapPointersImag[bin][ch][tap] = &( hReverb->loopBufImag[bin][sample] ); - energyBuildup -= 1.0f; /* A tap is added, thus remove its energy from the buildup */ - tap++; - actualizedEnergy += 1.0f; - } - currentEnergy *= attenuationFactorPerSampleSq; - } - hReverb->taps[bin][ch] = tap; /* Number of taps determined at the above random procedure */ - } - - /* The decorrelator design and IIR attenuation rate affects the energy of reverb, which is compensated here */ - hReverb->reverbEqGains[bin] = sqrtf( revEnes[bin] ); /* Determined reverb spectrum */ - hReverb->reverbEqGains[bin] *= sqrtf( intendedEnergy / actualizedEnergy ); /* Correction of random effects at the decorrelator design */ - hReverb->reverbEqGains[bin] *= sqrtf( 0.5f * ( 1.0f - attenuationFactorPerSampleSq ) ); /* Correction of IIR decay rate */ - } - - return; -} - - -/*------------------------------------------------------------------------- - * ivas_binaural_reverb_open() - * - * Allocate and initialize binaural room reverberator handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_binaural_reverb_open( - REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ - const int16_t numBins, /* i : number of CLDFB bins */ - const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ - ivas_roomAcoustics_t *roomAcoustics, /* i/o: room acoustics parameters */ - const AUDIO_CONFIG output_config, /* i : output audio configuration */ - const int32_t sampling_rate, /* i : sampling rate */ - const RENDERER_TYPE renderer_type /* i : renderer type */ -#ifdef HRTF_BINARY_FILE - , - const HRTFS_FASTCONV_HANDLE hHrtfFastConv, /* i : FastConv HRTF handle */ - const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ -#endif -) -{ - int16_t bin, chIdx, k, len; - REVERB_STRUCT_HANDLE hReverb; - const float *revTimes; - float t60[CLDFB_NO_CHANNELS_MAX]; - float ene[CLDFB_NO_CHANNELS_MAX]; - - if ( ( *hReverbPr = (REVERB_STRUCT_HANDLE) malloc( sizeof( REVERB_STRUCT ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); - } - - hReverb = *hReverbPr; - - hReverb->useBinauralCoherence = 1; - hReverb->preDelayBufferLength = 1; - hReverb->preDelayBufferIndex = 0; - - hReverb->numBins = numBins; - hReverb->blockSize = numCldfbSlotsPerFrame; - - for ( k = 0; k < REVERB_PREDELAY_MAX + 1; k++ ) - { - set_f( hReverb->preDelayBufferReal[k], 0.0f, hReverb->numBins ); - set_f( hReverb->preDelayBufferImag[k], 0.0f, hReverb->numBins ); - } - - if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) - { - if ( !roomAcoustics->override ) - { -#ifdef HRTF_BINARY_FILE - revTimes = hHrtfFastConv->fastconvReverberationTimes; -#else - revTimes = fastconvReverberationTimes; -#endif - } - else - { - revTimes = t60; - } - } - else - { -#ifdef HRTF_BINARY_FILE - revTimes = hHrtfParambin->parametricReverberationTimes; -#else - revTimes = parametricReverberationTimes; -#endif - } - - for ( bin = 0; bin < hReverb->numBins; bin++ ) - { - /* Loop Buffer */ - hReverb->loopBufLengthMax[bin] = (int16_t) ( 500 / ( 1 + bin ) + ( CLDFB_NO_CHANNELS_MAX - bin ) ); - - len = hReverb->loopBufLengthMax[bin] + hReverb->blockSize; - if ( ( hReverb->loopBufReal[bin] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); - } - - if ( ( hReverb->loopBufImag[bin] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); - } - - set_f( hReverb->loopBufReal[bin], 0.0f, len ); - set_f( hReverb->loopBufImag[bin], 0.0f, len ); - - /* Determine loop buffer length. The following formula is manually tuned to generate sufficiently long - * but not excessively long loops to generate reverberation. */ - /* Note: the resulted length is very sensitive to the precision of the constants below (e.g. 1.45 vs. 1.45f) */ - hReverb->loopBufLength[bin] = (int16_t) ( 1.45 * (int16_t) ( revTimes[bin] * 150.0 ) + 1 ); - hReverb->loopBufLength[bin] = min( hReverb->loopBufLength[bin], hReverb->loopBufLengthMax[bin] ); - - /* Sparse Filter Tap Locations */ - for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - len = hReverb->loopBufLength[bin]; - - if ( ( hReverb->tapPhaseShiftType[bin][chIdx] = (int16_t *) malloc( len * sizeof( int16_t ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); - } - set_s( hReverb->tapPhaseShiftType[bin][chIdx], 0, len ); - - if ( ( hReverb->tapPointersReal[bin][chIdx] = (float **) malloc( len * sizeof( float * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); - } - - if ( ( hReverb->tapPointersImag[bin][chIdx] = (float **) malloc( len * sizeof( float * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); - } - - len = hReverb->blockSize; - if ( ( hReverb->outputBufferReal[bin][chIdx] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); - } - - if ( ( hReverb->outputBufferImag[bin][chIdx] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); - } - - set_f( hReverb->outputBufferReal[bin][chIdx], 0.0f, len ); - set_f( hReverb->outputBufferImag[bin][chIdx], 0.0f, len ); - } - } - - if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) - { - if ( !roomAcoustics->override ) - { -#ifdef HRTF_BINARY_FILE - ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, hHrtfFastConv->fastconvReverberationTimes, hHrtfFastConv->fastconvReverberationEneCorrections ); -#else - ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, fastconvReverberationTimes, fastconvReverberationEneCorrections ); -#endif - ivas_binaural_reverb_setPreDelay( hReverb, 10 ); - } - else - { -#ifdef HRTF_BINARY_FILE - ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfFastConv, output_config, roomAcoustics->use_brir, sampling_rate, t60, ene ); -#else - ivas_reverb_prepare_cldfb_params( roomAcoustics, output_config, roomAcoustics->use_brir, sampling_rate, t60, ene ); -#endif - ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, t60, ene ); - ivas_binaural_reverb_setPreDelay( hReverb, (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ) ); - } - } - else - { -#ifdef HRTF_BINARY_FILE - ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections ); -#else - ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, parametricReverberationTimes, parametricReverberationEneCorrections ); -#endif - ivas_binaural_reverb_setPreDelay( hReverb, 10 ); - } - - return IVAS_ERR_OK; -} - - -/*------------------------------------------------------------------------- - * ivas_binaural_reverb_close() - * - * Close binaural room reverberator handle - *------------------------------------------------------------------------*/ - -void ivas_binaural_reverb_close( - REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ -) -{ - int16_t bin, chIdx; - - if ( hReverb == NULL || *hReverb == NULL ) - { - return; - } - - for ( bin = 0; bin < ( *hReverb )->numBins; bin++ ) - { - for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - free( ( *hReverb )->tapPhaseShiftType[bin][chIdx] ); - free( ( *hReverb )->tapPointersReal[bin][chIdx] ); - free( ( *hReverb )->tapPointersImag[bin][chIdx] ); - free( ( *hReverb )->outputBufferReal[bin][chIdx] ); - free( ( *hReverb )->outputBufferImag[bin][chIdx] ); - } - free( ( *hReverb )->loopBufReal[bin] ); - free( ( *hReverb )->loopBufImag[bin] ); - } - - free( ( *hReverb ) ); - ( *hReverb ) = NULL; - - return; -} diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index fbdc4f5857..62b933ffc7 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -37,6 +37,7 @@ #include "ivas_cnst.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #ifdef SBA_BR_SWITCHING #include "ivas_rom_com.h" #endif diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c new file mode 100644 index 0000000000..9130036f0c --- /dev/null +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -0,0 +1,483 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "prot.h" +#include "ivas_prot.h" +#include "ivas_prot_rend.h" +#include "ivas_stat_dec.h" +#include "ivas_cnst.h" +#include +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + + +#ifdef DEBUG_MODE_DIRAC +/*-----------------------------------------------------------------------* + * Local function prototypes + *-----------------------------------------------------------------------*/ + +static void debug_mode_dirac( float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], const int16_t nchan_transport, const int16_t output_frame ); +#endif + + +/*-------------------------------------------------------------------------* + * ivas_sba2MC_cldfb() + * + * SBA signals transformed into MC in CLDFB domain + *-------------------------------------------------------------------------*/ + +void ivas_sba2mc_cldfb( + IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */ + float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part */ + float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part */ + const int16_t nb_channels_out, /* i : nb of output channels */ + const int16_t nb_bands, /* i : nb of CLDFB bands to process */ + const float *hoa_dec_mtx /* i : HOA decoding mtx */ +) +{ + int16_t iBlock, iBand, n, m; + float realOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX], imagOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX]; + float g; + float *p_real, *p_imag, *p_realOut, *p_imagOut; + int16_t nb_channels_in; + + push_wmops( "ivas_sba2mc_cldfb" ); + + nb_channels_in = hInSetup.nchan_out_woLFE; + assert( ( nb_channels_in == 16 ) && ( nb_channels_out == 11 ) && "ivas_sba2mc_cldfb; only HOA3 to CICP19 is for now supported!" ); + + for ( n = 0; n < nb_channels_out; n++ ) + { + set_zero( realOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands ); + set_zero( imagOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands ); + + for ( m = 0; m < nb_channels_in; m++ ) + { + g = hoa_dec_mtx[SBA_NHARM_HOA3 * n + m]; + p_realOut = realOut[n]; + p_imagOut = imagOut[n]; + for ( iBlock = 0; iBlock < MAX_PARAM_SPATIAL_SUBFRAMES; iBlock++ ) + { + p_real = RealBuffer[m][iBlock]; + p_imag = ImagBuffer[m][iBlock]; + for ( iBand = 0; iBand < nb_bands; iBand++ ) + { + *p_realOut = *p_realOut + g * *( p_real++ ); + *p_imagOut = *p_imagOut + g * *( p_imag++ ); + p_realOut++; + p_imagOut++; + } + } + } + } + + for ( n = 0; n < nb_channels_out; n++ ) + { + p_realOut = realOut[n]; + p_imagOut = imagOut[n]; + for ( iBlock = 0; iBlock < MAX_PARAM_SPATIAL_SUBFRAMES; iBlock++ ) + { + p_real = RealBuffer[n][iBlock]; + p_imag = ImagBuffer[n][iBlock]; + for ( iBand = 0; iBand < nb_bands; iBand++ ) + { + *( p_real++ ) = *p_realOut++; + *( p_imag++ ) = *p_imagOut++; + } + } + } + + pop_wmops(); + + return; +} + + +/*-------------------------------------------------------------------------* + * ivas_mc2sba() + * + * MC signals transformed into SBA in TD domain + *-------------------------------------------------------------------------*/ + +void ivas_mc2sba( + IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ + float buffer_td[][L_FRAME48k], /* i/o: MC signals (on input) and the HOA3 (on output) */ + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t sba_order, /* i : Ambisonic (SBA) order */ + const float gain_lfe /* i : gain for LFE, 0 = ignore LFE */ +) +{ + int16_t i, j, k; + int16_t idx_lfe, idx_in; + float buffer_tmp[16][L_FRAME48k]; + float gains[16]; + int16_t azimuth, elevation; + int16_t sba_num_chans; + + assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); + + /* Init*/ + sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); + for ( j = 0; j < sba_num_chans; j++ ) + { + set_zero( buffer_tmp[j], output_frame ); + } + + /* HOA encoding*/ + idx_lfe = 0; + idx_in = 0; + for ( i = 0; i < hIntSetup.nchan_out_woLFE + hIntSetup.num_lfe; i++ ) + { + if ( ( hIntSetup.num_lfe > 0 ) && ( i == hIntSetup.index_lfe[idx_lfe] ) ) + { + if ( gain_lfe > 0.f ) + { + /* Add LFE to omni W with gain*/ + for ( k = 0; k < output_frame; k++ ) + { + buffer_tmp[0][k] += gain_lfe * buffer_td[i][k]; + } + } + + if ( idx_lfe < ( hIntSetup.num_lfe - 1 ) ) + { + idx_lfe++; + } + } + else + { + azimuth = (int16_t) ( hIntSetup.ls_azimuth[idx_in] ); + elevation = (int16_t) ( hIntSetup.ls_elevation[idx_in] ); + idx_in++; + + /* get HOA response for direction (ACN/SN3D)*/ + ivas_dirac_dec_get_response( + azimuth, + elevation, + gains, + sba_order ); + + for ( j = 0; j < sba_num_chans; j++ ) + { + for ( k = 0; k < output_frame; k++ ) + { + buffer_tmp[j][k] += gains[j] * buffer_td[i][k]; + } + } + } + } + + for ( j = 0; j < sba_num_chans; j++ ) + { + mvr2r( buffer_tmp[j], buffer_td[j], output_frame ); + } + + return; +} + + +/*-------------------------------------------------------------------* + * ivas_sba_remapTCs() + * + * Get TCs from Ambisonics signal in ACN + *-------------------------------------------------------------------*/ + +int16_t ivas_sba_remapTCs( + float sba_data[][L_FRAME48k], /* i/o: SBA signals */ + Decoder_Struct *st_ivas, /* i/o: decoder struct */ + const int16_t output_frame /* i : frame length */ +) +{ + int16_t nchan_remapped; + +#ifdef DEBUG_MODE_DIRAC + debug_mode_dirac( sba_data, st_ivas->nchan_transport, output_frame ); +#endif + + nchan_remapped = st_ivas->nchan_transport; + if ( ( st_ivas->sba_mode != SBA_MODE_SPAR && st_ivas->sba_planar && nchan_remapped >= 3 ) || + ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && nchan_remapped == 3 ) ) + { + + nchan_remapped++; + if ( st_ivas->sba_mode != SBA_MODE_SPAR ) + { + assert( ( ( st_ivas->nchan_transport == 3 ) || ( st_ivas->nchan_transport == 5 ) || ( st_ivas->nchan_transport == 7 ) ) && "Number of channels must be odd for SBA planar!" ); + } + + if ( nchan_remapped == 4 ) + { + /*For planar A-format channel 2 and 3 are identical -> Z=0*/ + mvr2r( sba_data[2], sba_data[3], output_frame ); + } + } + + if ( st_ivas->nchan_transport >= 3 ) + { + int16_t i = 0; + float temp; + + /*convert WYXZ downmix to WYZX*/ + for ( i = 0; i < output_frame; i++ ) + { + temp = sba_data[2][i]; + sba_data[2][i] = sba_data[3][i]; + sba_data[3][i] = temp; + if ( st_ivas->nchan_transport == 3 ) + { + sba_data[2][i] = 0; + } + } + } + + if ( st_ivas->sba_mode != SBA_MODE_SPAR ) + { + ivas_sba_zero_vert_comp( sba_data, st_ivas->sba_analysis_order, st_ivas->sba_planar, output_frame ); + } + + return ( nchan_remapped ); +} + + +/*-------------------------------------------------------------------------* + * ivas_ism2sba() + * + * ISM transformed into SBA in TD domain. + *-------------------------------------------------------------------------*/ + +void ivas_ism2sba( + float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ + ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ + const ISM_METADATA_HANDLE hIsmMetaData[], /* i : object metadata */ + const int16_t num_objects, /* i : number of objects */ + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ +) +{ + int16_t i, j, k; + float buffer_tmp[16][L_FRAME48k]; + float gains[16]; + float g1, g2; + int16_t azimuth, elevation; + int16_t sba_num_chans; + + assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); + assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" ); + + /* Init*/ + sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); + for ( j = 0; j < sba_num_chans; j++ ) + { + set_zero( buffer_tmp[j], output_frame ); + } + + for ( i = 0; i < num_objects; i++ ) + { + // TODO tmu review when #215 is resolved + azimuth = (int16_t) floorf( hIsmMetaData[i]->azimuth + 0.5f ); + elevation = (int16_t) floorf( hIsmMetaData[i]->elevation + 0.5f ); + + /*get HOA gets for direction (ACN/SN3D)*/ + ivas_dirac_dec_get_response( azimuth, elevation, gains, sba_order ); + + for ( j = 0; j < sba_num_chans; j++ ) + { + g1 = 1.f; + g2 = 0.f; + for ( k = 0; k < output_frame; k++ ) + { + buffer_tmp[j][k] += ( g2 * gains[j] + g1 * hIsmRendererData->prev_gains[i][j] ) * buffer_td[i][k]; + g2 += 1.f / ( output_frame - 1 ); + g1 = 1.0f - g2; + } + hIsmRendererData->prev_gains[i][j] = gains[j]; + } + } + + for ( j = 0; j < sba_num_chans; j++ ) + { + mvr2r( buffer_tmp[j], buffer_td[j], output_frame ); + } + + return; +} + + +/*-------------------------------------------------------------------* + * ivas_sba_upmixer_renderer() + * + * SBA upmix & rendering + *-------------------------------------------------------------------*/ + +void ivas_sba_upmixer_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ + float output[][L_FRAME48k], /* i/o: transport/output audio channels */ + const int16_t output_frame /* i : output frame length */ +) +{ + int16_t i, nchan_internal; + float temp; + + push_wmops( "ivas_sba_upmixer_renderer" ); + + nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); + + if ( st_ivas->nchan_transport >= 3 ) + { + /*convert WYZX downmix to WYXZ*/ + for ( i = 0; i < output_frame; i++ ) + { + temp = output[2][i]; + output[2][i] = output[3][i]; + output[3][i] = temp; + } + } + + /* Upmixer + Renderer */ + ivas_spar_dec_upmixer( st_ivas, output, nchan_internal, output_frame ); + + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) + { + ivas_sba_linear_renderer( output, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); + } + + pop_wmops(); + + return; +} + + +/*-------------------------------------------------------------------* + * ivas_sba_mix_matrix_determiner() + * + * Determine SBA mixing matrices + *-------------------------------------------------------------------*/ + +void ivas_sba_mix_matrix_determiner( + SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ + float output[][L_FRAME48k], /* i/o: transport/output audio channels */ + const int16_t bfi, /* i : BFI flag */ + const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ + const int16_t output_frame /* i : output frame length */ +) +{ + int16_t i, ch; + float temp; + int16_t num_bands_out, nchan_transport, nchan_out; + + /* Convert numeric range */ + for ( ch = 0; ch < nchan_remapped; ch++ ) + { + for ( i = 0; i < output_frame; i++ ) + { + temp = output[ch][i]; + temp = floorf( temp + 0.5f ); + + if ( temp > MAX16B_FLT ) + { + temp = MAX16B_FLT; + } + else if ( temp < ( -1.0f * PCM16_TO_FLT_FAC ) ) + { + temp = ( -1.0f * PCM16_TO_FLT_FAC ); + } + temp *= ( 1.0f / PCM16_TO_FLT_FAC ); + output[ch][i] = temp; + } + } + + /* AGC */ + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + nchan_out = nchan_transport; + ivas_agc_dec_process( hSpar->hAgcDec, output, output, nchan_transport, output_frame ); + + /* Convert numeric range back */ + for ( ch = 0; ch < nchan_out; ch++ ) + { + for ( i = 0; i < output_frame; i++ ) + { + output[ch][i] = output[ch][i] * PCM16_TO_FLT_FAC; + } + } + + /* Mixing matrix determiner */ + num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi ); + + return; +} + + +#ifdef DEBUG_MODE_DIRAC +/*-----------------------------------------------------------------------* + * Debugging function + *-----------------------------------------------------------------------*/ + +static void debug_mode_dirac( + float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], + const int16_t nchan_transport, + const int16_t output_frame ) +{ + int16_t i, n; + int16_t tmp[L_FRAME48k]; + char file_name[50] = { 0 }; + +#ifdef DEBUG_MODE_DIRAC_NOCORE + for ( n = 0; n < nchan_transport; n++ ) + { + sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); + dbgread( tmp, sizeof( int16_t ), output_frame, file_name ); + for ( i = 0; i < output_frame; i++ ) + { + output[n][i] = (float) ( tmp[i] ); + } + } +#else + for ( n = 0; n < nchan_transport; n++ ) + { + for ( i = 0; i < output_frame; i++ ) + { + tmp[i] = (int16_t) ( output[n][i] + 0.5f ); + } + + sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); + dbgwrite( tmp, sizeof( int16_t ), output_frame, 1, file_name ); + } +#endif + + return; +} +#endif diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index b83fb8dcd0..86df968ee1 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -876,81 +876,8 @@ ivas_error ivas_crend_init_from_setofhrtf( #endif #endif -/*---------------------------------------------------------------------* - * destroy_HRTF() - * - * Destroy the HRTF CRend handle - *---------------------------------------------------------------------*/ - -static ivas_error destroy_HRTF( - HRTFS_HANDLE *hHRTF /* i/o: HRTF CRend handle */ -) -{ - uint16_t i, j; - - if ( *hHRTF != NULL && hHRTF != NULL ) - { - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL ) - { - 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] ); - } - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL ) - { - 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] ); - } - } - - free( *hHRTF ); - *hHRTF = NULL; - } - - return IVAS_ERR_OK; -} #ifdef HRTF_BINARY_FILE -/*---------------------------------------------------------------------* - * destroy_SetOfHRTF() - * - * Destroy the HRTF data set. - *---------------------------------------------------------------------*/ - -ivas_error destroy_SetOfHRTF( - HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ -) -{ - if ( hSetOfHRTF != NULL ) - { - destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_combined ) ); - destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_hoa3 ) ); - destroy_HRTF( &( hSetOfHRTF->hHRTF_brir_combined ) ); - } - - return IVAS_ERR_OK; -} #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index a9c400cdde..c389bfcad2 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -36,6 +36,7 @@ #include #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_binauralRenderer.h" #include "ivas_rom_dec.h" diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index f65eb07f29..52509cea43 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -37,7 +37,6 @@ #include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" -//#include "lib_rend.h" // VE2AT: remove it from this file? #ifdef DEBUGGING #include "debug.h" #endif @@ -48,148 +47,8 @@ * Local function prototypes *---------------------------------------------------------------------*/ -static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, float output[][L_FRAME48k], const int16_t subframe_length, const int16_t subframe_idx ); - static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd ); -static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t headRotEnabled, const IVAS_QUATERNION *headPosition ); - -static void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t numSources, const int16_t lfe_idx, const IVAS_FORMAT in_format, const ISM_METADATA_HANDLE *hIsmMetaData, float output[][L_FRAME48k] ); - - -/*---------------------------------------------------------------------* - * ivas_td_binaural_open() - * - * Open and initialize TD Object binaural renderer - *---------------------------------------------------------------------*/ - -ivas_error ivas_td_binaural_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; - TDREND_PosType_t PosType; - int16_t nS; - int16_t SrcInd[MAX_NUM_TDREND_CHANNELS]; - const float *ls_azimuth, *ls_elevation; - float Pos[3]; - float Dir[3]; - TDREND_DirAtten_t *DirAtten_p; - int16_t nchan_rend; - ivas_error error; - - error = IVAS_ERR_OK; - - if ( ( hBinRendererTd = malloc( sizeof( BINAURAL_TD_OBJECT_RENDERER ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); - } - if ( ( hBinRendererTd->TdRend_MixSpatSpec_p = malloc( sizeof( TDREND_MixSpatSpec_t ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); - } - if ( ( hBinRendererTd->DirAtten_p = malloc( sizeof( TDREND_DirAtten_t ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); - } - if ( ( hBinRendererTd->Listener_p = malloc( sizeof( TDREND_MIX_Listener_t ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); - } - - hBinRendererTd->NumOfSrcs = 0; - hBinRendererTd->MaxSrcInd = -1; - - /* Mixer spatial setup */ - hBinRendererTd->TdRend_MixSpatSpec_p->UseCommonDistAttenModel = TRUE; - hBinRendererTd->TdRend_MixSpatSpec_p->DistAttenModel = 0; /* 0=Turned off, else use TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED */ - - TDREND_MIX_Init( hBinRendererTd, &st_ivas->hHrtfTD, hBinRendererTd->TdRend_MixSpatSpec_p, st_ivas->hDecoderConfig->output_Fs ); - - /* Set the attenuation (or can set MixSpatSpec.DistAttenModel above) */ - TDREND_MIX_SetDistAttenModel( hBinRendererTd, TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED ); - - /* Add sources to module and mixer, headphones */ - PosType = TDREND_POSTYPE_ABSOLUTE; /* or TDREND_POSTYPE_RELATIVE_TO_LISTENER */ - - nchan_rend = st_ivas->nchan_transport; - if ( st_ivas->ivas_format == MC_FORMAT ) - { - nchan_rend--; /* Skip LFE channel -- added to the others */ - } - - for ( nS = 0; nS < nchan_rend; nS++ ) - { - if ( ( error = TDREND_MIX_AddSrc( hBinRendererTd, &SrcInd[nS], PosType ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - if ( st_ivas->ivas_format == MC_FORMAT ) - { - switch ( st_ivas->transport_config ) - { - case AUDIO_CONFIG_5_1: - ls_azimuth = ls_azimuth_CICP6; - ls_elevation = ls_elevation_CICP6; - break; - case AUDIO_CONFIG_7_1: - ls_azimuth = ls_azimuth_CICP12; - ls_elevation = ls_elevation_CICP12; - break; - case AUDIO_CONFIG_5_1_2: - ls_azimuth = ls_azimuth_CICP14; - ls_elevation = ls_elevation_CICP14; - break; - case AUDIO_CONFIG_5_1_4: - ls_azimuth = ls_azimuth_CICP16; - ls_elevation = ls_elevation_CICP16; - break; - case AUDIO_CONFIG_7_1_4: - ls_azimuth = ls_azimuth_CICP19; - ls_elevation = ls_elevation_CICP19; - break; - case AUDIO_CONFIG_LS_CUSTOM: - ls_azimuth = st_ivas->hTransSetup.ls_azimuth; - ls_elevation = st_ivas->hTransSetup.ls_elevation; - break; - default: - ls_azimuth = NULL; - ls_elevation = NULL; - } - - DirAtten_p = hBinRendererTd->DirAtten_p; - - for ( nS = 0; nS < nchan_rend; nS++ ) - { - /* Set source positions according to loudspeaker layout */ - Pos[0] = cosf( ls_elevation[nS] * PI_OVER_180 ) * cosf( ls_azimuth[nS] * PI_OVER_180 ); - Pos[1] = cosf( ls_elevation[nS] * PI_OVER_180 ) * sinf( ls_azimuth[nS] * PI_OVER_180 ); - Pos[2] = sinf( ls_elevation[nS] * PI_OVER_180 ); - Dir[0] = 1.0f; - Dir[1] = 0.0f; - Dir[2] = 0.0f; - - /* Source directivity info */ - DirAtten_p->ConeInnerAngle = 360.0f; - DirAtten_p->ConeOuterAngle = 360.0f; - DirAtten_p->ConeOuterGain = 1.0f; - - TDREND_MIX_SRC_SetPos( hBinRendererTd, nS, Pos ); - TDREND_MIX_SRC_SetDir( hBinRendererTd, nS, Dir ); - TDREND_MIX_SRC_SetPlayState( hBinRendererTd, nS, TDREND_PLAYSTATUS_PLAYING ); - TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p ); - } - } - - st_ivas->hBinRendererTd = hBinRendererTd; - - st_ivas->binaural_latency_ns = (int32_t) ( BINAURAL_TD_LATENCY_S * 1000000000.f ); - - return error; -} - /*---------------------------------------------------------------------* * ivas_td_binaural_close() @@ -218,80 +77,13 @@ void ivas_td_binaural_close( } -/*---------------------------------------------------------------------* - * ObjRenderIVASFrame() - * - * Receives the current frames for the object streams, updates metadata - * and renders the current frame. - *---------------------------------------------------------------------*/ -// VE2AT: shopuld be defined in lib_dec -void ObjRenderIVASFrame( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame /* i : output frame length */ -) -{ - int16_t subframe_length; - int16_t subframe_idx; - float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k]; - - subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; - if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ - { - - if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on && ( st_ivas->ini_frame == 0 ) ) - { -#ifdef FIX_197_CREND_INTERFACE - ivas_reverb_open( &st_ivas->hCrendWrapper->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ); -#else - ivas_reverb_open( &st_ivas->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ); -#endif - } - } - - /* Update object position(s) */ - TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, output ); - - for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) - { - /* Update the listener's location/orientation */ - TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, - st_ivas->hDecoderConfig->Opt_Headrotation, - ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[subframe_idx] : NULL ); - - if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) - { -#ifdef FIX_197_CREND_INTERFACE - ivas_reverb_process( st_ivas->hCrendWrapper->hCrend->hReverb, st_ivas->transport_config, 0, output, reverb_signal, subframe_idx ); -#else - ivas_reverb_process( st_ivas->hCrend->hReverb, st_ivas->transport_config, 0, output, reverb_signal, subframe_idx ); -#endif - } - - /* Render subframe */ - TDREND_GetMix( st_ivas->hBinRendererTd, output, subframe_length, subframe_idx ); - } - - if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ - { - if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) - { - /* add reverb to rendered signals */ - v_add( reverb_signal[0], output[0], output[0], output_frame ); - v_add( reverb_signal[1], output[1], output[1], output_frame ); - } - } - - return; -} - - /*---------------------------------------------------------------------* * TDREND_GetMix() * * Render one 5 ms subframe from the mixer *---------------------------------------------------------------------*/ -static ivas_error TDREND_GetMix( + +ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ float output[][L_FRAME48k], /* i/o: ISm object synth / rendered output in 0,1 */ const int16_t subframe_length, /* i/o: subframe length */ @@ -373,13 +165,14 @@ static void TDREND_Clear_Update_flags( return; } + /*---------------------------------------------------------------------* * TDREND_Update_object_positions() * * Update object position(s) *---------------------------------------------------------------------*/ -static void TDREND_Update_object_positions( +void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o : TD Renderer handle */ const int16_t numSources, /* i : Number of sources to render */ const int16_t lfe_idx, /* i : Input LFE index */ @@ -435,13 +228,14 @@ static void TDREND_Update_object_positions( return; } + /*---------------------------------------------------------------------* * TDREND_Update_listener_orientation() * * Update listener orientation (s) *---------------------------------------------------------------------*/ -static void TDREND_Update_listener_orientation( +void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ const int16_t headRotEnabled, /* i : Headrotation flag */ const IVAS_QUATERNION *headPosition /* i : Head Position */ @@ -490,7 +284,13 @@ static void TDREND_Update_listener_orientation( return; } -// VE2AT: should be defined in lib_dec + +/*---------------------------------------------------------------------* + * ivas_rend_TDObjRendOpen() + * + * + *---------------------------------------------------------------------*/ + ivas_error ivas_rend_TDObjRendOpen( TDREND_WRAPPER *pTDRend, IVAS_REND_AudioConfig inConfig, @@ -631,6 +431,7 @@ ivas_error ivas_rend_TDObjRendOpen( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * ivas_rend_TDObjRenderFrame() * @@ -638,7 +439,6 @@ ivas_error ivas_rend_TDObjRendOpen( * and renders the current frame. *---------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error ivas_rend_TDObjRenderFrame( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const IVAS_REND_AudioConfig inConfig, /* i : Input audio configuration */ diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index a5a4606e92..a034adf214 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -135,28 +135,79 @@ ivas_error ivas_rend_crendConvolver( #endif -void ivas_sba2mc_cldfb( - IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */ - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part */ - const int16_t nb_channels_out, /* i : nb of output channels */ - const int16_t nb_bands, /* i : nb of CLDFB bands to process */ - const float *hoa_dec_mtx /* i : HOA decoding mtx */ + +/*----------------------------------------------------------------------------------* + * SBA rendering + *----------------------------------------------------------------------------------*/ + +void ivas_sba_prototype_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ + float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ + float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ + const int16_t firstSubframe, /* i : First subframe to map */ + const int16_t nSubframes /* i : Number of subframes to map */ ); +ivas_error ivas_sba_linear_renderer( + float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t nchan_in, /* i : number of input ambisonics channels */ + const AUDIO_CONFIG output_config, /* i : output audio configuration */ + const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */ + const float hoa_dec_mtx[] /* i : HOA decoding mtx */ +); + +ivas_error ivas_sba_get_hoa_dec_matrix( + const IVAS_OUTPUT_SETUP hOutSetup, /* i : target output setup */ + float **hoa_dec_mtx, /* o : ALLRAD decoder matrix */ + const int16_t ambisonics_order /* i : Ambisonics order */ +); + +void ivas_dirac_dec_binaural( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t nchan_transport /* i : number of transport channels */ +); + +ivas_error ivas_dirac_dec_init_binaural_data( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : HRTF structure for rendering */ +); + +void ivas_dirac_dec_close_binaural_data( + DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ +); + +ivas_error ivas_dirac_dec_binaural_copy_hrtfs( + HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ +); + +void QuatToRotMat( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ +); + +void rotateAziEle( + float azi_in, /* i : output elevation */ + float ele_in, /* i : input elevation */ + int16_t *azi, /* o : rotated azimuth */ + int16_t *ele, /* o : rotated elevation */ + float Rmat[3][3], /* i : real-space rotation matrix */ + const int16_t isPlanar /* i : is roation planar and elevation meaningless? */ +); /*----------------------------------------------------------------------------------* * TD object renderer *----------------------------------------------------------------------------------*/ ivas_error ivas_rend_TDObjRenderFrame( - const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ - const IVAS_REND_AudioConfig inConfig, /* i : Input audio configuration */ - const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ - const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ - const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ - const int16_t output_frame, /* i : output frame length */ - float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ + const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ + const IVAS_REND_AudioConfig inConfig, /* i : Input audio configuration */ + const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ + const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ + const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ + const int16_t output_frame, /* i : output frame length */ + float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ); ivas_error ivas_rend_TDObjRendOpen( @@ -166,6 +217,38 @@ ivas_error ivas_rend_TDObjRendOpen( const int32_t output_Fs ); +void ivas_td_binaural_close( + BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */ +); + + +ivas_error TDREND_GetMix( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + float output[][L_FRAME48k], /* i/o: ISm object synth / rendered output in 0,1 */ + const int16_t subframe_length, /* i/o: subframe length */ + const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ +); + +void TDREND_Update_listener_orientation( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ + const int16_t headRotEnabled, /* i : Headrotation flag */ + const IVAS_QUATERNION *headPosition /* i : Head Position */ +); + +void TDREND_Update_object_positions( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o : TD Renderer handle */ + const int16_t numSources, /* i : Number of sources to render */ + const int16_t lfe_idx, /* i : Input LFE index */ + const IVAS_FORMAT in_format, /* i : Format of input sources */ + const ISM_METADATA_HANDLE *hIsmMetaData, /* i : Input metadata for ISM objects */ + float output[][L_FRAME48k] /* i/o: SCE/MC channels */ +); + +void BSplineModelEvalDealloc( + ModelParams_t *model, /* i : Model parameters */ + ModelEval_t *modelEval /* i : Model evaluation structure */ +); + /* ----- Object renderer - hrfilt ----- */ void GetFilterFromAngle( @@ -344,12 +427,67 @@ void TDREND_firfilt( * Crend renderer *----------------------------------------------------------------------------------*/ +ivas_error ivas_rend_openCrend( + CREND_WRAPPER_HANDLE *pCrend, + const IVAS_REND_AudioConfig inConfig, + const IVAS_REND_AudioConfig outConfig, + RENDER_CONFIG_DATA *hRendCfg, + int16_t Opt_Headrotation, + HRTFS_CREND_HANDLE hSetOfHRTF, + const int32_t output_Fs +); + +void ivas_rend_closeCrend( + CREND_WRAPPER_HANDLE *pCrend +); + +ivas_error ivas_rend_crendProcess( + const CREND_WRAPPER *pCrend, + const IVAS_REND_AudioConfig inConfig, + const IVAS_REND_AudioConfig outConfig, + DECODER_CONFIG_HANDLE hDecoderConfig, + HEAD_TRACK_DATA_HANDLE hHeadTrackData, + IVAS_OUTPUT_SETUP_HANDLE hIntSetup, + EFAP_HANDLE hEFAPdata, + float output[][L_FRAME48k], /* i/o: input/output audio channels */ + const int32_t output_Fs +); /*----------------------------------------------------------------------------------* * Reverberator *----------------------------------------------------------------------------------*/ +ivas_error ivas_binaural_reverb_open( + REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ + const int16_t numBins, /* i : number of CLDFB bins */ + const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ + ivas_roomAcoustics_t *roomAcoustics, /* i/o: room acoustics parameters */ + const AUDIO_CONFIG output_config, /* i : output audio configuration */ + const int32_t sampling_rate, /* i : sampling rate */ + const RENDERER_TYPE renderer_type /* i : renderer type */ +#ifdef HRTF_BINARY_FILE + , + const HRTFS_FASTCONV_HANDLE hHrtfFastConv, /* i : FastConv HRTF handle */ + const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ +#endif +); + +void ivas_binaural_reverb_close( + REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ +); + +void ivas_binaural_reverb_processFrame( + REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ + const int16_t numInChannels, /* i : num input channels to be processed */ + float inReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real */ + float inImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ + float outReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ + float outImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data imag */ + const uint8_t offsetSamplesIO /* i : number of offset samples */ +); + + ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ @@ -599,6 +737,24 @@ void rotateFrame_sd_cldfb( ); +/*----------------------------------------------------------------------------------* + * Renderer configuration + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_render_config_open( + RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ +); + +void ivas_render_config_close( + RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ +); + +ivas_error ivas_render_config_init_from_rom( + RENDER_CONFIG_HANDLE *hRenderConfig, /* i/o: Renderer config handle */ + const int16_t room_flag_on /* i : room effect on/off flag */ +); + + /*----------------------------------------------------------------------------------* * Orientation tracking *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 412e4d7068..7d70e26b85 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -45,6 +45,19 @@ #include "wmc_auto.h" +/* The reverberator structure implemented here is described in detail in: + * Vilkamo, J., Neugebauer, B., & Plogsties, J. (2012). Sparse frequency-domain reverberator. + * Journal of the Audio Engineering Society, 59(12), 936-943. */ + +/*------------------------------------------------------------------------- + * Local constants + *------------------------------------------------------------------------*/ + +#define BIN_REND_RANDOM_SEED 1 /* random seed for generating reverb decorrelators */ + +#define CLDFB_SLOTS_PER_SECOND 800 /* Used for initializing reverb */ + + /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ @@ -118,6 +131,151 @@ typedef struct ivas_reverb_params_t static ivas_error calc_jot_t60_coeffs( float *pH_dB, const uint16_t nrFrequencies, float *pFrequencies, float *pCoeffA, float *pCoeffB, const float fNyquist ); +/*------------------------------------------------------------------------- + * binRend_rand() + * + * + *------------------------------------------------------------------------*/ + +static uint16_t binRend_rand( + REVERB_STRUCT_HANDLE hReverb /* i/o: binaural reverb handle */ +) +{ + hReverb->binRend_RandNext = hReverb->binRend_RandNext * 1103515245 + 12345; + + return (uint16_t) ( hReverb->binRend_RandNext / 65536 ) % 32768; +} + + +/*------------------------------------------------------------------------- + * ivas_binaural_reverb_setPreDelay() + * + * + *------------------------------------------------------------------------*/ + +static void ivas_binaural_reverb_setPreDelay( + REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ + const int16_t delaySamples /* i : reverb pre-delay in CLDFB slots */ +) +{ + if ( delaySamples < 1 ) + { + hReverb->preDelayBufferLength = 1; + + return; + } + + if ( delaySamples > REVERB_PREDELAY_MAX ) + { + hReverb->preDelayBufferLength = REVERB_PREDELAY_MAX; + + return; + } + + hReverb->preDelayBufferLength = delaySamples; + + return; +} + + +/*------------------------------------------------------------------------- + * ivas_binaural_reverb_setReverbTimes() + * + * + *------------------------------------------------------------------------*/ + +static void ivas_binaural_reverb_setReverbTimes( + REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ + const int32_t output_Fs, /* i : sampling_rate */ + const float *revTimes, /* i : reverberation times T60 for each CLDFB bin in seconds */ + const float *revEnes /* i : spectrum for reverberated sound at each CLDFB bin */ +) +{ + int16_t bin, ch, tap, sample; + float binCenterFreq, diffuseFieldICC, tmpVal, attenuationFactorPerSample; + float intendedEnergy, actualizedEnergy, energyBuildup, currentEnergy, attenuationFactorPerSampleSq; + + hReverb->binRend_RandNext = (uint16_t) BIN_REND_RANDOM_SEED; + hReverb->highestBinauralCoherenceBin = 0; + for ( bin = 0; bin < hReverb->numBins; bin++ ) + { + /* Determine the diffuse field binaural coherence */ + binCenterFreq = ( (float) bin + 0.5f ) / ( (float) hReverb->numBins ) * ( (float) output_Fs ) / 2.0f; + if ( bin == 0 ) + { + diffuseFieldICC = 1.0f; + } + else if ( binCenterFreq < 2700.0f ) + { + diffuseFieldICC = sinf( EVS_PI * binCenterFreq / 550.0f + 1e-20f ) / ( EVS_PI * binCenterFreq / 550.0f + 1e-20f ) * ( 1.0f - binCenterFreq / 2700.0f ); + hReverb->highestBinauralCoherenceBin = bin; + } + else + { + diffuseFieldICC = 0.0f; + } + + /* Mixing gains to generate a diffuse-binaural sound based on incoherent sound */ + tmpVal = ( 1.0f - sqrtf( 1.0f - powf( diffuseFieldICC, 2.0 ) ) ) / 2.0f; + if ( diffuseFieldICC > 0 ) + { + hReverb->binauralCoherenceCrossmixGains[bin] = sqrtf( fabsf( tmpVal ) ); + } + else + { + hReverb->binauralCoherenceCrossmixGains[bin] = -sqrtf( fabsf( tmpVal ) ); + } + hReverb->binauralCoherenceDirectGains[bin] = sqrtf( 1.0f - fabsf( tmpVal ) ); + + /* Determine attenuation factor that generates the appropriate energy decay according to reverberation time */ + attenuationFactorPerSample = powf( 10.0f, -3.0f * ( 1.0f / ( (float) CLDFB_SLOTS_PER_SECOND * revTimes[bin] ) ) ); + hReverb->loopAttenuationFactor[bin] = powf( attenuationFactorPerSample, hReverb->loopBufLength[bin] ); + attenuationFactorPerSampleSq = attenuationFactorPerSample * attenuationFactorPerSample; + + /* Design sparse decorrelation filters. The decorrelation filters, due to random procedures involved, + * may affect the spectrum of the output. The spectral effect is therefore monitored and compensated for. */ + intendedEnergy = 0.0f; + actualizedEnergy = 0.0f; + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + energyBuildup = 0.0f; + currentEnergy = 1.0f; + tap = 0; + + for ( sample = 0; sample < hReverb->loopBufLength[bin]; sample++ ) + { + intendedEnergy += currentEnergy; + + /* The randomization at the energy build up affects where the sparse taps are located */ + energyBuildup += currentEnergy + 0.1f * ( (float) binRend_rand( hReverb ) / PCM16_TO_FLT_FAC - 0.5f ); + + if ( energyBuildup >= 1.0f ) /* A new filter tap is added at this condition */ + { + /* Four efficient phase operations: n*pi/2, n=0,1,2,3 */ + hReverb->tapPhaseShiftType[bin][ch][tap] = (int16_t) ( binRend_rand( hReverb ) % 4 ); + /* Set the tapPointer to point to the determined sample at the loop buffer */ + hReverb->tapPointersReal[bin][ch][tap] = &( hReverb->loopBufReal[bin][sample] ); + hReverb->tapPointersImag[bin][ch][tap] = &( hReverb->loopBufImag[bin][sample] ); + energyBuildup -= 1.0f; /* A tap is added, thus remove its energy from the buildup */ + tap++; + actualizedEnergy += 1.0f; + } + currentEnergy *= attenuationFactorPerSampleSq; + } + hReverb->taps[bin][ch] = tap; /* Number of taps determined at the above random procedure */ + } + + /* The decorrelator design and IIR attenuation rate affects the energy of reverb, which is compensated here */ + hReverb->reverbEqGains[bin] = sqrtf( revEnes[bin] ); /* Determined reverb spectrum */ + hReverb->reverbEqGains[bin] *= sqrtf( intendedEnergy / actualizedEnergy ); /* Correction of random effects at the decorrelator design */ + hReverb->reverbEqGains[bin] *= sqrtf( 0.5f * ( 1.0f - attenuationFactorPerSampleSq ) ); /* Correction of IIR decay rate */ + } + + return; +} + + /*-----------------------------------------------------------------------------------------* * Function compute_feedback_matrix() * @@ -1441,3 +1599,372 @@ ivas_error ivas_reverb_process( return IVAS_ERR_OK; } + + +/*------------------------------------------------------------------------- + * ivas_binaural_reverb_processFrame() + * + * Compute the reverberation - room effect + *------------------------------------------------------------------------*/ + +void ivas_binaural_reverb_processFrame( + REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ + const int16_t numInChannels, /* i : num inputs to be processed */ + float inReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real, Comment: This change swaps two first dimensions as first dimension is not constant. */ + float inImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ + float outReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ + float outImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data imag */ + const uint8_t offsetSamplesIO /* i : number of offset samples */ +) +{ + /* Declare the required variables */ + int16_t idx, bin, ch, sample, invertSampleIndex, tapIdx, *phaseShiftTypePr; + float **tapRealPr, **tapImagPr; + + /* 1) Rotate the data in the loop buffer of the reverberator. + * Notice that the audio at the loop buffers is at time-inverted order + * for convolution purposes later on. */ + for ( bin = 0; bin < hReverb->numBins; bin++ ) + { + /* Move the data forwards by blockSize (i.e. by the frame size of 16 CLDFB slots) */ + mvr2r( hReverb->loopBufReal[bin], hReverb->loopBufReal[bin] + hReverb->blockSize, hReverb->loopBufLength[bin] ); + mvr2r( hReverb->loopBufImag[bin], hReverb->loopBufImag[bin] + hReverb->blockSize, hReverb->loopBufLength[bin] ); + + /* Add the data from the end of the loop to the beginning, with an attenuation factor + * according to RT60. This procedure generates an IIR decaying response. The response + * is decorrelated later on. */ + v_multc( hReverb->loopBufReal[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor[bin], hReverb->loopBufReal[bin], hReverb->blockSize ); + v_multc( hReverb->loopBufImag[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor[bin], hReverb->loopBufImag[bin], hReverb->blockSize ); + } + + /* 2) Apply the determined pre-delay to the input audio, and add the delayed audio to the loop. */ + idx = hReverb->preDelayBufferIndex; + for ( sample = 0; sample < hReverb->blockSize; sample++ ) + { + uint16_t sampleWithOffset; + sampleWithOffset = sample + offsetSamplesIO; + invertSampleIndex = hReverb->blockSize - sample - 1; + for ( bin = 0; bin < hReverb->numBins; bin++ ) + { + /* Add from pre-delay buffer a sample to the loop buffer, in a time-inverted order. + * Also apply the spectral gains determined for the reverberation */ + hReverb->loopBufReal[bin][invertSampleIndex] += hReverb->preDelayBufferReal[idx][bin] * hReverb->reverbEqGains[bin]; + hReverb->loopBufImag[bin][invertSampleIndex] += hReverb->preDelayBufferImag[idx][bin] * hReverb->reverbEqGains[bin]; + hReverb->preDelayBufferReal[idx][bin] = 0.0f; + hReverb->preDelayBufferImag[idx][bin] = 0.0f; + } + + /* Add every second input channel as is to the pre-delay buffer, and every second input channel with + * 90 degrees phase shift to reduce energy imbalances between coherent and incoherent sounds */ + for ( ch = 0; ch < numInChannels; ch++ ) + { + if ( ch % 2 ) + { + v_add( hReverb->preDelayBufferReal[idx], inReal[ch][sampleWithOffset], hReverb->preDelayBufferReal[idx], hReverb->numBins ); + v_add( hReverb->preDelayBufferImag[idx], inImag[ch][sampleWithOffset], hReverb->preDelayBufferImag[idx], hReverb->numBins ); + } + else + { + v_sub( hReverb->preDelayBufferReal[idx], inImag[ch][sampleWithOffset], hReverb->preDelayBufferReal[idx], hReverb->numBins ); + v_add( hReverb->preDelayBufferImag[idx], inReal[ch][sampleWithOffset], hReverb->preDelayBufferImag[idx], hReverb->numBins ); + } + } + idx = ( idx + 1 ) % hReverb->preDelayBufferLength; + } + hReverb->preDelayBufferIndex = idx; + + /* 3) Perform the filtering/decorrelating, using complex and sparse FIR filtering */ + for ( bin = 0; bin < hReverb->numBins; bin++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + /* These tap pointers have been determined to point to the loop buffer at sparse locations */ + tapRealPr = hReverb->tapPointersReal[bin][ch]; + tapImagPr = hReverb->tapPointersImag[bin][ch]; + phaseShiftTypePr = hReverb->tapPhaseShiftType[bin][ch]; + + /* Flush output */ + set_f( hReverb->outputBufferReal[bin][ch], 0.0f, hReverb->blockSize ); + set_f( hReverb->outputBufferImag[bin][ch], 0.0f, hReverb->blockSize ); + + /* Add from temporally decaying sparse tap locations the audio to the output. */ + for ( tapIdx = 0; tapIdx < hReverb->taps[bin][ch]; tapIdx++ ) + { + switch ( phaseShiftTypePr[tapIdx] ) + { + case 0: /* 0 degrees phase */ + v_add( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); + v_add( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); + break; + case 1: /* 90 degrees phase */ + v_sub( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); + v_add( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); + break; + case 2: /* 180 degrees phase */ + v_sub( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); + v_sub( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); + break; + default: /* 270 degrees phase */ + v_add( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); + v_sub( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); + break; + } + } + } + + /* Generate diffuse field binaural coherence by mixing the incoherent reverberated channels with pre-defined gains */ + if ( bin <= hReverb->highestBinauralCoherenceBin ) + { + if ( hReverb->useBinauralCoherence ) + { + for ( sample = 0; sample < hReverb->blockSize; sample++ ) + { + float leftRe, rightRe, leftIm, rightIm; + + leftRe = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferReal[bin][0][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferReal[bin][1][sample]; + rightRe = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferReal[bin][1][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferReal[bin][0][sample]; + leftIm = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferImag[bin][0][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferImag[bin][1][sample]; + rightIm = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferImag[bin][1][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferImag[bin][0][sample]; + + hReverb->outputBufferReal[bin][0][sample] = leftRe; + hReverb->outputBufferReal[bin][1][sample] = rightRe; + hReverb->outputBufferImag[bin][0][sample] = leftIm; + hReverb->outputBufferImag[bin][1][sample] = rightIm; + } + } + } + } + + /* 4) Write data to output */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + for ( sample = 0; sample < hReverb->blockSize; sample++ ) + { + uint16_t sampleWithOffset; + + sampleWithOffset = sample + offsetSamplesIO; + /* Audio was in the temporally inverted order for convolution, re-invert audio to output */ + invertSampleIndex = hReverb->blockSize - sample - 1; + + for ( bin = 0; bin < hReverb->numBins; bin++ ) + { + outReal[ch][sampleWithOffset][bin] = hReverb->outputBufferReal[bin][ch][invertSampleIndex]; + outImag[ch][sampleWithOffset][bin] = hReverb->outputBufferImag[bin][ch][invertSampleIndex]; + } + for ( ; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) + { + outReal[ch][sampleWithOffset][bin] = 0.0f; + outImag[ch][sampleWithOffset][bin] = 0.0f; + } + } + } + + return; +} + + +/*------------------------------------------------------------------------- + * ivas_binaural_reverb_open() + * + * Allocate and initialize binaural room reverberator handle + *------------------------------------------------------------------------*/ + +ivas_error ivas_binaural_reverb_open( + REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ + const int16_t numBins, /* i : number of CLDFB bins */ + const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ + ivas_roomAcoustics_t *roomAcoustics, /* i/o: room acoustics parameters */ + const AUDIO_CONFIG output_config, /* i : output audio configuration */ + const int32_t sampling_rate, /* i : sampling rate */ + const RENDERER_TYPE renderer_type /* i : renderer type */ +#ifdef HRTF_BINARY_FILE + , + const HRTFS_FASTCONV_HANDLE hHrtfFastConv, /* i : FastConv HRTF handle */ + const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ +#endif +) +{ + int16_t bin, chIdx, k, len; + REVERB_STRUCT_HANDLE hReverb; + const float *revTimes; + float t60[CLDFB_NO_CHANNELS_MAX]; + float ene[CLDFB_NO_CHANNELS_MAX]; + + if ( ( *hReverbPr = (REVERB_STRUCT_HANDLE) malloc( sizeof( REVERB_STRUCT ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); + } + + hReverb = *hReverbPr; + + hReverb->useBinauralCoherence = 1; + hReverb->preDelayBufferLength = 1; + hReverb->preDelayBufferIndex = 0; + + hReverb->numBins = numBins; + hReverb->blockSize = numCldfbSlotsPerFrame; + + for ( k = 0; k < REVERB_PREDELAY_MAX + 1; k++ ) + { + set_f( hReverb->preDelayBufferReal[k], 0.0f, hReverb->numBins ); + set_f( hReverb->preDelayBufferImag[k], 0.0f, hReverb->numBins ); + } + + if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + if ( !roomAcoustics->override ) + { +#ifdef HRTF_BINARY_FILE + revTimes = hHrtfFastConv->fastconvReverberationTimes; +#else + revTimes = fastconvReverberationTimes; +#endif + } + else + { + revTimes = t60; + } + } + else + { +#ifdef HRTF_BINARY_FILE + revTimes = hHrtfParambin->parametricReverberationTimes; +#else + revTimes = parametricReverberationTimes; +#endif + } + + for ( bin = 0; bin < hReverb->numBins; bin++ ) + { + /* Loop Buffer */ + hReverb->loopBufLengthMax[bin] = (int16_t) ( 500 / ( 1 + bin ) + ( CLDFB_NO_CHANNELS_MAX - bin ) ); + + len = hReverb->loopBufLengthMax[bin] + hReverb->blockSize; + if ( ( hReverb->loopBufReal[bin] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); + } + + if ( ( hReverb->loopBufImag[bin] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); + } + + set_f( hReverb->loopBufReal[bin], 0.0f, len ); + set_f( hReverb->loopBufImag[bin], 0.0f, len ); + + /* Determine loop buffer length. The following formula is manually tuned to generate sufficiently long + * but not excessively long loops to generate reverberation. */ + /* Note: the resulted length is very sensitive to the precision of the constants below (e.g. 1.45 vs. 1.45f) */ + hReverb->loopBufLength[bin] = (int16_t) ( 1.45 * (int16_t) ( revTimes[bin] * 150.0 ) + 1 ); + hReverb->loopBufLength[bin] = min( hReverb->loopBufLength[bin], hReverb->loopBufLengthMax[bin] ); + + /* Sparse Filter Tap Locations */ + for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + len = hReverb->loopBufLength[bin]; + + if ( ( hReverb->tapPhaseShiftType[bin][chIdx] = (int16_t *) malloc( len * sizeof( int16_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); + } + set_s( hReverb->tapPhaseShiftType[bin][chIdx], 0, len ); + + if ( ( hReverb->tapPointersReal[bin][chIdx] = (float **) malloc( len * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); + } + + if ( ( hReverb->tapPointersImag[bin][chIdx] = (float **) malloc( len * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); + } + + len = hReverb->blockSize; + if ( ( hReverb->outputBufferReal[bin][chIdx] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); + } + + if ( ( hReverb->outputBufferImag[bin][chIdx] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); + } + + set_f( hReverb->outputBufferReal[bin][chIdx], 0.0f, len ); + set_f( hReverb->outputBufferImag[bin][chIdx], 0.0f, len ); + } + } + + if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + if ( !roomAcoustics->override ) + { +#ifdef HRTF_BINARY_FILE + ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, hHrtfFastConv->fastconvReverberationTimes, hHrtfFastConv->fastconvReverberationEneCorrections ); +#else + ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, fastconvReverberationTimes, fastconvReverberationEneCorrections ); +#endif + ivas_binaural_reverb_setPreDelay( hReverb, 10 ); + } + else + { +#ifdef HRTF_BINARY_FILE + ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfFastConv, output_config, roomAcoustics->use_brir, sampling_rate, t60, ene ); +#else + ivas_reverb_prepare_cldfb_params( roomAcoustics, output_config, roomAcoustics->use_brir, sampling_rate, t60, ene ); +#endif + ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, t60, ene ); + ivas_binaural_reverb_setPreDelay( hReverb, (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ) ); + } + } + else + { +#ifdef HRTF_BINARY_FILE + ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections ); +#else + ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, parametricReverberationTimes, parametricReverberationEneCorrections ); +#endif + ivas_binaural_reverb_setPreDelay( hReverb, 10 ); + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * ivas_binaural_reverb_close() + * + * Close binaural room reverberator handle + *------------------------------------------------------------------------*/ + +void ivas_binaural_reverb_close( + REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ +) +{ + int16_t bin, chIdx; + + if ( hReverb == NULL || *hReverb == NULL ) + { + return; + } + + for ( bin = 0; bin < ( *hReverb )->numBins; bin++ ) + { + for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + free( ( *hReverb )->tapPhaseShiftType[bin][chIdx] ); + free( ( *hReverb )->tapPointersReal[bin][chIdx] ); + free( ( *hReverb )->tapPointersImag[bin][chIdx] ); + free( ( *hReverb )->outputBufferReal[bin][chIdx] ); + free( ( *hReverb )->outputBufferImag[bin][chIdx] ); + } + free( ( *hReverb )->loopBufReal[bin] ); + free( ( *hReverb )->loopBufImag[bin] ); + } + + free( ( *hReverb ) ); + ( *hReverb ) = NULL; + + return; +} diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 8bdf5b5eb2..564fc91340 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -198,51 +198,6 @@ void rotateAziEle( } -/*------------------------------------------------------------------------- - * rotateAziEle_DirAC() - * - * Apply rotation to DirAC DOAs - *------------------------------------------------------------------------*/ - -void rotateAziEle_DirAC( - int16_t *azi, /* i/o: array of azimuth values */ - int16_t *ele, /* i/o: array of elevation values */ - const int16_t band1, /* i : bands to work on (lower limit) */ - const int16_t band2, /* i : bands to work on (upper bound) */ - const float *p_Rmat /* i : pointer to real-space rotation matrix */ -) -{ - int16_t b; - float dv_0, dv_1, dv_2; - float dv_r_0, dv_r_1, dv_r_2; - float w; - - push_wmops( "rotateAziEle_DirAC" ); - - for ( b = band1; b < band2; b++ ) - { - - /*Conversion spherical to cartesian coordinates*/ - w = cosf( ele[b] * PI_OVER_180 ); - dv_0 = w * cosf( azi[b] * PI_OVER_180 ); - dv_1 = w * sinf( azi[b] * PI_OVER_180 ); - dv_2 = sinf( ele[b] * PI_OVER_180 ); - - dv_r_0 = p_Rmat[0] * dv_0 + p_Rmat[1] * dv_1 + p_Rmat[2] * dv_2; - dv_r_1 = p_Rmat[3] * dv_0 + p_Rmat[4] * dv_1 + p_Rmat[5] * dv_2; - dv_r_2 = p_Rmat[6] * dv_0 + p_Rmat[7] * dv_1 + p_Rmat[8] * dv_2; - - /*Conversion spherical to cartesian coordinates*/ - azi[b] = (int16_t) ( atan2f( dv_r_1, dv_r_0 ) * _180_OVER_PI ); - ele[b] = (int16_t) ( atan2f( dv_r_2, sqrtf( dv_r_0 * dv_r_0 + dv_r_1 * dv_r_1 ) ) * _180_OVER_PI ); - } - - pop_wmops(); - - return; -} - - /*------------------------------------------------------------------------- * rotateFrame_shd() * diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index d71edf724a..840fedbd3d 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -49,292 +49,6 @@ static void ivas_sba_mtx_mult( float output_f[][L_FRAME48k], const int16_t output_frame, const int16_t nchan_in, const IVAS_OUTPUT_SETUP output_setup, const float *mtx_hoa_decoder ); -#ifdef DEBUG_MODE_DIRAC -static void debug_mode_dirac( float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], const int16_t nchan_transport, const int16_t output_frame ); -#endif - - -/*-------------------------------------------------------------------------* - * ivas_mc2sba() - * - * MC signals transformed into SBA in TD domain - *-------------------------------------------------------------------------*/ -// VE2AT: should be defined in lib_dec -void ivas_mc2sba( - IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ - float buffer_td[][L_FRAME48k], /* i/o: MC signals (on input) and the HOA3 (on output) */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const float gain_lfe /* i : gain for LFE, 0 = ignore LFE */ -) -{ - int16_t i, j, k; - int16_t idx_lfe, idx_in; - float buffer_tmp[16][L_FRAME48k]; - float gains[16]; - int16_t azimuth, elevation; - int16_t sba_num_chans; - - assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); - - /* Init*/ - sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); - for ( j = 0; j < sba_num_chans; j++ ) - { - set_zero( buffer_tmp[j], output_frame ); - } - - /* HOA encoding*/ - idx_lfe = 0; - idx_in = 0; - for ( i = 0; i < hIntSetup.nchan_out_woLFE + hIntSetup.num_lfe; i++ ) - { - if ( ( hIntSetup.num_lfe > 0 ) && ( i == hIntSetup.index_lfe[idx_lfe] ) ) - { - if ( gain_lfe > 0.f ) - { - /* Add LFE to omni W with gain*/ - for ( k = 0; k < output_frame; k++ ) - { - buffer_tmp[0][k] += gain_lfe * buffer_td[i][k]; - } - } - - if ( idx_lfe < ( hIntSetup.num_lfe - 1 ) ) - { - idx_lfe++; - } - } - else - { - azimuth = (int16_t) ( hIntSetup.ls_azimuth[idx_in] ); - elevation = (int16_t) ( hIntSetup.ls_elevation[idx_in] ); - idx_in++; - - /* get HOA response for direction (ACN/SN3D)*/ - ivas_dirac_dec_get_response( - azimuth, - elevation, - gains, - sba_order ); - - for ( j = 0; j < sba_num_chans; j++ ) - { - for ( k = 0; k < output_frame; k++ ) - { - buffer_tmp[j][k] += gains[j] * buffer_td[i][k]; - } - } - } - } - - for ( j = 0; j < sba_num_chans; j++ ) - { - mvr2r( buffer_tmp[j], buffer_td[j], output_frame ); - } - - return; -} - - -/*-------------------------------------------------------------------------* - * ivas_sba2MC_cldfb() - * - * SBA signals transformed into MC in CLDFB domain - *-------------------------------------------------------------------------*/ - -void ivas_sba2mc_cldfb( - IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */ - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part */ - const int16_t nb_channels_out, /* i : nb of output channels */ - const int16_t nb_bands, /* i : nb of CLDFB bands to process */ - const float *hoa_dec_mtx /* i : HOA decoding mtx */ -) -{ - int16_t iBlock, iBand, n, m; - float realOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX], imagOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX]; - float g; - float *p_real, *p_imag, *p_realOut, *p_imagOut; - int16_t nb_channels_in; - - push_wmops( "ivas_sba2mc_cldfb" ); - - nb_channels_in = hInSetup.nchan_out_woLFE; - assert( ( nb_channels_in == 16 ) && ( nb_channels_out == 11 ) && "ivas_sba2mc_cldfb; only HOA3 to CICP19 is for now supported!" ); - - for ( n = 0; n < nb_channels_out; n++ ) - { - set_zero( realOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands ); - set_zero( imagOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands ); - - for ( m = 0; m < nb_channels_in; m++ ) - { - g = hoa_dec_mtx[SBA_NHARM_HOA3 * n + m]; - p_realOut = realOut[n]; - p_imagOut = imagOut[n]; - for ( iBlock = 0; iBlock < MAX_PARAM_SPATIAL_SUBFRAMES; iBlock++ ) - { - p_real = RealBuffer[m][iBlock]; - p_imag = ImagBuffer[m][iBlock]; - for ( iBand = 0; iBand < nb_bands; iBand++ ) - { - *p_realOut = *p_realOut + g * *( p_real++ ); - *p_imagOut = *p_imagOut + g * *( p_imag++ ); - p_realOut++; - p_imagOut++; - } - } - } - } - - for ( n = 0; n < nb_channels_out; n++ ) - { - p_realOut = realOut[n]; - p_imagOut = imagOut[n]; - for ( iBlock = 0; iBlock < MAX_PARAM_SPATIAL_SUBFRAMES; iBlock++ ) - { - p_real = RealBuffer[n][iBlock]; - p_imag = ImagBuffer[n][iBlock]; - for ( iBand = 0; iBand < nb_bands; iBand++ ) - { - *( p_real++ ) = *p_realOut++; - *( p_imag++ ) = *p_imagOut++; - } - } - } - - pop_wmops(); - - return; -} - -/*-------------------------------------------------------------------* - * ivas_sba_remapTCs() - * - * Get TCs from Ambisonics signal in ACN - *-------------------------------------------------------------------*/ -// VE2AT: should be defined in lib_dec -int16_t ivas_sba_remapTCs( - float sba_data[][L_FRAME48k], /* i/o: SBA signals */ - Decoder_Struct *st_ivas, /* i/o: decoder struct */ - const int16_t output_frame /* i : frame length */ -) -{ - int16_t nchan_remapped; - -#ifdef DEBUG_MODE_DIRAC - debug_mode_dirac( sba_data, st_ivas->nchan_transport, output_frame ); -#endif - - nchan_remapped = st_ivas->nchan_transport; - if ( ( st_ivas->sba_mode != SBA_MODE_SPAR && st_ivas->sba_planar && nchan_remapped >= 3 ) || - ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && nchan_remapped == 3 ) ) - { - - nchan_remapped++; - if ( st_ivas->sba_mode != SBA_MODE_SPAR ) - { - assert( ( ( st_ivas->nchan_transport == 3 ) || ( st_ivas->nchan_transport == 5 ) || ( st_ivas->nchan_transport == 7 ) ) && "Number of channels must be odd for SBA planar!" ); - } - - if ( nchan_remapped == 4 ) - { - /*For planar A-format channel 2 and 3 are identical -> Z=0*/ - mvr2r( sba_data[2], sba_data[3], output_frame ); - } - } - - if ( st_ivas->nchan_transport >= 3 ) - { - int16_t i = 0; - float temp; - - /*convert WYXZ downmix to WYZX*/ - for ( i = 0; i < output_frame; i++ ) - { - temp = sba_data[2][i]; - sba_data[2][i] = sba_data[3][i]; - sba_data[3][i] = temp; - if ( st_ivas->nchan_transport == 3 ) - { - sba_data[2][i] = 0; - } - } - } - - if ( st_ivas->sba_mode != SBA_MODE_SPAR ) - { - ivas_sba_zero_vert_comp( sba_data, st_ivas->sba_analysis_order, st_ivas->sba_planar, output_frame ); - } - - return ( nchan_remapped ); -} - - -/*-------------------------------------------------------------------------* - * ivas_ism2sba() - * - * ISM transformed into SBA in TD domain. - *-------------------------------------------------------------------------*/ -// VE2AT: should be defined in lib_dec -void ivas_ism2sba( - float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ - ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ - const ISM_METADATA_HANDLE hIsmMetaData[], /* i : object metadata */ - const int16_t num_objects, /* i : number of objects */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ -) -{ - int16_t i, j, k; - float buffer_tmp[16][L_FRAME48k]; - float gains[16]; - float g1, g2; - int16_t azimuth, elevation; - int16_t sba_num_chans; - - assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); - assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" ); - - /* Init*/ - sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); - for ( j = 0; j < sba_num_chans; j++ ) - { - set_zero( buffer_tmp[j], output_frame ); - } - - for ( i = 0; i < num_objects; i++ ) - { - // TODO tmu review when #215 is resolved - azimuth = (int16_t) floorf( hIsmMetaData[i]->azimuth + 0.5f ); - elevation = (int16_t) floorf( hIsmMetaData[i]->elevation + 0.5f ); - - /*get HOA gets for direction (ACN/SN3D)*/ - ivas_dirac_dec_get_response( azimuth, elevation, gains, sba_order ); - - for ( j = 0; j < sba_num_chans; j++ ) - { - g1 = 1.f; - g2 = 0.f; - for ( k = 0; k < output_frame; k++ ) - { - buffer_tmp[j][k] += ( g2 * gains[j] + g1 * hIsmRendererData->prev_gains[i][j] ) * buffer_td[i][k]; - g2 += 1.f / ( output_frame - 1 ); - g1 = 1.0f - g2; - } - hIsmRendererData->prev_gains[i][j] = gains[j]; - } - } - - for ( j = 0; j < sba_num_chans; j++ ) - { - mvr2r( buffer_tmp[j], buffer_td[j], output_frame ); - } - - return; -} - /*-------------------------------------------------------------------* * ivas_sba_linear_renderer() @@ -482,117 +196,12 @@ static void ivas_sba_mtx_mult( } -/*-------------------------------------------------------------------* - * ivas_sba_upmixer_renderer() - * - * SBA upmix & rendering - *-------------------------------------------------------------------*/ -// VE2AT: should be defined in lib_dec -void ivas_sba_upmixer_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float output[][L_FRAME48k], /* i/o: transport/output audio channels */ - const int16_t output_frame /* i : output frame length */ -) -{ - int16_t i, nchan_internal; - float temp; - - push_wmops( "ivas_sba_upmixer_renderer" ); - - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); - - if ( st_ivas->nchan_transport >= 3 ) - { - /*convert WYZX downmix to WYXZ*/ - for ( i = 0; i < output_frame; i++ ) - { - temp = output[2][i]; - output[2][i] = output[3][i]; - output[3][i] = temp; - } - } - - /* Upmixer + Renderer */ - ivas_spar_dec_upmixer( st_ivas, output, nchan_internal, output_frame ); - - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) - { - ivas_sba_linear_renderer( output, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); - } - - pop_wmops(); - - return; -} - - -/*-------------------------------------------------------------------* - * ivas_sba_mix_matrix_determiner() - * - * Determine SBA mixing matrices - *-------------------------------------------------------------------*/ -// VE2AT: should be defined in lib_dec -void ivas_sba_mix_matrix_determiner( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - float output[][L_FRAME48k], /* i/o: transport/output audio channels */ - const int16_t bfi, /* i : BFI flag */ - const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ - const int16_t output_frame /* i : output frame length */ -) -{ - int16_t i, ch; - float temp; - int16_t num_bands_out, nchan_transport, nchan_out; - - /* Convert numeric range */ - for ( ch = 0; ch < nchan_remapped; ch++ ) - { - for ( i = 0; i < output_frame; i++ ) - { - temp = output[ch][i]; - temp = floorf( temp + 0.5f ); - - if ( temp > MAX16B_FLT ) - { - temp = MAX16B_FLT; - } - else if ( temp < ( -1.0f * PCM16_TO_FLT_FAC ) ) - { - temp = ( -1.0f * PCM16_TO_FLT_FAC ); - } - temp *= ( 1.0f / PCM16_TO_FLT_FAC ); - output[ch][i] = temp; - } - } - - /* AGC */ - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - nchan_out = nchan_transport; - ivas_agc_dec_process( hSpar->hAgcDec, output, output, nchan_transport, output_frame ); - - /* Convert numeric range back */ - for ( ch = 0; ch < nchan_out; ch++ ) - { - for ( i = 0; i < output_frame; i++ ) - { - output[ch][i] = output[ch][i] * PCM16_TO_FLT_FAC; - } - } - - /* Mixing matrix determiner */ - num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; - ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi ); - - return; -} - - /*-------------------------------------------------------------------* * ivas_sba_prototype_renderer() * * Render prototype audio signals using SBA mixing matrices *-------------------------------------------------------------------*/ -// VE2AT: should be defined in lib_dec + void ivas_sba_prototype_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ @@ -745,44 +354,3 @@ void ivas_sba_prototype_renderer( return; } - -#ifdef DEBUG_MODE_DIRAC -/*-----------------------------------------------------------------------* - * Debugging function - *-----------------------------------------------------------------------*/ - -static void debug_mode_dirac( - float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], - const int16_t nchan_transport, - const int16_t output_frame ) -{ - int16_t i, n; - int16_t tmp[L_FRAME48k]; - char file_name[50] = { 0 }; - -#ifdef DEBUG_MODE_DIRAC_NOCORE - for ( n = 0; n < nchan_transport; n++ ) - { - sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); - dbgread( tmp, sizeof( int16_t ), output_frame, file_name ); - for ( i = 0; i < output_frame; i++ ) - { - output[n][i] = (float) ( tmp[i] ); - } - } -#else - for ( n = 0; n < nchan_transport; n++ ) - { - for ( i = 0; i < output_frame; i++ ) - { - tmp[i] = (int16_t) ( output[n][i] + 0.5f ); - } - - sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); - dbgwrite( tmp, sizeof( int16_t ), output_frame, 1, file_name ); - } -#endif - - return; -} -#endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 634c260934..a6e48c0996 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -34,6 +34,7 @@ #include "ivas_cnst.h" #include "lib_rend.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "ivas_rom_rend.h" @@ -5269,7 +5270,7 @@ int32_t IVAS_REND_GetCntFramesLimited( *-------------------------------------------------------------------*/ #ifdef FIX_197_CREND_INTERFACE -ivas_error ivas_rend_initEfap( +ivas_error ivas_rend_initEfap( // VE2AT: this fucntionis not used - could it be removed? AUDIO_CONFIG outConfig, EFAP_HANDLE *hEfap ) { @@ -5277,11 +5278,13 @@ ivas_error ivas_rend_initEfap( IVAS_REND_AudioConfig audioCfg; EFAP_WRAPPER wrap; LSSETUP_CUSTOM_STRUCT customLsOut; + wrap.hEfap = NULL; wrap.pCustomLsSetup = NULL; audioCfg = getRendAudioConfigFromIvasAudioConfig( outConfig ); memset( &customLsOut, 0, sizeof( LSSETUP_CUSTOM_STRUCT ) ); err = initEfap( &wrap, audioCfg, &customLsOut ); + *hEfap = wrap.hEfap; return err; -- GitLab From 4a1d2261ab15a432c150621a6f002e4b16683493 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Feb 2023 11:34:54 +0100 Subject: [PATCH 09/40] move function declarations to appropriate libraries --- lib_com/ivas_prot.h | 11 +---------- lib_dec/ivas_hrtf.c | 2 +- lib_dec/ivas_mc_param_dec.c | 1 + lib_dec/ivas_out_setup_conversion.c | 1 + lib_dec/ivas_spar_decoder.c | 1 + lib_dec/lib_dec.c | 1 + lib_rend/ivas_limiter.c | 2 +- lib_rend/ivas_prot_rend.h | 14 ++++++++++++++ lib_rend/ivas_stat_rend.h | 2 +- lib_rend/lib_rend.c | 2 +- 10 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 61d6afdda7..524df4b3de 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4496,17 +4496,8 @@ void ivas_spar_param_to_masa_param_mapping( * output setup prototypes *----------------------------------------------------------------------------------*/ -/*! r: number of output channels */ -int16_t audioCfg2channels( - const AUDIO_CONFIG output_config /* i : output audio configuration */ -); - -void ivas_output_init( - IVAS_OUTPUT_SETUP *hOutSetup, /* o : output setup structure */ - const AUDIO_CONFIG output_config /* i : output audio configuration */ -); -// VE2AT: this fucntion is used in lib_rend at one place - the fucntion ivas_rend_initEfap() is however not used; wh +// VE2AT: this function is used in lib_rend at one place - the function ivas_rend_initEfap() is however not used; where is its best place? // VE2AT: rename it IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( AUDIO_CONFIG config diff --git a/lib_dec/ivas_hrtf.c b/lib_dec/ivas_hrtf.c index 338de7e14b..a5c972881f 100644 --- a/lib_dec/ivas_hrtf.c +++ b/lib_dec/ivas_hrtf.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -//VE2AT: this file functions are called from lib_dec only; is it expected? +// VE2AT: this file functions are called from lib_dec only; is it expected? #include #include "options.h" #include "prot.h" diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 541fa3b7c6..745e9c04ff 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -38,6 +38,7 @@ #include "rom_com.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index cc6688732a..787ceaaf44 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -36,6 +36,7 @@ #include #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" #ifdef DEBUGGING diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 2eff5d2cba..cb4e701ac2 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -39,6 +39,7 @@ #include "prot.h" #include "string.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_stat_com.h" #include diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 038385033a..d9e12a2222 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -32,6 +32,7 @@ #include "lib_dec.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "prot.h" #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter.c index 19b1a828b7..3c4850b988 100644 --- a/lib_rend/ivas_limiter.c +++ b/lib_rend/ivas_limiter.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: keep in lib_rend or move to lib_dec ? + #include #include #include diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index a034adf214..ab73283634 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -135,6 +135,20 @@ ivas_error ivas_rend_crendConvolver( #endif +/*----------------------------------------------------------------------------------* + * output setup prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: number of output channels */ +int16_t audioCfg2channels( + const AUDIO_CONFIG output_config /* i : output audio configuration */ +); + +void ivas_output_init( + IVAS_OUTPUT_SETUP *hOutSetup, /* o : output setup structure */ + const AUDIO_CONFIG output_config /* i : output audio configuration */ +); + /*----------------------------------------------------------------------------------* * SBA rendering diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index e819fc9b42..81a43fd476 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -147,7 +147,7 @@ typedef struct /*----------------------------------------------------------------------------------* * Binaural Rendering structure *----------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? + /* Binaural reverberator structure */ typedef struct ivas_binaural_reverb_struct { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index a6e48c0996..4ce7437f04 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -321,7 +321,7 @@ static int32_t limitRendererOutput( #ifdef FIX_197_CREND_INTERFACE AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( #else -static AUDIO_CONFIG rendAudioConfigToIvasAudioConfig( // VE2AT: similar is defined again at line 397, why? +static AUDIO_CONFIG rendAudioConfigToIvasAudioConfig( #endif IVAS_REND_AudioConfig rendConfig ) { -- GitLab From 706e5e123c6eff1aae874e272fbd36e727d39a87 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Feb 2023 11:50:42 +0100 Subject: [PATCH 10/40] - move structures to appropriate libraries - revisit VE2AT comments --- lib_com/ivas_prot.h | 2 +- lib_dec/ivas_stat_dec.h | 129 +++++++++++++++++++++++++++++++-- lib_dec/ivas_vbap.c | 20 ++++++ lib_rend/ivas_output_init.c | 2 +- lib_rend/ivas_stat_rend.h | 140 ++---------------------------------- 5 files changed, 148 insertions(+), 145 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 524df4b3de..2f86907148 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4498,7 +4498,7 @@ void ivas_spar_param_to_masa_param_mapping( // VE2AT: this function is used in lib_rend at one place - the function ivas_rend_initEfap() is however not used; where is its best place? -// VE2AT: rename it +// VE2AT: possibly rename it IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( AUDIO_CONFIG config ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index dab905865d..7280bc0227 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -41,7 +41,7 @@ #include "ivas_stat_com.h" #include "ivas_stat_rend.h" #ifndef FIX_197_CREND_INTERFACE -#include "common_api_types.h" // VE2AT: don't we want to avoid this include in the library? I admit that the rules hefre are not 100% clear to me but introducing it just for IVAS_QUATERNION is not necessry I think +#include "common_api_types.h" #endif #ifndef FIX_197_CREND_INTERFACE @@ -820,6 +820,22 @@ typedef struct ivas_spar_md_dec_state_t int16_t spar_hoa_md_flag; } ivas_spar_md_dec_state_t; +/* AGC structure */ +typedef struct ivas_agc_dec_chan_state_t +{ + float lastGain; + int16_t gainExpVal; + +} ivas_agc_dec_chan_state_t; + +typedef struct ivas_agc_dec_state_t +{ + ivas_agc_com_state_t agc_com; + ivas_agc_dec_chan_state_t *gain_state; + ivas_agc_chan_data_t *gain_data; + +} ivas_agc_dec_state_t; + #ifndef FIX_197_CREND_INTERFACE /* AGC structure */ @@ -993,12 +1009,111 @@ typedef struct mct_dec_data_structure } MCT_DEC_DATA, *MCT_DEC_HANDLE; + +/*----------------------------------------------------------------------------------* + * LFE decoder structure + *----------------------------------------------------------------------------------*/ + +typedef struct ivas_lfe_dec_data_structure +{ + ivas_filters_process_state_t filter_state; + LFE_WINDOW_HANDLE pWindow_state; + const uint16_t *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS]; + int16_t lfe_dec_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS]; + float lfe_block_delay_s; + int16_t lfe_prior_buf_len; + float *prior_out_buffer; + + float *prevsynth_buf; + float *lfe_delay_buf; + int16_t lfe_addl_delay; + int16_t bfi_count; + +} LFE_DEC_DATA, *LFE_DEC_HANDLE; + + +// VE2AT: the following structures are used only in lib_dec; is it expected? +/*----------------------------------------------------------------------------------* + * VBAP structures + *----------------------------------------------------------------------------------*/ + +/* Defines a single virtual surface triplet of loudspeakers + * with a precalculated inverse matrix */ +typedef struct vbap_vs_triplet_structure +{ + uint8_t speaker_node[3]; + float inverse_matrix[3][3]; + +} VBAP_VS_TRIPLET; + +/* Storage structure for fast runtime triplet search */ +typedef struct triplet_search_structure +{ + VBAP_VS_TRIPLET *triplets; + int16_t num_triplets; + int16_t initial_search_indices[VBAP_NUM_SEARCH_SECTORS]; + +} VBAP_SEARCH_STRUCT; + +/* VBAP data structure. Contains the formed virtual surface arrangement * and supporting data. */ +typedef struct vbap_data_structure +{ + VBAP_SEARCH_STRUCT search_struct[2]; /* Default to max two groups in this implementation */ + int16_t num_search_structs; + int16_t num_speaker_nodes; + int16_t num_speaker_nodes_internal; + int16_t top_virtual_speaker_node_index; /* These indices can be negative */ + int16_t bottom_virtual_speaker_node_index; + int16_t back_virtual_speaker_node_index; + float *bottom_virtual_speaker_node_division_gains; + float *top_virtual_speaker_node_division_gains; + float *back_virtual_speaker_node_division_gains; + +} VBAP_DATA, *VBAP_HANDLE; + + +/*----------------------------------------------------------------------------------* + * renderer structures + *----------------------------------------------------------------------------------*/ + +typedef struct renderer_struct +{ + float prev_gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS]; + float interpolator[L_FRAME48k]; + +} ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; + +/* Fastconv binaural data structure */ +typedef struct ivas_binaural_rendering_struct +{ + /* Common variables for all modules */ + IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/ + EFAP_HANDLE hEFAPdata; /* EFAP structure*/ + float *hoa_dec_mtx; /* pointer to HOA decoder mtx */ + int8_t rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ + int16_t max_band; /* band upto which rendering is performed */ + int16_t conv_band; /* band upto which convolution in cldfb domain is performed */ + int16_t timeSlots; /* number of time slots of binaural renderer */ + int16_t nInChannels; /* number input channels */ + int8_t render_lfe; /* Flag to render LFE in binaural rendering*/ + IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */ + + /* Convolution module structure */ + BINRENDERER_CONV_MODULE_HANDLE hBinRenConvModule; + + /* Variables related to reverb module */ + float earlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX]; + REVERB_STRUCT_HANDLE hReverb; + +} BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; + + #ifndef FIX_197_CREND_INTERFACE /*----------------------------------------------------------------------------------* * EFAP structures *----------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? +// typedef struct EFAP_VERTEX { float azi; /* azimuth of the loudspeaker */ @@ -1061,7 +1176,7 @@ typedef struct EFAP /*----------------------------------------------------------------------------------* * VBAP structures *----------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? +// enum SpeakerNodeGroup { SPEAKER_NODE_BOTTOM_HALF, @@ -1119,7 +1234,7 @@ typedef struct vbap_data_structure /*----------------------------------------------------------------------------------* * renderer structures *----------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? + typedef struct renderer_struct { float prev_gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS]; @@ -1187,7 +1302,7 @@ typedef struct ivas_masa_decoder_struct /*----------------------------------------------------------------------------------* * Binaural Rendering structure *----------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? + /* Binaural reverberator structure */ typedef struct ivas_binaural_reverb_struct { @@ -1347,7 +1462,7 @@ typedef struct ivas_binaural_rendering_struct /*----------------------------------------------------------------------------------* * Head tracking data structure *----------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? + typedef struct ivas_binaural_head_track_struct { @@ -1614,7 +1729,7 @@ typedef struct ivas_binaural_td_rendering_struct /*------------------------------------------------------------------------------------------* * Crend structures *------------------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? + typedef struct ivas_hrtfs_structure { float *pOut_to_bin_re[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; diff --git a/lib_dec/ivas_vbap.c b/lib_dec/ivas_vbap.c index cdd96210fa..9c595ea1fe 100644 --- a/lib_dec/ivas_vbap.c +++ b/lib_dec/ivas_vbap.c @@ -95,6 +95,26 @@ typedef struct connection_option float arc_weighted; } ConnectionOption; +enum SpeakerNodeGroup +{ + SPEAKER_NODE_BOTTOM_HALF, + SPEAKER_NODE_HORIZONTAL, + SPEAKER_NODE_TOP_HALF, + SPEAKER_NODE_BACK, + SPEAKER_NODE_ALL +}; + +/* Defines a single speaker node */ +typedef struct vbap_speaker_node_structure +{ + float azi_deg; + float ele_deg; + float unit_vec[3]; + enum SpeakerNodeGroup group; + +} VBAP_SPEAKER_NODE; + + /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 970e6a54cb..24beb242da 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: move these low-level fucntions to lib_com? +// VE2AT: move these low-level functions to lib_com? #include #include "options.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 81a43fd476..18d86716bc 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -186,24 +186,7 @@ typedef struct ivas_binaural_reverb_struct } REVERB_STRUCT, *REVERB_STRUCT_HANDLE; -// VE2AT: this should be ivas_stat_dec.h -/* AGC structure */ -typedef struct ivas_agc_dec_chan_state_t -{ - float lastGain; - int16_t gainExpVal; - -} ivas_agc_dec_chan_state_t; - -typedef struct ivas_agc_dec_state_t -{ - ivas_agc_com_state_t agc_com; - ivas_agc_dec_chan_state_t *gain_state; - ivas_agc_chan_data_t *gain_data; - -} ivas_agc_dec_state_t; -// VE2AT: this should be ivas_stat_dec.h /* TD decorr */ typedef struct ivas_td_decorr_APD_filt_state_t { @@ -226,7 +209,7 @@ typedef struct ivas_td_decorr_state_t } ivas_td_decorr_state_t; -// VE2AT: this should be ivas_stat_dec.h + /* Parametric binaural data structure */ typedef struct ivas_dirac_dec_binaural_data_structure { @@ -282,6 +265,7 @@ typedef struct ivas_binaural_rendering_conv_module_struct /*----------------------------------------------------------------------------------* * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...) *----------------------------------------------------------------------------------*/ + typedef struct ivas_output_setup_structure { AUDIO_CONFIG output_config; @@ -304,7 +288,7 @@ typedef struct ivas_output_setup_structure /*----------------------------------------------------------------------------------* * EFAP structures *----------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? + typedef struct EFAP_VERTEX { float azi; /* azimuth of the loudspeaker */ @@ -364,104 +348,9 @@ typedef struct EFAP } EFAP, *EFAP_HANDLE; -/*----------------------------------------------------------------------------------* - * VBAP structures - *----------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? -enum SpeakerNodeGroup -{ - SPEAKER_NODE_BOTTOM_HALF, - SPEAKER_NODE_HORIZONTAL, - SPEAKER_NODE_TOP_HALF, - SPEAKER_NODE_BACK, - SPEAKER_NODE_ALL -}; - -/* Defines a single virtual surface triplet of loudspeakers - * with a precalculated inverse matrix */ -typedef struct vbap_vs_triplet_structure -{ - uint8_t speaker_node[3]; - float inverse_matrix[3][3]; - -} VBAP_VS_TRIPLET; - -/* Defines a single speaker node */ -typedef struct vbap_speaker_node_structure -{ - float azi_deg; - float ele_deg; - float unit_vec[3]; - enum SpeakerNodeGroup group; - -} VBAP_SPEAKER_NODE; - -/* Storage structure for fast runtime triplet search */ -typedef struct triplet_search_structure -{ - VBAP_VS_TRIPLET *triplets; - int16_t num_triplets; - int16_t initial_search_indices[VBAP_NUM_SEARCH_SECTORS]; - -} VBAP_SEARCH_STRUCT; - -/* VBAP data structure. Contains the formed virtual surface arrangement * and supporting data. */ -typedef struct vbap_data_structure -{ - VBAP_SEARCH_STRUCT search_struct[2]; /* Default to max two groups in this implementation */ - int16_t num_search_structs; - int16_t num_speaker_nodes; - int16_t num_speaker_nodes_internal; - int16_t top_virtual_speaker_node_index; /* These indices can be negative */ - int16_t bottom_virtual_speaker_node_index; - int16_t back_virtual_speaker_node_index; - float *bottom_virtual_speaker_node_division_gains; - float *top_virtual_speaker_node_division_gains; - float *back_virtual_speaker_node_division_gains; - -} VBAP_DATA, *VBAP_HANDLE; - - -/*----------------------------------------------------------------------------------* - * renderer structures - *----------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? -typedef struct renderer_struct -{ - float prev_gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS]; - float interpolator[L_FRAME48k]; - -} ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; - -/* Fastconv binaural data structure */ -typedef struct ivas_binaural_rendering_struct -{ - /* Common variables for all modules */ - IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/ - EFAP_HANDLE hEFAPdata; /* EFAP structure*/ - float *hoa_dec_mtx; /* pointer to HOA decoder mtx */ - int8_t rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ - int16_t max_band; /* band upto which rendering is performed */ - int16_t conv_band; /* band upto which convolution in cldfb domain is performed */ - int16_t timeSlots; /* number of time slots of binaural renderer */ - int16_t nInChannels; /* number input channels */ - int8_t render_lfe; /* Flag to render LFE in binaural rendering*/ - IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */ - - /* Convolution module structure */ - BINRENDERER_CONV_MODULE_HANDLE hBinRenConvModule; - - /* Variables related to reverb module */ - float earlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX]; - REVERB_STRUCT_HANDLE hReverb; - -} BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; - - /*----------------------------------------------------------------------------------* * Head tracking data structure *----------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? typedef struct ivas_binaural_head_track_struct { @@ -861,7 +750,7 @@ typedef struct ivas_binaural_td_rendering_struct /*------------------------------------------------------------------------------------------* * Crend structures *------------------------------------------------------------------------------------------*/ -// VE2AT: move to ivas_rom_rend.h ? + typedef struct ivas_hrtfs_structure { float *pOut_to_bin_re[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; @@ -982,27 +871,6 @@ typedef struct ivas_hrtfs_parambin_struct #endif -/*----------------------------------------------------------------------------------* - * LFE decoder structure - *----------------------------------------------------------------------------------*/ -// VE2AT: this should be ivas_stat_dec.h -typedef struct ivas_lfe_dec_data_structure -{ - ivas_filters_process_state_t filter_state; - LFE_WINDOW_HANDLE pWindow_state; - const uint16_t *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS]; - int16_t lfe_dec_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS]; - float lfe_block_delay_s; - int16_t lfe_prior_buf_len; - float *prior_out_buffer; - - float *prevsynth_buf; - float *lfe_delay_buf; - int16_t lfe_addl_delay; - int16_t bfi_count; - -} LFE_DEC_DATA, *LFE_DEC_HANDLE; - /*----------------------------------------------------------------------------------* * Limiter structure -- GitLab From e252d752763480fc1363c5c41009e19470ef0394 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Feb 2023 12:59:09 +0100 Subject: [PATCH 11/40] revision of includes in lib_rend --- apps/decoder.c | 1 + lib_com/ivas_prot.h | 49 +------- lib_dec/ivas_rom_dec.c | 39 ------ lib_dec/ivas_rom_dec.h | 18 --- lib_dec/ivas_td_decorr.c | 2 +- lib_rend/ivas_allrad_dec.c | 1 + lib_rend/ivas_crend.c | 2 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 2 +- lib_rend/ivas_efap.c | 4 +- lib_rend/ivas_limiter.c | 10 +- lib_rend/ivas_objectRenderer.c | 2 +- lib_rend/ivas_objectRenderer_mix.c | 2 +- lib_rend/ivas_objectRenderer_sfx.c | 4 +- lib_rend/ivas_objectRenderer_vec.c | 3 +- lib_rend/ivas_orient_trk.c | 3 +- lib_rend/ivas_output_init.c | 1 + lib_rend/ivas_prot_rend.h | 124 ++++++++++++++----- lib_rend/ivas_render_config.c | 3 +- lib_rend/ivas_reverb.c | 2 +- lib_rend/ivas_reverb_delay_line.c | 1 + lib_rend/ivas_reverb_fft_filter.c | 6 +- lib_rend/ivas_reverb_filter_design.c | 4 +- lib_rend/ivas_reverb_iir_filter.c | 3 +- lib_rend/ivas_rom_rend.c | 37 ++++++ lib_rend/ivas_rom_rend.h | 15 +++ lib_rend/ivas_rotation.c | 2 +- lib_rend/ivas_sba_rendering.c | 1 + lib_rend/lib_rend.c | 3 +- lib_util/hrtf_file_reader.c | 64 +++++++--- lib_util/hrtf_file_reader.h | 13 +- 30 files changed, 229 insertions(+), 192 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index f018814423..c9b76a3cde 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -50,6 +50,7 @@ #endif #include "wmc_auto.h" #include "render_config_reader.h" +#include "hrtf_file_reader.h" #define WMC_TOOL_SKIP diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2f86907148..98c5f553c0 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -681,33 +681,6 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( const AUDIO_CONFIG output_config /* i : output audio configuration */ ); -/*! r: limiter struct handle */ -IVAS_LIMITER_HANDLE ivas_limiter_open( - const int16_t num_channels, /* i : number of I/O channels */ - const int32_t sampling_rate /* i : sampling rate for processing */ -); - -void ivas_limiter_close( - IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */ -); - -void ivas_limiter_dec -( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], /* i/o: input/output buffer */ - const int16_t num_channels, /* i : number of channels to be processed */ - const int16_t output_frame, /* i : number of samples per channel in the buffer */ - const int16_t BER_detect /* i : BER detect flag */ -); - -void limiter_process( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ - const float threshold, /* i : signal amplitude above which limiting starts to be applied */ - const int16_t BER_detect, /* i : BER detect flag */ - int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL) */ -); - void smooth_dft2td_transition( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ float output[CPE_CHANNELS][L_FRAME48k], /* i/o: synthesis @external Fs */ @@ -4588,7 +4561,7 @@ void ivas_ism2sba( /*----------------------------------------------------------------------------------* - * Amplitude Panning (EFAP, VBAP) prototypes + * Amplitude Panning VBAP prototypes *----------------------------------------------------------------------------------*/ void panning_wrap_angles( @@ -4598,26 +4571,6 @@ void panning_wrap_angles( float *ele_wrapped /* o : wrapped elevation component */ ); -ivas_error efap_init_data( - EFAP_HANDLE *hEFAPdata, /* i/o: handle for EFAP data structure that will be initialized */ - const float *speaker_node_azi_deg, /* i : vector of speaker node azimuths (positive left) */ - const float *speaker_node_ele_deg, /* i : vector of speaker node elevations (positive up) */ - const int16_t num_speaker_nodes, /* i : number of speaker nodes in the set */ - const int16_t efap_mode /* i : indicates whether EFAP or EFIP is used */ -); - -void efap_free_data( - EFAP_HANDLE *hEFAPdata /* i/o: EFAP handle to be freed */ -); - -void efap_determine_gains( - EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ - float *gains, /* o : gain vector for speaker nodes for given direction */ - const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ - const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ - const int16_t efap_mode /* i : indicates whether EFAP or EFIP is used */ -); - ivas_error vbap_init_data( VBAP_HANDLE *hVBAPdata, /* i/o: handle for VBAP data structure that will be initialized */ const float *speaker_node_azi_deg, /* i : vector of speaker node azimuths (positive left) */ diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 50ddf18839..1945d75bab 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -513,43 +513,4 @@ const int16_t sba_map_tc[8] = }; -/*----------------------------------------------------------------------------------* - * FASTCONV and PARAMETRIC binaural renderer ROM tables - *----------------------------------------------------------------------------------*/ - -const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = -{ - 3.0903f, 2.0053f, 1.0860f, 0.8072f, 0.7079f -}; - -const float spreadCohEne05[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = -{ - 2.3988f, 1.7783f, 1.1220f, 1.1220f, 1.1220f -}; - -const float spreadCohEne1[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = -{ - 1.5975f, 1.1220f, 1.1220f, 1.1220f, 1.1220f -}; - -const float lowBitRateBinauralEQ[LOW_BIT_RATE_BINAURAL_EQ_BINS] = -{ - 0.979f, 0.893f, 0.762f, 0.615f, 0.52f, 0.48f, 0.477f, 0.477f, 0.48f, 0.501f, 0.546f, 0.602f, 0.652f, 0.664f, 0.652f, 0.639f, 0.635f -}; - -const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS] = -{ - 0.047421f, 0.19773f, 0.22582f, 0.10637f, 0.0087111f, 0.012028f, 0.031972f, 0.019668f, 0.0079928f -}; - -const float diffuseFieldCoherenceDifferenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS] = -{ - -0.095628f, -0.30569f, -0.34427f, -0.15425f, -0.044628f, -0.057224f, -0.050835f, -0.035214f, -0.02215f -}; - -const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS] = -{ - 0.048207f, 0.10796f, 0.11845f, 0.047886f, 0.035917f, 0.045196f, 0.018863f, 0.015547f, 0.014157f -}; - /* clang-format on */ diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index 37302a25e5..99438d8d95 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -111,22 +111,4 @@ extern const float ap_split_frequencies[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]; extern const int16_t sba_map_tc[8]; -/*----------------------------------------------------------------------------------* - * FASTCONV and PARAMETRIC binaural renderer ROM tables - *----------------------------------------------------------------------------------*/ - -/* These are equalization values for spread and surround coherent sounds, approximating the spectrum - * for such sounds at anechoic multichannel listening. */ -extern const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; -extern const float spreadCohEne05[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; -extern const float spreadCohEne1[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; - -/* Values for low-bit-rate equalization */ -extern const float lowBitRateBinauralEQ[LOW_BIT_RATE_BINAURAL_EQ_BINS]; - -/* Diffuse field binaural coherence directional adjustment values */ -extern const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS]; -extern const float diffuseFieldCoherenceDifferenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS]; -extern const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS]; - #endif diff --git a/lib_dec/ivas_td_decorr.c b/lib_dec/ivas_td_decorr.c index 34f88aeb03..69c7132730 100644 --- a/lib_dec/ivas_td_decorr.c +++ b/lib_dec/ivas_td_decorr.c @@ -100,7 +100,7 @@ static ivas_error ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, const * * Allocate and initialize SPAR time domain decorrelator handle *------------------------------------------------------------------------*/ - +// VE2AT: this fucntion is used also in lib_rend...; where to put it? ivas_error ivas_spar_td_decorr_dec_open( ivas_td_decorr_state_t **hTdDecorr, /* i/o: SPAR Covar. decoder handle */ const int32_t output_Fs, /* i : output sampling rate */ diff --git a/lib_rend/ivas_allrad_dec.c b/lib_rend/ivas_allrad_dec.c index 3e8bcc179c..cb7651d44e 100644 --- a/lib_rend/ivas_allrad_dec.c +++ b/lib_rend/ivas_allrad_dec.c @@ -37,6 +37,7 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" //#include "ivas_stat_dec.h" #include "ivas_rom_rend.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 86df968ee1..e2f633e13f 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -37,7 +37,7 @@ #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" -#include "ivas_stat_dec.h" +//#include "ivas_stat_dec.h" #include #include "ivas_rom_binaural_crend_head.h" #ifdef FIX_197_CREND_INTERFACE diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index c389bfcad2..34bb1a7aa0 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -39,7 +39,7 @@ #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_binauralRenderer.h" -#include "ivas_rom_dec.h" +#include "ivas_rom_rend.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_rend/ivas_efap.c b/lib_rend/ivas_efap.c index 587046082d..afc27f04af 100644 --- a/lib_rend/ivas_efap.c +++ b/lib_rend/ivas_efap.c @@ -37,8 +37,9 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_stat_dec.h" -#include "ivas_rom_dec.h" +//#include "ivas_rom_dec.h" #ifdef DEBUGGING #include "debug.h" #endif @@ -101,6 +102,7 @@ static float vertex_distance( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGL static float point_plane_distance( const float P1[3], const float P2[3], const float P3[3], const float X[3] ); static float point_poly_distance( const EFAP_POLYSET poly, const float X[3] ); + static void efap_crossp( const float *v1, const float *v2, float *v ); static int16_t find_int_in_tri( const EFAP_LS_TRIANGLE *tri, const int16_t n, const int16_t r, int16_t *pos ); diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter.c index 3c4850b988..9f86416681 100644 --- a/lib_rend/ivas_limiter.c +++ b/lib_rend/ivas_limiter.c @@ -30,12 +30,14 @@ *******************************************************************************************************/ +#include +#include "options.h" #include -#include -#include - -#include "ivas_prot.h" +//#include +//#include #include "prot.h" +//#include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "wmc_auto.h" #include diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 52509cea43..d29d2c0e88 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot.h" -#include "ivas_prot.h" +//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index 7f088d6cd1..41545b1e57 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot.h" -#include "ivas_prot.h" +//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_TdBinauralRenderer.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index 7a9ddd6b85..a812b4640a 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -33,7 +33,8 @@ #include #include "options.h" #include -#include "ivas_prot.h" +//#include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "prot.h" #include "wmc_auto.h" @@ -47,6 +48,7 @@ /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ + static void sincResample( const float *input, float *output, const int16_t length_in, const int16_t length_out ); diff --git a/lib_rend/ivas_objectRenderer_vec.c b/lib_rend/ivas_objectRenderer_vec.c index 68d50bc559..e23c324912 100644 --- a/lib_rend/ivas_objectRenderer_vec.c +++ b/lib_rend/ivas_objectRenderer_vec.c @@ -33,8 +33,9 @@ #include #include "options.h" #include -#include "ivas_prot.h" #include "prot.h" +//#include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index df7d80bf60..070ffc9cfb 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -32,8 +32,9 @@ #include #include "options.h" -#include "prot.h" +//#include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_cnst.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 24beb242da..a85709f650 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -35,6 +35,7 @@ #include "ivas_cnst.h" //#include "ivas_prot.h" #include "prot.h" +#include "ivas_prot_rend.h" //#include "ivas_stat_dec.h" //#include "ivas_rom_dec.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index ab73283634..033db2e044 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -41,7 +41,7 @@ #else #include "lib_rend.h" #endif - +#include "ivas_stat_dec.h" // VE2AT: needed for Decoder_Struct; what to do with this? /* clang-format off */ @@ -149,6 +149,62 @@ void ivas_output_init( const AUDIO_CONFIG output_config /* i : output audio configuration */ ); +/*----------------------------------------------------------------------------------* + * Limiter prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: limiter struct handle */ +IVAS_LIMITER_HANDLE ivas_limiter_open( + const int16_t num_channels, /* i : number of I/O channels */ + const int32_t sampling_rate /* i : sampling rate for processing */ +); + +void ivas_limiter_close( + IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */ +); + +void ivas_limiter_dec +( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], /* i/o: input/output buffer */ + const int16_t num_channels, /* i : number of channels to be processed */ + const int16_t output_frame, /* i : number of samples per channel in the buffer */ + const int16_t BER_detect /* i : BER detect flag */ +); + +void limiter_process( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ + const float threshold, /* i : signal amplitude above which limiting starts to be applied */ + const int16_t BER_detect, /* i : BER detect flag */ + int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL) */ +); + + +/*----------------------------------------------------------------------------------* + * Amplitude Panning EFAP prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error efap_init_data( + EFAP_HANDLE *hEFAPdata, /* i/o: handle for EFAP data structure that will be initialized */ + const float *speaker_node_azi_deg, /* i : vector of speaker node azimuths (positive left) */ + const float *speaker_node_ele_deg, /* i : vector of speaker node elevations (positive up) */ + const int16_t num_speaker_nodes, /* i : number of speaker nodes in the set */ + const int16_t efap_mode /* i : indicates whether EFAP or EFIP is used */ +); + +void efap_free_data( + EFAP_HANDLE *hEFAPdata /* i/o: EFAP handle to be freed */ +); + +void efap_determine_gains( + EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ + float *gains, /* o : gain vector for speaker nodes for given direction */ + const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ + const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ + const int16_t efap_mode /* i : indicates whether EFAP or EFIP is used */ +); + /*----------------------------------------------------------------------------------* * SBA rendering @@ -196,19 +252,6 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ ); -void QuatToRotMat( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ -); - -void rotateAziEle( - float azi_in, /* i : output elevation */ - float ele_in, /* i : input elevation */ - int16_t *azi, /* o : rotated azimuth */ - int16_t *ele, /* o : rotated elevation */ - float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t isPlanar /* i : is roation planar and elevation meaningless? */ -); /*----------------------------------------------------------------------------------* * TD object renderer @@ -501,7 +544,6 @@ void ivas_binaural_reverb_processFrame( const uint8_t offsetSamplesIO /* i : number of offset samples */ ); - ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ @@ -700,37 +742,51 @@ void ivas_reverb_get_hrtf_set_properties( /*---------------------------------------------------------------------------------* - * Binaural Renderer Prototypes + * Rotation Prototypes *-----------------------------------------------------------------------------------*/ void Quat2Euler( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float *yaw, /* o : yaw */ - float *pitch, /* o : pitch */ - float *roll /* o : roll */ + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ +); + +void QuatToRotMat( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ +); + +void rotateAziEle( + float azi_in, /* i : output elevation */ + float ele_in, /* i : input elevation */ + int16_t *azi, /* o : rotated azimuth */ + int16_t *ele, /* o : rotated elevation */ + float Rmat[3][3], /* i : real-space rotation matrix */ + const int16_t isPlanar /* i : is roation planar and elevation meaningless? */ ); void SHrotmatgen( - float SHrotmat[SBA_NHARM_HOA3][SBA_NHARM_HOA3], /* o : SHD rotation matrix */ - float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t order /* i : ambisonics order */ + float SHrotmat[SBA_NHARM_HOA3][SBA_NHARM_HOA3], /* o : SHD rotation matrix */ + float Rmat[3][3], /* i : real-space rotation matrix */ + const int16_t order /* i : ambisonics order */ ); void rotateFrame_shd( - HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ - float output[][L_FRAME48k], /* i/o: unrotated HOA3 signal buffer in TD */ - const int16_t subframe_len, /* i : subframe length per channel */ - const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ - const int16_t subframe_idx /* i : subframe index */ + HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ + float output[][L_FRAME48k], /* i/o: unrotated HOA3 signal buffer in TD */ + const int16_t subframe_len, /* i : subframe length per channel */ + const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ + const int16_t subframe_idx /* i : subframe index */ ); void rotateFrame_sd( - HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ - float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */ - const int16_t subframe_len, /* i : subframe length per channel */ - const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ - const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ - const int16_t subframe_idx /* i : subframe index */ + HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ + float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */ + const int16_t subframe_len, /* i : subframe length per channel */ + const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ + const int16_t subframe_idx /* i : subframe index */ ); void rotateFrame_shd_cldfb( diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index a27fc58f2d..c6a42a4537 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -33,7 +33,8 @@ #include #include "options.h" #include "prot.h" -#include "ivas_prot.h" +//#include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "ivas_rom_TdBinauralRenderer.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 7d70e26b85..550a3e2951 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot.h" -#include "ivas_prot.h" +//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_reverb_delay_line.c b/lib_rend/ivas_reverb_delay_line.c index ef0ca8b6c1..892a0d21c9 100644 --- a/lib_rend/ivas_reverb_delay_line.c +++ b/lib_rend/ivas_reverb_delay_line.c @@ -33,6 +33,7 @@ #include #include "options.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "prot.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c index 8555d7d502..ef2dacf3a0 100644 --- a/lib_rend/ivas_reverb_fft_filter.c +++ b/lib_rend/ivas_reverb_fft_filter.c @@ -32,13 +32,13 @@ #include #include "options.h" -#include "ivas_prot.h" +#include "prot.h" +//#include "ivas_prot.h" +#include "ivas_prot_rend.h" #ifdef DEBUGGING #include "debug.h" #endif #include -#include "prot.h" -#include "ivas_prot_rend.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c index 097f06e515..5da6ca8ac1 100644 --- a/lib_rend/ivas_reverb_filter_design.c +++ b/lib_rend/ivas_reverb_filter_design.c @@ -32,7 +32,8 @@ #include #include "options.h" -#include "ivas_prot.h" +#include "prot.h" +//#include "ivas_prot.h" #include "ivas_prot_rend.h" #ifdef DEBUGGING #include "debug.h" @@ -40,7 +41,6 @@ #include #include #include -#include "prot.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_reverb_iir_filter.c b/lib_rend/ivas_reverb_iir_filter.c index db3534ee8a..fb52a5d2a2 100644 --- a/lib_rend/ivas_reverb_iir_filter.c +++ b/lib_rend/ivas_reverb_iir_filter.c @@ -32,8 +32,9 @@ #include #include "options.h" -#include "ivas_prot.h" #include "prot.h" +//#include "ivas_prot.h" +#include "ivas_prot_rend.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index 5aa3578e28..9624dddf54 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -72,6 +72,43 @@ const int16_t channelIndex_CICP14[7] = { 0, 1, 2, 5, 6, 9, 10 }; const int16_t channelIndex_CICP16[9] = { 0, 1, 2, 5, 6, 9, 10, 11, 12 }; const int16_t channelIndex_CICP19[11] = { 0, 1, 2, 3, 4, 7, 8, 9, 10, 13, 14 }; + +const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = +{ + 3.0903f, 2.0053f, 1.0860f, 0.8072f, 0.7079f +}; + +const float spreadCohEne05[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = +{ + 2.3988f, 1.7783f, 1.1220f, 1.1220f, 1.1220f +}; + +const float spreadCohEne1[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = +{ + 1.5975f, 1.1220f, 1.1220f, 1.1220f, 1.1220f +}; + +const float lowBitRateBinauralEQ[LOW_BIT_RATE_BINAURAL_EQ_BINS] = +{ + 0.979f, 0.893f, 0.762f, 0.615f, 0.52f, 0.48f, 0.477f, 0.477f, 0.48f, 0.501f, 0.546f, 0.602f, 0.652f, 0.664f, 0.652f, 0.639f, 0.635f +}; + +const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS] = +{ + 0.047421f, 0.19773f, 0.22582f, 0.10637f, 0.0087111f, 0.012028f, 0.031972f, 0.019668f, 0.0079928f +}; + +const float diffuseFieldCoherenceDifferenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS] = +{ + -0.095628f, -0.30569f, -0.34427f, -0.15425f, -0.044628f, -0.057224f, -0.050835f, -0.035214f, -0.02215f +}; + +const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS] = +{ + 0.048207f, 0.10796f, 0.11845f, 0.047886f, 0.035917f, 0.045196f, 0.018863f, 0.015547f, 0.014157f +}; + + /*----------------------------------------------------------------------------------* * TD ISm binaural renderer ROM tables *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index b18caa02dc..825858db1f 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -53,6 +53,21 @@ extern const int16_t channelIndex_CICP14[7]; extern const int16_t channelIndex_CICP16[9]; extern const int16_t channelIndex_CICP19[11]; +/* These are equalization values for spread and surround coherent sounds, approximating the spectrum + * for such sounds at anechoic multichannel listening. */ +extern const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; +extern const float spreadCohEne05[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; +extern const float spreadCohEne1[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; + +/* Values for low-bit-rate equalization */ +extern const float lowBitRateBinauralEQ[LOW_BIT_RATE_BINAURAL_EQ_BINS]; + +/* Diffuse field binaural coherence directional adjustment values */ +extern const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS]; +extern const float diffuseFieldCoherenceDifferenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS]; +extern const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS]; + + /*----------------------------------------------------------------------------------* * TD ISM Object renderer *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 564fc91340..a39f34d82f 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -36,7 +36,7 @@ #include #include "cnst.h" #include "prot.h" -#include "ivas_prot.h" +//#include "ivas_prot.h" #include "ivas_prot_rend.h" //#include "ivas_cnst.h" //#include "ivas_rom_com.h" diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index 840fedbd3d..035fa607ac 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -34,6 +34,7 @@ #include "options.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 4ce7437f04..683d548a8f 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -36,9 +36,8 @@ #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" -#include "ivas_rom_dec.h" +//#include "ivas_rom_dec.h" #include "ivas_rom_rend.h" -#include "ivas_prot_rend.h" #ifdef FIX_197_CREND_INTERFACE #include "lib_rend.h" #endif diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index abdde9e8a1..a0f46966dd 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -34,7 +34,7 @@ #include #include #include "prot.h" -//#include "ivas_prot.h" +#include "ivas_prot.h" #include "ivas_prot_rend.h" #ifdef HRTF_BINARY_FILE //#include "lib_dec.h" @@ -129,7 +129,9 @@ void hrtfFileReader_close( * Check the HRTF file header read from binary file --------------------------------------------------------------------*/ -static ivas_error read_and_check_hrtf_binary_file_header( ivas_hrtfs_file_header_t *hrtf_file_header, FILE *f_hrtf ) +static ivas_error read_and_check_hrtf_binary_file_header( + ivas_hrtfs_file_header_t *hrtf_file_header, + FILE *f_hrtf ) { int32_t file_size; @@ -173,7 +175,8 @@ static ivas_error read_and_check_hrtf_binary_file_header( ivas_hrtfs_file_header * Check the HRTF section header - read from binary file --------------------------------------------------------------------*/ -static ivas_error check_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header ) +static ivas_error check_hrtf_binary_header( + ivas_hrtfs_header_t *hrtf_header ) { // Check the renderer type if ( ( hrtf_header->rend_type != RENDERER_BINAURAL_MIXER_CONV ) && ( hrtf_header->rend_type != RENDERER_BINAURAL_MIXER_CONV_ROOM ) && @@ -201,13 +204,16 @@ static ivas_error check_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header ) return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * read_hrtf_binary_header() * * Read the HRTF header from binary file --------------------------------------------------------------------*/ -static ivas_error read_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header, FILE *f_hrtf ) +static ivas_error read_hrtf_binary_header( + ivas_hrtfs_header_t *hrtf_header, + FILE *f_hrtf ) { // HRTF Header // Renderer type (4 bytes) : See "RENDERER_TYPE" @@ -422,6 +428,7 @@ static ivas_error LoadBSplineBinary( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * TDREND_MIX_LoadHRTF() * @@ -435,9 +442,7 @@ static ivas_error TDREND_MIX_LoadHRTF( { int16_t tmp; ivas_error error; - #ifdef HRTF_BINARY_FILE - bool is_tdrend; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; @@ -445,7 +450,6 @@ static ivas_error TDREND_MIX_LoadHRTF( ivas_hrtfs_header_t hrtf_header; int32_t hrtf_data_size_max; char *hrtf_data; - #endif error = IVAS_ERR_OK; @@ -747,6 +751,7 @@ static ivas_error ivas_hrtf_init( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * create_HRTF_from_rawdata() * @@ -758,7 +763,7 @@ static ivas_error create_HRTF_from_rawdata( char *hrtf_data /* i: pointer to binary file */ ) { - int i, j, k; + int16_t i, j, k; int16_t max_num_iterations_diffuse; uint16_t max_total_num_fsamp_per_iteration, max_total_num_fsamp_per_iteration_diff; uint32_t mem_size; @@ -968,6 +973,7 @@ static ivas_error create_HRTF_from_rawdata( return IVAS_ERR_OK; } + #ifdef HRTF_BINARY_FILE static ivas_error init_fastconv_HRTF_handle( HRTFS_FASTCONV *hHrtf /* i/o: HRTF FastConv handle */ @@ -1022,6 +1028,7 @@ static ivas_error init_fastconv_HRTF_handle( return IVAS_ERR_OK; } + static ivas_error create_fastconv_HRTF_from_rawdata( HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ char *hrtf_data, /* i : pointer to binary file */ @@ -1029,7 +1036,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ ) { - int i, j; + int16_t i, j; char *hrtf_data_rptr; // if ( hHRTF == NULL ) @@ -1048,14 +1055,14 @@ static ivas_error create_fastconv_HRTF_from_rawdata( hrtf_data_rptr = hrtf_data; - // BINAURAL_CONVBANDS + /* BINAURAL_CONVBANDS */ if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); } hrtf_data_rptr += sizeof( uint16_t ); - // HRIR + /* HRIR */ if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { ( *hHRTF )->FASTCONV_HRIR_latency_s = *( (float *) ( hrtf_data_rptr ) ); @@ -1108,7 +1115,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA ) { - // HRIR_HOA3 + /* HRIR_HOA3 */ ( *hHRTF )->FASTCONV_HOA3_latency_s = *( (float *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( float ); @@ -1157,7 +1164,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } } } - // BRIR + /* BRIR */ if ( rend_type == RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { ( *hHRTF )->FASTCONV_BRIR_latency_s = *( (float *) ( hrtf_data_rptr ) ); @@ -1221,9 +1228,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata( memcpy( ( *hHRTF )->fastconvReverberationEneCorrections, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); } + return IVAS_ERR_OK; } + +/*---------------------------------------------------------------------* + * load_fastconv_HRTF_from_binary() + * + * Load FastConv HRTF binary data into the handle + *---------------------------------------------------------------------*/ + ivas_error load_fastconv_HRTF_from_binary( IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ @@ -1300,12 +1315,18 @@ ivas_error load_fastconv_HRTF_from_binary( #ifdef HRTF_BINARY_FILE +/*---------------------------------------------------------------------* + * create_parambin_HRTF_from_rawdata() + * + * + *---------------------------------------------------------------------*/ + static ivas_error create_parambin_HRTF_from_rawdata( HRTFS_PARAMBIN_HANDLE *hHRTF, /* i/o: Parametric binauralizer HRTF handle */ char *hrtf_data /* i : pointer to binary file */ ) { - int i, j; + int16_t i, j; char *hrtf_data_rptr; uint32_t data_size_tmp; @@ -1363,6 +1384,13 @@ static ivas_error create_parambin_HRTF_from_rawdata( return IVAS_ERR_OK; } + +/*---------------------------------------------------------------------* + * load_parambin_HRTF_from_binary() + * + * Load parametric binauralizer HRTF binary data into the handle + *---------------------------------------------------------------------*/ + ivas_error load_parambin_HRTF_from_binary( IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParamBin, /* i/o: Parametric binauralizer HRTF handle */ const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ @@ -1443,9 +1471,9 @@ ivas_error load_parambin_HRTF_from_binary( *---------------------------------------------------------------------*/ ivas_error create_SetOfHRTF_from_binary( - IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: HRTF CRend handle */ - const hrtfFileReader *hrtfReader, /* i: pointer to hrtfFileReader handle */ - int32_t output_Fs ) /* i: Output sampling frequency */ + IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: HRTF CRend handle */ + const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ + int32_t output_Fs ) /* i : Output sampling frequency */ { FILE *f_hrtf; int32_t hrtf_data_size_max; @@ -1519,7 +1547,7 @@ ivas_error create_SetOfHRTF_from_binary( if ( hHRTF != NULL ) { - // Create the HRTF reading the raw data from the binary file + /* Create the HRTF reading the raw data from the binary file */ if ( ( create_HRTF_from_rawdata( hHRTF, hrtf_data ) ) != IVAS_ERR_OK ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create HRTF from binary file" ); diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index b446551150..0671904ca5 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -73,6 +73,7 @@ ivas_error load_HRTF_binary( const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); + #ifdef HRTF_BINARY_FILE /*---------------------------------------------------------------------* * create_SetOfHRTF_from_binary() @@ -85,19 +86,9 @@ ivas_error create_SetOfHRTF_from_binary( const hrtfFileReader *hrtfReader, /* i: pointer to hrtfFileReader handle */ int32_t output_Fs /* i: Output sampling frequency */ ); - -/*---------------------------------------------------------------------* - * destroy_SetOfHRTF() - * - * Destroy the HRTF data set. - *---------------------------------------------------------------------*/ - -ivas_error destroy_SetOfHRTF( - IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ -); - #endif + #ifdef HRTF_BINARY_FILE /*---------------------------------------------------------------------* * load_fastconv_HRTF_from_binary() -- GitLab From bf824395483bb5240a231e1e8a014725349dc788 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Feb 2023 14:06:34 +0100 Subject: [PATCH 12/40] - comments - rename function ObjRenderIVASFrame to ivas_td_binaural_renderer() --- lib_com/ivas_prot.h | 6 +-- lib_dec/ivas_dec.c | 4 +- lib_dec/ivas_hrtf.c | 4 +- lib_util/hrtf_file_reader.c | 77 +++++++++++++++++++------------------ 4 files changed, 46 insertions(+), 45 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 98c5f553c0..05ffe0aec1 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4850,7 +4850,7 @@ ivas_error ivas_td_binaural_open( ); -void ObjRenderIVASFrame( +void ivas_td_binaural_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ const int16_t output_frame /* i : output frame length */ @@ -4985,8 +4985,8 @@ ivas_error ivas_crend_init_from_hrtf_handle( HRTFS_HANDLE hrtf); #endif -ivas_error destroy_SetOfHRTF( - HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ +void destroy_SetOfHRTF( + HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ ); #endif diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index fc44363745..c9442f4f60 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -204,7 +204,7 @@ ivas_error ivas_dec( /* Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASFrame( st_ivas, output, output_frame ); + ivas_td_binaural_renderer( st_ivas, output, output_frame ); } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { @@ -434,7 +434,7 @@ ivas_error ivas_dec( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASFrame( st_ivas, output, output_frame ); + ivas_td_binaural_renderer( st_ivas, output, output_frame ); ivas_binaural_add_LFE( st_ivas, output_frame, output ); } } diff --git a/lib_dec/ivas_hrtf.c b/lib_dec/ivas_hrtf.c index a5c972881f..704c980dc4 100644 --- a/lib_dec/ivas_hrtf.c +++ b/lib_dec/ivas_hrtf.c @@ -190,7 +190,7 @@ static ivas_error destroy_HRTF( * Destroy the HRTF data set. *---------------------------------------------------------------------*/ -ivas_error destroy_SetOfHRTF( +void destroy_SetOfHRTF( HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ ) { @@ -201,7 +201,7 @@ ivas_error destroy_SetOfHRTF( destroy_HRTF( &( hSetOfHRTF->hHRTF_brir_combined ) ); } - return IVAS_ERR_OK; + return; } diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index a0f46966dd..8b8748cbdc 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -135,11 +135,11 @@ static ivas_error read_and_check_hrtf_binary_file_header( { int32_t file_size; - // [Declaration of the binary file] - // File Identifier (8 bytes) - // Size of file in bytes (4 bytes) - // Number of HRTF (2 bytes) - // Max length of HRTF data (4 bytes) + /* [Declaration of the binary file] */ + /* File Identifier (8 bytes) */ + /* Size of file in bytes (4 bytes) */ + /* Number of HRTF (2 bytes) */ + /* Max length of HRTF data (4 bytes) */ fseek( f_hrtf, 0, SEEK_END ); file_size = ftell( f_hrtf ); @@ -178,7 +178,7 @@ static ivas_error read_and_check_hrtf_binary_file_header( static ivas_error check_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header ) { - // Check the renderer type + /* Check the renderer type */ if ( ( hrtf_header->rend_type != RENDERER_BINAURAL_MIXER_CONV ) && ( hrtf_header->rend_type != RENDERER_BINAURAL_MIXER_CONV_ROOM ) && #ifdef HRTF_BINARY_FILE ( hrtf_header->rend_type != RENDERER_BINAURAL_FASTCONV ) && ( hrtf_header->rend_type != RENDERER_BINAURAL_FASTCONV_ROOM ) && @@ -189,16 +189,16 @@ static ivas_error check_hrtf_binary_header( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (renderer type)" ); } - // Check the output format of the decoder + /* Check the output format of the decoder */ if ( ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) && ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_HOA ) && ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (input audio configuration)" ); } - // Check the sampling frequency + /* Check the sampling frequency */ if ( ( hrtf_header->frequency != 48000 ) && ( hrtf_header->frequency != 32000 ) && ( hrtf_header->frequency != 16000 ) ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (sampling frequency)" ); + return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Header of HRTF binary file not compliant (sampling frequency)" ); } return IVAS_ERR_OK; @@ -215,11 +215,11 @@ static ivas_error read_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header, FILE *f_hrtf ) { - // HRTF Header - // Renderer type (4 bytes) : See "RENDERER_TYPE" - // Input configuration (4 bytes) : See "BINAURAL_INPUT_AUDIO_CONFIG" - // Sampling Frequency (4 bytes) - // Raw data size (4 bytes) + /* HRTF Header */ + /* Renderer type (4 bytes) : See "RENDERER_TYPE" */ + /* Input configuration (4 bytes) : See "BINAURAL_INPUT_AUDIO_CONFIG" */ + /* Sampling Frequency (4 bytes) */ + /* Raw data size (4 bytes) */ if ( ( fread( &( hrtf_header->rend_type ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->input_cfg ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->frequency ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->data_size ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) ) { @@ -786,26 +786,26 @@ static ivas_error create_HRTF_from_rawdata( hrtf_data_rptr = hrtf_data; - // latency_s + /* latency_s */ ( *hHRTF )->latency_s = *( (float *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( float ); - // max_num_ir + /* max_num_ir */ ( *hHRTF )->max_num_ir = *( (uint16_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( uint16_t ); - // BINAURAL_CHANNELS + /* BINAURAL_CHANNELS */ if ( BINAURAL_CHANNELS != *( (int16_t *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file format not compliant (BINAURAL_CHANNELS)" ); } hrtf_data_rptr += sizeof( uint16_t ); - // max_num_iterations + /* max_num_iterations */ ( *hHRTF )->max_num_iterations = *( (int16_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( int16_t ); - // num_iterations + /* num_iterations */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) @@ -815,7 +815,7 @@ static ivas_error create_HRTF_from_rawdata( } } - // pIndex_frequency_max + /* pIndex_frequency_max */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) @@ -831,20 +831,20 @@ static ivas_error create_HRTF_from_rawdata( } } - // max_num_iterations_diffuse + /* max_num_iterations_diffuse */ max_num_iterations_diffuse = *( (int16_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( int16_t ); if ( max_num_iterations_diffuse != 0 ) { - // num_iterations_diffuse + /* 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 ); } - // pIndex_frequency_max_diffuse (the size depends on num_iterations_diffuse) + /* 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 ); @@ -858,22 +858,22 @@ static ivas_error create_HRTF_from_rawdata( } } - // index_frequency_max_diffuse + /* index_frequency_max_diffuse */ ( *hHRTF )->index_frequency_max_diffuse = *( (uint16_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( uint16_t ); - // inv_diffuse_weight + /* inv_diffuse_weight */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { ( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( float ); } - // max_total_num_fsamp_per_iteration + /* max_total_num_fsamp_per_iteration */ max_total_num_fsamp_per_iteration = *( (uint16_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( uint16_t ); - // coeff_re (the size depends on pIndex_frequency_max) + /* coeff_re (the size depends on pIndex_frequency_max) */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) @@ -897,7 +897,7 @@ static ivas_error create_HRTF_from_rawdata( } } - // coeff_im (the size depends on pIndex_frequency_max) + /* 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++ ) @@ -921,13 +921,13 @@ static ivas_error create_HRTF_from_rawdata( } } - // max_total_num_fsamp_per_iteration_diff + /* 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 ); if ( max_total_num_fsamp_per_iteration_diff != 0 ) { - // coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse + /* coeff_diffuse_re : 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 ); @@ -948,7 +948,7 @@ static ivas_error create_HRTF_from_rawdata( } } - // coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse + /* 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 ); @@ -1215,7 +1215,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } } - // Reverb Parameters + /* Reverb Parameters */ if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); @@ -1295,7 +1295,7 @@ ivas_error load_fastconv_HRTF_from_binary( return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } - // Create the HRTF reading the raw data from the binary file + /* Create the HRTF reading the raw data from the binary file */ if ( ( create_fastconv_HRTF_from_rawdata( &hHrtfFastConv, hrtf_data, hrtf_header.rend_type, hrtf_header.input_cfg ) ) != IVAS_ERR_OK ) { free( hrtf_data ); @@ -1332,21 +1332,21 @@ static ivas_error create_parambin_HRTF_from_rawdata( hrtf_data_rptr = hrtf_data; - // HRTF_SH_CHANNELS + /* HRTF_SH_CHANNELS */ if ( HRTF_SH_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_SH_CHANNELS)" ); } hrtf_data_rptr += sizeof( uint16_t ); - // HRTF_NUM_BINS + /* HRTF_NUM_BINS */ if ( HRTF_NUM_BINS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_NUM_BINS)" ); } hrtf_data_rptr += sizeof( uint16_t ); - // HRTF + /* HRTF */ data_size_tmp = HRTF_NUM_BINS * sizeof( float ); for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { @@ -1365,7 +1365,7 @@ static ivas_error create_parambin_HRTF_from_rawdata( } } - // Reverb Parameters + /* Reverb Parameters */ if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); @@ -1445,7 +1445,7 @@ ivas_error load_parambin_HRTF_from_binary( return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } - // Create the HRTF reading the raw data from the binary file + /* Create the HRTF reading the raw data from the binary file */ if ( ( create_parambin_HRTF_from_rawdata( &hHrtfParamBin, hrtf_data ) ) != IVAS_ERR_OK ) { free( hrtf_data ); @@ -1559,6 +1559,7 @@ ivas_error create_SetOfHRTF_from_binary( if ( ( ( *hSetOfHRTF ).hHRTF_hrir_combined == NULL ) || ( ( *hSetOfHRTF ).hHRTF_brir_combined == NULL ) || ( ( *hSetOfHRTF ).hHRTF_hrir_hoa3 == NULL ) ) { + // VE2AT: Makefile build returns "undefined reference to `destroy_SetOfHRTF'"; MSCV is happy... destroy_SetOfHRTF( hSetOfHRTF ); return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create all the HRTF from binary file" ); } -- GitLab From 46679e79def6071c7e70daec0036c4324504ec17 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Feb 2023 14:51:16 +0100 Subject: [PATCH 13/40] removal of includes --- lib_com/ivas_prot.h | 2 +- lib_rend/lib_rend.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 05ffe0aec1..e4c8a9a395 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -41,7 +41,7 @@ #include "stat_dec.h" #include "stat_com.h" #ifdef FIX_197_CREND_INTERFACE -#include "ivas_stat_rend.h" +//#include "ivas_stat_rend.h" #endif #include "ivas_stat_enc.h" #include "ivas_stat_dec.h" diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 683d548a8f..a4a01da7b5 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -39,7 +39,7 @@ //#include "ivas_rom_dec.h" #include "ivas_rom_rend.h" #ifdef FIX_197_CREND_INTERFACE -#include "lib_rend.h" +//#include "lib_rend.h" #endif #include "prot.h" #include "wmc_auto.h" -- GitLab From 25e5631bb7322b1d552a282796c1cb529f7e85dd Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Feb 2023 18:11:18 +0100 Subject: [PATCH 14/40] remove #include "lib_rend.h" from ivas_crend.c file --- lib_rend/ivas_crend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index e2f633e13f..f650b22b55 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -42,7 +42,7 @@ #include "ivas_rom_binaural_crend_head.h" #ifdef FIX_197_CREND_INTERFACE #include "ivas_stat_rend.h" -#include "lib_rend.h" +//#include "lib_rend.h" #else #include "lib_rend.h" #include "ivas_lib_rend_internal.h" -- GitLab From a8ed242607517f9737efa8d1bb99d4e22be64b88 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Feb 2023 19:40:44 +0100 Subject: [PATCH 15/40] remove more dependencies --- lib_com/common_api_types.h | 62 ++++++++++++++ lib_com/ivas_cnst.h | 2 +- lib_dec/ivas_corecoder_dec_reconfig.c | 2 +- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_stat_dec.h | 2 +- lib_enc/ivas_stat_enc.h | 3 +- lib_rend/ivas_stat_rend.h | 111 +++----------------------- lib_rend/lib_rend.c | 38 ++++----- lib_rend/lib_rend.h | 44 +++++++--- lib_util/hrtf_file_reader.c | 23 ++++++ lib_util/hrtf_file_reader.h | 4 +- 11 files changed, 155 insertions(+), 138 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index a24e03f248..b0b2e045ed 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -49,6 +49,9 @@ #define IVAS_CLDFB_NO_CHANNELS_MAX ( 60 ) #define IVAS_MAX_INPUT_LFE_CHANNELS 4 +#define RENDERER_HEAD_POSITIONS_PER_FRAME 4 // todo (Marc) -> renanr IVAS_RENDERER_HEAD_POSITIONS_PER_FRAME ? + + /*----------------------------------------------------------------------------------* * Common API structures *----------------------------------------------------------------------------------*/ @@ -86,6 +89,8 @@ typedef struct typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE; typedef struct ivas_masa_qmetadata_frame_struct *IVAS_MASA_QMETADATA_HANDLE; +typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; + typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE; #ifdef HRTF_BINARY_FILE typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE; @@ -157,4 +162,61 @@ typedef struct _IVAS_JBM_TRACE_DATA } IVAS_JBM_TRACE_DATA; +typedef enum +{ + IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED = 0, + IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS, + IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED, + IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL, + IVAS_REND_AUDIO_CONFIG_TYPE_MASA, + IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN, +} IVAS_REND_AudioConfigType; + +/* TODO(sgi): Harmonize with AUDIO_CONFIG */ +/* + Note: numerical values carry specific information here. + + MSB LSB + -------------------------------------------------------------------------------- + ... unused (assumed all 0) ... | config type (1 byte) | config variant (1 byte) | + -------------------------------------------------------------------------------- + + Where "config type" is the general type from the following list: + - unknown + - channel-based + - ambisonics + - object-based + - binaural + - MASA + + Config variants are concrete configs of each type. + */ +typedef enum +{ + IVAS_REND_AUDIO_CONFIG_MONO = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 0, + IVAS_REND_AUDIO_CONFIG_STEREO = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 1, + IVAS_REND_AUDIO_CONFIG_5_1 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 2, + IVAS_REND_AUDIO_CONFIG_7_1 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 3, + IVAS_REND_AUDIO_CONFIG_5_1_2 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 4, + IVAS_REND_AUDIO_CONFIG_5_1_4 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 5, + IVAS_REND_AUDIO_CONFIG_7_1_4 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 6, + IVAS_REND_AUDIO_CONFIG_LS_CUSTOM = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 255, + + IVAS_REND_AUDIO_CONFIG_FOA = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 0, + IVAS_REND_AUDIO_CONFIG_HOA2 = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 1, + IVAS_REND_AUDIO_CONFIG_HOA3 = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 2, + + IVAS_REND_AUDIO_CONFIG_OBJECT = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED << 8 | 0, + + IVAS_REND_AUDIO_CONFIG_BINAURAL = IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL << 8 | 0, + IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM = IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL << 8 | 1, + + IVAS_REND_AUDIO_CONFIG_MASA1 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA << 8 | 0, + IVAS_REND_AUDIO_CONFIG_MASA2 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA << 8 | 1, + + IVAS_REND_AUDIO_CONFIG_UNKNOWN = IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN << 8 | 0, +} IVAS_REND_AudioConfig; + +typedef uint16_t IVAS_REND_InputId; + #endif /* COMMON_API_TYPES_H */ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e07ca8cbcb..4195ce07ec 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -36,7 +36,7 @@ #include #include "options.h" #include "cnst.h" -#include "ivas_error.h" +//#include "ivas_error.h" /* clang-format off */ diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 5bc6822735..d19834ddcb 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -35,7 +35,7 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" -#include "lib_dec.h" +//#include "lib_dec.h" #include "prot.h" #include #include diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index f2c32a63af..ecfb2a13c5 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -36,7 +36,7 @@ #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" -#include "lib_dec.h" +//#include "lib_dec.h" #include "prot.h" #include #include diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 7280bc0227..b802e12fe9 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -36,8 +36,8 @@ #include #include "options.h" #include "cnst.h" -#include "stat_dec.h" #include "ivas_cnst.h" +#include "stat_dec.h" #include "ivas_stat_com.h" #include "ivas_stat_rend.h" #ifndef FIX_197_CREND_INTERFACE diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index ecf730cffa..0f8258e022 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -35,10 +35,9 @@ #include #include "options.h" -#include "ivas_cnst.h" #include "cnst.h" -#include "stat_enc.h" #include "ivas_cnst.h" +#include "stat_enc.h" #include "ivas_stat_com.h" /*----------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index c824d1a6e4..b0f0229fd7 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -38,104 +38,33 @@ #include "cnst.h" #include "ivas_cnst.h" #include "ivas_stat_com.h" -#include "common_api_types.h" +#include "common_api_types.h" // VE2AT: should it stay here? (in lib_enc, lib_dec, there is no such include) #endif #ifdef FIX_197_CREND_INTERFACE -#define RENDERER_HEAD_POSITIONS_PER_FRAME 4 // todo (Marc) -> renanr IVAS_RENDERER_HEAD_POSITIONS_PER_FRAME ? -typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; -typedef struct -{ - int16_t numSamplesPerChannel; - int16_t numChannels; -} IVAS_REND_AudioBufferConfig; - -typedef struct -{ - IVAS_REND_AudioBufferConfig config; - float *data; -} IVAS_REND_AudioBuffer; +//typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; -typedef struct -{ - IVAS_REND_AudioBufferConfig config; - const float *data; -} IVAS_REND_ReadOnlyAudioBuffer; typedef struct { float azimuth; float elevation; -} IVAS_REND_AudioObjectPosition; - -typedef struct IVAS_REND *IVAS_REND_HANDLE; -typedef struct IVAS_REND const *IVAS_REND_CONST_HANDLE; - -typedef enum -{ - IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED = 0, - IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS, - IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED, - IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL, - IVAS_REND_AUDIO_CONFIG_TYPE_MASA, - IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN, -} IVAS_REND_AudioConfigType; - -/* TODO(sgi): Harmonize with AUDIO_CONFIG */ -/* - Note: numerical values carry specific information here. - - MSB LSB - -------------------------------------------------------------------------------- - ... unused (assumed all 0) ... | config type (1 byte) | config variant (1 byte) | - -------------------------------------------------------------------------------- - - Where "config type" is the general type from the following list: - - unknown - - channel-based - - ambisonics - - object-based - - binaural - - MASA - - Config variants are concrete configs of each type. - */ -typedef enum -{ - IVAS_REND_AUDIO_CONFIG_MONO = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 0, - IVAS_REND_AUDIO_CONFIG_STEREO = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 1, - IVAS_REND_AUDIO_CONFIG_5_1 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 2, - IVAS_REND_AUDIO_CONFIG_7_1 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 3, - IVAS_REND_AUDIO_CONFIG_5_1_2 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 4, - IVAS_REND_AUDIO_CONFIG_5_1_4 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 5, - IVAS_REND_AUDIO_CONFIG_7_1_4 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 6, - IVAS_REND_AUDIO_CONFIG_LS_CUSTOM = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 255, - - IVAS_REND_AUDIO_CONFIG_FOA = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 0, - IVAS_REND_AUDIO_CONFIG_HOA2 = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 1, - IVAS_REND_AUDIO_CONFIG_HOA3 = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 2, - - IVAS_REND_AUDIO_CONFIG_OBJECT = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED << 8 | 0, +} IVAS_REND_AudioObjectPosition; // VE2AT: where should this go, into lib_rend.h, common_api_types.h, ...? should be introduced public -> internal conversion? - IVAS_REND_AUDIO_CONFIG_BINAURAL = IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL << 8 | 0, - IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM = IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL << 8 | 1, - IVAS_REND_AUDIO_CONFIG_MASA1 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA << 8 | 0, - IVAS_REND_AUDIO_CONFIG_MASA2 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA << 8 | 1, +//typedef struct IVAS_REND *IVAS_REND_HANDLE; +//typedef struct IVAS_REND const *IVAS_REND_CONST_HANDLE; - IVAS_REND_AUDIO_CONFIG_UNKNOWN = IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN << 8 | 0, -} IVAS_REND_AudioConfig; -typedef uint16_t IVAS_REND_InputId; - -typedef struct -{ - int16_t numLfeChannels; - float lfeOutputGains[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; -} IVAS_REND_LfeRouting; +// VE2AT: not used, can it be removed? +//typedef struct +//{ +// int16_t numLfeChannels; +// float lfeOutputGains[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; +//} IVAS_REND_LfeRouting; typedef struct { @@ -814,24 +743,6 @@ typedef struct ivas_hrtfs_crend_structure } HRTFS_CREND, *HRTFS_CREND_HANDLE; -typedef struct ivas_hrtfs_header_t -{ - int32_t rend_type; - int32_t input_cfg; - int32_t frequency; - uint32_t data_size; - -} ivas_hrtfs_header_t; - -typedef struct ivas_hrtfs_file_header_t -{ - char identifier[8]; - int32_t file_size; - int16_t nb_hrtf; - int32_t max_data_size; - -} ivas_hrtfs_file_header_t; - #endif #ifdef HRTF_BINARY_FILE diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 791375ce4c..5ac7248ad9 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -38,6 +38,7 @@ #include "ivas_rom_com.h" //#include "ivas_rom_dec.h" #include "ivas_rom_rend.h" +//#include "ivas_stat_rend.h" #ifdef FIX_197_CREND_INTERFACE //#include "lib_rend.h" #endif @@ -5295,23 +5296,24 @@ int32_t IVAS_REND_GetCntFramesLimited( *-------------------------------------------------------------------*/ #ifdef FIX_197_CREND_INTERFACE -ivas_error ivas_rend_initEfap( // VE2AT: this fucntionis not used - could it be removed? - AUDIO_CONFIG outConfig, - EFAP_HANDLE *hEfap ) -{ - ivas_error err; - IVAS_REND_AudioConfig audioCfg; - EFAP_WRAPPER wrap; - LSSETUP_CUSTOM_STRUCT customLsOut; - - wrap.hEfap = NULL; - wrap.pCustomLsSetup = NULL; - audioCfg = getRendAudioConfigFromIvasAudioConfig( outConfig ); - memset( &customLsOut, 0, sizeof( LSSETUP_CUSTOM_STRUCT ) ); - err = initEfap( &wrap, audioCfg, &customLsOut ); +//ivas_error ivas_rend_initEfap( // VE2AT: this function is not used - could it be removed? +// AUDIO_CONFIG outConfig, +// EFAP_HANDLE *hEfap ) +//{ +// ivas_error err; +// IVAS_REND_AudioConfig audioCfg; +// EFAP_WRAPPER wrap; +// LSSETUP_CUSTOM_STRUCT customLsOut; +// +// wrap.hEfap = NULL; +// wrap.pCustomLsSetup = NULL; +// audioCfg = getRendAudioConfigFromIvasAudioConfig( outConfig ); +// memset( &customLsOut, 0, sizeof( LSSETUP_CUSTOM_STRUCT ) ); +// err = initEfap( &wrap, audioCfg, &customLsOut ); +// +// *hEfap = wrap.hEfap; +// +// return err; +//} - *hEfap = wrap.hEfap; - - return err; -} #endif diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 00a3dc0cc4..492ac56662 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -33,15 +33,15 @@ #ifndef LIB_REND_H #define LIB_REND_H -#include -#include -#include - -#include "options.h" +//#include +//#include +//#include #include "common_api_types.h" #include "ivas_error.h" +#include +#include #ifdef FIX_197_CREND_INTERFACE -#include "ivas_stat_rend.h" +#include "ivas_stat_rend.h" // VE2AT: this should go away, right? the remaining dependency is "IVAS_REND_AudioObjectPosition" #endif #define RENDERER_MAX_ISM_INPUTS 4 @@ -145,6 +145,28 @@ typedef uint16_t IVAS_REND_InputId; #endif +typedef struct +{ + int16_t numSamplesPerChannel; + int16_t numChannels; +} IVAS_REND_AudioBufferConfig; + +typedef struct +{ + IVAS_REND_AudioBufferConfig config; + float *data; +} IVAS_REND_AudioBuffer; + +typedef struct +{ + IVAS_REND_AudioBufferConfig config; + const float *data; +} IVAS_REND_ReadOnlyAudioBuffer; + +typedef struct IVAS_REND *IVAS_REND_HANDLE; +typedef struct IVAS_REND const *IVAS_REND_CONST_HANDLE; + + /* clang-format off */ /*----------------------------------------------------------------------------------* * Function prototypes @@ -174,7 +196,7 @@ ivas_error IVAS_REND_SetCustomHrtf( /* Functions to be called before/during rendering */ ivas_error IVAS_REND_NumOutChannels( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ int16_t *numOutChannels /* o : number of output channels */ ); @@ -290,10 +312,10 @@ int32_t IVAS_REND_GetCntFramesLimited( #endif #ifdef FIX_197_CREND_INTERFACE -ivas_error ivas_rend_initEfap( - AUDIO_CONFIG outConfig, - EFAP_HANDLE *hEfap - ); +//ivas_error ivas_rend_initEfap( +// AUDIO_CONFIG outConfig, +// EFAP_HANDLE *hEfap +//); #endif /* clang-format on */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index b4cd4c7d27..9514f8b427 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -41,12 +41,35 @@ #endif +/*---------------------------------------------------------------------* + * Local structures + *---------------------------------------------------------------------*/ + struct hrtfFileReader { FILE *file; char *file_path; }; +typedef struct ivas_hrtfs_header_t +{ + int32_t rend_type; + int32_t input_cfg; + int32_t frequency; + uint32_t data_size; + +} ivas_hrtfs_header_t; + +typedef struct ivas_hrtfs_file_header_t +{ + char identifier[8]; + int32_t file_size; + int16_t nb_hrtf; + int32_t max_data_size; + +} ivas_hrtfs_file_header_t; + + /*---------------------------------------------------------------------* * Local constants *---------------------------------------------------------------------*/ diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 0671904ca5..6e5cca2968 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -33,11 +33,9 @@ #ifndef IVAS_HRTF_FILE_READER_H #define IVAS_HRTF_FILE_READER_H -#include #include "common_api_types.h" #include "ivas_error.h" -#include "options.h" - +// VE2AT: would it make sense to put includes of "ivas_error.h" into "common_api_types" in order to not repeate it again and again? typedef struct hrtfFileReader hrtfFileReader; -- GitLab From b57244298dcba2c4b563794d4b318e0826fa865b Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 09:33:14 +0100 Subject: [PATCH 16/40] comment --- lib_dec/ivas_td_decorr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_td_decorr.c b/lib_dec/ivas_td_decorr.c index 69c7132730..c0cb0e54dd 100644 --- a/lib_dec/ivas_td_decorr.c +++ b/lib_dec/ivas_td_decorr.c @@ -100,7 +100,7 @@ static ivas_error ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, const * * Allocate and initialize SPAR time domain decorrelator handle *------------------------------------------------------------------------*/ -// VE2AT: this fucntion is used also in lib_rend...; where to put it? +// VE2AT: this function is used also in lib_rend...; where to put it? ivas_error ivas_spar_td_decorr_dec_open( ivas_td_decorr_state_t **hTdDecorr, /* i/o: SPAR Covar. decoder handle */ const int32_t output_Fs, /* i : output sampling rate */ -- GitLab From 7b98efe1dea6a107ec6b1e2d6bb52e8e906681ef Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 10:00:40 +0100 Subject: [PATCH 17/40] comments --- lib_dec/ivas_hrtf.c | 2 +- lib_dec/ivas_ls_custom_dec.c | 2 +- lib_rend/ivas_objectRenderer.c | 2 ++ lib_rend/ivas_prot_rend.h | 2 +- lib_rend/ivas_stat_rend.h | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_hrtf.c b/lib_dec/ivas_hrtf.c index 704c980dc4..e126b7c344 100644 --- a/lib_dec/ivas_hrtf.c +++ b/lib_dec/ivas_hrtf.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: this file functions are called from lib_dec only; is it expected? +// VE2AT: this file functions are called from lib_dec only; is it expected, or binary HRTF support in Ext renderer will be done later? #include #include "options.h" #include "prot.h" diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c index 16d8ae286b..824163f985 100644 --- a/lib_dec/ivas_ls_custom_dec.c +++ b/lib_dec/ivas_ls_custom_dec.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: this file functions are called from lib_dec only; is it expected? +// VE2AT: this file functions are called from lib_dec only; is it expected, or it will be implemented for Ext renderer later? #include #include "options.h" #include "ivas_prot.h" diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 22a676e129..2135b4738c 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -42,6 +42,8 @@ #endif #include "wmc_auto.h" +//VE2AT: dependency on "IVAS_REND_AudioObjectPosition" needs to be solved in this file; Could common_api_types.h be included here while "IVAS_REND_AudioObjectPosition" is part of it? + /*---------------------------------------------------------------------* * Local function prototypes diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index bd569b431d..80bab0d854 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -41,7 +41,7 @@ #else #include "lib_rend.h" #endif -#include "ivas_stat_dec.h" // VE2AT: needed for Decoder_Struct; what to do with this? +#include "ivas_stat_dec.h" // VE2AT: needed for Decoder_Struct; what to do with this? Is this related to #156? /* clang-format off */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index b0f0229fd7..a11a43a669 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -52,7 +52,7 @@ typedef struct { float azimuth; float elevation; -} IVAS_REND_AudioObjectPosition; // VE2AT: where should this go, into lib_rend.h, common_api_types.h, ...? should be introduced public -> internal conversion? +} IVAS_REND_AudioObjectPosition; // VE2AT: where should this go, into common_api_types.h, ...? Or should there be introduced public -> internal conversion? //typedef struct IVAS_REND *IVAS_REND_HANDLE; -- GitLab From 75c41eecc9133bbae1f9ccbd15158189615e64cd Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 14:46:55 +0100 Subject: [PATCH 18/40] - move ivas_hrtf.c back to lib_rend - comments --- Workspace_msvc/lib_dec.vcxproj | 1 - Workspace_msvc/lib_dec.vcxproj.filters | 3 - Workspace_msvc/lib_rend.vcxproj | 1 + lib_com/ivas_prot.h | 54 ----- {lib_dec => lib_rend}/ivas_hrtf.c | 8 +- lib_rend/ivas_prot_rend.h | 45 ++++ lib_rend/lib_rend.c | 296 ++++++++++++++++++------- lib_rend/lib_rend.h | 12 +- 8 files changed, 277 insertions(+), 143 deletions(-) rename {lib_dec => lib_rend}/ivas_hrtf.c (99%) diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 59b00db3bf..6d9b7c0682 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -276,7 +276,6 @@ - diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index d6fc1dcbbf..779794a1c0 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -512,9 +512,6 @@ dec_ivas_c - - dec_ivas_c - dec_ivas_c diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index e7efa18f8a..865652649a 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -198,6 +198,7 @@ + diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index bc0e66ce70..39dac79d10 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4518,10 +4518,6 @@ void ivas_binaural_add_LFE( #endif -ivas_error ivas_headTrack_open( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ -); - /*----------------------------------------------------------------------------------* @@ -4943,56 +4939,6 @@ int16_t ivas_get_num_bands_from_bw_idx( * HRTF *----------------------------------------------------------------------------------*/ -ivas_error ivas_HRTF_binary_open( - TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ -); - -void ivas_HRTF_binary_close( - TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ -); - -ivas_error ivas_HRTF_fastconv_binary_open( - HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ -); - -void ivas_HRTF_fastconv_binary_close( - HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ -); - -ivas_error ivas_HRTF_parambin_binary_open( - HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ -); - -void ivas_HRTF_parambin_binary_close( - HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ -); - -#ifdef HRTF_BINARY_FILE - -ivas_error ivas_HRTF_CRend_binary_open( - HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ -); - -void ivas_HRTF_CRend_binary_close( - HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ -); - -#ifndef FIX_197_CREND_INTERFACE - -ivas_error ivas_crend_init_from_setofhrtf( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_crend_init_from_hrtf_handle( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - HRTFS_HANDLE hrtf); -#endif - -void destroy_SetOfHRTF( - HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ -); - -#endif #ifndef FIX_197_CREND_INTERFACE diff --git a/lib_dec/ivas_hrtf.c b/lib_rend/ivas_hrtf.c similarity index 99% rename from lib_dec/ivas_hrtf.c rename to lib_rend/ivas_hrtf.c index e126b7c344..0e1660fd0a 100644 --- a/lib_dec/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -33,7 +33,8 @@ #include #include "options.h" #include "prot.h" -#include "ivas_prot.h" +//#include "ivas_prot.h" +#include "ivas_prot_rend.h" #include "ivas_error.h" #include "wmc_auto.h" @@ -224,6 +225,7 @@ ivas_error ivas_HRTF_fastconv_binary_open( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------* * ivas_HRTF_fastconv_binary_close() * @@ -243,9 +245,8 @@ void ivas_HRTF_fastconv_binary_close( return; } -#endif -#ifdef HRTF_BINARY_FILE + /*-----------------------------------------------------------------------* * ivas_HRTF_parambin_binary_open() * @@ -264,6 +265,7 @@ ivas_error ivas_HRTF_parambin_binary_open( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------* * ivas_HRTF_parambin_binary_close() * diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 80bab0d854..49c6ff9aba 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -253,6 +253,47 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( ); +/*----------------------------------------------------------------------------------* + * HRTF + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_HRTF_binary_open( + TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ +); + +void ivas_HRTF_binary_close( + TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ +); + +ivas_error ivas_HRTF_fastconv_binary_open( + HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ +); + +void ivas_HRTF_fastconv_binary_close( + HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ +); + +ivas_error ivas_HRTF_parambin_binary_open( + HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ +); + +void ivas_HRTF_parambin_binary_close( + HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ +); + +ivas_error ivas_HRTF_CRend_binary_open( + HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ +); + +void ivas_HRTF_CRend_binary_close( + HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ +); + +void destroy_SetOfHRTF( + HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ +); + + /*----------------------------------------------------------------------------------* * TD object renderer *----------------------------------------------------------------------------------*/ @@ -750,6 +791,10 @@ void ivas_reverb_get_hrtf_set_properties( * Rotation Prototypes *-----------------------------------------------------------------------------------*/ +ivas_error ivas_headTrack_open( + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ +); + void Quat2Euler( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ float *yaw, /* o : yaw */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 5ac7248ad9..1d207a0c7c 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1173,7 +1173,9 @@ static ivas_error initMcPanGainsWithConversionMapping( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Missing multichannel conversion mapping" ); } -static ivas_error initMcPanGainsWithEfap( input_mc *inputMc, IVAS_REND_AudioConfig outConfig ) +static ivas_error initMcPanGainsWithEfap( + input_mc *inputMc, + const IVAS_REND_AudioConfig outConfig ) { int16_t i; int16_t numNonLfeInChannels; @@ -1368,10 +1370,10 @@ static ivas_error initMcPanGainsWithStereoLookup( /* Returns 1 (true) if configs A and B are equal, otherwise returns 0 (false). * If both configs are custom LS layouts, layout details are compared to determine equality. */ static bool configsAreEqual( - IVAS_REND_AudioConfig configA, - LSSETUP_CUSTOM_STRUCT customLsA, - IVAS_REND_AudioConfig configB, - LSSETUP_CUSTOM_STRUCT customLsB ) + const IVAS_REND_AudioConfig configA, + const LSSETUP_CUSTOM_STRUCT customLsA, + const IVAS_REND_AudioConfig configB, + const LSSETUP_CUSTOM_STRUCT customLsB ) { int16_t i; @@ -1764,10 +1766,10 @@ static ivas_error initMcBinauralRendering( } static lfe_routing defaultLfeRouting( - IVAS_REND_AudioConfig inConfig, - LSSETUP_CUSTOM_STRUCT customLsIn, - IVAS_REND_AudioConfig outConfig, - LSSETUP_CUSTOM_STRUCT customLsOut ) + const IVAS_REND_AudioConfig inConfig, + const LSSETUP_CUSTOM_STRUCT customLsIn, + const IVAS_REND_AudioConfig outConfig, + const LSSETUP_CUSTOM_STRUCT customLsOut ) { int32_t i; lfe_routing routing; @@ -2121,7 +2123,9 @@ static void clearInputSba( return; } -static ivas_error initMasaDummyDecForMcOut( input_masa *inputMasa, IVAS_REND_AudioConfig outConfig ) +static ivas_error initMasaDummyDecForMcOut( + input_masa *inputMasa, + const IVAS_REND_AudioConfig outConfig ) { ivas_error error; int16_t numCldfbAnalyses; @@ -2212,7 +2216,9 @@ static ivas_error initMasaDummyDecForMcOut( input_masa *inputMasa, IVAS_REND_Aud return IVAS_ERR_OK; } -static ivas_error initMasaDummyDecForSbaOut( input_masa *inputMasa, IVAS_REND_AudioConfig outConfig ) +static ivas_error initMasaDummyDecForSbaOut( + input_masa *inputMasa, + const IVAS_REND_AudioConfig outConfig ) { ivas_error error; int16_t numCldfbAnalyses; @@ -2282,7 +2288,9 @@ static ivas_error initMasaDummyDecForSbaOut( input_masa *inputMasa, IVAS_REND_Au return IVAS_ERR_OK; } -static ivas_error initMasaDummyDecForBinauralOut( input_masa *inputMasa, IVAS_REND_AudioConfig outConfig ) +static ivas_error initMasaDummyDecForBinauralOut( + input_masa *inputMasa, + const IVAS_REND_AudioConfig outConfig ) { ivas_error error; @@ -2363,7 +2371,9 @@ static ivas_error initMasaDummyDecForBinauralOut( input_masa *inputMasa, IVAS_RE return IVAS_ERR_OK; } -static ivas_error updateMasaDummyDec( input_masa *inputMasa, IVAS_REND_AudioConfig outConfig ) +static ivas_error updateMasaDummyDec( + input_masa *inputMasa, + const IVAS_REND_AudioConfig outConfig ) { ivas_error error; @@ -2390,7 +2400,11 @@ static ivas_error updateMasaDummyDec( input_masa *inputMasa, IVAS_REND_AudioConf return IVAS_ERR_OK; } -static DecoderDummy *initDecoderDummy( int32_t sampleRate, int16_t numTransChannels, IVAS_REND_AudioConfig outConfig, const uint8_t enableRenderConfig ) +static DecoderDummy *initDecoderDummy( + const int32_t sampleRate, + const int16_t numTransChannels, + const IVAS_REND_AudioConfig outConfig, + const uint8_t enableRenderConfig ) { ivas_error error; int16_t i; @@ -2420,7 +2434,7 @@ static DecoderDummy *initDecoderDummy( int32_t sampleRate, int16_t numTransChann decDummy->hHrtfTD = NULL; decDummy->hSpar = NULL; decDummy->hoa_dec_mtx = NULL; - decDummy->hVBAPdata = NULL; + decDummy->hVBAPdata = NULL; // VE2AT: is "hVBAPdata" really used in Ext Rend? decDummy->hMasa = NULL; decDummy->hDiracDecBin = NULL; decDummy->hQMetaData = NULL; @@ -2501,7 +2515,8 @@ static ivas_error setRendInputActiveMasa( return IVAS_ERR_OK; } -static void freeDecoderDummy( DecoderDummy **ppDecDummy ) +static void freeDecoderDummy( + DecoderDummy **ppDecDummy ) { int16_t i; DecoderDummy *pDecDummy; @@ -2568,7 +2583,8 @@ static void freeDecoderDummy( DecoderDummy **ppDecDummy ) pDecDummy = NULL; } -static void clearInputMasa( input_masa *inputMasa ) +static void clearInputMasa( + input_masa *inputMasa ) { rendering_context rendCtx; @@ -2668,10 +2684,7 @@ ivas_error IVAS_REND_Open( } for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) { - initRendInputBase( &hIvasRend->inputsMasa[i].base, - IVAS_REND_AUDIO_CONFIG_UNKNOWN, - 0, - getRendCtx( hIvasRend ) ); + initRendInputBase( &hIvasRend->inputsMasa[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) ); hIvasRend->inputsMasa[i].decDummy = NULL; hIvasRend->inputsMasa[i].metadataHasBeenFed = false; } @@ -2985,8 +2998,8 @@ static ivas_error getConstInputById( static ivas_error findFreeInputSlot( const void *inputs, - int32_t inputStructSize, - int32_t maxInputs, + const int32_t inputStructSize, + const int32_t maxInputs, int32_t *inputIndex ) { /* Using a void pointer and a separately provided size is a hack for this function @@ -3024,10 +3037,18 @@ static ivas_error findFreeInputSlot( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_AddInput() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_AddInput( - IVAS_REND_HANDLE hIvasRend, - IVAS_REND_AudioConfig inConfig, - IVAS_REND_InputId *inputId ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_AudioConfig inConfig, /* i : audio config for a new input */ + IVAS_REND_InputId *inputId /* o : ID of the new input */ +) { ivas_error error; int32_t maxNumInputsOfType; @@ -3091,10 +3112,19 @@ ivas_error IVAS_REND_AddInput( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_ConfigureCustomInputLoudspeakerLayout() + * + * + * Note: this will reset any custom LFE routing set for the input + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( - IVAS_REND_HANDLE hIvasRend, - const IVAS_REND_InputId inputId, - const IVAS_CUSTOM_LS_DATA layout ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + const IVAS_CUSTOM_LS_DATA layout /* i : custom loudspeaker layout for input */ +) { input_mc *inputMc; ivas_error error; @@ -3145,10 +3175,17 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_SetInputGain() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_SetInputGain( - IVAS_REND_HANDLE hIvasRend, - const IVAS_REND_InputId inputId, - const float gain /* linear gain, not in dB */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + const float gain /* i : linear gain (not in dB) */ ) { input_base *inputBase; @@ -3172,10 +3209,18 @@ ivas_error IVAS_REND_SetInputGain( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_SetInputLfeMtx() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_SetInputLfeMtx( - IVAS_REND_HANDLE hIvasRend, - const IVAS_REND_InputId inputId, - const IVAS_REND_LfePanMtx *lfePanMtx ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + const IVAS_REND_LfePanMtx *lfePanMtx /* i : LFE panning matrix */ +) { int16_t i; input_base *pInputBase; @@ -3215,12 +3260,20 @@ ivas_error IVAS_REND_SetInputLfeMtx( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_SetInputLfePos() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_SetInputLfePos( - IVAS_REND_HANDLE hIvasRend, - const IVAS_REND_InputId inputId, - const float inputGain, - const float outputAzimuth, - const float outputElevation ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + const float inputGain, /* i : Input gain to be applied to the LFE channel(s) */ + const float outputAzimuth, /* i : Output azimuth position */ + const float outputElevation /* i : Output elevation position */ +) { input_base *pInputBase; input_mc *pInputMc; @@ -3257,9 +3310,17 @@ ivas_error IVAS_REND_SetInputLfePos( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_RemoveInput() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_RemoveInput( - IVAS_REND_HANDLE hIvasRend, - const IVAS_REND_InputId inputId ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId /* i : ID of the input */ +) { ivas_error error; input_base *inputBase; @@ -3298,10 +3359,18 @@ ivas_error IVAS_REND_RemoveInput( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_GetInputNumChannels() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetInputNumChannels( - IVAS_REND_CONST_HANDLE hIvasRend, - const IVAS_REND_InputId inputId, - int16_t *numChannels ) + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + int16_t *numChannels /* o : number of channels of the input */ +) { ivas_error error; const input_base *pInput; @@ -3327,6 +3396,13 @@ ivas_error IVAS_REND_GetInputNumChannels( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_GetDelay() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetDelay( IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ int16_t *nSamples, /* o : Renderer delay in samples */ @@ -3433,10 +3509,18 @@ ivas_error IVAS_REND_GetDelay( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_FeedInputAudio() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_FeedInputAudio( - IVAS_REND_HANDLE hIvasRend, - const IVAS_REND_InputId inputId, - const IVAS_REND_ReadOnlyAudioBuffer inputAudio ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + const IVAS_REND_ReadOnlyAudioBuffer inputAudio /* i : buffer with input audio */ +) { ivas_error error; input_base *inputBase; @@ -3487,10 +3571,18 @@ ivas_error IVAS_REND_FeedInputAudio( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_FeedInputObjectMetadata() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_FeedInputObjectMetadata( - IVAS_REND_HANDLE hIvasRend, - const IVAS_REND_InputId inputId, - const IVAS_REND_AudioObjectPosition objectPosition ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + const IVAS_REND_AudioObjectPosition objectPosition /* i : object position struct */ +) { input_base *inputBase; input_ism *inputIsm; @@ -3521,10 +3613,18 @@ ivas_error IVAS_REND_FeedInputObjectMetadata( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_FeedInputMasaMetadata() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_FeedInputMasaMetadata( - IVAS_REND_HANDLE hIvasRend, - const IVAS_REND_InputId inputId, - IVAS_MASA_METADATA_HANDLE masaMetadata ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + IVAS_MASA_METADATA_HANDLE masaMetadata /* i : MASA metadata frame */ +) { ivas_error error; input_base *inputBase; @@ -3555,44 +3655,53 @@ ivas_error IVAS_REND_FeedInputMasaMetadata( return IVAS_ERR_OK; } -ivas_error IVAS_REND_InitConfig( IVAS_REND_HANDLE st, - bool rendererConfigEnabled ) + +/*-------------------------------------------------------------------* + * IVAS_REND_InitConfig() + * + * + *-------------------------------------------------------------------*/ + +ivas_error IVAS_REND_InitConfig( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const bool rendererConfigEnabled /* i : flag indicating if a renderer configuration file was supplied */ +) { ivas_error error; if ( rendererConfigEnabled ) { - st->rendererConfigEnabled = 1; + hIvasRend->rendererConfigEnabled = 1; } else { - st->rendererConfigEnabled = 0; + hIvasRend->rendererConfigEnabled = 0; } #ifdef FIX_197_CREND_INTERFACE if ( rendererConfigEnabled ) { - if ( ( error = ivas_render_config_open( &( st->hRendererConfig ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_render_config_open( &( hIvasRend->hRendererConfig ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ivas_render_config_init_from_rom( &st->hRendererConfig, st->rendererConfigEnabled ) != IVAS_ERR_OK ) + if ( ivas_render_config_init_from_rom( &hIvasRend->hRendererConfig, hIvasRend->rendererConfigEnabled ) != IVAS_ERR_OK ) { return IVAS_ERR_INTERNAL_FATAL; } } else { - st->hRendererConfig = NULL; + hIvasRend->hRendererConfig = NULL; } #else - if ( ( error = ivas_render_config_open( &( st->hRendererConfig ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_render_config_open( &( hIvasRend->hRendererConfig ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ivas_render_config_init_from_rom( &st->hRendererConfig, st->rendererConfigEnabled ) != IVAS_ERR_OK ) + if ( ivas_render_config_init_from_rom( &hIvasRend->hRendererConfig, hIvasRend->rendererConfigEnabled ) != IVAS_ERR_OK ) { return IVAS_ERR_INTERNAL_FATAL; } @@ -3601,6 +3710,13 @@ ivas_error IVAS_REND_InitConfig( IVAS_REND_HANDLE st, return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_GetRenderConfig() + * + * + *-------------------------------------------------------------------*/ + int16_t IVAS_REND_GetRenderConfig( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */ @@ -3643,6 +3759,12 @@ int16_t IVAS_REND_GetRenderConfig( } +/*-------------------------------------------------------------------* + * IVAS_REND_FeedRenderConfig() + * + * + *-------------------------------------------------------------------*/ + int16_t IVAS_REND_FeedRenderConfig( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ @@ -3681,9 +3803,16 @@ int16_t IVAS_REND_FeedRenderConfig( } +/*-------------------------------------------------------------------* + * IVAS_REND_SetHeadRotation() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_SetHeadRotation( - IVAS_REND_HANDLE hIvasRend, - const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME] ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME] /* i : head positions for next rendering call */ +) { int16_t i; @@ -3717,6 +3846,11 @@ ivas_error IVAS_REND_SetHeadRotation( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ + /* Take one channel from input buffer and copy it to each channel in output buffer, with different gain applied per output channel. This function takes 2 gain vectors - one for the beginning and one @@ -4963,7 +5097,9 @@ static ivas_error renderActiveInputsSba( return IVAS_ERR_OK; } -static void copyMasaMetadataToDiracRenderer( MASA_METADATA_FRAME *meta, DIRAC_DEC_HANDLE hDirAC ) +static void copyMasaMetadataToDiracRenderer( + MASA_METADATA_FRAME *meta, + DIRAC_DEC_HANDLE hDirAC ) { int16_t band, sf, bin; @@ -4993,9 +5129,13 @@ static void copyMasaMetadataToDiracRenderer( MASA_METADATA_FRAME *meta, DIRAC_DE } } } + + return; } -static ivas_error renderMasaToMc( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio ) +static ivas_error renderMasaToMc( + input_masa *masaInput, + IVAS_REND_AudioBuffer outAudio ) { float tmpBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; @@ -5017,7 +5157,9 @@ static ivas_error renderMasaToMc( input_masa *masaInput, IVAS_REND_AudioBuffer o return IVAS_ERR_OK; } -static ivas_error renderMasaToSba( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio ) +static ivas_error renderMasaToSba( + input_masa *masaInput, + IVAS_REND_AudioBuffer outAudio ) { float tmpBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; @@ -5031,7 +5173,9 @@ static ivas_error renderMasaToSba( input_masa *masaInput, IVAS_REND_AudioBuffer return IVAS_ERR_OK; } -static ivas_error renderMasaToBinaural( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio ) +static ivas_error renderMasaToBinaural( + input_masa *masaInput, + IVAS_REND_AudioBuffer outAudio ) { float tmpBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; @@ -5047,7 +5191,7 @@ static ivas_error renderMasaToBinaural( input_masa *masaInput, IVAS_REND_AudioBu static ivas_error renderInputMasa( input_masa *masaInput, - IVAS_REND_AudioConfig outConfig, + const IVAS_REND_AudioConfig outConfig, IVAS_REND_AudioBuffer outAudio ) { ivas_error error; @@ -5122,9 +5266,7 @@ static ivas_error renderActiveInputsMasa( /* Skip inactive inputs */ continue; } - if ( ( error = renderInputMasa( pCurrentInput, - hIvasRend->outputConfig, - outAudio ) ) != IVAS_ERR_OK ) + if ( ( error = renderInputMasa( pCurrentInput, hIvasRend->outputConfig, outAudio ) ) != IVAS_ERR_OK ) { return error; } @@ -5141,8 +5283,9 @@ static ivas_error renderActiveInputsMasa( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_GetSamples( - IVAS_REND_HANDLE hIvasRend, - IVAS_REND_AudioBuffer outAudio ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ +) { ivas_error error; int16_t numOutChannels; @@ -5214,7 +5357,8 @@ ivas_error IVAS_REND_GetSamples( *-------------------------------------------------------------------*/ void IVAS_REND_Close( - IVAS_REND_HANDLE *phIvasRend ) + IVAS_REND_HANDLE *phIvasRend /* i/o: Pointer to renderer handle */ +) { uint16_t i; IVAS_REND_HANDLE hIvasRend; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 492ac56662..661b0e6f1f 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -271,18 +271,18 @@ ivas_error IVAS_REND_FeedInputMasaMetadata( ); ivas_error IVAS_REND_InitConfig( - IVAS_REND_HANDLE st, /* i/o: Renderer handle */ - bool rendererConfigEnabled /* i : flag indicating if a renderer configuration file was supplied */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const bool rendererConfigEnabled /* i : flag indicating if a renderer configuration file was supplied */ ); int16_t IVAS_REND_GetRenderConfig( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */ ); int16_t IVAS_REND_FeedRenderConfig( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ ); ivas_error IVAS_REND_SetHeadRotation( -- GitLab From fb6021f6b81c60a053748799e671485cc3278309 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 14:57:29 +0100 Subject: [PATCH 19/40] remove old comment --- lib_rend/ivas_hrtf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index 0e1660fd0a..76c1c275e9 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: this file functions are called from lib_dec only; is it expected, or binary HRTF support in Ext renderer will be done later? + #include #include "options.h" #include "prot.h" -- GitLab From db9d95d39513dc3b35397cbbb69b1e965e150792 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 15:15:54 +0100 Subject: [PATCH 20/40] remove destroy_SetOfHRTF() called twice --- lib_dec/ivas_init_dec.c | 1 - lib_rend/ivas_prot_rend.h | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1c9bfee8d1..15e3d0f539 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1791,7 +1791,6 @@ void ivas_destroy_dec( /* CRend binaural renderer handle */ if ( st_ivas->hSetOfHRTF != NULL ) { - destroy_SetOfHRTF( st_ivas->hSetOfHRTF ); ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 49c6ff9aba..125f988355 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -270,15 +270,15 @@ ivas_error ivas_HRTF_fastconv_binary_open( ); void ivas_HRTF_fastconv_binary_close( - HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ + HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ ); ivas_error ivas_HRTF_parambin_binary_open( - HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ + HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ ); void ivas_HRTF_parambin_binary_close( - HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ + HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */ ); ivas_error ivas_HRTF_CRend_binary_open( @@ -290,7 +290,7 @@ void ivas_HRTF_CRend_binary_close( ); void destroy_SetOfHRTF( - HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ + HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ ); -- GitLab From 0df124349ef41139ac13e56854664377a61c9fae Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 19:40:23 +0100 Subject: [PATCH 21/40] patch for Linux build --- lib_rend/ivas_crend.c | 77 ++++++++++++++++++++++++++ lib_rend/ivas_hrtf.c | 79 --------------------------- lib_rend/ivas_objectRenderer_hrFilt.c | 15 ++--- lib_util/hrtf_file_reader.c | 3 +- lib_util/hrtf_file_reader.h | 2 - 5 files changed, 86 insertions(+), 90 deletions(-) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index f650b22b55..cf9a974acd 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2721,3 +2721,80 @@ ivas_error ivas_rend_crendConvolver( } #endif + +// VE2AT: moved here to avoid Linux build error; but should it be put somewhere else? +/*---------------------------------------------------------------------* + * destroy_HRTF() + * + * Destroy the HRTF CRend handle + *---------------------------------------------------------------------*/ + +static ivas_error destroy_HRTF( + HRTFS_HANDLE *hHRTF /* i/o: HRTF CRend handle */ +) +{ + uint16_t i, j; + + if ( *hHRTF != NULL && hHRTF != NULL ) + { + for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + { + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL ) + { + 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] ); + } + } + } + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL ) + { + 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] ); + } + } + + free( *hHRTF ); + *hHRTF = NULL; + } + + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * destroy_SetOfHRTF() + * + * Destroy the HRTF data set. + *---------------------------------------------------------------------*/ + +void destroy_SetOfHRTF( + HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ +) +{ + if ( hSetOfHRTF != NULL ) + { + destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_combined ) ); + destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_hoa3 ) ); + destroy_HRTF( &( hSetOfHRTF->hHRTF_brir_combined ) ); + } + + return; +} diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index 76c1c275e9..031a9cc067 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -126,87 +126,8 @@ void ivas_HRTF_CRend_binary_close( return; } -#endif - - -/*---------------------------------------------------------------------* - * destroy_HRTF() - * - * Destroy the HRTF CRend handle - *---------------------------------------------------------------------*/ - -static ivas_error destroy_HRTF( - HRTFS_HANDLE *hHRTF /* i/o: HRTF CRend handle */ -) -{ - uint16_t i, j; - - if ( *hHRTF != NULL && hHRTF != NULL ) - { - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL ) - { - 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] ); - } - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL ) - { - 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] ); - } - } - - free( *hHRTF ); - *hHRTF = NULL; - } - - return IVAS_ERR_OK; -} -/*---------------------------------------------------------------------* - * destroy_SetOfHRTF() - * - * Destroy the HRTF data set. - *---------------------------------------------------------------------*/ - -void destroy_SetOfHRTF( - HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ -) -{ - if ( hSetOfHRTF != NULL ) - { - destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_combined ) ); - destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_hoa3 ) ); - destroy_HRTF( &( hSetOfHRTF->hHRTF_brir_combined ) ); - } - - return; -} - - -#ifdef HRTF_BINARY_FILE /*-----------------------------------------------------------------------* * ivas_HRTF_fastconv_binary_open() * diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index b1402c8340..a218784577 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -61,12 +61,12 @@ static void SkipSmallest_ValueIndex( int16_t *use_inds, const ValueIndex_t *VI, --------------------------------------------------------------------*/ ivas_error TDREND_REND_RenderSourceHRFilt( - TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */ - const float *hrf_left_delta, /* i: Left filter interpolation delta */ - const float *hrf_right_delta, /* i: Right filter interpolation delta */ - const int16_t intp_count, /* i: Interpolation count */ - float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */ - const int16_t subframe_length /* i : Subframe length in use */ + TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */ + const float *hrf_left_delta, /* i : Left filter interpolation delta */ + const float *hrf_right_delta, /* i : Right filter interpolation delta */ + const int16_t intp_count, /* i : Interpolation count */ + float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */ + const int16_t subframe_length /* i : Subframe length in use */ ) { float LeftOutputFrame[L_SPATIAL_SUBFR_48k]; @@ -496,10 +496,10 @@ void HRTF_model_precalc( maximum_s( model->azimDim3, model->elevDim3, &model->azimDim3Max ); - return; } + /*-------------------------------------------------------------------* * BSplineModelEvalDealloc() * @@ -513,6 +513,7 @@ void BSplineModelEvalDealloc( { /* Allocated in LoadBSplineBinary() */ int16_t i; + if ( model->modelROM ) { free( (void *) model->azimBsShape ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 9514f8b427..af4b851807 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -34,7 +34,7 @@ #include #include #include "prot.h" -#include "ivas_prot.h" +//#include "ivas_prot.h" #include "ivas_prot_rend.h" #ifdef HRTF_BINARY_FILE //#include "lib_dec.h" @@ -1559,7 +1559,6 @@ ivas_error create_SetOfHRTF_from_binary( if ( ( ( *hSetOfHRTF ).hHRTF_hrir_combined == NULL ) || ( ( *hSetOfHRTF ).hHRTF_brir_combined == NULL ) || ( ( *hSetOfHRTF ).hHRTF_hrir_hoa3 == NULL ) ) { - // VE2AT: Makefile build returns "undefined reference to `destroy_SetOfHRTF'"; MSCV is happy... destroy_SetOfHRTF( hSetOfHRTF ); return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create all the HRTF from binary file" ); } diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 6e5cca2968..acd6f6ae51 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -84,10 +84,8 @@ ivas_error create_SetOfHRTF_from_binary( const hrtfFileReader *hrtfReader, /* i: pointer to hrtfFileReader handle */ int32_t output_Fs /* i: Output sampling frequency */ ); -#endif -#ifdef HRTF_BINARY_FILE /*---------------------------------------------------------------------* * load_fastconv_HRTF_from_binary() * -- GitLab From 10f1ad413432940274599000845115a63d7ff4be Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 19:51:39 +0100 Subject: [PATCH 22/40] - update wrt. cmdl_tools - cleaning of to-do comments --- .gitignore | 1 + apps/renderer.c | 187 ++++++++++--------------------- lib_rend/ivas_objectRenderer.c | 2 +- lib_rend/ivas_output_init.c | 2 +- lib_util/cmdl_tools.c | 84 ++++++++++++++ lib_util/cmdl_tools.h | 7 ++ lib_util/cmdln_parser.c | 76 ++++++++----- lib_util/cmdln_parser.h | 17 +-- lib_util/ls_custom_file_reader.c | 2 +- 9 files changed, 206 insertions(+), 172 deletions(-) diff --git a/.gitignore b/.gitignore index c87c691a4a..16e82490f3 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ Externals/ # coan output files that are created when cleaning out switches coan_out_* +/lib_rend/ivas_hrtf_destroy.c diff --git a/apps/renderer.c b/apps/renderer.c index 19b88a92dd..b049de6212 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -54,6 +54,10 @@ #include "wmc_auto.h" +/*------------------------------------------------------------------------------------------* + * Local constants + *------------------------------------------------------------------------------------------*/ + #define RENDERER_MAX_CLI_ARG_LENGTH ( FILENAME_MAX ) #define RENDERER_MAX_METADATA_LENGTH 8192 #define RENDERER_MAX_METADATA_LINE_LENGTH 1024 @@ -69,6 +73,11 @@ static #define SEP_FOLDER '/' #endif + +/*------------------------------------------------------------------------------------------* + * Local structures + *------------------------------------------------------------------------------------------*/ + typedef struct { uint32_t frameCounter; @@ -264,96 +273,48 @@ static const CmdLnParser_Option cliOptions[] = { }, }; -static const int32_t numCliOptions = sizeof( cliOptions ) / sizeof( CmdLnParser_Option ); - -static IVAS_REND_AudioConfig ambisonicsOrderToEnum( - const int16_t order ); -static void parseSceneDescriptionFile( - char *path, - char *audioFilePath, - InputConfig *inConfig, - IsmPositionProvider *positionProvider, - MasaFileReader **masaReaders ); +/*------------------------------------------------------------------------------------------* + * Local function prototypes + *------------------------------------------------------------------------------------------*/ -static ivas_error parseCustomLayoutFile( - const char *filePath, - IVAS_CUSTOM_LS_DATA *pLsSetupCustom ); +static const int32_t numCliOptions = sizeof( cliOptions ) / sizeof( CmdLnParser_Option ); -static CmdlnArgs parseCmdlnArgs( - const int argc, - char **argv ); +static IVAS_REND_AudioConfig ambisonicsOrderToEnum( const int16_t order ); -static IsmPositionProvider *IsmPositionProvider_open( - void ); +static void parseSceneDescriptionFile( char *path, char *audioFilePath, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders ); -static void IsmPositionProvider_getNextFrame( - IsmPositionProvider *positionProvider, - ObjectPositionBuffer *objectMetadataBuffer ); +static ivas_error parseCustomLayoutFile( const char *filePath, IVAS_CUSTOM_LS_DATA *pLsSetupCustom ); -static void IsmPositionProvider_close( - IsmPositionProvider *positionProvider ); +static CmdlnArgs parseCmdlnArgs( const int argc, char **argv ); -static void readFromShorthandMetadata( - IsmPositionProvider *positionProvider, - ObjectPositionBuffer *objectMetadataBuffer, - const uint32_t objIdx ); - -void getMetadataFromFileReader( - IsmFileReader *ismReader, - ObjectPositionBuffer *objectMetadataBuffer, - const uint32_t objIdx ); +static IsmPositionProvider *IsmPositionProvider_open( void ); -static void splitConfigFile( - const char *mdfFilePath, - char *metadataString, - uint32_t *metadataStringLength, - char *wavFileName, - uint32_t *wavFileNameLength ); +static void IsmPositionProvider_getNextFrame( IsmPositionProvider *positionProvider, ObjectPositionBuffer *objectMetadataBuffer ); -static char *readNextMetadataChunk( - char *line, - const char *delimiter ); +static void IsmPositionProvider_close( IsmPositionProvider *positionProvider ); -static void parseUint8( - const char *line, - uint8_t *ret ); +static void readFromShorthandMetadata( IsmPositionProvider *positionProvider, ObjectPositionBuffer *objectMetadataBuffer, const uint32_t objIdx ); -static void parseUint16( - const char *line, - uint16_t *ret ); +void getMetadataFromFileReader( IsmFileReader *ismReader, ObjectPositionBuffer *objectMetadataBuffer, const uint32_t objIdx ); -static int8_t parseUint32( - const char *line, - uint32_t *ret ); +static void splitConfigFile( const char *mdfFilePath, char *metadataString, uint32_t *metadataStringLength, char *wavFileName, uint32_t *wavFileNameLength ); -static int8_t parseInt32( - const char *line, - int32_t *ret ); +static char *readNextMetadataChunk( char *line, const char *delimiter ); -static void parseObjectPosition( - char *line, - IVAS_REND_AudioObjectPosition *position, - uint16_t *positionDuration ); +static void parseUint8( const char *line, uint8_t *ret ); -static void parseMetadata( - char *metadataString, - char *inDir, - InputConfig *inConfig, - IsmPositionProvider *positionProvider, - MasaFileReader **masaReaders ); +static void parseUint16( const char *line, uint16_t *ret ); -static ivas_error parseLfePanMtxFile( - const char *lfeRoutingMatrixFilePath, - IVAS_REND_LfePanMtx *lfePanMtx ); +static int8_t parseUint32( const char *line, uint32_t *ret ); -static void convert_backslash( char *str ); +static int8_t parseInt32( const char *line, int32_t *ret ); -static void remove_cr( char *str ); +static void parseObjectPosition( char *line, IVAS_REND_AudioObjectPosition *position, uint16_t *positionDuration ); -static void clearString( char *str ); +static void parseMetadata( char *metadataString, char *inDir, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders ); -static bool isEmptyString( const char *str ); +static ivas_error parseLfePanMtxFile( const char *lfeRoutingMatrixFilePath, IVAS_REND_LfePanMtx *lfePanMtx ); static void printSupportedAudioConfigs( void ); @@ -364,7 +325,14 @@ static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSa static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); -static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( IVAS_REND_AudioBuffer buffer, const int16_t chBeginIdx, const int16_t numChannels ) +/*------------------------------------------------------------------------------------------* + * Local functions + *------------------------------------------------------------------------------------------*/ + +static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( + IVAS_REND_AudioBuffer buffer, + const int16_t chBeginIdx, + const int16_t numChannels ) { IVAS_REND_ReadOnlyAudioBuffer subBuffer; @@ -375,6 +343,7 @@ static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( IVAS_REND_AudioBuffer return subBuffer; } + static int16_t getTotalNumInChannels( IVAS_REND_HANDLE hIvasRend, IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS], @@ -454,6 +423,7 @@ static int16_t getTotalNumInChannels( return totalNumInChannels; } + static void setupWithSingleFormatInput( CmdlnArgs args, char *audioFilePath, @@ -506,6 +476,7 @@ static void setupWithSingleFormatInput( } } + static float dBToLin( const float gain_dB ) { @@ -513,7 +484,11 @@ static float dBToLin( } -/* ============================================================================ */ +/*------------------------------------------------------------------------------------------* + * main() + * + * Main External renderer function for command-line interface + *------------------------------------------------------------------------------------------*/ int main( int argc, @@ -1055,6 +1030,11 @@ int main( return 0; } + +/*------------------------------------------------------------------------------------------* + * Local functions + *------------------------------------------------------------------------------------------*/ + static IVAS_REND_AudioConfig ambisonicsOrderToEnum( const int16_t order ) { @@ -1714,7 +1694,7 @@ void readFromShorthandMetadata( return; } -void IsmPositionProvider_getNextFrame( +static void IsmPositionProvider_getNextFrame( IsmPositionProvider *positionProvider, ObjectPositionBuffer *objectMetadataBuffer ) { @@ -1760,7 +1740,8 @@ void IsmPositionProvider_getNextFrame( return; } -void IsmPositionProvider_close( IsmPositionProvider *positionProvider ) +static void IsmPositionProvider_close( + IsmPositionProvider *positionProvider ) { uint32_t i; @@ -2337,6 +2318,8 @@ static void parseSceneDescriptionFile( strncat( audioFilePath, inAudioFilePath, inAudioFilePathLen ); parseMetadata( mtdStr, inDir, inConfig, positionProvider, masaReaders ); + + return; } static void printSupportedAudioConfigs() @@ -2430,64 +2413,10 @@ static ivas_error parseLfePanMtxFile( } fclose( mtxFile ); - return IVAS_ERR_OK; -} - -// VE2AT: possibly move these functions to cmdln_parser.c ? -static void convert_backslash( - char *str ) -{ - int16_t i, len; - - /* check that all backslashes are correct on the given platform */ - len = (int16_t) strlen( str ); - - for ( i = 0; i < len; i++ ) - { -#ifdef _WIN32 - if ( str[i] == '/' ) - { - str[i] = '\\'; - } -#else - if ( str[i] == '\\' ) - { - str[i] = '/'; - } -#endif - } - return; -} - -static void remove_cr( char *str ) -{ - char *pos; - - /* remove all \r characters from the string */ - pos = strchr( str, '\r' ); - while ( pos != NULL ) - { - strcpy( pos, pos + 1 ); - pos = strchr( pos, '\r' ); - } - - return; -} - -static void clearString( - char *str ) -{ - str[0] = '\0'; - - return; + return IVAS_ERR_OK; } -static bool isEmptyString( - const char *str ) -{ - return str[0] == '\0'; -} /*--------------------------------------------------------------------------* * convertInputBuffer() diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 2135b4738c..8ebdc7cfdd 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -42,7 +42,7 @@ #endif #include "wmc_auto.h" -//VE2AT: dependency on "IVAS_REND_AudioObjectPosition" needs to be solved in this file; Could common_api_types.h be included here while "IVAS_REND_AudioObjectPosition" is part of it? +//VE2AT: dependency on "IVAS_REND_AudioObjectPosition" needs to be solved in this file /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index a85709f650..82af0cbd2f 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -29,7 +29,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: move these low-level functions to lib_com? + #include #include "options.h" #include "ivas_cnst.h" diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c index d9e4d5386e..63973667e3 100644 --- a/lib_util/cmdl_tools.c +++ b/lib_util/cmdl_tools.c @@ -31,6 +31,7 @@ *******************************************************************************************************/ #include "cmdl_tools.h" +#include /*---------------------------------------------------------------------* * to_upper() @@ -141,3 +142,86 @@ bool is_number( const char *str ) return true; } + + +/*---------------------------------------------------------------------* + * convert_backslash() + * + * + *---------------------------------------------------------------------*/ + +void convert_backslash( + char *str ) +{ + int16_t i, len; + + /* check that all backslashes are correct on the given platform */ + len = (int16_t) strlen( str ); + + for ( i = 0; i < len; i++ ) + { +#ifdef _WIN32 + if ( str[i] == '/' ) + { + str[i] = '\\'; + } +#else + if ( str[i] == '\\' ) + { + str[i] = '/'; + } +#endif + } + + return; +} + +/*---------------------------------------------------------------------* + * remove_cr() + * + * + *---------------------------------------------------------------------*/ + +void remove_cr( + char *str ) +{ + char *pos; + + /* remove all \r characters from the string */ + pos = strchr( str, '\r' ); + while ( pos != NULL ) + { + strcpy( pos, pos + 1 ); + pos = strchr( pos, '\r' ); + } + + return; +} + + +/*---------------------------------------------------------------------* + * clearString() + * + * + *---------------------------------------------------------------------*/ + +void clearString( + char *str ) +{ + str[0] = '\0'; + + return; +} + + +/*---------------------------------------------------------------------* + * isEmptyString() + * + * + *---------------------------------------------------------------------*/ + +bool isEmptyString( + const char *str ) +{ + return str[0] == '\0'; +} diff --git a/lib_util/cmdl_tools.h b/lib_util/cmdl_tools.h index 92dba6c1e1..b160473002 100644 --- a/lib_util/cmdl_tools.h +++ b/lib_util/cmdl_tools.h @@ -42,5 +42,12 @@ bool is_number( const char *str ); char *to_upper( char *str ); +void convert_backslash( char *str ); + +void remove_cr( char *str ); + +void clearString( char *str ); + +bool isEmptyString( const char *str ); #endif /* CMDL_TOOLS_H */ diff --git a/lib_util/cmdln_parser.c b/lib_util/cmdln_parser.c index 2a29505a39..860765476a 100644 --- a/lib_util/cmdln_parser.c +++ b/lib_util/cmdln_parser.c @@ -48,7 +48,9 @@ typedef struct int8_t hasBeenParsed; } Option; -static int16_t validateNoDuplicateIds( const OptionProps *props, int32_t numOpts ) +static int16_t validateNoDuplicateIds( + const OptionProps *props, + int32_t numOpts ) { for ( int32_t i = 0; i < numOpts; ++i ) { @@ -65,7 +67,8 @@ static int16_t validateNoDuplicateIds( const OptionProps *props, int32_t numOpts return 0; } -static int16_t validateOptionProps( OptionProps props ) +static int16_t validateOptionProps( + OptionProps props ) { /* Check required properties */ if ( props.match == NULL ) @@ -85,7 +88,10 @@ static int16_t validateOptionProps( OptionProps props ) } /* Validate given OptionProps and use them to initialize array of Options */ -static int16_t initOpts( const OptionProps *options, int32_t numOpts, Option *opts ) +static int16_t initOpts( + const OptionProps *options, + const int32_t numOpts, + Option *opts ) { for ( int32_t i = 0; i < numOpts; ++i ) { @@ -111,7 +117,8 @@ static int16_t initOpts( const OptionProps *options, int32_t numOpts, Option *op return 0; } -static int8_t stringLooksLikeOption( const char *str ) +static int8_t stringLooksLikeOption( + const char *str ) { if ( str[0] == '-' ) { @@ -121,7 +128,8 @@ static int8_t stringLooksLikeOption( const char *str ) return 0; } -static const char *stringToOptionName( const char *str ) +static const char *stringToOptionName( + const char *str ) { while ( *str == '-' ) { @@ -131,7 +139,9 @@ static const char *stringToOptionName( const char *str ) return str; } -static int8_t optionMatchesString( Option opt, const char *str ) +static int8_t optionMatchesString( + Option opt, + const char *str ) { if ( !stringLooksLikeOption( str ) ) { @@ -148,12 +158,13 @@ static int8_t optionMatchesString( Option opt, const char *str ) return 0; } -static int16_t parseOpts( int32_t argc, - char **argv, - Option *opts, - int32_t numOpts, - void *pOutputStruct, - CmdLnParser_FnPtr_ParseOption parseOption ) +static int16_t parseOpts( + int32_t argc, + char **argv, + Option *opts, + const int32_t numOpts, + void *pOutputStruct, + CmdLnParser_FnPtr_ParseOption parseOption ) { Option *currOpt = NULL; int32_t currOptIdx = 1; @@ -234,7 +245,8 @@ static int16_t parseOpts( int32_t argc, return 0; } -static const char *getBasename( const char *path ) +static const char *getBasename( + const char *path ) { /* Find last forward slash in path */ const char *namePtr = strrchr( path, '/' ); @@ -254,12 +266,14 @@ static const char *getBasename( const char *path ) return path; } -static int32_t totalOptionNameLength( const OptionProps opt ) +static int32_t totalOptionNameLength( + const OptionProps opt ) { return strlen( opt.match ) + strlen( opt.matchShort ); } -static void printWhitespace( int32_t n ) +static void printWhitespace( + const int32_t n ) { for ( int32_t i = 0; i < n; ++i ) { @@ -267,7 +281,9 @@ static void printWhitespace( int32_t n ) } } -static void printOptDescriptionAligned( const char *descPtr, int32_t descriptionColumnIdx ) +static void printOptDescriptionAligned( + const char *descPtr, + int32_t descriptionColumnIdx ) { if ( descPtr == NULL ) { @@ -290,12 +306,14 @@ static void printOptDescriptionAligned( const char *descPtr, int32_t description } ++descPtr; } + + return; } static void printUsage( const char *argv0, const OptionProps *optionProps, - int32_t numOptions ) + const int32_t numOptions ) { fprintf( stderr, "\n" ); fprintf( stderr, "Usage: %s [options]\n", getBasename( argv0 ) ); @@ -326,14 +344,17 @@ static void printUsage( printWhitespace( maxOptNameLength - optNameLength + preDescriptionWhitespace ); printOptDescriptionAligned( opt.description, maxOptNameLength + preDescriptionWhitespace + leftColumnAdditionalChars ); } + + return; } -int16_t CmdLnParser_parseArgs( int32_t argc, - char **argv, - const OptionProps *optionProps, - int32_t numOptions, - void *pOutputStruct, - CmdLnParser_FnPtr_ParseOption parseOption ) +int16_t CmdLnParser_parseArgs( + int32_t argc, + char **argv, + const OptionProps *optionProps, + const int32_t numOptions, + void *pOutputStruct, + CmdLnParser_FnPtr_ParseOption parseOption ) { assert( numOptions <= MAX_SUPPORTED_OPTS ); @@ -357,9 +378,12 @@ fail: return -1; } -void CmdLnParser_printUsage( char *executableName, - const CmdLnParser_Option *options, - int32_t numOptions ) +void CmdLnParser_printUsage( + char *executableName, + const CmdLnParser_Option *options, + const int32_t numOptions ) { printUsage( executableName, options, numOptions ); + + return; } diff --git a/lib_util/cmdln_parser.h b/lib_util/cmdln_parser.h index b5db25c193..61f3ad4a30 100644 --- a/lib_util/cmdln_parser.h +++ b/lib_util/cmdln_parser.h @@ -47,21 +47,10 @@ typedef struct } CmdLnParser_Option; /* Function for parsing option values into an output struct, to be implemented by the user */ -typedef void ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, /* i : option ID of matched option */ - char **optionValues, /* i : array of string values following the matched option in argv */ - int16_t numOptionValues, /* i : number of string values following the matched option in argv */ - void *pOutputStruct /* o : struct to store parsed values */ -); +typedef void ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct ); -int16_t CmdLnParser_parseArgs( int32_t argc, - char **argv, - const CmdLnParser_Option *options, - int32_t numOptions, - void *pOutputStruct, - CmdLnParser_FnPtr_ParseOption parseOption ); +int16_t CmdLnParser_parseArgs( int32_t argc, char **argv, const CmdLnParser_Option *options, const int32_t numOptions, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption ); -void CmdLnParser_printUsage( char *executableName, - const CmdLnParser_Option *options, - int32_t numOptions ); +void CmdLnParser_printUsage( char *executableName, const CmdLnParser_Option *options, const int32_t numOptions ); #endif /* CMDLN_PARSER_H */ diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index d2e823c816..1295a2685d 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -269,7 +269,7 @@ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading( tok++; } - if ( *tok == '\0' ) + if ( *tok == '\0' ) // replace by isEmptyString() { continue; } -- GitLab From 82c2d01d7caa40337eaeb15a7964a38e93705389 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 20:15:50 +0100 Subject: [PATCH 23/40] cleaning --- lib_com/ivas_cnst.h | 7 +++--- lib_com/ivas_prot.h | 3 --- lib_dec/ivas_corecoder_dec_reconfig.c | 1 - lib_dec/ivas_init_dec.c | 1 - lib_dec/ivas_output_config.c | 3 --- lib_dec/ivas_stat_dec.h | 4 ++-- lib_rend/ivas_allrad_dec.c | 4 +--- lib_rend/ivas_crend.c | 2 -- lib_rend/ivas_efap.c | 1 - lib_rend/ivas_hrtf.c | 1 - lib_rend/ivas_limiter.c | 3 --- lib_rend/ivas_objectRenderer.c | 1 - lib_rend/ivas_objectRenderer_hrFilt.c | 2 -- lib_rend/ivas_objectRenderer_mix.c | 1 - lib_rend/ivas_objectRenderer_sfx.c | 1 - lib_rend/ivas_objectRenderer_sources.c | 9 ++++++- lib_rend/ivas_objectRenderer_vec.c | 2 +- lib_rend/ivas_orient_trk.c | 1 - lib_rend/ivas_output_init.c | 3 --- lib_rend/ivas_render_config.c | 1 - lib_rend/ivas_reverb.c | 1 - lib_rend/ivas_reverb_fft_filter.c | 2 +- lib_rend/ivas_reverb_filter_design.c | 1 - lib_rend/ivas_reverb_iir_filter.c | 2 -- lib_rend/ivas_reverb_utils.c | 2 -- lib_rend/ivas_rotation.c | 4 ---- lib_rend/lib_rend.c | 33 +++++++++++++++----------- lib_rend/lib_rend.h | 3 --- lib_util/hrtf_file_reader.c | 4 ---- lib_util/ls_custom_file_reader.c | 4 ++-- lib_util/masa_file_reader.c | 2 +- lib_util/mime_io.c | 2 +- lib_util/render_config_reader.c | 2 +- 33 files changed, 40 insertions(+), 73 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 4195ce07ec..58716b2465 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -36,7 +36,6 @@ #include #include "options.h" #include "cnst.h" -//#include "ivas_error.h" /* clang-format off */ @@ -1380,9 +1379,9 @@ typedef enum typedef enum { BINAURAL_INPUT_AUDIO_CONFIG_INVALID, - BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, // 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4 - BINAURAL_INPUT_AUDIO_CONFIG_HOA, // FOA, HOA2, HOA3 - BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED // Not used + BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, /* 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4 */ + BINAURAL_INPUT_AUDIO_CONFIG_HOA, /* FOA, HOA2, HOA3 */ + BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED /* Not used */ } BINAURAL_INPUT_AUDIO_CONFIG; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 39dac79d10..9c45dfec93 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -40,9 +40,6 @@ #include "stat_enc.h" #include "stat_dec.h" #include "stat_com.h" -#ifdef FIX_197_CREND_INTERFACE -//#include "ivas_stat_rend.h" -#endif #include "ivas_stat_enc.h" #include "ivas_stat_dec.h" #include "ivas_stat_com.h" diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index d19834ddcb..21b8cdf05f 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -35,7 +35,6 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" -//#include "lib_dec.h" #include "prot.h" #include #include diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 15e3d0f539..cf938f3738 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -36,7 +36,6 @@ #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" -//#include "lib_dec.h" #include "prot.h" #include #include diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 1f0350633a..85a2e1af20 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -34,10 +34,7 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" -//#include "prot.h" #include "ivas_stat_dec.h" -//#include "ivas_rom_dec.h" -//#include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #include diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index b802e12fe9..be23f6af40 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1113,7 +1113,7 @@ typedef struct ivas_binaural_rendering_struct /*----------------------------------------------------------------------------------* * EFAP structures *----------------------------------------------------------------------------------*/ -// + typedef struct EFAP_VERTEX { float azi; /* azimuth of the loudspeaker */ @@ -1176,7 +1176,7 @@ typedef struct EFAP /*----------------------------------------------------------------------------------* * VBAP structures *----------------------------------------------------------------------------------*/ -// + enum SpeakerNodeGroup { SPEAKER_NODE_BOTTOM_HALF, diff --git a/lib_rend/ivas_allrad_dec.c b/lib_rend/ivas_allrad_dec.c index cb7651d44e..fc840755aa 100644 --- a/lib_rend/ivas_allrad_dec.c +++ b/lib_rend/ivas_allrad_dec.c @@ -31,14 +31,12 @@ *******************************************************************************************************/ #include +#include "options.h" #include #include -//#include -#include "options.h" #include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" -//#include "ivas_stat_dec.h" #include "ivas_rom_rend.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index cf9a974acd..58f1995aba 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -37,12 +37,10 @@ #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" -//#include "ivas_stat_dec.h" #include #include "ivas_rom_binaural_crend_head.h" #ifdef FIX_197_CREND_INTERFACE #include "ivas_stat_rend.h" -//#include "lib_rend.h" #else #include "lib_rend.h" #include "ivas_lib_rend_internal.h" diff --git a/lib_rend/ivas_efap.c b/lib_rend/ivas_efap.c index afc27f04af..4301d75dec 100644 --- a/lib_rend/ivas_efap.c +++ b/lib_rend/ivas_efap.c @@ -39,7 +39,6 @@ #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" -//#include "ivas_rom_dec.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index 031a9cc067..b38785c8e1 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_error.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter.c index 9f86416681..9ea9192e2e 100644 --- a/lib_rend/ivas_limiter.c +++ b/lib_rend/ivas_limiter.c @@ -33,10 +33,7 @@ #include #include "options.h" #include -//#include -//#include #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" #include diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 8ebdc7cfdd..e943502973 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index a218784577..0220b48145 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -35,11 +35,9 @@ #include "options.h" #include "prot.h" #include -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "ivas_cnst.h" -//#include "ivas_rom_TdBinauralRenderer.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index d26b1fbfe1..daefc63160 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_TdBinauralRenderer.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index a812b4640a..005025827b 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "prot.h" diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index ee2dfe484f..694764979d 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -34,25 +34,32 @@ #include "options.h" #include #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" #endif + /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ static void TDREND_SRC_SPATIAL_Dealloc( TDREND_SRC_SPATIAL_t *SrcSpatial_p ); + static void TDREND_SRC_SPATIAL_Init( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_PosType_t PosType ); + static void TDREND_SRC_SPATIAL_SetDirAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DirAtten_t *DirAtten_p ); + static float TDREND_SRC_SPATIAL_GetDirGain( const TDREND_DirAtten_t *DirAtten_p, const float *Front_p, const float *RelPos_p ); + static float TDREND_SRC_SPATIAL_GetDistGain( const TDREND_DistAtten_t *DistAtten_p, const float Dist ); + static ivas_error TDREND_SRC_REND_Alloc( TDREND_SRC_REND_t **SrcRend_pp ); + static void TDREND_SRC_REND_Init( TDREND_SRC_REND_t *SrcRend_p ); + /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetPos() * diff --git a/lib_rend/ivas_objectRenderer_vec.c b/lib_rend/ivas_objectRenderer_vec.c index e23c324912..c3a780c725 100644 --- a/lib_rend/ivas_objectRenderer_vec.c +++ b/lib_rend/ivas_objectRenderer_vec.c @@ -34,13 +34,13 @@ #include "options.h" #include #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" #endif + /*-------------------------------------------------------------------* * TDREND_SPATIAL_VecInit() * diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index 070ffc9cfb..4b72c16ce6 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -32,7 +32,6 @@ #include #include "options.h" -//#include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 82af0cbd2f..193e775f22 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -33,11 +33,8 @@ #include #include "options.h" #include "ivas_cnst.h" -//#include "ivas_prot.h" #include "prot.h" #include "ivas_prot_rend.h" -//#include "ivas_stat_dec.h" -//#include "ivas_rom_dec.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index c6a42a4537..405ae8d72f 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "ivas_rom_TdBinauralRenderer.h" diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 550a3e2951..ee1e3ca215 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c index ef2dacf3a0..725f5e6bc1 100644 --- a/lib_rend/ivas_reverb_fft_filter.c +++ b/lib_rend/ivas_reverb_fft_filter.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #ifdef DEBUGGING #include "debug.h" @@ -47,6 +46,7 @@ *------------------------------------------------------------------------------------------*/ static void fft_wrapper_2ch( float *buffer_L, float *buffer_R, const int16_t fft_size ); + static void ifft_wrapper_2ch( float *buffer_L, float *buffer_R, const int16_t fft_size ); diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c index 5da6ca8ac1..3069d1248a 100644 --- a/lib_rend/ivas_reverb_filter_design.c +++ b/lib_rend/ivas_reverb_filter_design.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_rend/ivas_reverb_iir_filter.c b/lib_rend/ivas_reverb_iir_filter.c index fb52a5d2a2..ce73c9d864 100644 --- a/lib_rend/ivas_reverb_iir_filter.c +++ b/lib_rend/ivas_reverb_iir_filter.c @@ -33,12 +33,10 @@ #include #include "options.h" #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" #ifdef DEBUGGING #include "debug.h" #endif -#include #include "wmc_auto.h" diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index c4d7f7d49e..46b56d430f 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -33,9 +33,7 @@ #include #include "options.h" #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" -//#include "ivas_rom_binauralRenderer.h" #include "ivas_rom_rend.h" #include #ifdef DEBUGGING diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index a39f34d82f..2622d02308 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -36,11 +36,7 @@ #include #include "cnst.h" #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" -//#include "ivas_cnst.h" -//#include "ivas_rom_com.h" -//#include "ivas_rom_dec.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 1d207a0c7c..4be94427f5 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -31,26 +31,22 @@ *******************************************************************************************************/ #include "options.h" -#include "ivas_cnst.h" #include "lib_rend.h" +#include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" +#include "ivas_cnst.h" #include "ivas_rom_com.h" -//#include "ivas_rom_dec.h" #include "ivas_rom_rend.h" -//#include "ivas_stat_rend.h" -#ifdef FIX_197_CREND_INTERFACE -//#include "lib_rend.h" -#endif -#include "prot.h" -#include "wmc_auto.h" - #include #include #include -#include -#include -#include +#include "wmc_auto.h" + + +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ /* Maximum buffer length (per channel) in samples. * Keep this separate from L_FRAME48k in case we want to support different size later */ @@ -63,6 +59,10 @@ #define BINAURAL_RENDERING_FRAME_SIZE_MS 20 +/*-------------------------------------------------------------------* + * Local types + *-------------------------------------------------------------------*/ + typedef float pan_vector[MAX_OUTPUT_CHANNELS]; typedef float pan_matrix[MAX_INPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; typedef float rotation_gains[MAX_INPUT_CHANNELS][MAX_INPUT_CHANNELS]; @@ -203,6 +203,11 @@ struct IVAS_REND RENDER_CONFIG_DATA *hRendererConfig; /* Renderer config pointer */ }; + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ + static IVAS_QUATERNION quaternionInit( void ) { @@ -214,8 +219,8 @@ static IVAS_QUATERNION quaternionInit( static float *getSmplPtr( IVAS_REND_AudioBuffer buffer, - uint32_t chnlIdx, - uint32_t smplIdx ) + const uint32_t chnlIdx, + const uint32_t smplIdx ) { return buffer.data + chnlIdx * buffer.config.numSamplesPerChannel + smplIdx; } diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 661b0e6f1f..18f4dd60e2 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -33,9 +33,6 @@ #ifndef LIB_REND_H #define LIB_REND_H -//#include -//#include -//#include #include "common_api_types.h" #include "ivas_error.h" #include diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index af4b851807..0d413cb4aa 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -34,11 +34,7 @@ #include #include #include "prot.h" -//#include "ivas_prot.h" #include "ivas_prot_rend.h" -#ifdef HRTF_BINARY_FILE -//#include "lib_dec.h" -#endif /*---------------------------------------------------------------------* diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 1295a2685d..ace442029d 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -34,8 +34,8 @@ #include #include #include -#include "ivas_prot.h" // VE: !!!!! -#include "prot.h" // VE: !!!!! +#include "ivas_prot.h" +#include "prot.h" struct LsCustomFileReader diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 29ef9e347a..58ecf35c82 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -31,7 +31,7 @@ *******************************************************************************************************/ #include "masa_file_reader.h" -#include "ivas_prot.h" // VE: !!!!! +#include "ivas_prot.h" #include "ivas_stat_com.h" #include #include diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index b640512466..4615a9219d 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -33,7 +33,7 @@ #include "options.h" #include "mime_io.h" #include "mime.h" -#include "prot.h" // VE: !!!!! +#include "prot.h" #include "string.h" #include #include diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 3ade7e576a..c715905938 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -37,7 +37,7 @@ #include #include #include "cmdl_tools.h" -#include "prot.h" // VE: !!!!! +#include "prot.h" /*------------------------------------------------------------------------------------------* -- GitLab From 122053bbf18e1e016e61643c641c2eb520d61631 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 20:20:29 +0100 Subject: [PATCH 24/40] - cleaning - apply clang-format --- lib_dec/ivas_ism_renderer.c | 2 +- lib_rend/ivas_objectRenderer.c | 4 ++-- lib_rend/ivas_stat_rend.h | 9 +-------- lib_rend/lib_rend.c | 30 +++++++++++++++--------------- lib_util/cmdl_tools.c | 2 +- 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 00052f1667..a965a0ffed 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -205,7 +205,7 @@ void ivas_ism_render( /*-------------------------------------------------------------------------* * ivas_ism_get_stereo_gains() * - * + * *-------------------------------------------------------------------------*/ void ivas_ism_get_stereo_gains( diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index e943502973..b33d43bac1 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -41,7 +41,7 @@ #endif #include "wmc_auto.h" -//VE2AT: dependency on "IVAS_REND_AudioObjectPosition" needs to be solved in this file +// VE2AT: dependency on "IVAS_REND_AudioObjectPosition" needs to be solved in this file /*---------------------------------------------------------------------* @@ -289,7 +289,7 @@ void TDREND_Update_listener_orientation( /*---------------------------------------------------------------------* * ivas_rend_TDObjRendOpen() * - * + * *---------------------------------------------------------------------*/ ivas_error ivas_rend_TDObjRendOpen( diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index a11a43a669..43a83a6409 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -45,9 +45,6 @@ #ifdef FIX_197_CREND_INTERFACE -//typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; - - typedef struct { float azimuth; @@ -55,12 +52,8 @@ typedef struct } IVAS_REND_AudioObjectPosition; // VE2AT: where should this go, into common_api_types.h, ...? Or should there be introduced public -> internal conversion? -//typedef struct IVAS_REND *IVAS_REND_HANDLE; -//typedef struct IVAS_REND const *IVAS_REND_CONST_HANDLE; - - // VE2AT: not used, can it be removed? -//typedef struct +// typedef struct //{ // int16_t numLfeChannels; // float lfeOutputGains[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 4be94427f5..48213de6e1 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -5445,24 +5445,24 @@ int32_t IVAS_REND_GetCntFramesLimited( *-------------------------------------------------------------------*/ #ifdef FIX_197_CREND_INTERFACE -//ivas_error ivas_rend_initEfap( // VE2AT: this function is not used - could it be removed? -// AUDIO_CONFIG outConfig, -// EFAP_HANDLE *hEfap ) +// ivas_error ivas_rend_initEfap( // VE2AT: this function is not used - could it be removed? +// AUDIO_CONFIG outConfig, +// EFAP_HANDLE *hEfap ) //{ -// ivas_error err; -// IVAS_REND_AudioConfig audioCfg; -// EFAP_WRAPPER wrap; -// LSSETUP_CUSTOM_STRUCT customLsOut; +// ivas_error err; +// IVAS_REND_AudioConfig audioCfg; +// EFAP_WRAPPER wrap; +// LSSETUP_CUSTOM_STRUCT customLsOut; // -// wrap.hEfap = NULL; -// wrap.pCustomLsSetup = NULL; -// audioCfg = getRendAudioConfigFromIvasAudioConfig( outConfig ); -// memset( &customLsOut, 0, sizeof( LSSETUP_CUSTOM_STRUCT ) ); -// err = initEfap( &wrap, audioCfg, &customLsOut ); +// wrap.hEfap = NULL; +// wrap.pCustomLsSetup = NULL; +// audioCfg = getRendAudioConfigFromIvasAudioConfig( outConfig ); +// memset( &customLsOut, 0, sizeof( LSSETUP_CUSTOM_STRUCT ) ); +// err = initEfap( &wrap, audioCfg, &customLsOut ); // -// *hEfap = wrap.hEfap; +// *hEfap = wrap.hEfap; // -// return err; -//} +// return err; +// } #endif diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c index 63973667e3..b0b7e906cc 100644 --- a/lib_util/cmdl_tools.c +++ b/lib_util/cmdl_tools.c @@ -147,7 +147,7 @@ bool is_number( const char *str ) /*---------------------------------------------------------------------* * convert_backslash() * - * + * *---------------------------------------------------------------------*/ void convert_backslash( -- GitLab From 369cfb351314bdee287f2a11abdd4dfd71a75946 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 20:21:50 +0100 Subject: [PATCH 25/40] remove unnecessary declarations --- lib_rend/ivas_rom_rend.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 825858db1f..cb43c2a0ff 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -117,26 +117,6 @@ extern const float ls_elevation_CICP1[1]; /* Downmix matrices */ extern const float ls_conversion_cicpX_mono[12][1]; extern const float ls_conversion_cicpX_stereo[12][2]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp6[]; -#ifdef FIX_I54_LS_CONVERSION -extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp12[]; -#endif -extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp6[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp14[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp6[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp12[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp14[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp16[]; - -/* Upmix matrices */ -extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp14[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp16[]; -#ifdef FIX_I54_LS_CONVERSION -extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp19[]; -#endif -extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp19[]; -extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp19[]; /* Mapping table of input config : output config with corresponding matrix */ extern const LS_CONVERSION_MAPPING ls_conversion_mapping[]; -- GitLab From 6fdfb05f74754843b8a25c5ab2f5e91899775adb Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 20:46:43 +0100 Subject: [PATCH 26/40] add missing file --- lib_dec/ivas_objectRenderer_internal.c | 249 +++++++++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 lib_dec/ivas_objectRenderer_internal.c diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c new file mode 100644 index 0000000000..06bbc4d57f --- /dev/null +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -0,0 +1,249 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "prot.h" +#include "ivas_prot.h" +#include "ivas_prot_rend.h" +#include +#include "ivas_rom_com.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + + +/*---------------------------------------------------------------------* + * ivas_td_binaural_open() + * + * Open and initialize TD Object binaural renderer + *---------------------------------------------------------------------*/ + +ivas_error ivas_td_binaural_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; + TDREND_PosType_t PosType; + int16_t nS; + int16_t SrcInd[MAX_NUM_TDREND_CHANNELS]; + const float *ls_azimuth, *ls_elevation; + float Pos[3]; + float Dir[3]; + TDREND_DirAtten_t *DirAtten_p; + int16_t nchan_rend; + ivas_error error; + + error = IVAS_ERR_OK; + + if ( ( hBinRendererTd = malloc( sizeof( BINAURAL_TD_OBJECT_RENDERER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); + } + if ( ( hBinRendererTd->TdRend_MixSpatSpec_p = malloc( sizeof( TDREND_MixSpatSpec_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); + } + if ( ( hBinRendererTd->DirAtten_p = malloc( sizeof( TDREND_DirAtten_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); + } + if ( ( hBinRendererTd->Listener_p = malloc( sizeof( TDREND_MIX_Listener_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); + } + + hBinRendererTd->NumOfSrcs = 0; + hBinRendererTd->MaxSrcInd = -1; + + /* Mixer spatial setup */ + hBinRendererTd->TdRend_MixSpatSpec_p->UseCommonDistAttenModel = TRUE; + hBinRendererTd->TdRend_MixSpatSpec_p->DistAttenModel = 0; /* 0=Turned off, else use TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED */ + + TDREND_MIX_Init( hBinRendererTd, &st_ivas->hHrtfTD, hBinRendererTd->TdRend_MixSpatSpec_p, st_ivas->hDecoderConfig->output_Fs ); + + /* Set the attenuation (or can set MixSpatSpec.DistAttenModel above) */ + TDREND_MIX_SetDistAttenModel( hBinRendererTd, TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED ); + + /* Add sources to module and mixer, headphones */ + PosType = TDREND_POSTYPE_ABSOLUTE; /* or TDREND_POSTYPE_RELATIVE_TO_LISTENER */ + + nchan_rend = st_ivas->nchan_transport; + if ( st_ivas->ivas_format == MC_FORMAT ) + { + nchan_rend--; /* Skip LFE channel -- added to the others */ + } + + for ( nS = 0; nS < nchan_rend; nS++ ) + { + if ( ( error = TDREND_MIX_AddSrc( hBinRendererTd, &SrcInd[nS], PosType ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( st_ivas->ivas_format == MC_FORMAT ) + { + switch ( st_ivas->transport_config ) + { + case AUDIO_CONFIG_5_1: + ls_azimuth = ls_azimuth_CICP6; + ls_elevation = ls_elevation_CICP6; + break; + case AUDIO_CONFIG_7_1: + ls_azimuth = ls_azimuth_CICP12; + ls_elevation = ls_elevation_CICP12; + break; + case AUDIO_CONFIG_5_1_2: + ls_azimuth = ls_azimuth_CICP14; + ls_elevation = ls_elevation_CICP14; + break; + case AUDIO_CONFIG_5_1_4: + ls_azimuth = ls_azimuth_CICP16; + ls_elevation = ls_elevation_CICP16; + break; + case AUDIO_CONFIG_7_1_4: + ls_azimuth = ls_azimuth_CICP19; + ls_elevation = ls_elevation_CICP19; + break; + case AUDIO_CONFIG_LS_CUSTOM: + ls_azimuth = st_ivas->hTransSetup.ls_azimuth; + ls_elevation = st_ivas->hTransSetup.ls_elevation; + break; + default: + ls_azimuth = NULL; + ls_elevation = NULL; + } + + DirAtten_p = hBinRendererTd->DirAtten_p; + + for ( nS = 0; nS < nchan_rend; nS++ ) + { + /* Set source positions according to loudspeaker layout */ + Pos[0] = cosf( ls_elevation[nS] * PI_OVER_180 ) * cosf( ls_azimuth[nS] * PI_OVER_180 ); + Pos[1] = cosf( ls_elevation[nS] * PI_OVER_180 ) * sinf( ls_azimuth[nS] * PI_OVER_180 ); + Pos[2] = sinf( ls_elevation[nS] * PI_OVER_180 ); + Dir[0] = 1.0f; + Dir[1] = 0.0f; + Dir[2] = 0.0f; + + /* Source directivity info */ + DirAtten_p->ConeInnerAngle = 360.0f; + DirAtten_p->ConeOuterAngle = 360.0f; + DirAtten_p->ConeOuterGain = 1.0f; + + TDREND_MIX_SRC_SetPos( hBinRendererTd, nS, Pos ); + TDREND_MIX_SRC_SetDir( hBinRendererTd, nS, Dir ); + TDREND_MIX_SRC_SetPlayState( hBinRendererTd, nS, TDREND_PLAYSTATUS_PLAYING ); + TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p ); + } + } + + st_ivas->hBinRendererTd = hBinRendererTd; + +#ifdef FIX_310_TD_REND_DELAY + st_ivas->binaural_latency_ns = (int32_t) ( hBinRendererTd->HrFiltSet_p->latency_s * 1000000000.f ); +#else + st_ivas->binaural_latency_ns = (int32_t) ( BINAURAL_TD_LATENCY_S * 1000000000.f ); +#endif + + return error; +} + + +/*---------------------------------------------------------------------* + * ivas_td_binaural_renderer() + * + * Receives the current frames for the object streams, updates metadata + * and renders the current frame. + *---------------------------------------------------------------------*/ + +void ivas_td_binaural_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ + const int16_t output_frame /* i : output frame length */ +) +{ + int16_t subframe_length; + int16_t subframe_idx; + float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k]; + + subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; + if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ + { + + if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on && ( st_ivas->ini_frame == 0 ) ) + { +#ifdef FIX_197_CREND_INTERFACE + ivas_reverb_open( &st_ivas->hCrendWrapper->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ); +#else + ivas_reverb_open( &st_ivas->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ); +#endif + } + } + + /* Update object position(s) */ + TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, output ); + + for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) + { + /* Update the listener's location/orientation */ + TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, + st_ivas->hDecoderConfig->Opt_Headrotation, + ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[subframe_idx] : NULL ); + + if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) + { +#ifdef FIX_197_CREND_INTERFACE + ivas_reverb_process( st_ivas->hCrendWrapper->hCrend->hReverb, st_ivas->transport_config, 0, output, reverb_signal, subframe_idx ); +#else + ivas_reverb_process( st_ivas->hCrend->hReverb, st_ivas->transport_config, 0, output, reverb_signal, subframe_idx ); +#endif + } + + /* Render subframe */ + TDREND_GetMix( st_ivas->hBinRendererTd, output, subframe_length, subframe_idx ); + } + + if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ + { + if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) + { + /* add reverb to rendered signals */ + v_add( reverb_signal[0], output[0], output[0], output_frame ); + v_add( reverb_signal[1], output[1], output[1], output_frame ); + } + } + + return; +} -- GitLab From c57ac5dc3bddc21a6ac2a0c6db5508cfc8645a16 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Feb 2023 22:00:50 +0100 Subject: [PATCH 27/40] fix merging issue --- lib_rend/ivas_objectRenderer_mix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index daefc63160..f22d83fb23 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -495,6 +495,9 @@ static void DefaultBSplineModel( HRTF_model_precalc( model ); +#ifdef FIX_310_TD_REND_DELAY + HrFiltSet_p->latency_s = orange53_rom_latency_s; +#endif HrFiltSet_p->SampleRate = output_Fs; HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; -- GitLab From fceb96f4b7301f89b6fd14dada86ffc69f49ed65 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 14 Feb 2023 14:33:15 +0100 Subject: [PATCH 28/40] address/remove a few VE2AT comments --- lib_dec/ivas_ls_custom_dec.c | 1 - lib_dec/ivas_stat_dec.h | 1 + lib_dec/ivas_td_decorr.c | 2 +- lib_rend/ivas_prot_rend.h | 2 +- lib_rend/ivas_stat_rend.h | 12 ++---------- lib_rend/lib_rend.c | 31 +------------------------------ lib_rend/lib_rend.h | 2 +- 7 files changed, 7 insertions(+), 44 deletions(-) diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c index 824163f985..ef3698ab8c 100644 --- a/lib_dec/ivas_ls_custom_dec.c +++ b/lib_dec/ivas_ls_custom_dec.c @@ -29,7 +29,6 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -// VE2AT: this file functions are called from lib_dec only; is it expected, or it will be implemented for Ext renderer later? #include #include "options.h" #include "ivas_prot.h" diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index be23f6af40..0177f1d15f 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1033,6 +1033,7 @@ typedef struct ivas_lfe_dec_data_structure // VE2AT: the following structures are used only in lib_dec; is it expected? +// AT2VE: at the moment yes, I anticipate we will need to move them out in the future. /*----------------------------------------------------------------------------------* * VBAP structures *----------------------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_td_decorr.c b/lib_dec/ivas_td_decorr.c index c0cb0e54dd..3b903ac8a3 100644 --- a/lib_dec/ivas_td_decorr.c +++ b/lib_dec/ivas_td_decorr.c @@ -100,7 +100,7 @@ static ivas_error ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, const * * Allocate and initialize SPAR time domain decorrelator handle *------------------------------------------------------------------------*/ -// VE2AT: this function is used also in lib_rend...; where to put it? +// VE2AT: this function is used also in lib_rend...; where to put it? --> TODO move ivas_error ivas_spar_td_decorr_dec_open( ivas_td_decorr_state_t **hTdDecorr, /* i/o: SPAR Covar. decoder handle */ const int32_t output_Fs, /* i : output sampling rate */ diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 125f988355..1ed1a0fe42 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -41,7 +41,7 @@ #else #include "lib_rend.h" #endif -#include "ivas_stat_dec.h" // VE2AT: needed for Decoder_Struct; what to do with this? Is this related to #156? +#include "ivas_stat_dec.h" // VE2AT: needed for Decoder_Struct; what to do with this? Is this related to #156? AT2VE: Yes, need to keep until #156 is resolved. /* clang-format off */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 43a83a6409..f7c872ef1d 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -38,7 +38,7 @@ #include "cnst.h" #include "ivas_cnst.h" #include "ivas_stat_com.h" -#include "common_api_types.h" // VE2AT: should it stay here? (in lib_enc, lib_dec, there is no such include) +#include "common_api_types.h" #endif @@ -49,15 +49,7 @@ typedef struct { float azimuth; float elevation; -} IVAS_REND_AudioObjectPosition; // VE2AT: where should this go, into common_api_types.h, ...? Or should there be introduced public -> internal conversion? - - -// VE2AT: not used, can it be removed? -// typedef struct -//{ -// int16_t numLfeChannels; -// float lfeOutputGains[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; -//} IVAS_REND_LfeRouting; +} IVAS_REND_AudioObjectPosition; // VE2AT: where should this go, into common_api_types.h, ...? Or should there be introduced public -> internal conversion? AT2VE: will be moved back in !421 typedef struct { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 48213de6e1..6782542b17 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2439,7 +2439,7 @@ static DecoderDummy *initDecoderDummy( decDummy->hHrtfTD = NULL; decDummy->hSpar = NULL; decDummy->hoa_dec_mtx = NULL; - decDummy->hVBAPdata = NULL; // VE2AT: is "hVBAPdata" really used in Ext Rend? + decDummy->hVBAPdata = NULL; // VE2AT: is "hVBAPdata" really used in Ext Rend? AT2VE: not at the moment, we should not depend on Decoder_Struct here anyway. decDummy->hMasa = NULL; decDummy->hDiracDecBin = NULL; decDummy->hQMetaData = NULL; @@ -5437,32 +5437,3 @@ int32_t IVAS_REND_GetCntFramesLimited( } #endif - -/*-------------------------------------------------------------------* - * ivas_rend_initEfap() - * - * - *-------------------------------------------------------------------*/ - -#ifdef FIX_197_CREND_INTERFACE -// ivas_error ivas_rend_initEfap( // VE2AT: this function is not used - could it be removed? -// AUDIO_CONFIG outConfig, -// EFAP_HANDLE *hEfap ) -//{ -// ivas_error err; -// IVAS_REND_AudioConfig audioCfg; -// EFAP_WRAPPER wrap; -// LSSETUP_CUSTOM_STRUCT customLsOut; -// -// wrap.hEfap = NULL; -// wrap.pCustomLsSetup = NULL; -// audioCfg = getRendAudioConfigFromIvasAudioConfig( outConfig ); -// memset( &customLsOut, 0, sizeof( LSSETUP_CUSTOM_STRUCT ) ); -// err = initEfap( &wrap, audioCfg, &customLsOut ); -// -// *hEfap = wrap.hEfap; -// -// return err; -// } - -#endif diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 18f4dd60e2..96767b90ae 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -38,7 +38,7 @@ #include #include #ifdef FIX_197_CREND_INTERFACE -#include "ivas_stat_rend.h" // VE2AT: this should go away, right? the remaining dependency is "IVAS_REND_AudioObjectPosition" +#include "ivas_stat_rend.h" // VE2AT: this should go away, right? the remaining dependency is "IVAS_REND_AudioObjectPosition" AT2VE: Will be removed with !421 #endif #define RENDERER_MAX_ISM_INPUTS 4 -- GitLab From fd09e35e46cdaca583b8e117ec35c05c52bdd376 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 14 Feb 2023 14:53:06 +0100 Subject: [PATCH 29/40] remove/update comments --- lib_com/ivas_prot.h | 3 +-- lib_dec/ivas_stat_dec.h | 3 +-- lib_rend/ivas_objectRenderer.c | 2 -- lib_rend/ivas_prot_rend.h | 2 +- lib_rend/ivas_stat_rend.h | 2 +- lib_rend/lib_rend.c | 3 +-- lib_rend/lib_rend.h | 2 +- lib_util/hrtf_file_reader.h | 2 +- 8 files changed, 7 insertions(+), 12 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9c45dfec93..3b35b3ca45 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4470,8 +4470,7 @@ void ivas_spar_param_to_masa_param_mapping( *----------------------------------------------------------------------------------*/ -// VE2AT: this function is used in lib_rend at one place - the function ivas_rend_initEfap() is however not used; where is its best place? -// VE2AT: possibly rename it +// note: will be rmeoved with !421 IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( AUDIO_CONFIG config ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 0177f1d15f..b44d07325f 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1032,8 +1032,7 @@ typedef struct ivas_lfe_dec_data_structure } LFE_DEC_DATA, *LFE_DEC_HANDLE; -// VE2AT: the following structures are used only in lib_dec; is it expected? -// AT2VE: at the moment yes, I anticipate we will need to move them out in the future. +// Note: the following structures are used only in lib_dec but this would likely change in the future /*----------------------------------------------------------------------------------* * VBAP structures *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index b33d43bac1..517ce1f60d 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -41,8 +41,6 @@ #endif #include "wmc_auto.h" -// VE2AT: dependency on "IVAS_REND_AudioObjectPosition" needs to be solved in this file - /*---------------------------------------------------------------------* * Local function prototypes diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 1ed1a0fe42..d2c18baeef 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -41,7 +41,7 @@ #else #include "lib_rend.h" #endif -#include "ivas_stat_dec.h" // VE2AT: needed for Decoder_Struct; what to do with this? Is this related to #156? AT2VE: Yes, need to keep until #156 is resolved. +#include "ivas_stat_dec.h" // Note: needed until #156 is resolved /* clang-format off */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index f7c872ef1d..d2e95f2350 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -49,7 +49,7 @@ typedef struct { float azimuth; float elevation; -} IVAS_REND_AudioObjectPosition; // VE2AT: where should this go, into common_api_types.h, ...? Or should there be introduced public -> internal conversion? AT2VE: will be moved back in !421 +} IVAS_REND_AudioObjectPosition; // Note: will be moved back in !421 typedef struct { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 6782542b17..d2d9f99c24 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2439,7 +2439,7 @@ static DecoderDummy *initDecoderDummy( decDummy->hHrtfTD = NULL; decDummy->hSpar = NULL; decDummy->hoa_dec_mtx = NULL; - decDummy->hVBAPdata = NULL; // VE2AT: is "hVBAPdata" really used in Ext Rend? AT2VE: not at the moment, we should not depend on Decoder_Struct here anyway. + decDummy->hVBAPdata = NULL; // note: not used at the moment decDummy->hMasa = NULL; decDummy->hDiracDecBin = NULL; decDummy->hQMetaData = NULL; @@ -5436,4 +5436,3 @@ int32_t IVAS_REND_GetCntFramesLimited( return hIvasRend->hLimiter->cnt_frames_limited; } #endif - diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 96767b90ae..6cc007c62a 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -38,7 +38,7 @@ #include #include #ifdef FIX_197_CREND_INTERFACE -#include "ivas_stat_rend.h" // VE2AT: this should go away, right? the remaining dependency is "IVAS_REND_AudioObjectPosition" AT2VE: Will be removed with !421 +#include "ivas_stat_rend.h" // note: will be removed with !421 #endif #define RENDERER_MAX_ISM_INPUTS 4 diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index acd6f6ae51..7dc265a53c 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -35,7 +35,7 @@ #include "common_api_types.h" #include "ivas_error.h" -// VE2AT: would it make sense to put includes of "ivas_error.h" into "common_api_types" in order to not repeate it again and again? +// VE2AT: would it make sense to put includes of "ivas_error.h" into "common_api_types" in order to not repeate it again and again? -> YES, TBD typedef struct hrtfFileReader hrtfFileReader; -- GitLab From 83de2287f3898d5d6c3e0c577d0bd31ba94a6a8c Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 14 Feb 2023 15:00:07 +0100 Subject: [PATCH 30/40] move back destroy_SetOfHRTF() --- lib_rend/ivas_crend.c | 77 ------------------------------------- lib_util/hrtf_file_reader.h | 11 ++++++ 2 files changed, 11 insertions(+), 77 deletions(-) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 58f1995aba..836f0c5f6a 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2719,80 +2719,3 @@ ivas_error ivas_rend_crendConvolver( } #endif - -// VE2AT: moved here to avoid Linux build error; but should it be put somewhere else? -/*---------------------------------------------------------------------* - * destroy_HRTF() - * - * Destroy the HRTF CRend handle - *---------------------------------------------------------------------*/ - -static ivas_error destroy_HRTF( - HRTFS_HANDLE *hHRTF /* i/o: HRTF CRend handle */ -) -{ - uint16_t i, j; - - if ( *hHRTF != NULL && hHRTF != NULL ) - { - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL ) - { - 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] ); - } - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL ) - { - 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] ); - } - } - - free( *hHRTF ); - *hHRTF = NULL; - } - - return IVAS_ERR_OK; -} - - -/*---------------------------------------------------------------------* - * destroy_SetOfHRTF() - * - * Destroy the HRTF data set. - *---------------------------------------------------------------------*/ - -void destroy_SetOfHRTF( - HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ -) -{ - if ( hSetOfHRTF != NULL ) - { - destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_combined ) ); - destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_hoa3 ) ); - destroy_HRTF( &( hSetOfHRTF->hHRTF_brir_combined ) ); - } - - return; -} diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 7dc265a53c..0ef9ffc18f 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -86,6 +86,17 @@ ivas_error create_SetOfHRTF_from_binary( ); +/*---------------------------------------------------------------------* + * destroy_SetOfHRTF() + * + * Destroy the HRTF data set. + *---------------------------------------------------------------------*/ + +ivas_error destroy_SetOfHRTF( + IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ +); + + /*---------------------------------------------------------------------* * load_fastconv_HRTF_from_binary() * -- GitLab From 616b826397a020746a9fbd4d8959586a324bdc1b Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 14 Feb 2023 15:48:20 +0100 Subject: [PATCH 31/40] - apply clang-format --- lib_com/ivas_prot.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index a8b57910a8..e188805d8e 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4491,7 +4491,7 @@ void ivas_spar_param_to_masa_param_mapping( *----------------------------------------------------------------------------------*/ -// note: will be rmeoved with !421 +// note: will be removed with !421 IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( AUDIO_CONFIG config ); -- GitLab From 06bbc81a7c6f3b0225343506648d8f7ec3dd0d8e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 14 Feb 2023 15:51:09 +0100 Subject: [PATCH 32/40] - apply clang-format --- lib_dec/ivas_init_dec.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 86f884c660..c0b331b4af 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1957,22 +1957,22 @@ void ivas_init_dec_get_num_cldfb_instances( else #endif { - *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; + *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; - if ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) - { - *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE; - } - else if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) - { - *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; - } - else - { - *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; + if ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) + { + *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE; + } + else if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) + { + *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; + } + else + { + *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; + } } } - } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { /* do nothing for ParamMC */ -- GitLab From 80327aada5afd8ef2f257520f5bd2e460f5a5000 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 15 Feb 2023 12:07:29 +0100 Subject: [PATCH 33/40] accept FIX_310_TD_REND_DELAY leftover + formatting --- lib_rend/ivas_crend.c | 6 ++---- lib_rend/ivas_objectRenderer_mix.c | 2 -- lib_rend/lib_rend.h | 6 ------ 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 0e9fcec386..753b8321f7 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -915,7 +915,7 @@ ivas_error ivas_crend_open( return error; } } - } + } if ( ( hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) { @@ -1960,9 +1960,7 @@ ivas_error ivas_rend_openCrend( #else if ( pCrend->hHrtfCrend == NULL ) { - if ( ( error = ivas_rend_initCrend( pCrend, inConfig, outConfig, hRendCfg, - hSetOfHRTF, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_initCrend( pCrend, inConfig, outConfig, hRendCfg, hSetOfHRTF, output_Fs ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index f22d83fb23..9da9c2750c 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -495,9 +495,7 @@ static void DefaultBSplineModel( HRTF_model_precalc( model ); -#ifdef FIX_310_TD_REND_DELAY HrFiltSet_p->latency_s = orange53_rom_latency_s; -#endif HrFiltSet_p->SampleRate = output_Fs; HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 6cc007c62a..5f87d92117 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -308,12 +308,6 @@ int32_t IVAS_REND_GetCntFramesLimited( ); #endif -#ifdef FIX_197_CREND_INTERFACE -//ivas_error ivas_rend_initEfap( -// AUDIO_CONFIG outConfig, -// EFAP_HANDLE *hEfap -//); -#endif /* clang-format on */ #endif -- GitLab From bfc7f5218fb7f2dc0c52329cc72666b499355327 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 15 Feb 2023 23:17:57 +0100 Subject: [PATCH 34/40] reimplement FIX_197_CREND_INTERFACE_LIB_REND_H --- lib_com/common_api_types.h | 69 ++-------- lib_com/ivas_prot.h | 21 --- lib_com/options.h | 3 +- lib_dec/ivas_dec.c | 1 - lib_dec/ivas_output_config.c | 43 ------- lib_dec/ivas_sba_dirac_stereo_dec.c | 8 +- lib_dec/ivas_stat_dec.h | 167 +++++++++++++++++------- lib_rend/ivas_crend.c | 60 +++++++-- lib_rend/ivas_prot_rend.h | 14 +- lib_rend/ivas_stat_rend.h | 192 ++++++---------------------- lib_rend/lib_rend.h | 52 -------- 11 files changed, 227 insertions(+), 403 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index e0a0166ff6..bc825e057e 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -49,7 +49,7 @@ #define IVAS_CLDFB_NO_CHANNELS_MAX ( 60 ) #define IVAS_MAX_INPUT_LFE_CHANNELS 4 -#define RENDERER_HEAD_POSITIONS_PER_FRAME 4 // todo (Marc) -> renanr IVAS_RENDERER_HEAD_POSITIONS_PER_FRAME ? +#define RENDERER_HEAD_POSITIONS_PER_FRAME 4 /*----------------------------------------------------------------------------------* @@ -89,12 +89,11 @@ typedef struct typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE; typedef struct ivas_masa_qmetadata_frame_struct *IVAS_MASA_QMETADATA_HANDLE; -typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; +//typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE; typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE; typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE; - typedef struct ivas_hrtfs_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE; #ifdef DEBUGGING @@ -106,6 +105,12 @@ typedef enum } IVAS_RENDER_TYPE_OVERRIDE; #endif +typedef struct +{ + float azimuth; + float elevation; +} IVAS_REND_AudioObjectPosition; + typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG { int16_t override; @@ -157,62 +162,4 @@ typedef struct _IVAS_JBM_TRACE_DATA } IVAS_JBM_TRACE_DATA; - -typedef enum -{ - IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED = 0, - IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS, - IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED, - IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL, - IVAS_REND_AUDIO_CONFIG_TYPE_MASA, - IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN, -} IVAS_REND_AudioConfigType; - -/* TODO(sgi): Harmonize with AUDIO_CONFIG */ -/* - Note: numerical values carry specific information here. - - MSB LSB - -------------------------------------------------------------------------------- - ... unused (assumed all 0) ... | config type (1 byte) | config variant (1 byte) | - -------------------------------------------------------------------------------- - - Where "config type" is the general type from the following list: - - unknown - - channel-based - - ambisonics - - object-based - - binaural - - MASA - - Config variants are concrete configs of each type. - */ -typedef enum -{ - IVAS_REND_AUDIO_CONFIG_MONO = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 0, - IVAS_REND_AUDIO_CONFIG_STEREO = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 1, - IVAS_REND_AUDIO_CONFIG_5_1 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 2, - IVAS_REND_AUDIO_CONFIG_7_1 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 3, - IVAS_REND_AUDIO_CONFIG_5_1_2 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 4, - IVAS_REND_AUDIO_CONFIG_5_1_4 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 5, - IVAS_REND_AUDIO_CONFIG_7_1_4 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 6, - IVAS_REND_AUDIO_CONFIG_LS_CUSTOM = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 255, - - IVAS_REND_AUDIO_CONFIG_FOA = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 0, - IVAS_REND_AUDIO_CONFIG_HOA2 = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 1, - IVAS_REND_AUDIO_CONFIG_HOA3 = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 2, - - IVAS_REND_AUDIO_CONFIG_OBJECT = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED << 8 | 0, - - IVAS_REND_AUDIO_CONFIG_BINAURAL = IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL << 8 | 0, - IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM = IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL << 8 | 1, - - IVAS_REND_AUDIO_CONFIG_MASA1 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA << 8 | 0, - IVAS_REND_AUDIO_CONFIG_MASA2 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA << 8 | 1, - - IVAS_REND_AUDIO_CONFIG_UNKNOWN = IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN << 8 | 0, -} IVAS_REND_AudioConfig; - -typedef uint16_t IVAS_REND_InputId; - #endif /* COMMON_API_TYPES_H */ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f3a1504ccb..6da5c8121b 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -40,20 +40,10 @@ #include "stat_enc.h" #include "stat_dec.h" #include "stat_com.h" -#ifndef FIX_197_CREND_INTERFACE_LIB_REND_H -#ifdef FIX_197_CREND_INTERFACE -#include "ivas_stat_rend.h" // VE!!!!! -#endif -#endif #include "ivas_stat_enc.h" #include "ivas_stat_dec.h" #include "ivas_stat_com.h" #include "ivas_error_utils.h" -#ifdef FIX_197_CREND_INTERFACE -#ifndef FIX_197_CREND_INTERFACE_LIB_REND_H -#include "lib_rend.h" -#endif -#endif /* clang-format off */ @@ -4509,17 +4499,6 @@ void ivas_spar_param_to_masa_param_mapping( ); -/*----------------------------------------------------------------------------------* - * output setup prototypes - *----------------------------------------------------------------------------------*/ - - -// note: will be removed with !421 -IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( - AUDIO_CONFIG config -); - - /*---------------------------------------------------------------------------------* * Binaural FastConv Renderer Prototypes *-----------------------------------------------------------------------------------*/ diff --git a/lib_com/options.h b/lib_com/options.h index f3074839fe..8e397881cf 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -159,8 +159,7 @@ #define FIX_198_TDREND_INTERFACE /* Issue 198: Harmonize interface for TD renderer between decoder and external renderer */ #define DFT_STEREO_SPAR_MIXING -#ifdef DFT_STEREO_SPAR_MIXING -#define FIX_345_MSAN_ERROR /* FhG. Fix memory sanitizer error in PLC modes */ +#ifdef DFT_STEREO_SPAR_MIXING /*#define DFT_STEREO_SPAR_MIXING_DEBUG*/ /* more debugging output for DFT_STEREO_SPAR_MIXING_DEBUG */ #define DISABLE_RES_CHANNELS_MCT /* decode only W and residual for Y when outputting to stereo */ #endif diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index d40b9f8ac7..50ff1dc18f 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -434,7 +434,6 @@ ivas_error ivas_dec( #else getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ), getRendAudioConfigFromIvasAudioConfig( st_ivas->hOutSetup.output_config ), - #endif st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 85a2e1af20..f38e810ce3 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -403,46 +403,3 @@ void ivas_renderer_select( return; } - - -/*-------------------------------------------------------------------* - * getRendAudioConfigFromIvasAudioConfig() - * - * - *-------------------------------------------------------------------*/ - -IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( - const AUDIO_CONFIG config ) -{ - switch ( config ) - { - case AUDIO_CONFIG_MONO: - return IVAS_REND_AUDIO_CONFIG_MONO; - case AUDIO_CONFIG_STEREO: - return IVAS_REND_AUDIO_CONFIG_STEREO; - case AUDIO_CONFIG_BINAURAL: - return IVAS_REND_AUDIO_CONFIG_BINAURAL; - case AUDIO_CONFIG_BINAURAL_ROOM: - return IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM; - case AUDIO_CONFIG_5_1: - return IVAS_REND_AUDIO_CONFIG_5_1; - case AUDIO_CONFIG_7_1: - return IVAS_REND_AUDIO_CONFIG_7_1; - case AUDIO_CONFIG_5_1_2: - return IVAS_REND_AUDIO_CONFIG_5_1_2; - case AUDIO_CONFIG_5_1_4: - return IVAS_REND_AUDIO_CONFIG_5_1_4; - case AUDIO_CONFIG_7_1_4: - return IVAS_REND_AUDIO_CONFIG_7_1_4; - case AUDIO_CONFIG_FOA: - return IVAS_REND_AUDIO_CONFIG_FOA; - case AUDIO_CONFIG_HOA2: - return IVAS_REND_AUDIO_CONFIG_HOA2; - case AUDIO_CONFIG_HOA3: - return IVAS_REND_AUDIO_CONFIG_HOA3; - default: - break; - } - - return IVAS_REND_AUDIO_CONFIG_UNKNOWN; -} diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index f8f57ae53c..bbd612b7ec 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -964,16 +964,12 @@ void ivas_sba_dirac_stereo_dec( mvr2r( tmp_buf, hSCE->prev_hb_synth, memOffset ); } - if ( ( hCPE->hCoreCoder[0]->core == ACELP_CORE || hCPE->hCoreCoder[0]->last_core == ACELP_CORE ) && !fd_cng_flag -#if defined DFT_STEREO_SPAR_MIXING && defined FIX_345_MSAN_ERROR - && st_ivas->nchan_transport == 1 -#endif - ) + if ( ( hCPE->hCoreCoder[0]->core == ACELP_CORE || hCPE->hCoreCoder[0]->last_core == ACELP_CORE ) && !fd_cng_flag ) { /* upmix ACELP BWE */ ivas_sba_dirac_stereo_compute_hb_gain( hStereoDft, hb_gain ); -#if defined DFT_STEREO_SPAR_MIXING && !defined FIX_345_MSAN_ERROR +#ifdef DFT_STEREO_SPAR_MIXING if ( st_ivas->nchan_transport == 1 ) #endif { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 53206d6cf1..e9f0b828be 100755 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -40,33 +40,7 @@ #include "stat_dec.h" #include "ivas_stat_com.h" #include "ivas_stat_rend.h" -#include "common_api_types.h" -/*----------------------------------------------------------------------------------* - * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...) - *----------------------------------------------------------------------------------*/ - -#if !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H - -typedef struct ivas_output_setup_structure -{ - AUDIO_CONFIG output_config; - int16_t nchan_out_woLFE; /* number of output audio channels without LFE */ - int16_t ambisonics_order; - int8_t is_loudspeaker_setup; - int8_t is_planar_setup; - int8_t is_binaural_setup; - - int16_t num_lfe; - int16_t index_lfe[1]; - const float *ls_azimuth; - const float *ls_elevation; - - uint8_t separateChannelEnabled; - int16_t separateChannelIndex; - -} IVAS_OUTPUT_SETUP, *IVAS_OUTPUT_SETUP_HANDLE; -#endif /*----------------------------------------------------------------------------------* * DFT Stereo decoder structure *----------------------------------------------------------------------------------*/ @@ -825,7 +799,23 @@ typedef struct ivas_spar_md_dec_state_t int16_t spar_hoa_md_flag; } ivas_spar_md_dec_state_t; -#if !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H +/* AGC structure */ +typedef struct ivas_agc_dec_chan_state_t +{ + float lastGain; + int16_t gainExpVal; + +} ivas_agc_dec_chan_state_t; + +typedef struct ivas_agc_dec_state_t +{ + ivas_agc_com_state_t agc_com; + ivas_agc_dec_chan_state_t *gain_state; + ivas_agc_chan_data_t *gain_data; + +} ivas_agc_dec_state_t; + +#ifndef FIX_197_CREND_INTERFACE /* AGC structure */ typedef struct ivas_agc_dec_chan_state_t @@ -865,7 +855,7 @@ typedef struct ivas_td_decorr_state_t } ivas_td_decorr_state_t; -#endif /* !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H */ +#endif /* PCA structure */ typedef struct @@ -998,7 +988,106 @@ typedef struct mct_dec_data_structure } MCT_DEC_DATA, *MCT_DEC_HANDLE; -#if !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H + +/*----------------------------------------------------------------------------------* + * LFE decoder structure + *----------------------------------------------------------------------------------*/ + +typedef struct ivas_lfe_dec_data_structure +{ + ivas_filters_process_state_t filter_state; + LFE_WINDOW_HANDLE pWindow_state; + const uint16_t *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS]; + int16_t lfe_dec_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS]; + float lfe_block_delay_s; + int16_t lfe_prior_buf_len; + float *prior_out_buffer; + + float *prevsynth_buf; + float *lfe_delay_buf; + int16_t lfe_addl_delay; + int16_t bfi_count; + +} LFE_DEC_DATA, *LFE_DEC_HANDLE; + + +// Note: the following structures are used only in lib_dec but this would likely change in the future +/*----------------------------------------------------------------------------------* + * VBAP structures + *----------------------------------------------------------------------------------*/ + +/* Defines a single virtual surface triplet of loudspeakers + * with a precalculated inverse matrix */ +typedef struct vbap_vs_triplet_structure +{ + uint8_t speaker_node[3]; + float inverse_matrix[3][3]; + +} VBAP_VS_TRIPLET; + +/* Storage structure for fast runtime triplet search */ +typedef struct triplet_search_structure +{ + VBAP_VS_TRIPLET *triplets; + int16_t num_triplets; + int16_t initial_search_indices[VBAP_NUM_SEARCH_SECTORS]; + +} VBAP_SEARCH_STRUCT; + +/* VBAP data structure. Contains the formed virtual surface arrangement * and supporting data. */ +typedef struct vbap_data_structure +{ + VBAP_SEARCH_STRUCT search_struct[2]; /* Default to max two groups in this implementation */ + int16_t num_search_structs; + int16_t num_speaker_nodes; + int16_t num_speaker_nodes_internal; + int16_t top_virtual_speaker_node_index; /* These indices can be negative */ + int16_t bottom_virtual_speaker_node_index; + int16_t back_virtual_speaker_node_index; + float *bottom_virtual_speaker_node_division_gains; + float *top_virtual_speaker_node_division_gains; + float *back_virtual_speaker_node_division_gains; + +} VBAP_DATA, *VBAP_HANDLE; + + +/*----------------------------------------------------------------------------------* + * renderer structures + *----------------------------------------------------------------------------------*/ + +typedef struct renderer_struct +{ + float prev_gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS]; + float interpolator[L_FRAME48k]; + +} ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; + +/* Fastconv binaural data structure */ +typedef struct ivas_binaural_rendering_struct +{ + /* Common variables for all modules */ + IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/ + EFAP_HANDLE hEFAPdata; /* EFAP structure*/ + float *hoa_dec_mtx; /* pointer to HOA decoder mtx */ + int8_t rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ + int16_t max_band; /* band upto which rendering is performed */ + int16_t conv_band; /* band upto which convolution in cldfb domain is performed */ + int16_t timeSlots; /* number of time slots of binaural renderer */ + int16_t nInChannels; /* number input channels */ + int8_t render_lfe; /* Flag to render LFE in binaural rendering*/ + IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */ + + /* Convolution module structure */ + BINRENDERER_CONV_MODULE_HANDLE hBinRenConvModule; + + /* Variables related to reverb module */ + float earlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX]; + REVERB_STRUCT_HANDLE hReverb; + +} BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; + + +#ifndef FIX_197_CREND_INTERFACE /*----------------------------------------------------------------------------------* * EFAP structures @@ -1187,7 +1276,7 @@ typedef struct ivas_masa_decoder_struct } MASA_DECODER, *MASA_DECODER_HANDLE; -#if !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H +#ifndef FIX_197_CREND_INTERFACE /*----------------------------------------------------------------------------------* * Binaural Rendering structure @@ -1512,7 +1601,6 @@ typedef struct TDREND_HRFILT_FiltSet_struct ModelEval_t ModelEval; ModelParamsITD_t ModelParamsITD; TDREND_HRFILT_Method_t FilterMethod; /* HR filtering method */ - float latency_s; } TDREND_HRFILT_FiltSet_t; @@ -1820,20 +1908,6 @@ typedef struct ivas_hrtfs_file_header_t } ivas_hrtfs_file_header_t; -#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H -#ifdef FIX_197_CREND_INTERFACE - -/* Main Crend wrapper structure */ -typedef struct ivas_binaural_crend_wrapper_struct -{ - int32_t binaural_latency_ns; - CREND_HANDLE hCrend; - HRTFS_HANDLE hHrtfCrend; -} CREND_WRAPPER, *CREND_WRAPPER_HANDLE; - -#endif /* FIX_197_CREND_INTERFACE */ -#endif /* FIX_197_CREND_INTERFACE_LIB_REND_H */ - /*----------------------------------------------------------------------------------* * LFE decoder structure *----------------------------------------------------------------------------------*/ @@ -1875,7 +1949,7 @@ typedef struct #endif } IVAS_LIMITER, *IVAS_LIMITER_HANDLE; - +#endif /*----------------------------------------------------------------------------------* * Decoder configuration structure @@ -1903,7 +1977,6 @@ typedef struct decoder_config_structure } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; -#endif /* !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H */ /*----------------------------------------------------------------------------------* * diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 88c2b96378..931f5dc0ae 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -37,22 +37,8 @@ #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" -#ifndef FIX_197_CREND_INTERFACE_LIB_REND_H -#include "ivas_stat_dec.h" // VE!!!!! -#endif #include #include "ivas_rom_binaural_crend_head.h" -#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H -#include "lib_rend.h" -#include "ivas_lib_rend_internal.h" -#else -#ifdef FIX_197_CREND_INTERFACE -#include "ivas_stat_rend.h" -#else -#include "lib_rend.h" -#include "ivas_lib_rend_internal.h" -#endif -#endif #ifdef DEBUGGING #include "debug.h" #endif @@ -1387,6 +1373,49 @@ ivas_error ivas_crend_process( #endif +/*-------------------------------------------------------------------* + * getRendAudioConfigFromIvasAudioConfig() + * + * + *-------------------------------------------------------------------*/ + +static IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( + const AUDIO_CONFIG config ) +{ + switch ( config ) + { + case AUDIO_CONFIG_MONO: + return IVAS_REND_AUDIO_CONFIG_MONO; + case AUDIO_CONFIG_STEREO: + return IVAS_REND_AUDIO_CONFIG_STEREO; + case AUDIO_CONFIG_BINAURAL: + return IVAS_REND_AUDIO_CONFIG_BINAURAL; + case AUDIO_CONFIG_BINAURAL_ROOM: + return IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM; + case AUDIO_CONFIG_5_1: + return IVAS_REND_AUDIO_CONFIG_5_1; + case AUDIO_CONFIG_7_1: + return IVAS_REND_AUDIO_CONFIG_7_1; + case AUDIO_CONFIG_5_1_2: + return IVAS_REND_AUDIO_CONFIG_5_1_2; + case AUDIO_CONFIG_5_1_4: + return IVAS_REND_AUDIO_CONFIG_5_1_4; + case AUDIO_CONFIG_7_1_4: + return IVAS_REND_AUDIO_CONFIG_7_1_4; + case AUDIO_CONFIG_FOA: + return IVAS_REND_AUDIO_CONFIG_FOA; + case AUDIO_CONFIG_HOA2: + return IVAS_REND_AUDIO_CONFIG_HOA2; + case AUDIO_CONFIG_HOA3: + return IVAS_REND_AUDIO_CONFIG_HOA3; + default: + break; + } + + return IVAS_REND_AUDIO_CONFIG_UNKNOWN; +} + + /*------------------------------------------------------------------------- * initCrend_from_rom() * @@ -1454,6 +1483,7 @@ static ivas_error ivas_rend_initCrend( } #endif + if ( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ) != IVAS_ERR_OK ) { return error; @@ -2457,6 +2487,7 @@ static ivas_error ivas_rend_crendConvolver( #endif + /*-----------------------------------------------------------------------------------------* * Function ivas_rend_crend_Process() * @@ -2498,6 +2529,7 @@ ivas_error ivas_rend_crendProcess( inRendConfig = getRendAudioConfigFromIvasAudioConfig( inConfig ); outRendConfig = getRendAudioConfigFromIvasAudioConfig( outConfig ); #endif + push_wmops( "ivas_rend_crendProcess" ); #ifdef FIX_197_CREND_INTERFACE_LIB_REND_H diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 2354b71911..6a29ccfccf 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -36,11 +36,7 @@ #include #include "options.h" #include "ivas_error.h" -#ifdef FIX_197_CREND_INTERFACE -#include "ivas_stat_rend.h" -#else #include "lib_rend.h" -#endif #include "ivas_stat_dec.h" // Note: needed until #156 is resolved /* clang-format off */ @@ -547,8 +543,13 @@ void TDREND_firfilt( ivas_error ivas_rend_openCrend( CREND_WRAPPER_HANDLE *pCrend, +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, +#else const IVAS_REND_AudioConfig inConfig, const IVAS_REND_AudioConfig outConfig, +#endif RENDER_CONFIG_DATA *hRendCfg, int16_t Opt_Headrotation, HRTFS_CREND_HANDLE hSetOfHRTF, @@ -561,8 +562,13 @@ void ivas_rend_closeCrend( ivas_error ivas_rend_crendProcess( const CREND_WRAPPER *pCrend, +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, +#else const IVAS_REND_AudioConfig inConfig, const IVAS_REND_AudioConfig outConfig, +#endif DECODER_CONFIG_HANDLE hDecoderConfig, HEAD_TRACK_DATA_HANDLE hHeadTrackData, IVAS_OUTPUT_SETUP_HANDLE hIntSetup, diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index f67497203a..005d603867 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -35,104 +35,36 @@ #include #include "options.h" +#include "cnst.h" #include "ivas_cnst.h" +#include "ivas_stat_com.h" // note: needed for DIRAC_DEC_BIN_HANDLE until #156 is solved +#include "common_api_types.h" -#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H - -#define MAX_SPEAKERS 12 /* Max number of speakers (including LFE) in a channel-based config */ /*----------------------------------------------------------------------------------* - * Loudspeaker Configuration Conversion structure + * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...) *----------------------------------------------------------------------------------*/ -typedef struct ivas_LS_setupconversion_struct -{ - float *dmxMtx[MAX_OUTPUT_CHANNELS]; - float *targetEnergyPrev[MAX_OUTPUT_CHANNELS]; - float *dmxEnergyPrev[MAX_OUTPUT_CHANNELS]; - int16_t sfbOffset[MAX_SFB + 2]; - int16_t sfbCnt; - -} LSSETUP_CONVERSION_STRUCT, *LSSETUP_CONVERSION_HANDLE; - - -typedef struct ivas_LS_setupconversion_matrix -{ - int16_t index; - float value; -} LS_CONVERSION_MATRIX; - -typedef struct ivas_LS_setupconversion_mapping +typedef struct ivas_output_setup_structure { - AUDIO_CONFIG input_config; AUDIO_CONFIG output_config; - const LS_CONVERSION_MATRIX *conversion_matrix; -} LS_CONVERSION_MAPPING; - -typedef struct ivas_mono_downmix_renderer_struct -{ - float inputEnergy[CLDFB_NO_CHANNELS_MAX]; - float protoEnergy[CLDFB_NO_CHANNELS_MAX]; - -} MONO_DOWNMIX_RENDERER_STRUCT, *MONO_DOWNMIX_RENDERER_HANDLE; - - -/*----------------------------------------------------------------------------------* - * Custom Loudspeaker configuration structure - *----------------------------------------------------------------------------------*/ - -typedef struct ivas_LS_setup_custom -{ - int16_t is_planar_setup; /* flag to indicate if setup is planar or not */ - int16_t num_spk; /* number of custom loudspeakers */ - float ls_azimuth[MAX_OUTPUT_CHANNELS]; /* custom loudspeaker azimuths */ - float ls_elevation[MAX_OUTPUT_CHANNELS]; /* custom loudspeaker elevations */ - int16_t num_lfe; /* number of LFE channels */ - int16_t lfe_idx[MAX_OUTPUT_CHANNELS]; /* index for LFE channel insertion */ - int16_t separate_ch_found; /* flag to indicate if a center channel was found */ - float separate_ch_gains[MAX_OUTPUT_CHANNELS]; /* gains to pan McMASA separateChannel in case no center channel is present */ - -} LSSETUP_CUSTOM_STRUCT, *LSSETUP_CUSTOM_HANDLE; - -/* Channel types in a channel-based config */ -typedef enum -{ - CHANNEL_TYPE_UNUSED = 0, - CHANNEL_TYPE_SPEAKER, - CHANNEL_TYPE_LFE -} ChannelType; - -#else - -#ifdef FIX_197_CREND_INTERFACE -#include "cnst.h" -#include "ivas_cnst.h" -#include "ivas_stat_com.h" -#include "common_api_types.h" - + int16_t nchan_out_woLFE; /* number of output audio channels without LFE */ + int16_t ambisonics_order; + int8_t is_loudspeaker_setup; + int8_t is_planar_setup; + int8_t is_binaural_setup; -typedef struct -{ - float azimuth; - float elevation; -} IVAS_REND_AudioObjectPosition; // Note: will be moved back in !421 + int16_t num_lfe; + int16_t index_lfe[1]; + const float *ls_azimuth; + const float *ls_elevation; -typedef struct -{ - int16_t numLfeChannels; - float lfeOutputGains[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; -} IVAS_REND_LfeRouting; + uint8_t separateChannelEnabled; + int16_t separateChannelIndex; -#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H +} IVAS_OUTPUT_SETUP, *IVAS_OUTPUT_SETUP_HANDLE; -typedef struct -{ - int8_t headRotEnabled; - IVAS_QUATERNION headPositions[RENDERER_HEAD_POSITIONS_PER_FRAME]; - float crossfade[L_FRAME48k / RENDERER_HEAD_POSITIONS_PER_FRAME]; -} IVAS_REND_HeadRotData; -#endif /*----------------------------------------------------------------------------------* * Binaural FastConv Rendering structure *----------------------------------------------------------------------------------*/ @@ -250,30 +182,6 @@ typedef struct ivas_binaural_rendering_conv_module_struct } BINRENDERER_CONV_MODULE, *BINRENDERER_CONV_MODULE_HANDLE; -/*----------------------------------------------------------------------------------* - * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...) - *----------------------------------------------------------------------------------*/ - -typedef struct ivas_output_setup_structure -{ - AUDIO_CONFIG output_config; - int16_t nchan_out_woLFE; /* number of output audio channels without LFE */ - int16_t ambisonics_order; - int8_t is_loudspeaker_setup; - int8_t is_planar_setup; - int8_t is_binaural_setup; - - int16_t num_lfe; - int16_t index_lfe[1]; - const float *ls_azimuth; - const float *ls_elevation; - - uint8_t separateChannelEnabled; - int16_t separateChannelIndex; - -} IVAS_OUTPUT_SETUP, *IVAS_OUTPUT_SETUP_HANDLE; - - /*----------------------------------------------------------------------------------* * EFAP structures *----------------------------------------------------------------------------------*/ @@ -338,9 +246,17 @@ typedef struct EFAP /*----------------------------------------------------------------------------------* - * Head tracking data structure + * Head rotation data structure *----------------------------------------------------------------------------------*/ +typedef struct +{ + int8_t headRotEnabled; + IVAS_QUATERNION headPositions[RENDERER_HEAD_POSITIONS_PER_FRAME]; + float crossfade[L_FRAME48k / RENDERER_HEAD_POSITIONS_PER_FRAME]; + +} IVAS_REND_HeadRotData; + typedef struct ivas_binaural_head_track_struct { int16_t num_quaternions; @@ -738,6 +654,14 @@ typedef struct ivas_binaural_td_rendering_struct } BINAURAL_TD_OBJECT_RENDERER, *BINAURAL_TD_OBJECT_RENDERER_HANDLE; +typedef struct +{ + int32_t binaural_latency_ns; + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; + TDREND_HRFILT_FiltSet_t *hHrtfTD; + +} TDREND_WRAPPER, *TDREND_WRAPPER_HANDLE; + /*------------------------------------------------------------------------------------------* * Crend structures @@ -788,10 +712,13 @@ typedef struct ivas_binaural_crend_wrapper_struct int32_t binaural_latency_ns; CREND_HANDLE hCrend; HRTFS_HANDLE hHrtfCrend; + } CREND_WRAPPER, *CREND_WRAPPER_HANDLE; -/* htrfs from binary files. */ +/*------------------------------------------------------------------------------------------* + * HRTF structures - htrfs from binary files + *------------------------------------------------------------------------------------------*/ typedef struct ivas_hrtfs_crend_structure { @@ -824,6 +751,7 @@ typedef struct ivas_hrtfs_fastconv_struct float fastconvReverberationTimes[CLDFB_NO_CHANNELS_MAX]; float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; + } HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE; @@ -835,6 +763,7 @@ typedef struct ivas_hrtfs_parambin_struct float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX]; float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; float parametricEarlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX]; + } HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE; @@ -859,45 +788,6 @@ typedef struct } IVAS_LIMITER, *IVAS_LIMITER_HANDLE; -/*----------------------------------------------------------------------------------* - * Decoder configuration structure - *----------------------------------------------------------------------------------*/ - -typedef struct decoder_config_structure -{ - int32_t ivas_total_brate; /* IVAS total bitrate in bps */ - int32_t last_ivas_total_brate; /* last IVAS total bitrate in bps */ - int32_t output_Fs; /* output signal sampling frequency in Hz */ - int16_t nchan_out; /* number of output audio channels */ - AUDIO_CONFIG output_config; /* output audio configuration */ - int16_t Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ - int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ - int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ - int16_t orientation_tracking; /* indicates orientation tracking type */ - float no_diegetic_pan; - int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - - /* temp. development parameters */ -#ifdef DEBUGGING - int16_t forceSubframeBinauralization; /* Flag for forcing Parametric binauralizer to subframe mode */ - int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ -#endif - -} DECODER_CONFIG, *DECODER_CONFIG_HANDLE; - -#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H - -typedef struct -{ - int32_t binaural_latency_ns; - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; - TDREND_HRFILT_FiltSet_t *hHrtfTD; -} TDREND_WRAPPER, *TDREND_WRAPPER_HANDLE; - -#endif -#endif - - /*----------------------------------------------------------------------------------* * Loudspeaker Configuration Conversion structure *----------------------------------------------------------------------------------*/ @@ -959,6 +849,4 @@ typedef enum CHANNEL_TYPE_LFE } ChannelType; -#endif - #endif /* IVAS_STAT_REND_H */ diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 9164878c20..1a7738d37f 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -38,18 +38,12 @@ #include #include -#if defined FIX_197_CREND_INTERFACE && !defined FIX_197_CREND_INTERFACE_LIB_REND_H -#include "ivas_stat_rend.h" // note: will be removed with !421 -#endif #define RENDERER_MAX_ISM_INPUTS 4 #define RENDERER_MAX_MC_INPUTS 1 #define RENDERER_MAX_SBA_INPUTS 1 #define RENDERER_MAX_MASA_INPUTS 1 -#if !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H - -#define RENDERER_HEAD_POSITIONS_PER_FRAME 4 typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; @@ -71,12 +65,6 @@ typedef struct const float *data; } IVAS_REND_ReadOnlyAudioBuffer; -typedef struct -{ - float azimuth; - float elevation; -} IVAS_REND_AudioObjectPosition; - typedef struct IVAS_REND *IVAS_REND_HANDLE; typedef struct IVAS_REND const *IVAS_REND_CONST_HANDLE; @@ -137,46 +125,6 @@ typedef enum typedef uint16_t IVAS_REND_InputId; -#endif - -#ifndef FIX_197_CREND_INTERFACE_LIB_REND_H -#ifdef FIX_197_CREND_INTERFACE - -IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( - AUDIO_CONFIG config ); -#endif - -#ifdef FIX_197_CREND_INTERFACE -IVAS_REND_AudioConfigType getAudioConfigType( - const IVAS_REND_AudioConfig config ); - -ivas_error getAudioConfigNumChannels( - const IVAS_REND_AudioConfig config, - int16_t *numChannels ); -#endif -#endif - -typedef struct -{ - int16_t numSamplesPerChannel; - int16_t numChannels; -} IVAS_REND_AudioBufferConfig; - -typedef struct -{ - IVAS_REND_AudioBufferConfig config; - float *data; -} IVAS_REND_AudioBuffer; - -typedef struct -{ - IVAS_REND_AudioBufferConfig config; - const float *data; -} IVAS_REND_ReadOnlyAudioBuffer; - -typedef struct IVAS_REND *IVAS_REND_HANDLE; -typedef struct IVAS_REND const *IVAS_REND_CONST_HANDLE; - /* clang-format off */ /*----------------------------------------------------------------------------------* -- GitLab From 4158a087c6c698046d26f8f7fbf6476962aef358 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 15 Feb 2023 23:33:10 +0100 Subject: [PATCH 35/40] - apply clang-format --- lib_com/common_api_types.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index bc825e057e..d03a0b7f81 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -70,7 +70,6 @@ typedef struct _IVAS_ENC_CHANNEL_AWARE_CONFIG int16_t fec_offset; } IVAS_ENC_CHANNEL_AWARE_CONFIG; - typedef struct _IVAS_ISM_METADATA { float azimuth; @@ -89,8 +88,6 @@ typedef struct typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE; typedef struct ivas_masa_qmetadata_frame_struct *IVAS_MASA_QMETADATA_HANDLE; -//typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; - typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE; typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE; typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE; -- GitLab From 96d7422fb602146566124aa6ddeb67154e1a8584 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 16 Feb 2023 08:54:32 +0100 Subject: [PATCH 36/40] remove unnecessary include --- lib_rend/ivas_stat_rend.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 005d603867..133375137b 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -35,7 +35,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "ivas_stat_com.h" // note: needed for DIRAC_DEC_BIN_HANDLE until #156 is solved #include "common_api_types.h" -- GitLab From 3f343bc77e85616e2f14a2a2e3892335041bacc0 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 16 Feb 2023 16:40:01 +0100 Subject: [PATCH 37/40] Manually re-apply changes made by @vaclav Original commit message: - move ivas_td_decorr.c into lib_com - rename TD related functions and remove "spar" name from them --- Workspace_msvc/lib_com.vcxproj | 1 + Workspace_msvc/lib_com.vcxproj.filters | 3 ++ Workspace_msvc/lib_dec.vcxproj | 1 - Workspace_msvc/lib_dec.vcxproj.filters | 3 -- lib_com/ivas_prot.h | 20 ++++---- lib_com/ivas_stat_com.h | 26 ++++++++++ {lib_dec => lib_com}/ivas_td_decorr.c | 52 ++++++++++---------- lib_com/ivas_transient_det.c | 27 +++++----- lib_dec/ivas_sba_dec.c | 4 +- lib_dec/ivas_spar_decoder.c | 6 +-- lib_enc/ivas_spar_encoder.c | 4 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 8 +-- lib_rend/ivas_stat_rend.h | 22 --------- 13 files changed, 90 insertions(+), 87 deletions(-) rename {lib_dec => lib_com}/ivas_td_decorr.c (89%) diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 2bcf77f098..d55896b03c 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -268,6 +268,7 @@ + diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index f9d7920ca2..baa1700361 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -463,6 +463,9 @@ common_ivas_c + + common_ivas_c + diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 6d9b7c0682..4e1a123be1 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -321,7 +321,6 @@ - diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index 779794a1c0..4d466665c2 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -470,9 +470,6 @@ dec_ivas_c - - dec_ivas_c - dec_ivas_c diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6da5c8121b..c8fed7768c 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4116,23 +4116,23 @@ void ivas_cov_smooth_process( ); /* Transient detector module */ -ivas_error ivas_spar_transient_det_open( - ivas_trans_det_state_t **hTranDet, /* i/o: SPAR TD handle */ +ivas_error ivas_transient_det_open( + ivas_trans_det_state_t **hTranDet, /* i/o: Transient detector handle */ const int32_t sampling_rate /* i : sampling rate */ ); -void ivas_spar_transient_det_close( - ivas_trans_det_state_t **hTranDet /* i/o: SPAR TD handle */ +void ivas_transient_det_close( + ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */ ); int16_t ivas_transient_det_process( - ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ + ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ float *pIn_pcm, /* i : input audio channels */ const int16_t frame_len /* i : frame length in samples */ ); void ivas_td_decorr_get_ducking_gains( - ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ + ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ float *pIn_pcm, float *pIn_duck_gains, float *pOut_duck_gains, @@ -4140,15 +4140,15 @@ void ivas_td_decorr_get_ducking_gains( const int16_t tdet_flag ); -ivas_error ivas_spar_td_decorr_dec_open( - ivas_td_decorr_state_t **hTdDecorr, /* i/o: SPAR Covar. decoder handle */ +ivas_error ivas_td_decorr_dec_open( + ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ const int32_t output_Fs, /* i : output sampling rate */ const int16_t nchan_internal, /* i : number of internal channels */ const int16_t ducking_flag /* i : ducking flag */ ); -void ivas_spar_td_decorr_dec_close( - ivas_td_decorr_state_t **hTdDecorr /* i/o: SPAR Covar. decoder handle */ +void ivas_td_decorr_dec_close( + ivas_td_decorr_state_t **hTdDecorr /* i/o: TD decorrelator handle */ ); void ivas_td_decorr_process( diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 5c9b60aceb..8231588551 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -655,6 +655,32 @@ typedef struct ivas_trans_det_state_t } ivas_trans_det_state_t; +/*----------------------------------------------------------------------------------* + * Time domain decorrelator + *----------------------------------------------------------------------------------*/ + +typedef struct ivas_td_decorr_APD_filt_state_t +{ + int16_t order[IVAS_MAX_DECORR_APD_SECTIONS]; + int16_t idx[IVAS_MAX_DECORR_APD_SECTIONS]; + float coeffs[IVAS_MAX_DECORR_APD_SECTIONS]; + float *state[IVAS_MAX_DECORR_APD_SECTIONS]; + +} ivas_td_decorr_APD_filt_state_t; + +typedef struct ivas_td_decorr_state_t +{ + ivas_trans_det_state_t *pTrans_det; + float *look_ahead_buf; + ivas_td_decorr_APD_filt_state_t APD_filt_state[IVAS_MAX_DECORR_CHS]; + + int16_t num_apd_outputs; + int16_t num_apd_sections; + int16_t ducking_flag; + +} ivas_td_decorr_state_t; + + /*----------------------------------------------------------------------------------* * Filter Bank (FB) structures *----------------------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c similarity index 89% rename from lib_dec/ivas_td_decorr.c rename to lib_com/ivas_td_decorr.c index 3b903ac8a3..81c477fb43 100644 --- a/lib_dec/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -96,83 +96,83 @@ static ivas_error ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, const /*------------------------------------------------------------------------- - * ivas_spar_td_decorr_dec_open() + * ivas_td_decorr_dec_open() * - * Allocate and initialize SPAR time domain decorrelator handle + * Allocate and initialize time domain decorrelator handle *------------------------------------------------------------------------*/ -// VE2AT: this function is used also in lib_rend...; where to put it? --> TODO move -ivas_error ivas_spar_td_decorr_dec_open( - ivas_td_decorr_state_t **hTdDecorr, /* i/o: SPAR Covar. decoder handle */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t nchan_internal, /* i : number of internal channels */ - const int16_t ducking_flag /* i : ducking flag */ + +ivas_error ivas_td_decorr_dec_open( + ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t nchan_internal, /* i : number of internal channels */ + const int16_t ducking_flag /* i : ducking flag */ ) { int16_t i, j, len; int16_t num_out_chans; - ivas_td_decorr_state_t *hCovState; + ivas_td_decorr_state_t *hTdDecorr_loc; ivas_error error; num_out_chans = nchan_internal - 1; error = IVAS_ERR_OK; - if ( ( hCovState = (ivas_td_decorr_state_t *) malloc( sizeof( ivas_td_decorr_state_t ) ) ) == NULL ) + if ( ( hTdDecorr_loc = (ivas_td_decorr_state_t *) malloc( sizeof( ivas_td_decorr_state_t ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" ); } - if ( ( hCovState->look_ahead_buf = (float *) malloc( sizeof( float ) * (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) ) ) == NULL ) + if ( ( hTdDecorr_loc->look_ahead_buf = (float *) malloc( sizeof( float ) * (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" ); } - set_f( hCovState->look_ahead_buf, 0, (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) ); + set_f( hTdDecorr_loc->look_ahead_buf, 0, (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) ); - hCovState->num_apd_sections = ivas_get_APD_filt_orders( num_out_chans, output_Fs, hCovState->APD_filt_state[0].order ); + hTdDecorr_loc->num_apd_sections = ivas_get_APD_filt_orders( num_out_chans, output_Fs, hTdDecorr_loc->APD_filt_state[0].order ); for ( j = 0; j < num_out_chans; j++ ) { - for ( i = 0; i < hCovState->num_apd_sections; i++ ) + for ( i = 0; i < hTdDecorr_loc->num_apd_sections; i++ ) { - len = hCovState->APD_filt_state[0].order[i]; + len = hTdDecorr_loc->APD_filt_state[0].order[i]; - if ( ( hCovState->APD_filt_state[j].state[i] = (float *) malloc( sizeof( float ) * len ) ) == NULL ) + if ( ( hTdDecorr_loc->APD_filt_state[j].state[i] = (float *) malloc( sizeof( float ) * len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" ); } - set_f( hCovState->APD_filt_state[j].state[i], 0, len ); + set_f( hTdDecorr_loc->APD_filt_state[j].state[i], 0, len ); } } - ivas_td_decorr_init( hCovState, num_out_chans, ducking_flag ); + ivas_td_decorr_init( hTdDecorr_loc, num_out_chans, ducking_flag ); if ( ducking_flag ) { - if ( ( error = ivas_spar_transient_det_open( &hCovState->pTrans_det, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_transient_det_open( &hTdDecorr_loc->pTrans_det, output_Fs ) ) != IVAS_ERR_OK ) { return error; } } else { - hCovState->pTrans_det = NULL; + hTdDecorr_loc->pTrans_det = NULL; } - *hTdDecorr = hCovState; + *hTdDecorr = hTdDecorr_loc; return error; } /*------------------------------------------------------------------------- - * ivas_spar_td_decorr_dec_close() + * ivas_td_decorr_dec_close() * - * Deallocate SPAR time domain decorrelator handle + * Deallocate time domain decorrelator handle *------------------------------------------------------------------------*/ -void ivas_spar_td_decorr_dec_close( - ivas_td_decorr_state_t **hTdDecorr /* i/o: SPAR Covar. decoder handle */ +void ivas_td_decorr_dec_close( + ivas_td_decorr_state_t **hTdDecorr /* i/o: TD decorrelator handle */ ) { int16_t i, j; @@ -196,7 +196,7 @@ void ivas_spar_td_decorr_dec_close( if ( ( *hTdDecorr )->pTrans_det != NULL ) { - ivas_spar_transient_det_close( &( *hTdDecorr )->pTrans_det ); + ivas_transient_det_close( &( *hTdDecorr )->pTrans_det ); } free( ( *hTdDecorr ) ); diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c index 01a4374f93..8e98c1c025 100644 --- a/lib_com/ivas_transient_det.c +++ b/lib_com/ivas_transient_det.c @@ -49,7 +49,6 @@ #define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) #define IVAS_TDET_DUCK_MULT_FAC ( 1.1f ) #define IVAS_TDET_PARM_TRANS_THR ( 0.1f ) -#define IVAS_TDET_ONLY ( 1 ) /*env_hpf*/ #define IVAS_C_HPF_48k ( 0.675231906655777f ) @@ -84,8 +83,8 @@ *-----------------------------------------------------------------------------------------*/ static void ivas_transient_det_init( - ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ - const int32_t sampling_rate /* i : sampling rate */ + ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ + const int32_t sampling_rate /* i : sampling rate */ ) { float filt_coeff_arr[3][IVAS_BIQUAD_FILT_LEN << 1] = { { 0 } }; @@ -159,14 +158,14 @@ static void ivas_transient_det_init( /*------------------------------------------------------------------------- - * ivas_spar_transient_det_open() + * ivas_transient_det_open() * * Allocate and initialize SPAR TD handle *------------------------------------------------------------------------*/ -ivas_error ivas_spar_transient_det_open( - ivas_trans_det_state_t **hTranDet_in, /* i/o: SPAR TD handle */ - const int32_t sampling_rate /* i : sampling rate */ +ivas_error ivas_transient_det_open( + ivas_trans_det_state_t **hTranDet_in, /* i/o: Transient detector handle */ + const int32_t sampling_rate /* i : sampling rate */ ) { ivas_trans_det_state_t *hTranDet; @@ -185,13 +184,13 @@ ivas_error ivas_spar_transient_det_open( /*------------------------------------------------------------------------- - * ivas_spar_transient_det_close() + * ivas_transient_det_close() * - * Deallocate and initialize SPAR TD handle + * Deallocate and initialize Transient detector handle *------------------------------------------------------------------------*/ -void ivas_spar_transient_det_close( - ivas_trans_det_state_t **hTranDet /* i/o: SPAR TD handle */ +void ivas_transient_det_close( + ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */ ) { if ( hTranDet == NULL || *hTranDet == NULL ) @@ -221,7 +220,7 @@ int16_t ivas_transient_det_process( float mem = hTranDet->in_duck_gain; int16_t trans; - ivas_td_decorr_get_ducking_gains( hTranDet, pIn_pcm, NULL, NULL, frame_len, IVAS_TDET_ONLY ); + ivas_td_decorr_get_ducking_gains( hTranDet, pIn_pcm, NULL, NULL, frame_len, 1 ); if ( mem - hTranDet->in_duck_gain > IVAS_TDET_PARM_TRANS_THR ) { @@ -269,7 +268,7 @@ static float ivas_calc_duck_gain( *-----------------------------------------------------------------------------------------*/ void ivas_td_decorr_get_ducking_gains( - ivas_trans_det_state_t *hTranDet, + ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ float *pIn_pcm, float *pIn_duck_gains, float *pOut_duck_gains, @@ -301,7 +300,7 @@ void ivas_td_decorr_get_ducking_gains( /* env slow */ ivas_filter_process( &hTranDet->env_slow, e_slow, frame_len ); - if ( tdet_flag == IVAS_TDET_ONLY ) + if ( tdet_flag ) { for ( i = 0; i < frame_len; i++ ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 80365b21f6..93bf8c25cd 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -658,9 +658,9 @@ ivas_error ivas_sba_dec_reconfigure( hSpar->hMdDec->table_idx = -1; /* TD decorr. */ - ivas_spar_td_decorr_dec_close( &hSpar->hTdDecorr ); + ivas_td_decorr_dec_close( &hSpar->hTdDecorr ); - if ( ( error = ivas_spar_td_decorr_dec_open( &hSpar->hTdDecorr, hDecoderConfig->output_Fs, nchan_internal, 1 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, hDecoderConfig->output_Fs, nchan_internal, 1 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index f9f6a1ef9e..3ebb5b2c89 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -84,7 +84,7 @@ ivas_error ivas_spar_dec_open( output_Fs = st_ivas->hDecoderConfig->output_Fs; /* TD decorr. */ - if ( ( error = ivas_spar_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_channels_internal, 1 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_channels_internal, 1 ) ) != IVAS_ERR_OK ) { return error; } @@ -194,8 +194,8 @@ void ivas_spar_dec_close( /* MD handle */ ivas_spar_md_dec_close( &hSpar->hMdDec ); - /* Covar. State handle */ - ivas_spar_td_decorr_dec_close( &hSpar->hTdDecorr ); + /* TD decorrelator handle */ + ivas_td_decorr_dec_close( &hSpar->hTdDecorr ); /* FB mixer handle */ ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs ); diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 5e9dd6400c..e9eb960e9c 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -114,7 +114,7 @@ ivas_error ivas_spar_enc_open( } /* Transient Detector handle */ - if ( ( error = ivas_spar_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -252,7 +252,7 @@ void ivas_spar_enc_close( ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs ); /* Trans Det handle */ - ivas_spar_transient_det_close( &hSpar->hTranDet ); + ivas_transient_det_close( &hSpar->hTranDet ); /* AGC */ ivas_spar_agc_enc_close( &hSpar->hAgcEnc ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 4dd230b101..07b416a609 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -257,7 +257,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( { if ( hBinaural->hTdDecorr == NULL ) { - ivas_spar_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 1 ); + ivas_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 1 ); } if ( st_ivas->hDecoderConfig->ivas_total_brate < IVAS_24k4 ) @@ -271,12 +271,12 @@ ivas_error ivas_dirac_dec_init_binaural_data( } else { - ivas_spar_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 0 ); + ivas_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 0 ); } } else { - ivas_spar_td_decorr_dec_close( &( hBinaural->hTdDecorr ) ); + ivas_td_decorr_dec_close( &( hBinaural->hTdDecorr ) ); } st_ivas->hDiracDecBin = hBinaural; @@ -305,7 +305,7 @@ void ivas_dirac_dec_close_binaural_data( ivas_binaural_reverb_close( &( ( *hBinaural )->hReverb ) ); } - ivas_spar_td_decorr_dec_close( &( ( *hBinaural )->hTdDecorr ) ); + ivas_td_decorr_dec_close( &( ( *hBinaural )->hTdDecorr ) ); free( *hBinaural ); *hBinaural = NULL; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 133375137b..a8b234eb4c 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -106,28 +106,6 @@ typedef struct ivas_binaural_reverb_struct } REVERB_STRUCT, *REVERB_STRUCT_HANDLE; -/* TD decorr */ -typedef struct ivas_td_decorr_APD_filt_state_t -{ - int16_t order[IVAS_MAX_DECORR_APD_SECTIONS]; - int16_t idx[IVAS_MAX_DECORR_APD_SECTIONS]; - float coeffs[IVAS_MAX_DECORR_APD_SECTIONS]; - float *state[IVAS_MAX_DECORR_APD_SECTIONS]; - -} ivas_td_decorr_APD_filt_state_t; - -typedef struct ivas_td_decorr_state_t -{ - ivas_trans_det_state_t *pTrans_det; - float *look_ahead_buf; - ivas_td_decorr_APD_filt_state_t APD_filt_state[IVAS_MAX_DECORR_CHS]; - - int16_t num_apd_outputs; - int16_t num_apd_sections; - int16_t ducking_flag; - -} ivas_td_decorr_state_t; - /* Parametric binaural data structure */ typedef struct ivas_dirac_dec_binaural_data_structure { -- GitLab From 25f20cbbdc2fdd9b638029d815dfacde5d330e40 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 17 Feb 2023 11:49:05 +0100 Subject: [PATCH 38/40] Remove file from .gitignore Apparently it was added by mistake --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 16e82490f3..c87c691a4a 100644 --- a/.gitignore +++ b/.gitignore @@ -72,4 +72,3 @@ Externals/ # coan output files that are created when cleaning out switches coan_out_* -/lib_rend/ivas_hrtf_destroy.c -- GitLab From e4a2a38be9747b6b6adb994a956bb63aef257d2f Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 17 Feb 2023 12:55:05 +0100 Subject: [PATCH 39/40] Fix build errors --- lib_dec/ivas_ism_dec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index c354ca257e..6f07130d1d 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -33,6 +33,7 @@ #include #include "options.h" #include "ivas_prot.h" +#include "ivas_prot_rend.h" #ifdef DEBUGGING #include "debug.h" #endif @@ -122,8 +123,8 @@ static ivas_error ivas_ism_bitrate_switching( /* Open Crend Binaural renderer */ #ifdef FIX_197_CREND_INTERFACE if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), - getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ), - getRendAudioConfigFromIvasAudioConfig( st_ivas->hOutSetup.output_config ), + st_ivas->intern_config, + st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->Opt_Headrotation, st_ivas->hSetOfHRTF, -- GitLab From 333c8012c812cb0d5bd251188ae954cf31f6445c Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 17 Feb 2023 13:03:31 +0100 Subject: [PATCH 40/40] Fix formatting --- lib_dec/ivas_dec.c | 4 ++-- lib_dec/ivas_stat_dec.h | 2 -- lib_rend/ivas_crend.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) mode change 100755 => 100644 lib_dec/ivas_stat_dec.h diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index bf2baa6775..db54bca1be 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -446,8 +446,8 @@ ivas_error ivas_dec( { #ifdef FIX_197_CREND_INTERFACE if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, - st_ivas->intern_config , - st_ivas->hOutSetup.output_config , + st_ivas->intern_config, + st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, &st_ivas->hIntSetup, diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h old mode 100755 new mode 100644 index 3ea69cdd5a..1ceba1e3fd --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1024,7 +1024,6 @@ typedef struct vbap_data_structure } VBAP_DATA, *VBAP_HANDLE; - /*----------------------------------------------------------------------------------* * renderer structures *----------------------------------------------------------------------------------*/ @@ -1037,7 +1036,6 @@ typedef struct renderer_struct } ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; - /* Fastconv binaural data structure */ typedef struct ivas_binaural_rendering_struct { diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index afc0fa42fb..03df4a559b 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2086,7 +2086,7 @@ ivas_error ivas_rend_openCrend( if ( ( hRendCfg != NULL ) && ( hRendCfg->roomAcoustics.late_reverb_on ) ) { if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), - inConfig, + inConfig, #ifdef FIX_197_CREND_INTERFACE ( *pCrend )->hHrtfCrend, #else -- GitLab