diff --git a/apps/decoder.c b/apps/decoder.c index 33dc818f789a69565d1dfe7f9371008c526c70b6..be2cb2a6ccb0ad3ccbf48d5ef14fb2c2f9a0d6f1 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -146,6 +146,9 @@ typedef struct #endif #endif uint16_t acousticEnvironmentId; +#ifdef FIX_708_DPID_COMMAND_LINE + int16_t Opt_dpid_on; +#endif uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; } DecArguments; @@ -473,9 +476,6 @@ int main( * Configure the decoder *------------------------------------------------------------------------------------------*/ -/*------------------------------------------------------------------------------------------* - * Configure the decoder - *------------------------------------------------------------------------------------------*/ #ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { @@ -496,7 +496,11 @@ int main( 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, 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_DPID_COMMAND_LINE + arg.Opt_dpid_on, +#endif + arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -674,7 +678,11 @@ int main( if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, arg.directivityPatternId, renderConfig.directivity ) ) != IVAS_ERR_OK ) { +#ifdef FIX_730_DPID_NOT_SET_CORRECTLY + fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] ); +#else fprintf( stderr, "Failed to get directivity for objects: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] ); +#endif goto cleanup; } @@ -1035,6 +1043,9 @@ static bool parseCmdlIVAS_dec( arg->renderConfigEnabled = false; arg->renderConfigFilename = NULL; +#ifdef FIX_708_DPID_COMMAND_LINE + arg->Opt_dpid_on = 0; +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT arg->outputMdFilename = NULL; @@ -1062,7 +1073,11 @@ static bool parseCmdlIVAS_dec( arg->acousticEnvironmentId = 0; for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { +#ifdef FIX_730_DPID_NOT_SET_CORRECTLY + arg->directivityPatternId[i] = 65535; +#else arg->directivityPatternId[i] = 0; +#endif } /*-----------------------------------------------------------------* * Initialization @@ -1437,14 +1452,52 @@ static bool parseCmdlIVAS_dec( } else if ( strcmp( argv_to_upper, "-DPID" ) == 0 ) { +#ifdef FIX_708_DPID_COMMAND_LINE + int16_t id; + + arg->Opt_dpid_on = 1; +#endif ++i; int16_t tmp; tmp = 0; while ( is_number( argv[i + tmp] ) && tmp < IVAS_MAX_NUM_OBJECTS ) { +#ifdef FIX_708_DPID_COMMAND_LINE + id = (int16_t) atoi( argv[i + tmp] ); + + if ( !is_digits_only( argv[i + tmp] ) || id < 0 ) + { + fprintf( stdout, "Error: Invalid directivity pattern ID specified: %s\n\n", argv[i + tmp] ); + usage_dec(); + return false; + } + + arg->directivityPatternId[tmp] = id; +#else arg->directivityPatternId[tmp] = (int16_t) atoi( argv[i + tmp] ); +#endif ++tmp; } + +#ifdef FIX_708_DPID_COMMAND_LINE + if ( tmp == 0 ) + { + if ( argc - i <= 4 || argv[i][0] == '-' ) + { + fprintf( stderr, "Error: Directivity pattern ID not specified!\n\n" ); + usage_dec(); + return false; + } + + if ( !is_digits_only( argv[i + tmp] ) ) + { + fprintf( stdout, "Error: Invalid directivity pattern ID specified: %s\n\n", argv[i + tmp] ); + usage_dec(); + return false; + } + } +#endif + i += tmp; } @@ -1633,7 +1686,15 @@ static void usage_dec( void ) fprintf( stdout, "-force R : Force specific binaural rendering mode, R = (TDREND, CLDFBREND),\n" ); #endif fprintf( stdout, "-exof File : External orientation File for external orientation trajectory\n" ); +#ifdef FIX_708_DPID_COMMAND_LINE + fprintf( stdout, "-dpid ID : Directivity pattern ID(s) = [ID1, ID2, ID3, ID4]. Space-separated list of up\n" ); + fprintf( stdout, " to 4 numbers (unsigned integers) can be specified for BINAURAL output configuration.\n" ); + fprintf( stdout, " ID1, ID2, ID3, ID4 specify the directivity pattern IDs used for ISMs 1,2,3 and 4 respectively.\n" ); + fprintf( stdout, " This options needs to be accompanied by a render_config file, otherwise a default\n" ); + fprintf( stdout, " directivity pattern is used.\n" ); +#else fprintf( stdout, "-dpid ID : Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration\n" ); +#endif fprintf( stdout, "-aeid ID : Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output configuration\n" ); fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); diff --git a/apps/renderer.c b/apps/renderer.c index b23908574e058677de556cd73673535bc521b229..51ebc4bd800249dee420d4347cebb7a30c3d6a18 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -383,7 +383,11 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_directivityPatternId, .match = "ism_directivity_pattern_id", .matchShort = "dpid", +#ifdef FIX_708_DPID_COMMAND_LINE + .description = "Directivity pattern ID(s) = [ID1, ID2, ID3, ID4]. Space-separated list of up to 4 numbers (unsigned integers) can be specified for BINAURAL output configuration.\nID1, ID2, ID3, ID4 specify the directivity pattern IDs used for ISMs 1,2,3 and 4 respectively.\nThis options needs to be accompanied by a render_config file, otherwise a default directivity pattern is used.", +#else .description = "Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration", +#endif }, { .id = CmdLnOptionId_acousticEnvironmentId, @@ -2570,7 +2574,11 @@ static CmdlnArgs defaultArgs( for ( int32_t i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { +#ifdef FIX_730_DPID_NOT_SET_CORRECTLY + args.directivityPatternId[i] = 65535; +#else args.directivityPatternId[i] = 0; +#endif } args.acousticEnvironmentId = 0; diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 92339c1f819cb36fb8ccc2d78026979b156e62b6..c0ca7d8d3e186d663b70415b8021bc31c9db9b65 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_DPID_COMMAND_LINE + IVAS_ERR_DIRECTIVITY_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 */ @@ -251,6 +254,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_DPID_COMMAND_LINE + case IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED: + return "Directivity 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 e0ec02f4d9390508fd78b48a6fb9c01691c2f76c..dadd57e9bd4738000b3e12f1a2be3f8cb9012880 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,6 +158,9 @@ #define OSBA_SPLIT_RENDERING #endif +#define FIX_708_DPID_COMMAND_LINE /* issue 708: sanity checks for '-dpid' command-line */ +#define FIX_730_DPID_NOT_SET_CORRECTLY /* Eri: issue 730: write dpid read from file in correct index, print informative error message when DPID specified is not found. */ + #define FIX_RAM_COUNTING_5MS_RENDERING /* FhG: fix for correct RAM reporting with 5ms rendering */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index c3231411804ea6bc6fc15cb23a976a6b8a1affb6..3a4d4f8130122cd13538b6d38876f26be2acd937 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -3041,6 +3041,16 @@ static ivas_error doSanityChecks_IVAS( } } +#ifdef FIX_708_DPID_COMMAND_LINE + if ( st_ivas->hDecoderConfig->Opt_dpid_on ) + { + if ( !( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + return IVAS_ERROR( IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, "Wrong set-up: Directivity 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 e70403488dbadbbaf7c870767aede53192c93395..9cc26a06ce585d27a2252a731c5f35afcfd2a03b 100644 --- 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_DPID_COMMAND_LINE + int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ +#endif /* temp. development parameters */ #ifdef DEBUGGING diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index dfbd0d79985f6bc13c0d523563b3bc981195e218..7f66ca106a95c3357c2c98237a9c990bd0d24d60 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_DPID_COMMAND_LINE + hDecoderConfig->Opt_dpid_on = 0; +#endif return; } @@ -378,7 +381,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_DPID_COMMAND_LINE + const int16_t Opt_dpid_on, /* i : enable directivity pattern option */ +#endif + const int16_t delayCompensationEnabled /* i : enable delay compensation */ ) { Decoder_Struct *st_ivas; @@ -434,6 +440,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_DPID_COMMAND_LINE + hDecoderConfig->Opt_dpid_on = Opt_dpid_on; +#endif /* Set decoder parameters to initial values */ if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) @@ -2864,6 +2873,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_DPID_COMMAND_LINE + if ( st_ivas->hDecoderConfig->Opt_dpid_on ) + { + fprintf( stdout, "Directivity pattern: ON\n" ); + } +#endif } /*-----------------------------------------------------------------* diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 3ab0a7767020a7445a79edea6487ed279f411197..80f2f46aa3eebabf0d215cc54842b75503ae87ea 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -134,6 +134,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_DPID_COMMAND_LINE + const int16_t Opt_dpid_on, /* i : enable directivity pattern option */ +#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 3293e4d4a523ac0501da73849a1e915fcbb8be9c..35f6fafb864bd73e845cf60729afce6de5dcca89 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2616,7 +2616,9 @@ ivas_error RenderConfigReader_read( return IVAS_ERR_INVALID_RENDER_CONFIG; } idx = strtol( strtok( NULL, ":" ), NULL, 0 ); +#ifndef FIX_730_DPID_NOT_SET_CORRECTLY pRenderConfigReader->pDP->id = idx; +#endif params_idx = 0; pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); @@ -2624,13 +2626,20 @@ ivas_error RenderConfigReader_read( { params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); #ifdef DEBUGGING +#ifdef FIX_730_DPID_NOT_SET_CORRECTLY + fprintf( stderr, " PARAM: %s -> %s, DIRECTIVITYPATTERN -> %u\n", item, pValue, idx ); +#else fprintf( stderr, " PARAM: %s -> %s\n", item, pValue ); +#endif #endif /* Allocate memory for directivity arrays*/ if ( ( pRenderConfigReader->pDP[accDPIdx].pDirectivity = (float *) malloc( 3 * sizeof( float ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } +#ifdef FIX_730_DPID_NOT_SET_CORRECTLY + pRenderConfigReader->pDP[accDPIdx].id = idx; +#endif if ( strcmp( item, "DIRECTIVITY" ) == 0 ) { if ( read_txt_vector( pValue, 3, pRenderConfigReader->pDP[accDPIdx].pDirectivity ) ) @@ -2825,6 +2834,9 @@ ivas_error RenderConfigReader_getDirectivity( ) { uint16_t n, m; +#ifdef FIX_730_DPID_NOT_SET_CORRECTLY + uint16_t last_specified_id; +#endif bool idExists; @@ -2843,6 +2855,29 @@ ivas_error RenderConfigReader_getDirectivity( } else { +#ifdef FIX_730_DPID_NOT_SET_CORRECTLY + last_specified_id = id[0]; + + /* set unpspecified Directivity Patterns ID to last specified ID */ + for ( n = MAX_NUM_OBJECTS - 1; n > 0; n-- ) + { + if ( id[n] != 65535 ) + { + last_specified_id = id[n]; + break; + } + } + /* case when -dpid is not specified, select first directivity pattern from config file */ + if ( n == 0 ) + { + last_specified_id = (uint16_t) pRenderConfigReader->pDP[0].id; + } + + for ( ; n < MAX_NUM_OBJECTS; n++ ) + { + id[n] = last_specified_id; + } +#endif for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { idExists = false; @@ -2851,7 +2886,11 @@ ivas_error RenderConfigReader_getDirectivity( if ( id[n] == pRenderConfigReader->pDP[m].id ) { idExists = true; +#ifdef FIX_730_DPID_NOT_SET_CORRECTLY + mvr2r( pRenderConfigReader->pDP[m].pDirectivity, directivity + ( n * 3 ), 3 ); +#else mvr2r( pRenderConfigReader->pDP[id[n]].pDirectivity, directivity + ( n * 3 ), 3 ); +#endif break; } } diff --git a/scripts/testv/config_directivity_txt.cfg b/scripts/testv/config_directivity_txt.cfg index ae91929310a0712eb46514c13739c94acda580c8..f040d5708d84efae6b6a58f36094baf050c56b36 100644 --- a/scripts/testv/config_directivity_txt.cfg +++ b/scripts/testv/config_directivity_txt.cfg @@ -1,5 +1,17 @@ [directivitySetting] -directivityCount = 1; +directivityCount = 5; [directivityPattern:0] directivity = [0.0, 360.0, 0.2512] + +[directivityPattern:1] +directivity = [0.01, 180.0, 0.2512] + +[directivityPattern:2] +directivity = [0.02, 180.0, 0.2512] + +[directivityPattern:3] +directivity = [0.0, 90.0, 0.2512] + +[directivityPattern:4] +directivity = [0.0, 350.0, 0.2512]