diff --git a/apps/decoder.c b/apps/decoder.c index 660a71c4a900cae3b38388087faf7b474d9f5b49..73e725ae54138e7da0241fe44ed4e43bec53695e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -171,7 +171,7 @@ typedef struct IVAS_BIN_RENDERER_TYPE binaural_renderer_sec_old; #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - IVAS_AUDIO_CONFIG fastConv_set_cfg; + BINAURAL_INPUT_AUDIO_CONFIG fastConv_set_cfg; #else IVAS_AUDIO_CONFIG intern_audio_config; int16_t room_reverb_flag; @@ -188,7 +188,7 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); -static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const int32_t output_Fs ); +static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, IVAS_AUDIO_CONFIG out_config, const int32_t output_Fs ); #ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); static int16_t app_own_random( int16_t *seed ); @@ -733,7 +733,7 @@ int main( hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE; hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE; #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - hHrtfBinary.fastConv_set_cfg = IVAS_AUDIO_CONFIG_INVALID; + hHrtfBinary.fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_INVALID; #else hHrtfBinary.room_reverb_flag = 0; hHrtfBinary.intern_audio_config = IVAS_AUDIO_CONFIG_INVALID; @@ -2389,7 +2389,7 @@ static ivas_error decodeG192( /* Load HRTF binary file data */ if ( arg.hrtfReaderEnabled ) { - if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtfBinary, hIvasDec, arg.output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtfBinary, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -3300,7 +3300,7 @@ static ivas_error decodeVoIP( /* Load HRTF binary file data */ if ( arg.hrtfReaderEnabled ) { - if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtf, hIvasDec, arg.output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtf, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -3700,6 +3700,7 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, + IVAS_AUDIO_CONFIG out_config, const int32_t output_Fs ) { ivas_error error; @@ -3804,7 +3805,7 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->fastConv_set_cfg, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) + if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->fastConv_set_cfg, out_config, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->room_reverb_flag, hHrtfBinary->intern_audio_config, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #endif diff --git a/apps/renderer.c b/apps/renderer.c index 544dd283f1fe8f828c73c5a7f1769add4eafd49a..3e6a2d4130ded107c7d10687b500cbb39d160964 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -946,7 +946,7 @@ int main( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, IVAS_AUDIO_CONFIG_EXTERNAL, hrtfFileReader ) ) != IVAS_ERR_OK ) + if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, args.outConfig.audioConfig, hrtfFileReader ) ) != IVAS_ERR_OK ) #else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, 0, IVAS_AUDIO_CONFIG_INVALID, hrtfFileReader ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 00df25e87d564b767b3428b94c2cb519778ca125..0d04d931a989f710b5048a40a24adbeb6f6cf5b0 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -97,6 +97,17 @@ typedef enum _IVAS_AUDIO_CONFIG } IVAS_AUDIO_CONFIG; +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_HOA3, /* HOA3 */ + BINAURAL_INPUT_AUDIO_CONFIG_HOA2, /* HOA2 */ + BINAURAL_INPUT_AUDIO_CONFIG_FOA, /* FOA */ + BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED /* Not used */ + +} BINAURAL_INPUT_AUDIO_CONFIG; + /*----------------------------------------------------------------------------------* * Common API structures and enums diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 4a56f13237d705f003845e39439d254ee578bda7..6134c27d1412e1df0817b109c473c37b3a939bdc 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1499,17 +1499,6 @@ typedef enum #define BINAURAL_COHERENCE_DIFFERENCE_BINS 9 /* Number of bins for direction-dependent diffuse-field binaural coherence */ -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_HOA3, /* HOA3 */ - BINAURAL_INPUT_AUDIO_CONFIG_HOA2, /* HOA2 */ - BINAURAL_INPUT_AUDIO_CONFIG_FOA, /* FOA */ - BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED /* Not used */ - -} BINAURAL_INPUT_AUDIO_CONFIG; - #define HEADROT_ORDER 3 #define HEADROT_SHMAT_DIM ( ( HEADROT_ORDER + 1 ) * ( HEADROT_ORDER + 1 ) ) #define HEADROT_SHMAT_DIM2 ( HEADROT_SHMAT_DIM * HEADROT_SHMAT_DIM ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 3ed3ab09d443c6f0c299399e9bebe90a418a97ff..f0873e261e015449bdf2d2a09e4c6f8306ae1fe8 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -916,7 +916,7 @@ ivas_error IVAS_DEC_ReadFormat( IVAS_BIN_RENDERER_TYPE *binaural_renderer, /* o : binaural renderer type */ IVAS_BIN_RENDERER_TYPE *binaural_renderer_sec, /* o : secondary binaural renderer type */ #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - IVAS_AUDIO_CONFIG *fastConv_set_cfg /* o : HRTF set audio config. for FastConv rend.*/ + BINAURAL_INPUT_AUDIO_CONFIG *fastConv_set_cfg /* o : HRTF set audio config. for FastConv rend.*/ #else int16_t *room_reverb_flag, /* o : room reverb flag */ IVAS_AUDIO_CONFIG *intern_audio_config /* o : internal audio configuration */ @@ -1018,44 +1018,30 @@ ivas_error IVAS_DEC_ReadFormat( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_INVALID; + *fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_INVALID; if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV ) { if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || - output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { - /* SHD transformed HRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; - } - else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + /* SHD HRIRs */ + *fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_HOA3; + + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { /* BRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; + *fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_COMBINED; } } else if ( st_ivas->ivas_format == MC_FORMAT ) { - /* BRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; + /* HRIRs */ + *fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_COMBINED; - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( ( st_ivas->hDecoderConfig->Opt_Headrotation ) && + !( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) { - /* HRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL; - } - - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) - { - /* SHD transformed HRIRs for low complexity rotation */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; - - if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { - /* BRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; - } + /* SHD HRIRs for low complexity rotation */ + *fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_HOA3; } } } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index ecd7c2d02cbd8e79a4677c038c4b8b7a4107ca83..c37ba942cf2b13fc9a7cfb820515579abc831496 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -34,6 +34,7 @@ #define LIB_DEC_H #include "common_api_types.h" +#include "ivas_cnst.h" #include /*---------------------------------------------------------------------* @@ -160,7 +161,7 @@ ivas_error IVAS_DEC_ReadFormat( IVAS_BIN_RENDERER_TYPE *binaural_renderer, /* o : binaural renderer type */ IVAS_BIN_RENDERER_TYPE *binaural_renderer_sec,/* o: secondary binaural renderer type */ #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - IVAS_AUDIO_CONFIG *fastConv_set_cfg /* o : HRTF set audio config. for FastConv rend. */ + BINAURAL_INPUT_AUDIO_CONFIG *fastConv_set_cfg /* o : HRTF set audio config. for FastConv rend. */ #else int16_t *room_reverb_flag, /* o : room reverb flag */ IVAS_AUDIO_CONFIG *intern_audio_config /* o : internal audio configuration */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 518d2c353a9f63e3b92974ceeaea94027d01cd6c..49218846a214eb18a225fb6b3c1b5e38d1227e15 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1965,7 +1965,8 @@ static ivas_error create_parambin_HRTF_from_rawdata( ivas_error load_fastconv_HRTF_from_binary( IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - const IVAS_AUDIO_CONFIG fastConv_set_cfg, /* i : HRTF set audio config. for FastConv rend. */ + const BINAURAL_INPUT_AUDIO_CONFIG fastConv_set_cfg, /* i : HRTF set audio config. for FastConv rend. */ + const IVAS_AUDIO_CONFIG out_cfg, /* i : Output configuration */ #else const int16_t room_reverb_flag, /* i : room reverb flag */ const IVAS_AUDIO_CONFIG intern_audio_config, /* i : internal audio configuration */ @@ -2019,13 +2020,22 @@ ivas_error load_fastconv_HRTF_from_binary( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - if ( ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && - ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL ) || - ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA3 ) || - ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA2 ) || - ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA && fastConv_set_cfg == IVAS_AUDIO_CONFIG_FOA ) ) ) || - ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || - ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && fastConv_set_cfg == IVAS_AUDIO_CONFIG_EXTERNAL ) ) + bool load; + + load = false; + if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && /* HRIRs */ + ( out_cfg == IVAS_AUDIO_CONFIG_BINAURAL || out_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) || + ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && /* BRIRs */ + out_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) + { + load = ( (BINAURAL_INPUT_AUDIO_CONFIG) hrtf_header.input_cfg == fastConv_set_cfg ) ? true : false; + } + // not sure why this condition exists at all? + else if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && fastConv_set_cfg == BINAURAL_INPUT_AUDIO_CONFIG_INVALID ) + { + load = true; + } + if ( load ) #else if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && intern_audio_config == IVAS_AUDIO_CONFIG_HOA3 ) || diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index e9295e844293f6835301d1eff1ca612578a03168..0bff79f6de2acaec0f07fc2588d85886cf8b44f1 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -133,7 +133,8 @@ void destroy_SetOfHRTF( ivas_error load_fastconv_HRTF_from_binary( IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - const IVAS_AUDIO_CONFIG hrtf_set_config, /* i : HRTF set audio config. for FastConv rend. */ + const BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_config, /* i : HRTF set audio config. for FastConv rend. */ + const IVAS_AUDIO_CONFIG out_config, /* i : output configuration */ #else const int16_t room_reverb_flag, /* i : room reverb flag */ IVAS_AUDIO_CONFIG intern_audio_config, /* i : internal audio configuration */