From 6e9a2b1ac7344c588a7f41b5bdd0572e36108afb Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 22 Feb 2023 17:46:59 +0100 Subject: [PATCH 1/5] Issue 354 - improve "-hrtf" command-line option; under FIX_351_HRTF_COMMAND --- apps/decoder.c | 49 +++++++++++++++++++++++++++++++++++++++++ lib_com/options.h | 3 +++ lib_dec/ivas_stat_dec.h | 5 ++++- lib_dec/lib_dec.c | 22 ++++++++++++++++++ lib_dec/lib_dec.h | 4 ++++ 5 files changed, 82 insertions(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index bbbee76c88..3250d877cf 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -221,8 +221,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; } @@ -234,6 +247,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 ); @@ -247,6 +269,15 @@ int main( if ( arg.customLsOutputEnabled ) { +#ifdef FIX_351_HRTF_COMMAND + /* sanity check */ + if ( arg.outputFormat != IVAS_DEC_OUTPUT_LS_CUSTOM ) + { + fprintf( stderr, "\nError: Custom loudspeaker setup cannot be used in this output configuration.\n\n" ); + goto cleanup; + } +#endif + if ( ( error = CustomLsReader_open( arg.customLsSetupFilename, &hLsCustomReader ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: Can't open Custom loudspeaker setup file %s \n\n", arg.customLsSetupFilename ); @@ -260,6 +291,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 ); @@ -272,9 +312,17 @@ int main( *------------------------------------------------------------------------------------------*/ #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 { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -530,6 +578,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 9a6a9d4c5b..3cdc0eba4b 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,6 +158,9 @@ #define SMOOTH_WITH_TRANS_DET #endif +#define FIX_351_HRTF_COMMAND /* VA: Issue 354 - improve "-hrtf" command-line option */ + + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 7c6ac19f7e..b293b907a8 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 a1fee7f0fd..0fc0741980 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 #ifdef DEBUGGING hDecoderConfig->forceSubframeBinauralization = 0; #endif @@ -390,6 +393,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 #ifdef DEBUGGING , const int16_t forceSubframeBinauralization /* i : enable subframe binauralization */ @@ -445,6 +452,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 ) @@ -1911,6 +1921,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 d3035af0b5..eb79d2f007 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -132,6 +132,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 + #ifdef DEBUGGING , const int16_t forceSubframeBinauralization /* i : enable subframe binauralization */ -- GitLab From 27e685ce38c28d44c67e1d173ee1d0cf2f3ac1c8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 22 Feb 2023 17:58:27 +0100 Subject: [PATCH 2/5] remove FIX_FOR_TEST leftover --- apps/decoder.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 3250d877cf..7a72229b7a 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -499,9 +499,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 ); -- GitLab From 5cef09f104066be60e9a5d35f291a06fe9491902 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 Feb 2023 16:51:11 +0100 Subject: [PATCH 3/5] remove unreasonable sanity check --- apps/decoder.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 328126e38a..08d6938dc9 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -271,15 +271,6 @@ int main( if ( arg.customLsOutputEnabled ) { -#ifdef FIX_351_HRTF_COMMAND - /* sanity check */ - if ( arg.outputFormat != IVAS_DEC_OUTPUT_LS_CUSTOM ) - { - fprintf( stderr, "\nError: Custom loudspeaker setup cannot be used in this output configuration.\n\n" ); - goto cleanup; - } -#endif - if ( ( error = CustomLsReader_open( arg.customLsSetupFilename, &hLsCustomReader ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: Can't open Custom loudspeaker setup file %s \n\n", arg.customLsSetupFilename ); -- GitLab From e9c84dba54e0a28b64df684dd3429bb42a446bb1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 Feb 2023 17:01:28 +0100 Subject: [PATCH 4/5] temp. disable --- apps/decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 08d6938dc9..1efb1a9172 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -223,7 +223,7 @@ int main( if ( arg.hrtfReaderEnabled ) { -#ifdef FIX_351_HRTF_COMMAND +#ifdef FIX_351_HRTF_COMMANDaa /* sanity check */ if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) { -- GitLab From b32e10073159d7bc3f56592dc841507454ea9d12 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 Feb 2023 17:12:47 +0100 Subject: [PATCH 5/5] revert temp. disable --- apps/decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 1e7c48f2a7..0e246ca1ec 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -222,7 +222,7 @@ int main( if ( arg.hrtfReaderEnabled ) { -#ifdef FIX_351_HRTF_COMMANDaa +#ifdef FIX_351_HRTF_COMMAND /* sanity check */ if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) { -- GitLab