diff --git a/apps/decoder.c b/apps/decoder.c index be2cb2a6ccb0ad3ccbf48d5ef14fb2c2f9a0d6f1..06c1072110b9495690031acc9d207ffc56d901b6 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -494,11 +494,13 @@ int main( } #endif - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, - arg.tsmEnabled, arg.enable5ms, + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.enable5ms, 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_DPID_COMMAND_LINE arg.Opt_dpid_on, +#endif +#ifdef FIX_708_AEID_COMMAND_LINE + arg.acousticEnvironmentId, #endif arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { @@ -696,7 +698,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; @@ -1069,8 +1075,11 @@ static bool parseCmdlIVAS_dec( arg->noBadFrameDelay = false; #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 ) { #ifdef FIX_730_DPID_NOT_SET_CORRECTLY @@ -1079,6 +1088,7 @@ static bool parseCmdlIVAS_dec( arg->directivityPatternId[i] = 0; #endif } + /*-----------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -1448,6 +1458,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 51ebc4bd800249dee420d4347cebb7a30c3d6a18..3b2c38c690c496386c9b8b2c8d451ef97c2207db 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -2581,7 +2581,12 @@ static CmdlnArgs defaultArgs( #endif } +#ifdef FIX_708_AEID_COMMAND_LINE + args.acousticEnvironmentId = 65535; +#else args.acousticEnvironmentId = 0; +#endif + return args; } @@ -2748,6 +2753,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_com/ivas_error.h b/lib_com/ivas_error.h index c0ca7d8d3e186d663b70415b8021bc31c9db9b65..2ebaf6d30b3b312ccee1e435418b7aaa5d072c63 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -78,6 +78,9 @@ typedef enum IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED, #ifdef FIX_708_DPID_COMMAND_LINE IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, +#endif +#ifdef FIX_708_AEID_COMMAND_LINE + IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, #endif IVAS_ERR_INVALID_HRTF, IVAS_ERR_INVALID_INPUT_FORMAT, @@ -257,6 +260,10 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) #ifdef FIX_708_DPID_COMMAND_LINE case IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED: return "Directivity not supported"; +#endif +#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"; diff --git a/lib_com/options.h b/lib_com/options.h index 2365f6bc8b91b63680caeec5cb334b3d49324dd6..91427ad04be26e89a39ad578d342dcd6f16fab9f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,6 +168,8 @@ #define FIX_786_ERROR_ISM_METADATA_READ /* VA: fix error reading past the last line of .csv metadata files */ #define FIX_632_USAN_ERROR_NULL_POINTER /* FhG: issue 632 USAN offset to null pointer proto_diffuse_buffer_f in dirac rendering*/ #define FIX_759_CODE_COVERAGE_OSBA /* VA: issue 759: remove obsolete code in the OSBA encoder */ +#define FIX_708_AEID_COMMAND_LINE /* VA: issue 708: improve AEID command-line robustness */ + /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index bc78ddf7234444f59faf225d7d102585442ee32f..72a02f3fba0a660325629d37e163344318e66310 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -3054,6 +3054,16 @@ static ivas_error doSanityChecks_IVAS( } #endif +#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 5f946d48ada02810e6abb68eea36b4e3da7f31b3..4385597ef6526d0a51a3928911aaa1147c492463 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -908,6 +908,9 @@ typedef struct decoder_config_structure #ifdef FIX_708_DPID_COMMAND_LINE int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ #endif +#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 7f66ca106a95c3357c2c98237a9c990bd0d24d60..7162eb004e6ff81fed3eb076648709596c98b261 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -271,13 +271,14 @@ static void init_decoder_config( hDecoderConfig->Opt_Limiter = 1; #endif hDecoderConfig->Opt_5ms = 0; - hDecoderConfig->Opt_delay_comp = 0; - hDecoderConfig->Opt_ExternalOrientation = 0; #ifdef FIX_708_DPID_COMMAND_LINE hDecoderConfig->Opt_dpid_on = 0; #endif +#ifdef FIX_708_AEID_COMMAND_LINE + hDecoderConfig->Opt_aeid_on = 0; +#endif return; } @@ -383,6 +384,9 @@ ivas_error IVAS_DEC_Configure( const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ #ifdef FIX_708_DPID_COMMAND_LINE const int16_t Opt_dpid_on, /* i : enable directivity pattern option */ +#endif +#ifdef FIX_708_AEID_COMMAND_LINE + const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ #endif const int16_t delayCompensationEnabled /* i : enable delay compensation */ ) @@ -443,6 +447,9 @@ ivas_error IVAS_DEC_Configure( #ifdef FIX_708_DPID_COMMAND_LINE hDecoderConfig->Opt_dpid_on = Opt_dpid_on; #endif +#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 ) @@ -2880,6 +2887,13 @@ static ivas_error printConfigInfo_dec( fprintf( stdout, "Directivity pattern: ON\n" ); } #endif + +#ifdef FIX_708_AEID_COMMAND_LINE + if ( st_ivas->hDecoderConfig->Opt_aeid_on ) + { + fprintf( stdout, "Acoustic environment ID:ON\n" ); + } +#endif } /*-----------------------------------------------------------------* diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 80f2f46aa3eebabf0d215cc54842b75503ae87ea..8b9c41c018e24b190999a1ff9876edd07aab8b32 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -136,6 +136,9 @@ ivas_error IVAS_DEC_Configure( const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ #ifdef FIX_708_DPID_COMMAND_LINE const int16_t Opt_dpid_on, /* i : enable directivity pattern option */ +#endif +#ifdef FIX_708_AEID_COMMAND_LINE + const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ #endif const int16_t delayCompensationEnabled /* i : enable delay compensation */ ); diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 35f6fafb864bd73e845cf60729afce6de5dcca89..2571ea9784bb34c73e90ee24d0abf318f642229f 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2778,6 +2778,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 )