diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 5645b8e9bf46fa6b5903314d7975da46e8f52d1f..074b6d8845ceb7c405735fba0914e1a3b2aa6330 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -40,13 +40,20 @@ #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" #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 */ @@ -5421,8 +5428,9 @@ ivas_error ivas_crend_process( float output[][L_FRAME48k] /* i/o: input/output audio channels */ ); -#else +#else /* FIX_197_CREND_INTERFACE */ +#ifndef FIX_197_CREND_INTERFACE_LIB_REND_H IVAS_REND_AudioConfigType getAudioConfigType( const IVAS_REND_AudioConfig config ); @@ -5432,19 +5440,30 @@ ivas_error getAudioConfigNumChannels( IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( AUDIO_CONFIG config ); +#endif /* FIX_197_CREND_INTERFACE_LIB_REND_H */ ivas_error ivas_rend_initCrend( 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 RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, const int32_t output_Fs ); 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, @@ -5459,8 +5478,13 @@ ivas_error 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_com/options.h b/lib_com/options.h index 93bf718c7e0fe2ff7240f0898afc88dcd83b25c6..8e397881cf4da5a2da520ca45e2b3c7860d32351 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,6 +150,10 @@ #define FIX_197_CREND_INTERFACE +#ifdef FIX_197_CREND_INTERFACE +#define FIX_197_CREND_INTERFACE_LIB_REND_H +#endif + #define FIX_MEMORY_COUNTING_HRTF_BINARY_FILE #define FIX_334_DEBUG_BE_STEREO_SWITCHING /* FhG: Fix non-BE issue for stereo switching when DEBUGGING is enabled */ #define FIX_198_TDREND_INTERFACE /* Issue 198: Harmonize interface for TD renderer between decoder and external renderer */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 384baa0bb26482918c2e122394c771f8658c6294..e1337204908eba9f0fbc1ab05a5db068742aab03 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -209,8 +209,13 @@ ivas_error ivas_dec( { #ifdef FIX_197_CREND_INTERFACE if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + AUDIO_CONFIG_7_1_4, + AUDIO_CONFIG_BINAURAL_ROOM, +#else IVAS_REND_AUDIO_CONFIG_7_1_4, IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM, +#endif NULL, NULL, NULL, @@ -422,8 +427,14 @@ ivas_error ivas_dec( { #ifdef FIX_197_CREND_INTERFACE if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + st_ivas->intern_config, + st_ivas->hOutSetup.output_config, +#else getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ), getRendAudioConfigFromIvasAudioConfig( st_ivas->hOutSetup.output_config ), + +#endif st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, &st_ivas->hIntSetup, diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index dd094892e3694f5ef90b20e6fcbc74c4f03344f5..d9cb37f6ddcb287eb5a60e285c8b2d5703f1f27d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1249,8 +1249,13 @@ ivas_error ivas_init_decoder( } if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + st_ivas->intern_config, + st_ivas->hDecoderConfig->output_config, +#else getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ), getRendAudioConfigFromIvasAudioConfig( st_ivas->hDecoderConfig->output_config ), +#endif st_ivas->hRenderConfig, st_ivas->hDecoderConfig->Opt_Headrotation, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index f2f008ff376d28c7ba1f4d0b3fa772df42a493b7..60121fcbae7c038ed310a4f70ad2a197bf1b2bd2 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1087,8 +1087,13 @@ static ivas_error ivas_ism_bitrate_switching( /* Open Crend Binaural renderer */ #ifdef FIX_197_CREND_INTERFACE if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + st_ivas->intern_config, + st_ivas->hOutSetup.output_config, +#else getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ), getRendAudioConfigFromIvasAudioConfig( st_ivas->hOutSetup.output_config ), +#endif st_ivas->hRenderConfig, st_ivas->hDecoderConfig->Opt_Headrotation, st_ivas->hSetOfHRTF, diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 9c8e6407841d1cf2415f332ab4a5855c76797f82..72a2fcacbba49ccae7184561c310aa03b9b8642e 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1158,8 +1158,13 @@ static ivas_error ivas_mc_dec_reconfig( else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + st_ivas->intern_config, + st_ivas->hDecoderConfig->output_config, +#else getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ), getRendAudioConfigFromIvasAudioConfig( st_ivas->hDecoderConfig->output_config ), +#endif st_ivas->hRenderConfig, st_ivas->hDecoderConfig->Opt_Headrotation, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index a78f747b6a3495be691f12e4beca64b5c0896792..d13849a60c45bfdf978ad4d43c1797818d1e6603 100755 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -40,16 +40,13 @@ #include "ivas_cnst.h" #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 -#endif - -#ifndef FIX_197_CREND_INTERFACE - /*----------------------------------------------------------------------------------* * 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; @@ -828,7 +825,7 @@ typedef struct ivas_spar_md_dec_state_t int16_t spar_hoa_md_flag; } ivas_spar_md_dec_state_t; -#ifndef FIX_197_CREND_INTERFACE +#if !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H /* AGC structure */ typedef struct ivas_agc_dec_chan_state_t @@ -868,7 +865,7 @@ typedef struct ivas_td_decorr_state_t } ivas_td_decorr_state_t; -#endif +#endif /* !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H */ /* PCA structure */ typedef struct @@ -1001,7 +998,7 @@ typedef struct mct_dec_data_structure } MCT_DEC_DATA, *MCT_DEC_HANDLE; -#ifndef FIX_197_CREND_INTERFACE +#if !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H /*----------------------------------------------------------------------------------* * EFAP structures @@ -1190,7 +1187,7 @@ typedef struct ivas_masa_decoder_struct } MASA_DECODER, *MASA_DECODER_HANDLE; -#ifndef FIX_197_CREND_INTERFACE +#if !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H /*----------------------------------------------------------------------------------* * Binaural Rendering structure @@ -1515,6 +1512,7 @@ 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; @@ -1822,6 +1820,20 @@ 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 *----------------------------------------------------------------------------------*/ @@ -1891,7 +1903,8 @@ typedef struct decoder_config_structure } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; -#endif +#endif /* !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H */ + /*----------------------------------------------------------------------------------* * * Main IVAS decoder structure diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index f3ea41f08156d92ad28ddefe55f2640feb425742..2ddb2f642cbc282d91a26d9f9b8b0e8dc8652dec 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -36,9 +36,15 @@ #include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" +#ifndef FIX_197_CREND_INTERFACE_LIB_REND_H #include "ivas_stat_dec.h" +#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" #include "lib_rend.h" @@ -46,6 +52,7 @@ #include "lib_rend.h" #include "ivas_lib_rend_internal.h" #endif +#endif #ifdef DEBUGGING #include "debug.h" #endif @@ -1456,8 +1463,13 @@ ivas_error ivas_crend_process( ivas_error ivas_rend_initCrend( CREND_WRAPPER *pCrend, +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + const AUDIO_CONFIG inIvasConfig, + const AUDIO_CONFIG outIvasConfig, +#else const IVAS_REND_AudioConfig inConfig, const IVAS_REND_AudioConfig outConfig, +#endif RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, const int32_t output_Fs ) @@ -1468,8 +1480,15 @@ ivas_error ivas_rend_initCrend( IVAS_REND_AudioConfigType inConfigType; HRTFS_HANDLE hHrtf; ivas_error error; +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + IVAS_REND_AudioConfig inConfig; + IVAS_REND_AudioConfig outConfig; + inConfig = getRendAudioConfigFromIvasAudioConfig( inIvasConfig ); + outConfig = getRendAudioConfigFromIvasAudioConfig( outIvasConfig ); +#endif inConfigType = getAudioConfigType( inConfig ); + hHrtf = pCrend->hHrtfCrend; /* Do all error checks up front so that the nested if later is easier */ @@ -1503,7 +1522,6 @@ ivas_error ivas_rend_initCrend( } #endif - if ( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ) != IVAS_ERR_OK ) { return error; @@ -1980,8 +1998,13 @@ ivas_error ivas_rend_openCrend( #else CREND_WRAPPER *pCrend, #endif +#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, #ifdef FIX_197_CREND_INTERFACE int16_t Opt_Headrotation, @@ -2156,7 +2179,11 @@ ivas_error ivas_rend_openCrend( if ( ( hRendCfg != NULL ) && ( hRendCfg->roomAcoustics.late_reverb_on ) ) { if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + inConfig, +#else getIvasAudioConfigFromRendAudioConfig( inConfig ), +#endif #ifdef FIX_197_CREND_INTERFACE ( *pCrend )->hHrtfCrend, #else @@ -2508,8 +2535,13 @@ static ivas_error ivas_rend_crendConvolver( 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 #ifdef FIX_197_CREND_INTERFACE DECODER_CONFIG_HANDLE hDecoderConfig, HEAD_TRACK_DATA_HANDLE hHeadTrackData, @@ -2529,12 +2561,24 @@ ivas_error ivas_rend_crendProcess( AUDIO_CONFIG in_config; IVAS_REND_AudioConfigType inConfigType; ivas_error error; +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + IVAS_REND_AudioConfig inRendConfig; + IVAS_REND_AudioConfig outRendConfig; + inRendConfig = getRendAudioConfigFromIvasAudioConfig( inConfig ); + outRendConfig = getRendAudioConfigFromIvasAudioConfig( outConfig ); +#endif push_wmops( "ivas_rend_crendProcess" ); +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + in_config = getIvasAudioConfigFromRendAudioConfig( inRendConfig ); + inConfigType = getAudioConfigType( inRendConfig ); + getAudioConfigNumChannels( outRendConfig, &nchan_out ); +#else in_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); inConfigType = getAudioConfigType( inConfig ); getAudioConfigNumChannels( outConfig, &nchan_out ); +#endif output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); #ifdef FIX_197_CREND_INTERFACE subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; @@ -2581,7 +2625,11 @@ ivas_error ivas_rend_crendProcess( if ( ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + if ( ( error = ivas_rend_crendConvolver( pCrend, inRendConfig, outRendConfig, output, pcm_tmp, output_Fs, subframe_idx ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output, pcm_tmp, output_Fs, subframe_idx ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_rend/ivas_lib_rend_internal.h b/lib_rend/ivas_lib_rend_internal.h index 60d6ed7b51694d234b9154b21f9e2fce31823b97..a4951fedd84ae1860bd79c401110d25bbc5dbee1 100644 --- a/lib_rend/ivas_lib_rend_internal.h +++ b/lib_rend/ivas_lib_rend_internal.h @@ -30,18 +30,30 @@ *******************************************************************************************************/ +#ifndef IVAS_LIB_REND_INTERNALS_H +#define IVAS_LIB_REND_INTERNALS_H + +#include "options.h" #include "ivas_error.h" + +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H +#include "lib_rend.h" +#include "ivas_cnst.h" +#include +#include "ivas_stat_dec.h" + +#else /* FIX_197_CREND_INTERFACE_LIB_REND_H */ + #ifdef FIX_197_CREND_INTERFACE #include "ivas_stat_rend.h" -#else +#else /* FIX_197_CREND_INTERFACE */ #include "lib_rend.h" -#endif +#endif /* FIX_197_CREND_INTERFACE */ + #include "ivas_stat_dec.h" -#ifndef IVAS_LIB_REND_INTERNALS_H -#define IVAS_LIB_REND_INTERNALS_H +#endif /* FIX_197_CREND_INTERFACE_LIB_REND_H */ -#ifndef FIX_197_CREND_INTERFACE typedef struct { int8_t headRotEnabled; @@ -56,6 +68,8 @@ typedef struct TDREND_HRFILT_FiltSet_t *hHrtfTD; } TDREND_WRAPPER; +#ifndef FIX_197_CREND_INTERFACE + typedef struct { int32_t binaural_latency_ns; @@ -63,6 +77,8 @@ typedef struct HRTFS_HANDLE hHrtfCrend; } CREND_WRAPPER; +#endif + IVAS_REND_AudioConfigType getAudioConfigType( const IVAS_REND_AudioConfig config ); @@ -70,9 +86,16 @@ ivas_error getAudioConfigNumChannels( const IVAS_REND_AudioConfig config, int16_t *numChannels ); +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H +IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( + AUDIO_CONFIG config ); +#endif + AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( IVAS_REND_AudioConfig config ); +#ifndef FIX_197_CREND_INTERFACE + ivas_error ivas_rend_openCrend( CREND_WRAPPER *pCrend, const IVAS_REND_AudioConfig inConfig, diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index e57044930ec037e3743140f736e76639a17e67d5..fd3bcde641704e739ec53a77af740a9b09837a36 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -34,6 +34,76 @@ #define IVAS_STAT_REND_H #include +#include "options.h" +#include "ivas_cnst.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 + *----------------------------------------------------------------------------------*/ + +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 +{ + 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" @@ -139,6 +209,8 @@ typedef struct float lfeOutputGains[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; } IVAS_REND_LfeRouting; +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + typedef struct { int8_t headRotEnabled; @@ -146,6 +218,7 @@ typedef struct float crossfade[L_FRAME48k / RENDERER_HEAD_POSITIONS_PER_FRAME]; } IVAS_REND_HeadRotData; +#endif /*----------------------------------------------------------------------------------* * Binaural Rendering structure *----------------------------------------------------------------------------------*/ @@ -1044,12 +1117,16 @@ typedef struct decoder_config_structure } 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 /*----------------------------------------------------------------------------------* @@ -1113,4 +1190,6 @@ typedef enum CHANNEL_TYPE_LFE } ChannelType; +#endif + #endif /* IVAS_STAT_REND_H */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index ed0039296446039c96b3e4b4ece03caaa99731e0..300130bcfe72f8f9e3702722a6d7587d3ce6e567 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -38,9 +38,6 @@ #include "ivas_rom_dec.h" #include "ivas_rom_rend.h" #include "ivas_lib_rend_internal.h" -#ifdef FIX_197_CREND_INTERFACE -#include "lib_rend.h" -#endif #include "prot.h" #include "wmc_auto.h" @@ -1064,8 +1061,13 @@ static ivas_error setRendInputActiveIsm( else if ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) { error = ivas_rend_openCrend( &inputIsm->crendWrapper, +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + AUDIO_CONFIG_7_1_4, + getIvasAudioConfigFromRendAudioConfig( outConfig ), +#else IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, +#endif hRendCfg, #ifdef FIX_197_CREND_INTERFACE 0, @@ -1769,8 +1771,13 @@ static ivas_error initMcBinauralRendering( { if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + getIvasAudioConfigFromRendAudioConfig( ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_REND_AUDIO_CONFIG_7_1_4 : inConfig ), + getIvasAudioConfigFromRendAudioConfig( outConfig ), +#else ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_REND_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, +#endif hRendCfg, #ifdef FIX_197_CREND_INTERFACE 0, @@ -2047,7 +2054,11 @@ static ivas_error updateSbaPanGains( { case IVAS_REND_AUDIO_CONFIG_BINAURAL: #ifdef FIX_197_CREND_INTERFACE +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + error = ivas_rend_openCrend( &inputSba->crendWrapper, getIvasAudioConfigFromRendAudioConfig( inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), hRendCfg, 0, +#else error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, 0, +#endif NULL, *rendCtx.pOutSampleRate ); #else @@ -2062,7 +2073,11 @@ static ivas_error updateSbaPanGains( return error; } #ifdef FIX_197_CREND_INTERFACE +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + error = ivas_rend_openCrend( &inputSba->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), hRendCfg, 0, +#else error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, 0, +#endif NULL, *rendCtx.pOutSampleRate ); #else @@ -4116,7 +4131,11 @@ static ivas_error renderIsmToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); #ifdef FIX_197_CREND_INTERFACE +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + ivas_rend_crendProcess( ismInput->crendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, NULL, NULL, NULL, NULL, tmpCrendBuffer, *ismInput->base.ctx.pOutSampleRate ); +#else ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM, NULL, NULL, NULL, NULL, tmpCrendBuffer, *ismInput->base.ctx.pOutSampleRate ); +#endif #else ivas_rend_crendProcess( &ismInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM, tmpCrendBuffer, *ismInput->base.ctx.pOutSampleRate ); #endif @@ -4422,7 +4441,11 @@ static ivas_error renderMcToBinaural( /* call CREND */ #ifdef FIX_197_CREND_INTERFACE +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = ivas_rend_crendProcess( &mcInput->crendWrapper, mcInput->base.inConfig, outConfig, tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif @@ -4478,7 +4501,11 @@ static ivas_error renderMcToBinauralRoom( /* call CREND */ #ifdef FIX_197_CREND_INTERFACE +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = ivas_rend_crendProcess( &mcInput->crendWrapper, mcInput->base.inConfig, outConfig, tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif @@ -4549,7 +4576,11 @@ static ivas_error renderMcCustomLsToBinauralRoom( /* call CREND */ #ifdef FIX_197_CREND_INTERFACE +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = ivas_rend_crendProcess( &mcInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif @@ -4781,7 +4812,11 @@ static ivas_error renderSbaToBinaural( /* call CREND */ #ifdef FIX_197_CREND_INTERFACE +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( sbaInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = ivas_rend_crendProcess( &sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif @@ -4845,7 +4880,11 @@ static ivas_error renderSbaToBinauralRoom( /* call CREND */ #ifdef FIX_197_CREND_INTERFACE +#ifdef FIX_197_CREND_INTERFACE_LIB_REND_H + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = ivas_rend_crendProcess( &sbaInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif @@ -5251,23 +5290,3 @@ int32_t IVAS_REND_GetCntFramesLimited( return hIvasRend->hLimiter->cnt_frames_limited; } #endif - -#ifdef FIX_197_CREND_INTERFACE -ivas_error ivas_rend_initEfap( - 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 b2ca45c70c5e877cc5d123d74b8baaf0af112b20..789b426070aa29ed24638ecf77f23458ea50ba73 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -40,7 +40,8 @@ #include "options.h" #include "common_api_types.h" #include "ivas_error.h" -#ifdef FIX_197_CREND_INTERFACE + +#if defined FIX_197_CREND_INTERFACE && !defined FIX_197_CREND_INTERFACE_LIB_REND_H #include "ivas_stat_rend.h" #endif @@ -49,7 +50,7 @@ #define RENDERER_MAX_SBA_INPUTS 1 #define RENDERER_MAX_MASA_INPUTS 1 -#ifndef FIX_197_CREND_INTERFACE +#if !defined FIX_197_CREND_INTERFACE || defined FIX_197_CREND_INTERFACE_LIB_REND_H #define RENDERER_HEAD_POSITIONS_PER_FRAME 4 @@ -139,12 +140,25 @@ typedef enum typedef uint16_t IVAS_REND_InputId; +#endif -#else - +#ifndef FIX_197_CREND_INTERFACE_LIB_REND_H +#ifdef FIX_197_CREND_INTERFACE AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( IVAS_REND_AudioConfig config ); +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 /* clang-format off */ @@ -291,12 +305,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