diff --git a/apps/decoder.c b/apps/decoder.c index 685461fd3f3e4a0b40f7bea04f2047ee0d7329c7..0e246ca1ec2032e07d80753ec77c6f3fea2beb65 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -222,8 +222,21 @@ int main( if ( arg.hrtfReaderEnabled ) { +#ifdef FIX_351_HRTF_COMMAND + /* sanity check */ + if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) + { + arg.hrtfReaderEnabled = false; + fprintf( stderr, "\nError: HRTF binary file cannot be used in this output configuration.\n\n" ); + goto cleanup; + } +#endif + if ( ( error = hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) ) != IVAS_ERR_OK ) { +#ifdef FIX_351_HRTF_COMMAND + arg.hrtfReaderEnabled = false; +#endif fprintf( stderr, "\nError: Can't open HRTF binary file %s \n\n", arg.hrtfFileName ); goto cleanup; } @@ -235,6 +248,15 @@ int main( if ( arg.enableHeadRotation ) { +#ifdef FIX_351_HRTF_COMMAND + /* sanity check */ + if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) + { + fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" ); + goto cleanup; + } +#endif + if ( ( error = HeadRotationFileReader_open( arg.headrotTrajFileName, &headRotReader ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: Can't open head-rotation file %s \n\n", arg.headrotTrajFileName ); @@ -261,6 +283,15 @@ int main( if ( arg.renderConfigEnabled ) { +#ifdef FIX_351_HRTF_COMMAND + /* sanity check */ + if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) + { + fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" ); + goto cleanup; + } +#endif + if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: Can't open Renderer configuration file %s \n\n", arg.renderConfigFilename ); @@ -273,13 +304,21 @@ int main( *------------------------------------------------------------------------------------------*/ #ifdef REMOVE_FORCE_SUBFRAME_BIN - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled ) ) != IVAS_ERR_OK ) #else #ifdef DEBUGGING +#ifdef FIX_351_HRTF_COMMAND + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled, arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef FIX_351_HRTF_COMMAND + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation ) ) != IVAS_ERR_OK ) #endif +#endif #endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -456,9 +495,7 @@ int main( if ( ( error = create_SetOfHRTF_from_binary( hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in loading HRTF binary file %s for CRend \n\n", arg.hrtfCRendFileName ); -#ifndef FIX_FOR_TEST goto cleanup; -#endif } IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv; IVAS_DEC_GetHrtfFastConvHandle( hIvasDec, &hHrtfFastConv ); @@ -535,6 +572,7 @@ cleanup: #ifdef DEBUG_SBA_AUDIO_DUMP IVAS_DEC_GetSbaDebugParams( hIvasDec, &numOutChannels, &numTransportChannels, &pca_ingest_channels ); #endif + if ( arg.hrtfReaderEnabled ) { IVAS_DEC_HRTF_HANDLE hHrtfTD; diff --git a/lib_com/options.h b/lib_com/options.h index e9b04f07c722785452cee82edf86b425b980e53d..45406dadb9c98b0dcf671d4ca927565e707d16b3 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,7 @@ #endif #define BINAURALIZATION_DELAY_REPORT /* VA: Issue 255 - Changes the way the decoder delay is reported */ +#define FIX_351_HRTF_COMMAND /* VA: Issue 354 - improve "-hrtf" command-line option */ #define FIX_94_VERIFY_WAV_NUM_CHANNELS /* FhG: Issue 94 - Check if number of channels in input wav file matches encoder/renderer configuration */ diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 3c9bf13abfcf97db57ee8cda38c115c58ac5dcd9..f5ea0e041e5fff0483fef56cb8043d8ea025e47f 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1127,7 +1127,10 @@ typedef struct decoder_config_structure 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 */ +#ifdef FIX_351_HRTF_COMMAND + int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ +#endif + int16_t orientation_tracking; /* indicates orientation tracking type */ float no_diegetic_pan; int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index dba7cbedca0cddc267cabea66064d084f3f9d5a0..fb2bd7e4d1cbcc114ca17ce3f6f391c11d2c6515 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -223,6 +223,9 @@ static void init_decoder_config( hDecoderConfig->Opt_LsCustom = 0; hDecoderConfig->Opt_HRTF_binary = 0; hDecoderConfig->Opt_Headrotation = 0; +#ifdef FIX_351_HRTF_COMMAND + hDecoderConfig->Opt_RendConfigCustom = 0; +#endif #ifndef REMOVE_FORCE_SUBFRAME_BIN #ifdef DEBUGGING hDecoderConfig->forceSubframeBinauralization = 0; @@ -392,6 +395,10 @@ ivas_error IVAS_DEC_Configure( const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation /* i : enable head rotation for binaural output */ +#ifdef FIX_351_HRTF_COMMAND + , + const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ +#endif #ifndef REMOVE_FORCE_SUBFRAME_BIN #ifdef DEBUGGING , @@ -451,6 +458,9 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->Opt_LsCustom = customLsOutputEnabled; hDecoderConfig->Opt_Headrotation = enableHeadRotation; hDecoderConfig->Opt_HRTF_binary = hrtfReaderEnabled; +#ifdef FIX_351_HRTF_COMMAND + hDecoderConfig->Opt_RendConfigCustom = renderConfigEnabled; +#endif /* Set decoder parameters to initial values */ if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) @@ -1923,6 +1933,18 @@ static ivas_error printConfigInfo_dec( get_channel_config( st_ivas->hDecoderConfig->output_config, &config_str[0] ); fprintf( stdout, "Output configuration: %s\n", config_str ); +#ifdef FIX_351_HRTF_COMMAND + if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) + { + fprintf( stdout, "HRIR/BRIR file: ON\n" ); + } + + if ( st_ivas->hDecoderConfig->Opt_RendConfigCustom ) + { + fprintf( stdout, "Renderer config. file: ON\n" ); + } +#endif + if ( st_ivas->hDecoderConfig->Opt_Headrotation ) { fprintf( stdout, "Head rotation: ON\n" ); diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index d107995ffeb3535cd78e76a540e421c39b7e938b..10a9fdc49f81780f19d530ea93c4eaccc1f15636 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -130,6 +130,10 @@ ivas_error IVAS_DEC_Configure( const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation /* i : enable head rotation for binaural output */ +#ifdef FIX_351_HRTF_COMMAND + ,const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ +#endif + #ifndef REMOVE_FORCE_SUBFRAME_BIN #ifdef DEBUGGING ,