Loading apps/isar_post_rend.c +83 −40 Original line number Original line Diff line number Diff line Loading @@ -159,7 +159,7 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_inputMetadata, .id = CmdLnOptionId_inputMetadata, .match = "input_metadata", .match = "input_metadata", .matchShort = "im", .matchShort = "im", .description = "Space-separated list of path to metadata files for BINAURAL_SPLIT_PCM input mode", .description = "Space-separated list of paths to metadata files for BINAURAL_SPLIT_PCM input mode", }, }, { { .id = CmdLnOptionId_outputFile, .id = CmdLnOptionId_outputFile, Loading @@ -183,13 +183,13 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_SplitRendBFIFile, .id = CmdLnOptionId_SplitRendBFIFile, .match = "post_rend_bfi_file", .match = "post_rend_bfi_file", .matchShort = "prbfi", .matchShort = "prbfi", .description = "Split rendering option: bfi file", .description = "Split rendering BFI (Bad Frame Indicator) file", }, }, { { .id = CmdLnOptionId_noDelayCmp, .id = CmdLnOptionId_noDelayCmp, .match = "no_delay_compensation", .match = "no_delay_compensation", .matchShort = "no_delay_cmp", .matchShort = "no_delay_cmp", .description = "[flag] Turn off delay compensation", .description = "Turn off delay compensation", }, }, { { .id = CmdLnOptionId_complexityLevel, .id = CmdLnOptionId_complexityLevel, Loading @@ -201,7 +201,7 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_quietModeEnabled, .id = CmdLnOptionId_quietModeEnabled, .match = "quiet", .match = "quiet", .matchShort = "q", .matchShort = "q", .description = "[flag] Limit printouts to terminal", .description = "Quiet mode - limit printouts to terminal", }, }, { { .id = CmdLnOptionId_listFormats, .id = CmdLnOptionId_listFormats, Loading @@ -213,7 +213,7 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_framing, .id = CmdLnOptionId_framing, .match = "framing", .match = "framing", .matchShort = "fr", .matchShort = "fr", .description = "Set Render audio framing.", .description = "Set audio rendering frame size", }, }, #ifdef RTP_S4_251135_CR26253_0016_REV1 #ifdef RTP_S4_251135_CR26253_0016_REV1 { { Loading Loading @@ -349,7 +349,7 @@ static bool parseInConfig( /* Default case covers formats that are defined in the AUDIO_CONFIG enum, /* Default case covers formats that are defined in the AUDIO_CONFIG enum, * but cannot be used at input, e.g. BINAURAL */ * but cannot be used at input, e.g. BINAURAL */ const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_listFormats ); const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_listFormats ); fprintf( stderr, "Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match ); fprintf( stderr, "Error: Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match ); return false; return false; } } } } Loading Loading @@ -440,7 +440,7 @@ static bool checkRequiredArgs( if ( isEmptyString( args.inputFilePath ) ) if ( isEmptyString( args.inputFilePath ) ) { { tmpOption = findOptionById( CmdLnOptionId_inputFile ); tmpOption = findOptionById( CmdLnOptionId_inputFile ); fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); fprintf( stderr, "Missing mandatory parameter: --%s/-%s\n", tmpOption->match, tmpOption->matchShort ); missingRequiredArg = true; missingRequiredArg = true; } } Loading @@ -450,19 +450,13 @@ static bool checkRequiredArgs( { { /* Neither scene description input nor single-type input was specified on command line */ /* Neither scene description input nor single-type input was specified on command line */ tmpOption = findOptionById( CmdLnOptionId_inputFormat ); tmpOption = findOptionById( CmdLnOptionId_inputFormat ); fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); fprintf( stderr, "Missing mandatory parameter: --%s/-%s\n", tmpOption->match, tmpOption->matchShort ); missingRequiredArg = true; missingRequiredArg = true; } } if ( isEmptyString( args.outputFilePath ) ) if ( isEmptyString( args.outputFilePath ) ) { { tmpOption = findOptionById( CmdLnOptionId_outputFile ); tmpOption = findOptionById( CmdLnOptionId_outputFile ); fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); fprintf( stderr, "Missing mandatory parameter: --%s/-%s\n", tmpOption->match, tmpOption->matchShort ); missingRequiredArg = true; } if ( args.sampleRate == 0 ) { tmpOption = findOptionById( CmdLnOptionId_sampleRate ); fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); missingRequiredArg = true; missingRequiredArg = true; } } if ( missingRequiredArg ) if ( missingRequiredArg ) Loading Loading @@ -508,7 +502,7 @@ static CmdlnArgs defaultArgs( } } static void parseOption( static int16_t parseOption( const int32_t optionId, const int32_t optionId, char **optionValues, char **optionValues, const int16_t numOptionValues, const int16_t numOptionValues, Loading @@ -519,22 +513,34 @@ static void parseOption( switch ( optionId ) switch ( optionId ) { { case CmdLnOptionId_listFormats: case CmdLnOptionId_listFormats: assert( numOptionValues == 0 ); printSupportedAudioConfigs(); printSupportedAudioConfigs(); exit( 0 ); exit( 0 ); case CmdLnOptionId_inputFile: case CmdLnOptionId_inputFile: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No input file has been provided!\n" ); return -1; } strncpy( args->inputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->inputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; break; case CmdLnOptionId_inputFormat: case CmdLnOptionId_inputFormat: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No input file format has been provided!\n" ); return -1; } if ( !parseInConfig( optionValues[0], &args->inConfig, &args->sceneDescriptionInput ) ) if ( !parseInConfig( optionValues[0], &args->inConfig, &args->sceneDescriptionInput ) ) { { exit( -1 ); /* Error printout handled by failing function */ /* Error printout handled by failing function */ return -1; } } break; break; case CmdLnOptionId_inputMetadata: case CmdLnOptionId_inputMetadata: assert( numOptionValues <= RENDERER_MAX_ISAR_MD_INPUTS ); if ( numOptionValues < 1 || numOptionValues > RENDERER_MAX_ISAR_MD_INPUTS ) { fprintf( stderr, "Error: No paths to metadata files for BINAURAL_SPLIT_PCM input mode has been provided!\n" ); return -1; } for ( int16_t i = 0; i < numOptionValues; ++i ) for ( int16_t i = 0; i < numOptionValues; ++i ) { { strncpy( args->inMetadataFilePaths[i], optionValues[i], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->inMetadataFilePaths[i], optionValues[i], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); Loading @@ -542,68 +548,105 @@ static void parseOption( args->numInMetadataFiles = numOptionValues; args->numInMetadataFiles = numOptionValues; break; break; case CmdLnOptionId_outputFile: case CmdLnOptionId_outputFile: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No output file has been provided!\n" ); return -1; } strncpy( args->outputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->outputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; break; case CmdLnOptionId_sampleRate: case CmdLnOptionId_sampleRate: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No input sampling rate has been provided!\n" ); return -1; } args->sampleRate = (int32_t) ( strtol( optionValues[0], NULL, 10 ) * 1000 ); args->sampleRate = (int32_t) ( strtol( optionValues[0], NULL, 10 ) * 1000 ); if ( args->sampleRate == 0 ) if ( args->sampleRate == 0 ) { { fprintf( stderr, "Invalid sampling rate specified\n" ); fprintf( stderr, "Error: Invalid sampling rate specified\n" ); exit( -1 ); return -1; } } break; break; case CmdLnOptionId_trajFile: case CmdLnOptionId_trajFile: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No head rotation trajectory file has been provided!\n" ); return -1; } strncpy( args->headRotationFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->headRotationFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; break; case CmdLnOptionId_SplitRendBFIFile: case CmdLnOptionId_SplitRendBFIFile: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No bfi file has been provided!\n" ); return -1; } strncpy( args->splitRendBFIFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->splitRendBFIFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; break; case CmdLnOptionId_complexityLevel: case CmdLnOptionId_complexityLevel: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No complexity level has been provided!\n" ); return -1; } args->complexityLevel = (int32_t) ( strtol( optionValues[0], NULL, 10 ) ); args->complexityLevel = (int32_t) ( strtol( optionValues[0], NULL, 10 ) ); if ( args->complexityLevel < ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel > ISAR_POST_REND_COMPLEXITY_LEVEL_THREE ) if ( args->complexityLevel < ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel > ISAR_POST_REND_COMPLEXITY_LEVEL_THREE ) { { fprintf( stdout, "Invalid complexity level specified.\n" ); fprintf( stderr, "Error: Invalid complexity level specified.\n" ); exit( -1 ); return -1; } } else if ( args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_TWO ) else if ( args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_TWO ) { { fprintf( stdout, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" ); fprintf( stderr, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" ); } } break; break; case CmdLnOptionId_noDelayCmp: case CmdLnOptionId_noDelayCmp: assert( numOptionValues == 0 ); if ( numOptionValues != 0 ) { fprintf( stderr, "Error: Incorrect specification of the `-%s/--%s` command-line option!\n", cliOptions[optionId].matchShort, cliOptions[optionId].match ); return -1; } args->delayCompensationEnabled = false; args->delayCompensationEnabled = false; break; break; case CmdLnOptionId_quietModeEnabled: case CmdLnOptionId_quietModeEnabled: assert( numOptionValues == 0 ); if ( numOptionValues != 0 ) { fprintf( stderr, "Error: Incorrect specification of the `-%s/--%s` command-line option!\n", cliOptions[optionId].matchShort, cliOptions[optionId].match ); return -1; } args->quietModeEnabled = true; args->quietModeEnabled = true; break; break; case CmdLnOptionId_framing: case CmdLnOptionId_framing: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: Incorrect audio rendering frame size!\n" ); return -1; } if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) { { fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] ); fprintf( stderr, "Error: Unknown or invalid option for audio rendring frame size: %s\n", optionValues[0] ); exit( -1 ); return -1; } } break; break; #ifdef RTP_S4_251135_CR26253_0016_REV1 #ifdef RTP_S4_251135_CR26253_0016_REV1 case CmdLnOptionId_srParamsFile: case CmdLnOptionId_srParamsFile: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No path to split rending init params file has been provided!\n" ); return -1; } strncpy( args->srParamsFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->srParamsFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; break; #endif #endif default: default: assert( 0 && "This should be unreachable - all command line options should be explicitly handled." ); fprintf( stderr, "Error: Incorrect or invalid command-line usage!\n" ); return -1; break; break; } } return; return 0; } } Loading Loading @@ -639,7 +682,7 @@ static void printSupportedAudioConfigs( void ) #endif #endif }; }; fprintf( stdout, "Supported audio formats:\n" ); fprintf( stdout, "Supported audio formats:\n\n" ); for ( i = 0; i < sizeof( supportedFormats ) / sizeof( *supportedFormats ); i++ ) for ( i = 0; i < sizeof( supportedFormats ) / sizeof( *supportedFormats ); i++ ) { { fprintf( stdout, "%s\n", supportedFormats[i] ); fprintf( stdout, "%s\n", supportedFormats[i] ); Loading apps/renderer.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -2750,7 +2750,7 @@ static CmdlnArgs defaultArgs( return args; return args; } } static void parseOption( static int16_t parseOption( const int32_t optionId, const int32_t optionId, char **optionValues, char **optionValues, const int16_t numOptionValues, const int16_t numOptionValues, Loading Loading @@ -2946,7 +2946,7 @@ static void parseOption( break; break; } } return; return 0; } } static CmdlnArgs parseCmdlnArgs( static CmdlnArgs parseCmdlnArgs( Loading lib_util/cmdln_parser.c +23 −7 Original line number Original line Diff line number Diff line Loading @@ -179,7 +179,8 @@ static int16_t parseOpts( Option *opts, Option *opts, const int32_t numOpts, const int32_t numOpts, void *pOutputStruct, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption ) CmdLnParser_FnPtr_ParseOption parseOption ) { { Option *currOpt = NULL; Option *currOpt = NULL; int32_t currOptIdx = 1; int32_t currOptIdx = 1; Loading Loading @@ -238,7 +239,10 @@ static int16_t parseOpts( { { if ( currOpt != NULL ) if ( currOpt != NULL ) { { parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct ); if ( parseOption(currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct) != 0 ) { return -1; } currOpt->hasBeenParsed = 1; currOpt->hasBeenParsed = 1; } } Loading @@ -253,7 +257,10 @@ static int16_t parseOpts( /* Parse last option */ /* Parse last option */ if ( currOpt != NULL ) if ( currOpt != NULL ) { { parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct ); if (parseOption(currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct) != 0) { return -1; } currOpt->hasBeenParsed = 1; currOpt->hasBeenParsed = 1; } } Loading Loading @@ -330,28 +337,36 @@ static void printUsage( const OptionProps *optionProps, const OptionProps *optionProps, const int32_t numOptions ) const int32_t numOptions ) { { int32_t optNameLength; fprintf( stderr, "\n" ); fprintf( stderr, "\n" ); fprintf( stderr, "Usage: %s [options]\n", getBasename( argv0 ) ); fprintf( stderr, "Usage: %s [options]\n", getBasename( argv0 ) ); fprintf( stderr, "\n" ); fprintf( stderr, "\n" ); fprintf( stderr, "Valid options:\n" ); /* Find option with longest name, used for pretty formatting */ /* Find option with longest name, used for pretty formatting */ int32_t maxOptNameLength = 0; int32_t maxOptNameLength = 0; for ( int32_t i = 0; i < numOptions; ++i ) for ( int32_t i = 0; i < numOptions; ++i ) { { const int32_t optNameLength = totalOptionNameLength( optionProps[i] ); optNameLength = totalOptionNameLength( optionProps[i] ); if ( maxOptNameLength < optNameLength ) if ( maxOptNameLength < optNameLength ) { { maxOptNameLength = optNameLength; maxOptNameLength = optNameLength; } } } } fprintf( stderr, "Mandatory parameters:\n" ); const int32_t preDescriptionWhitespace = 8; const int32_t preDescriptionWhitespace = 8; const int32_t leftColumnAdditionalChars = 7; const int32_t leftColumnAdditionalChars = 7; for ( int32_t i = 0; i < numOptions; ++i ) for ( int32_t i = 0; i < numOptions; ++i ) { { OptionProps opt = optionProps[i]; OptionProps opt = optionProps[i]; const int32_t optNameLength = totalOptionNameLength( optionProps[i] ); optNameLength = totalOptionNameLength( optionProps[i] ); if (i == 2) { fprintf( stderr, "\nOptional parameters:\n" ); } /* TODO(sgi): make matchShort optional */ /* TODO(sgi): make matchShort optional */ fprintf( stderr, " --%s, -%s", opt.match, opt.matchShort ); fprintf( stderr, " --%s, -%s", opt.match, opt.matchShort ); Loading @@ -369,7 +384,8 @@ int16_t CmdLnParser_parseArgs( const OptionProps *optionProps, const OptionProps *optionProps, const int32_t numOptions, const int32_t numOptions, void *pOutputStruct, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption ) CmdLnParser_FnPtr_ParseOption parseOption ) { { assert( numOptions <= MAX_SUPPORTED_OPTS ); assert( numOptions <= MAX_SUPPORTED_OPTS ); Loading lib_util/cmdln_parser.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -45,7 +45,7 @@ typedef struct } CmdLnParser_Option; } CmdLnParser_Option; /* Function for parsing option values into an output struct, to be implemented by the user */ /* Function for parsing option values into an output struct, to be implemented by the user */ typedef void ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct ); typedef int16_t ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct ); int16_t CmdLnParser_parseArgs( int32_t argc, char **argv, const CmdLnParser_Option *options, const int32_t numOptions, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption ); int16_t CmdLnParser_parseArgs( int32_t argc, char **argv, const CmdLnParser_Option *options, const int32_t numOptions, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption ); Loading Loading
apps/isar_post_rend.c +83 −40 Original line number Original line Diff line number Diff line Loading @@ -159,7 +159,7 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_inputMetadata, .id = CmdLnOptionId_inputMetadata, .match = "input_metadata", .match = "input_metadata", .matchShort = "im", .matchShort = "im", .description = "Space-separated list of path to metadata files for BINAURAL_SPLIT_PCM input mode", .description = "Space-separated list of paths to metadata files for BINAURAL_SPLIT_PCM input mode", }, }, { { .id = CmdLnOptionId_outputFile, .id = CmdLnOptionId_outputFile, Loading @@ -183,13 +183,13 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_SplitRendBFIFile, .id = CmdLnOptionId_SplitRendBFIFile, .match = "post_rend_bfi_file", .match = "post_rend_bfi_file", .matchShort = "prbfi", .matchShort = "prbfi", .description = "Split rendering option: bfi file", .description = "Split rendering BFI (Bad Frame Indicator) file", }, }, { { .id = CmdLnOptionId_noDelayCmp, .id = CmdLnOptionId_noDelayCmp, .match = "no_delay_compensation", .match = "no_delay_compensation", .matchShort = "no_delay_cmp", .matchShort = "no_delay_cmp", .description = "[flag] Turn off delay compensation", .description = "Turn off delay compensation", }, }, { { .id = CmdLnOptionId_complexityLevel, .id = CmdLnOptionId_complexityLevel, Loading @@ -201,7 +201,7 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_quietModeEnabled, .id = CmdLnOptionId_quietModeEnabled, .match = "quiet", .match = "quiet", .matchShort = "q", .matchShort = "q", .description = "[flag] Limit printouts to terminal", .description = "Quiet mode - limit printouts to terminal", }, }, { { .id = CmdLnOptionId_listFormats, .id = CmdLnOptionId_listFormats, Loading @@ -213,7 +213,7 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_framing, .id = CmdLnOptionId_framing, .match = "framing", .match = "framing", .matchShort = "fr", .matchShort = "fr", .description = "Set Render audio framing.", .description = "Set audio rendering frame size", }, }, #ifdef RTP_S4_251135_CR26253_0016_REV1 #ifdef RTP_S4_251135_CR26253_0016_REV1 { { Loading Loading @@ -349,7 +349,7 @@ static bool parseInConfig( /* Default case covers formats that are defined in the AUDIO_CONFIG enum, /* Default case covers formats that are defined in the AUDIO_CONFIG enum, * but cannot be used at input, e.g. BINAURAL */ * but cannot be used at input, e.g. BINAURAL */ const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_listFormats ); const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_listFormats ); fprintf( stderr, "Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match ); fprintf( stderr, "Error: Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match ); return false; return false; } } } } Loading Loading @@ -440,7 +440,7 @@ static bool checkRequiredArgs( if ( isEmptyString( args.inputFilePath ) ) if ( isEmptyString( args.inputFilePath ) ) { { tmpOption = findOptionById( CmdLnOptionId_inputFile ); tmpOption = findOptionById( CmdLnOptionId_inputFile ); fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); fprintf( stderr, "Missing mandatory parameter: --%s/-%s\n", tmpOption->match, tmpOption->matchShort ); missingRequiredArg = true; missingRequiredArg = true; } } Loading @@ -450,19 +450,13 @@ static bool checkRequiredArgs( { { /* Neither scene description input nor single-type input was specified on command line */ /* Neither scene description input nor single-type input was specified on command line */ tmpOption = findOptionById( CmdLnOptionId_inputFormat ); tmpOption = findOptionById( CmdLnOptionId_inputFormat ); fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); fprintf( stderr, "Missing mandatory parameter: --%s/-%s\n", tmpOption->match, tmpOption->matchShort ); missingRequiredArg = true; missingRequiredArg = true; } } if ( isEmptyString( args.outputFilePath ) ) if ( isEmptyString( args.outputFilePath ) ) { { tmpOption = findOptionById( CmdLnOptionId_outputFile ); tmpOption = findOptionById( CmdLnOptionId_outputFile ); fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); fprintf( stderr, "Missing mandatory parameter: --%s/-%s\n", tmpOption->match, tmpOption->matchShort ); missingRequiredArg = true; } if ( args.sampleRate == 0 ) { tmpOption = findOptionById( CmdLnOptionId_sampleRate ); fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); missingRequiredArg = true; missingRequiredArg = true; } } if ( missingRequiredArg ) if ( missingRequiredArg ) Loading Loading @@ -508,7 +502,7 @@ static CmdlnArgs defaultArgs( } } static void parseOption( static int16_t parseOption( const int32_t optionId, const int32_t optionId, char **optionValues, char **optionValues, const int16_t numOptionValues, const int16_t numOptionValues, Loading @@ -519,22 +513,34 @@ static void parseOption( switch ( optionId ) switch ( optionId ) { { case CmdLnOptionId_listFormats: case CmdLnOptionId_listFormats: assert( numOptionValues == 0 ); printSupportedAudioConfigs(); printSupportedAudioConfigs(); exit( 0 ); exit( 0 ); case CmdLnOptionId_inputFile: case CmdLnOptionId_inputFile: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No input file has been provided!\n" ); return -1; } strncpy( args->inputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->inputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; break; case CmdLnOptionId_inputFormat: case CmdLnOptionId_inputFormat: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No input file format has been provided!\n" ); return -1; } if ( !parseInConfig( optionValues[0], &args->inConfig, &args->sceneDescriptionInput ) ) if ( !parseInConfig( optionValues[0], &args->inConfig, &args->sceneDescriptionInput ) ) { { exit( -1 ); /* Error printout handled by failing function */ /* Error printout handled by failing function */ return -1; } } break; break; case CmdLnOptionId_inputMetadata: case CmdLnOptionId_inputMetadata: assert( numOptionValues <= RENDERER_MAX_ISAR_MD_INPUTS ); if ( numOptionValues < 1 || numOptionValues > RENDERER_MAX_ISAR_MD_INPUTS ) { fprintf( stderr, "Error: No paths to metadata files for BINAURAL_SPLIT_PCM input mode has been provided!\n" ); return -1; } for ( int16_t i = 0; i < numOptionValues; ++i ) for ( int16_t i = 0; i < numOptionValues; ++i ) { { strncpy( args->inMetadataFilePaths[i], optionValues[i], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->inMetadataFilePaths[i], optionValues[i], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); Loading @@ -542,68 +548,105 @@ static void parseOption( args->numInMetadataFiles = numOptionValues; args->numInMetadataFiles = numOptionValues; break; break; case CmdLnOptionId_outputFile: case CmdLnOptionId_outputFile: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No output file has been provided!\n" ); return -1; } strncpy( args->outputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->outputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; break; case CmdLnOptionId_sampleRate: case CmdLnOptionId_sampleRate: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No input sampling rate has been provided!\n" ); return -1; } args->sampleRate = (int32_t) ( strtol( optionValues[0], NULL, 10 ) * 1000 ); args->sampleRate = (int32_t) ( strtol( optionValues[0], NULL, 10 ) * 1000 ); if ( args->sampleRate == 0 ) if ( args->sampleRate == 0 ) { { fprintf( stderr, "Invalid sampling rate specified\n" ); fprintf( stderr, "Error: Invalid sampling rate specified\n" ); exit( -1 ); return -1; } } break; break; case CmdLnOptionId_trajFile: case CmdLnOptionId_trajFile: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No head rotation trajectory file has been provided!\n" ); return -1; } strncpy( args->headRotationFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->headRotationFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; break; case CmdLnOptionId_SplitRendBFIFile: case CmdLnOptionId_SplitRendBFIFile: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No bfi file has been provided!\n" ); return -1; } strncpy( args->splitRendBFIFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->splitRendBFIFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; break; case CmdLnOptionId_complexityLevel: case CmdLnOptionId_complexityLevel: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No complexity level has been provided!\n" ); return -1; } args->complexityLevel = (int32_t) ( strtol( optionValues[0], NULL, 10 ) ); args->complexityLevel = (int32_t) ( strtol( optionValues[0], NULL, 10 ) ); if ( args->complexityLevel < ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel > ISAR_POST_REND_COMPLEXITY_LEVEL_THREE ) if ( args->complexityLevel < ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel > ISAR_POST_REND_COMPLEXITY_LEVEL_THREE ) { { fprintf( stdout, "Invalid complexity level specified.\n" ); fprintf( stderr, "Error: Invalid complexity level specified.\n" ); exit( -1 ); return -1; } } else if ( args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_TWO ) else if ( args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_TWO ) { { fprintf( stdout, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" ); fprintf( stderr, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" ); } } break; break; case CmdLnOptionId_noDelayCmp: case CmdLnOptionId_noDelayCmp: assert( numOptionValues == 0 ); if ( numOptionValues != 0 ) { fprintf( stderr, "Error: Incorrect specification of the `-%s/--%s` command-line option!\n", cliOptions[optionId].matchShort, cliOptions[optionId].match ); return -1; } args->delayCompensationEnabled = false; args->delayCompensationEnabled = false; break; break; case CmdLnOptionId_quietModeEnabled: case CmdLnOptionId_quietModeEnabled: assert( numOptionValues == 0 ); if ( numOptionValues != 0 ) { fprintf( stderr, "Error: Incorrect specification of the `-%s/--%s` command-line option!\n", cliOptions[optionId].matchShort, cliOptions[optionId].match ); return -1; } args->quietModeEnabled = true; args->quietModeEnabled = true; break; break; case CmdLnOptionId_framing: case CmdLnOptionId_framing: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: Incorrect audio rendering frame size!\n" ); return -1; } if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) { { fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] ); fprintf( stderr, "Error: Unknown or invalid option for audio rendring frame size: %s\n", optionValues[0] ); exit( -1 ); return -1; } } break; break; #ifdef RTP_S4_251135_CR26253_0016_REV1 #ifdef RTP_S4_251135_CR26253_0016_REV1 case CmdLnOptionId_srParamsFile: case CmdLnOptionId_srParamsFile: assert( numOptionValues == 1 ); if ( numOptionValues != 1 ) { fprintf( stderr, "Error: No path to split rending init params file has been provided!\n" ); return -1; } strncpy( args->srParamsFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); strncpy( args->srParamsFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); break; break; #endif #endif default: default: assert( 0 && "This should be unreachable - all command line options should be explicitly handled." ); fprintf( stderr, "Error: Incorrect or invalid command-line usage!\n" ); return -1; break; break; } } return; return 0; } } Loading Loading @@ -639,7 +682,7 @@ static void printSupportedAudioConfigs( void ) #endif #endif }; }; fprintf( stdout, "Supported audio formats:\n" ); fprintf( stdout, "Supported audio formats:\n\n" ); for ( i = 0; i < sizeof( supportedFormats ) / sizeof( *supportedFormats ); i++ ) for ( i = 0; i < sizeof( supportedFormats ) / sizeof( *supportedFormats ); i++ ) { { fprintf( stdout, "%s\n", supportedFormats[i] ); fprintf( stdout, "%s\n", supportedFormats[i] ); Loading
apps/renderer.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -2750,7 +2750,7 @@ static CmdlnArgs defaultArgs( return args; return args; } } static void parseOption( static int16_t parseOption( const int32_t optionId, const int32_t optionId, char **optionValues, char **optionValues, const int16_t numOptionValues, const int16_t numOptionValues, Loading Loading @@ -2946,7 +2946,7 @@ static void parseOption( break; break; } } return; return 0; } } static CmdlnArgs parseCmdlnArgs( static CmdlnArgs parseCmdlnArgs( Loading
lib_util/cmdln_parser.c +23 −7 Original line number Original line Diff line number Diff line Loading @@ -179,7 +179,8 @@ static int16_t parseOpts( Option *opts, Option *opts, const int32_t numOpts, const int32_t numOpts, void *pOutputStruct, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption ) CmdLnParser_FnPtr_ParseOption parseOption ) { { Option *currOpt = NULL; Option *currOpt = NULL; int32_t currOptIdx = 1; int32_t currOptIdx = 1; Loading Loading @@ -238,7 +239,10 @@ static int16_t parseOpts( { { if ( currOpt != NULL ) if ( currOpt != NULL ) { { parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct ); if ( parseOption(currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct) != 0 ) { return -1; } currOpt->hasBeenParsed = 1; currOpt->hasBeenParsed = 1; } } Loading @@ -253,7 +257,10 @@ static int16_t parseOpts( /* Parse last option */ /* Parse last option */ if ( currOpt != NULL ) if ( currOpt != NULL ) { { parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct ); if (parseOption(currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct) != 0) { return -1; } currOpt->hasBeenParsed = 1; currOpt->hasBeenParsed = 1; } } Loading Loading @@ -330,28 +337,36 @@ static void printUsage( const OptionProps *optionProps, const OptionProps *optionProps, const int32_t numOptions ) const int32_t numOptions ) { { int32_t optNameLength; fprintf( stderr, "\n" ); fprintf( stderr, "\n" ); fprintf( stderr, "Usage: %s [options]\n", getBasename( argv0 ) ); fprintf( stderr, "Usage: %s [options]\n", getBasename( argv0 ) ); fprintf( stderr, "\n" ); fprintf( stderr, "\n" ); fprintf( stderr, "Valid options:\n" ); /* Find option with longest name, used for pretty formatting */ /* Find option with longest name, used for pretty formatting */ int32_t maxOptNameLength = 0; int32_t maxOptNameLength = 0; for ( int32_t i = 0; i < numOptions; ++i ) for ( int32_t i = 0; i < numOptions; ++i ) { { const int32_t optNameLength = totalOptionNameLength( optionProps[i] ); optNameLength = totalOptionNameLength( optionProps[i] ); if ( maxOptNameLength < optNameLength ) if ( maxOptNameLength < optNameLength ) { { maxOptNameLength = optNameLength; maxOptNameLength = optNameLength; } } } } fprintf( stderr, "Mandatory parameters:\n" ); const int32_t preDescriptionWhitespace = 8; const int32_t preDescriptionWhitespace = 8; const int32_t leftColumnAdditionalChars = 7; const int32_t leftColumnAdditionalChars = 7; for ( int32_t i = 0; i < numOptions; ++i ) for ( int32_t i = 0; i < numOptions; ++i ) { { OptionProps opt = optionProps[i]; OptionProps opt = optionProps[i]; const int32_t optNameLength = totalOptionNameLength( optionProps[i] ); optNameLength = totalOptionNameLength( optionProps[i] ); if (i == 2) { fprintf( stderr, "\nOptional parameters:\n" ); } /* TODO(sgi): make matchShort optional */ /* TODO(sgi): make matchShort optional */ fprintf( stderr, " --%s, -%s", opt.match, opt.matchShort ); fprintf( stderr, " --%s, -%s", opt.match, opt.matchShort ); Loading @@ -369,7 +384,8 @@ int16_t CmdLnParser_parseArgs( const OptionProps *optionProps, const OptionProps *optionProps, const int32_t numOptions, const int32_t numOptions, void *pOutputStruct, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption ) CmdLnParser_FnPtr_ParseOption parseOption ) { { assert( numOptions <= MAX_SUPPORTED_OPTS ); assert( numOptions <= MAX_SUPPORTED_OPTS ); Loading
lib_util/cmdln_parser.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -45,7 +45,7 @@ typedef struct } CmdLnParser_Option; } CmdLnParser_Option; /* Function for parsing option values into an output struct, to be implemented by the user */ /* Function for parsing option values into an output struct, to be implemented by the user */ typedef void ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct ); typedef int16_t ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct ); int16_t CmdLnParser_parseArgs( int32_t argc, char **argv, const CmdLnParser_Option *options, const int32_t numOptions, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption ); int16_t CmdLnParser_parseArgs( int32_t argc, char **argv, const CmdLnParser_Option *options, const int32_t numOptions, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption ); Loading