From 30c2cec00714246e7677457ba45ca8c844726f8e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 29 Aug 2023 13:45:55 +0200 Subject: [PATCH 1/6] issue 708: improve AEID command-line robustness; under FIX_708_AEID_COMMAND_LINE --- apps/decoder.c | 26 +++++++++++++++++++++++++- apps/renderer.c | 5 +++++ lib_com/ivas_error.h | 7 +++++++ lib_com/options.h | 2 ++ lib_dec/ivas_init_dec.c | 10 ++++++++++ lib_dec/ivas_stat_dec.h | 3 +++ lib_dec/lib_dec.c | 15 ++++++++++++++- lib_dec/lib_dec.h | 3 +++ 8 files changed, 69 insertions(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index a63d8e9f4b..0e31105608 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -511,7 +511,11 @@ int main( #ifdef API_5MS_BASELINE arg.tsmEnabled, arg.enable5ms, #endif - arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) + arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, +#ifdef FIX_708_AEID_COMMAND_LINE + arg.acousticEnvironmentId, +#endif + arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -1115,11 +1119,16 @@ static bool parseCmdlIVAS_dec( #endif #endif +#ifdef FIX_708_AEID_COMMAND_LINE + arg->acousticEnvironmentId = 65535; +#else arg->acousticEnvironmentId = 0; +#endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { arg->directivityPatternId[i] = 0; } + /*-----------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -1497,6 +1506,21 @@ static bool parseCmdlIVAS_dec( else if ( strcmp( argv_to_upper, "-AEID" ) == 0 ) { ++i; +#ifdef FIX_708_AEID_COMMAND_LINE + if ( argc - i <= 4 ) + { + fprintf( stderr, "Error: Acoustic environment ID not specified!\n\n" ); + usage_dec(); + return false; + } + + if ( !is_digits_only( argv[i] ) ) + { + fprintf( stdout, "Error: Invalid acoustic environment ID specified: %s\n\n", argv[i] ); + usage_dec(); + return false; + } +#endif arg->acousticEnvironmentId = (int16_t) atoi( argv[i++] ); } else if ( strcmp( argv_to_upper, "-DPID" ) == 0 ) diff --git a/apps/renderer.c b/apps/renderer.c index 858a9d4150..7826e9f6d3 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -2692,7 +2692,12 @@ static CmdlnArgs defaultArgs( args.directivityPatternId[i] = 0; } +#ifdef FIX_708_AEID_COMMAND_LINE + args.acousticEnvironmentId = 65535; +#else args.acousticEnvironmentId = 0; +#endif + return args; } diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 813b1d570f..ec55cd7fae 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -76,6 +76,9 @@ typedef enum IVAS_ERR_INVALID_OUTPUT_FORMAT, IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED, IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED, +#ifdef FIX_708_AEID_COMMAND_LINE + IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, +#endif IVAS_ERR_INVALID_HRTF, IVAS_ERR_INVALID_INPUT_FORMAT, IVAS_ERR_INVALID_INDEX, /* ToDo: should be merged with IVAS_ERR_INDEX_OUT_OF_BOUNDS */ @@ -253,6 +256,10 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) #endif case IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED: return "External orientation not supported"; +#ifdef FIX_708_AEID_COMMAND_LINE + case IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED: + return "Acoustic environment not supported"; +#endif case IVAS_ERR_INVALID_HRTF: return "Unsupported HRTF filter set"; case IVAS_ERR_INVALID_INPUT_FORMAT: diff --git a/lib_com/options.h b/lib_com/options.h index be3261f808..650079b5eb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,6 +168,8 @@ #define FIX_718_JBM_MD_UDPATE /* Fhg: fix issue #718, wrong setting of the update flag in the TD obj renderer in the JBM path */ #define FIX_719_CRASH_IN_CLEANUP /* VA: issue 719: fix Decoder crash after call to goto to cleanup */ +#define FIX_708_AEID_COMMAND_LINE /* issue 708: improve AEID command-line robustness */ + /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 7c5642a5e9..2b811c1152 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -3109,6 +3109,16 @@ static ivas_error doSanityChecks_IVAS( } } +#ifdef FIX_708_AEID_COMMAND_LINE + if ( st_ivas->hDecoderConfig->Opt_aeid_on ) + { + if ( output_config != AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + return IVAS_ERROR( IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, "Wrong set-up: Acoustic environment is not supported in this output configuration." ); + } + } +#endif + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && output_config == AUDIO_CONFIG_EXTERNAL ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 5b799c29e1..e28893dae0 100755 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -903,6 +903,9 @@ typedef struct decoder_config_structure float non_diegetic_pan_gain; /* non diegetic panning gain*/ int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ +#ifdef FIX_708_AEID_COMMAND_LINE + int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ +#endif /* temp. development parameters */ #ifdef DEBUGGING diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b0d224b9c4..c12268dfd8 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -412,7 +412,10 @@ ivas_error IVAS_DEC_Configure( const int16_t renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ const int16_t Opt_non_diegetic_pan, /* i : diegetic or not */ const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ - const int16_t delayCompensationEnabled /* i : enable delay compensation */ +#ifdef FIX_708_AEID_COMMAND_LINE + const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ +#endif + const int16_t delayCompensationEnabled /* i : enable delay compensation */ ) { Decoder_Struct *st_ivas; @@ -468,6 +471,9 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->non_diegetic_pan_gain = non_diegetic_pan_gain; hDecoderConfig->Opt_delay_comp = delayCompensationEnabled; hDecoderConfig->Opt_ExternalOrientation = enableExternalOrientation; +#ifdef FIX_708_AEID_COMMAND_LINE + hDecoderConfig->Opt_aeid_on = acousticEnvironmentId != 65535 ? TRUE : FALSE; +#endif /* Set decoder parameters to initial values */ if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) @@ -3586,6 +3592,13 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "Non-diegetic panning: %.2f\n", st_ivas->hDecoderConfig->non_diegetic_pan_gain * 90.f ); } + +#ifdef FIX_708_AEID_COMMAND_LINE + if ( st_ivas->hDecoderConfig->Opt_aeid_on ) + { + fprintf( stdout, "Acoustic environment ID:ON\n" ); + } +#endif } #ifdef API_5MS diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index fa76331d7d..70c9b6d6f2 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -145,6 +145,9 @@ ivas_error IVAS_DEC_Configure( const int16_t renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ const int16_t Opt_non_diegetic_pan, /* i : diegetic or not */ const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ +#ifdef FIX_708_AEID_COMMAND_LINE + const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ +#endif const int16_t delayCompensationEnabled /* i : enable delay compensation */ ); -- GitLab From 940810dd99d452587f905f3d7a04ecc6d44e4839 Mon Sep 17 00:00:00 2001 From: Charles Kinuthia Date: Tue, 29 Aug 2023 15:02:29 +0200 Subject: [PATCH 2/6] handle case when -aeid is not specified - case when -aeid is not specified, select first ID from config file --- lib_util/render_config_reader.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index bdbfe3ec2b..4837f8af1b 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2773,6 +2773,14 @@ ivas_error RenderConfigReader_getAcousticEnvironment( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef FIX_708_AEID_COMMAND_LINE + /* case when -aeid is not specified, select first ID from config file */ + if ( id == 65535 && pRenderConfigReader->nAE > 0 ) + { + id = (uint16_t) pRenderConfigReader->pAE[0].id; + } +#endif + for ( n = 0; n < pRenderConfigReader->nAE; n++ ) { if ( id == pRenderConfigReader->pAE[n].id ) -- GitLab From 669754c0039436a7df98df7fb244a6ad09fe7726 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 29 Aug 2023 15:05:06 +0200 Subject: [PATCH 3/6] fix under FIX_708_AEID_COMMAND_LINE --- apps/decoder.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 0e31105608..b1ba2ce738 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1440,6 +1440,13 @@ static bool parseCmdlIVAS_dec( return false; } i += 2; + +#ifdef FIX_708_AEID_COMMAND_LINE + if ( arg->acousticEnvironmentId == 65535 ) + { + arg->acousticEnvironmentId = 0; + } +#endif } #ifdef SPLIT_REND_WITH_HEAD_ROT else if ( strcmp( argv_to_upper, "-OM" ) == 0 ) -- GitLab From 2f74fb00a3c17159c27b94a7b3b46452ff5840dd Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 31 Aug 2023 21:53:04 +0200 Subject: [PATCH 4/6] clang-format --- apps/decoder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index ecb48ca61b..0076492166 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2215,7 +2215,7 @@ static ivas_error decodeG192( goto cleanup; } } - } + } if ( arg.enableExternalOrientation ) { @@ -2243,7 +2243,7 @@ static ivas_error decodeG192( goto cleanup; } } - } + } /* decode and get samples */ nSamplesRendered = 0; -- GitLab From 4f40d80be724d2e19f5f2acb4e8e3492ab4ed0bc Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 1 Sep 2023 08:22:24 +0200 Subject: [PATCH 5/6] revert wrong commit --- apps/decoder.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0076492166..d7199c6b63 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1376,13 +1376,6 @@ static bool parseCmdlIVAS_dec( return false; } i += 2; - -#ifdef FIX_708_AEID_COMMAND_LINE - if ( arg->acousticEnvironmentId == 65535 ) - { - arg->acousticEnvironmentId = 0; - } -#endif } #ifdef SPLIT_REND_WITH_HEAD_ROT else if ( strcmp( argv_to_upper, "-OM" ) == 0 ) -- GitLab From 2f21403e4cb66061a41f1f388b2e6ef7a1fa5772 Mon Sep 17 00:00:00 2001 From: Jan Brouwer Date: Mon, 4 Sep 2023 16:52:29 +0200 Subject: [PATCH 6/6] add robustness check for renderer -aeid parsing; report error when specified acoustic environment ID is not found in the renderer configuration --- apps/decoder.c | 4 ++++ apps/renderer.c | 7 +++++++ lib_dec/lib_dec.c | 3 +++ 3 files changed, 14 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index d7199c6b63..7015e3de1c 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -692,7 +692,11 @@ int main( goto cleanup; } } +#ifdef FIX_708_AEID_COMMAND_LINE + else +#else else if ( error != IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING ) +#endif { fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", arg.acousticEnvironmentId ); goto cleanup; diff --git a/apps/renderer.c b/apps/renderer.c index 1656efdd78..bdd63ea8ee 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -2745,6 +2745,13 @@ static void parseOption( break; case CmdLnOptionId_acousticEnvironmentId: assert( numOptionValues == 1 ); +#ifdef FIX_708_AEID_COMMAND_LINE + if ( !is_digits_only( optionValues[0] ) ) + { + fprintf( stderr, "Invalid acousting environment ID specified: %s\n", optionValues[0] ); + exit( -1 ); + } +#endif args->acousticEnvironmentId = (int16_t) strtol( optionValues[0], NULL, 10 ); break; case CmdLnOptionId_syncMdDelay: diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 1cea9615e8..5d4d7ccc05 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -275,6 +275,9 @@ static void init_decoder_config( hDecoderConfig->Opt_delay_comp = 0; hDecoderConfig->Opt_ExternalOrientation = 0; +#ifdef FIX_708_AEID_COMMAND_LINE + hDecoderConfig->Opt_aeid_on = 0; +#endif return; } -- GitLab