Commit af7fd1b6 authored by Malenovsky, Vladimir's avatar Malenovsky, Vladimir
Browse files

simplify --help and --l arguments

parent bd1b9185
Loading
Loading
Loading
Loading
+9 −39
Original line number Diff line number Diff line
@@ -113,10 +113,7 @@ typedef struct
    ISAR_POST_REND_COMPLEXITY_LEVEL complexityLevel;
    bool delayCompensationEnabled;
    bool quietModeEnabled;
    bool sceneDescriptionInput;
    IVAS_RENDER_FRAMESIZE render_framesize;
    int16_t numMandatoryCmdLineParams;
    bool help;
} CmdlnArgs;

typedef enum
@@ -149,7 +146,7 @@ static const CmdLnParser_Option cliOptions[] = {
        .id = CmdLnOptionId_inputFormat,
        .match = "input_format",
        .matchShort = "if",
        .description = "Audio format of input file (e.g. BINAURAL_SPLIT_PCM, use -l for a list)",
        .description = "Audio format of input file (e.g. BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, ... Use -l for a list)",
    },
    {
        .id = CmdLnOptionId_outputFile,
@@ -161,7 +158,7 @@ static const CmdLnParser_Option cliOptions[] = {
        .id = CmdLnOptionId_inputMetadata,
        .match = "input_metadata",
        .matchShort = "im",
        .description = "Space-separated list of paths to metadata files for BINAURAL_SPLIT_PCM input mode",
        .description = "Path to the input metadata file for BINAURAL_SPLIT_PCM input mode",
    },
    {
        .id = CmdLnOptionId_sampleRate,
@@ -301,26 +298,11 @@ static const CmdLnParser_Option *findOptionById(

static bool parseInConfig(
    const char *inFormatStr,
    InputConfig *inConfig,
    bool *sceneDescriptionInput )
    InputConfig *inConfig )
{
    char charBuf[FILENAME_MAX];

    /* Initialize input config struct */
    inConfig->numBinBuses = 0;

    /* First check if input is being set to scene description file - this is not covered by parseAudioConfig(). */
    strncpy( charBuf, inFormatStr, sizeof( charBuf ) - 1 );
    charBuf[sizeof( charBuf ) - 1] = '\0';
    to_upper( charBuf );
    if ( strcmp( charBuf, "META" ) == 0 )
    {
        *sceneDescriptionInput = true;
        /* Parsing the file will be done later. At this point the actual file path
         * may not be known as command line parameters are still being parsed. */
        return true;
    }

    /* Check for single-format inputs. The given string should map to a member of AUDIO_CONFIG enum. */
    bool srRtp = false;
    IVAS_AUDIO_CONFIG audioConfig = parseAudioConfig( inFormatStr, &srRtp );
@@ -427,11 +409,8 @@ static bool checkRequiredArgs(
        missingRequiredArg = true;
    }

    const bool singleInputSpecified = ( args.inConfig.numBinBuses != 0 );

    if ( !args.sceneDescriptionInput && !singleInputSpecified )
    if ( args.inConfig.numBinBuses == 0 )
    {
        /* Neither scene description input nor single-type input was specified on command line */
        tmpOption = findOptionById( CmdLnOptionId_inputFormat );
        fprintf( stderr, "Missing mandatory parameter: --%s/-%s\n", tmpOption->match, tmpOption->matchShort );
        missingRequiredArg = true;
@@ -446,7 +425,7 @@ static bool checkRequiredArgs(

    if ( missingRequiredArg )
    {
        CmdLnParser_printUsage( args.executableName, cliOptions, numCliOptions, args.numMandatoryCmdLineParams );
        CmdLnParser_printUsage( args.executableName, cliOptions, numCliOptions, POST_REND_NUM_MANDATORY_CMD_LINE_PARAMS );
    }

    return !missingRequiredArg;
@@ -485,11 +464,8 @@ static CmdlnArgs defaultArgs(
    args.complexityLevel = ISAR_POST_REND_COMPLEXITY_LEVEL_THREE;
    args.delayCompensationEnabled = true;
    args.quietModeEnabled = false;
    args.sceneDescriptionInput = false;

    args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS;
    args.numMandatoryCmdLineParams = POST_REND_NUM_MANDATORY_CMD_LINE_PARAMS;
    args.help = false;

    return args;
}
@@ -522,7 +498,7 @@ static int16_t parseOption(
                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 ) )
            {
                /* Error printout handled by failing function */
                return -1;
@@ -631,8 +607,8 @@ static int16_t parseOption(
            strncpy( args->srParamsFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
            break;
        case CmdLnOptionId_help:
            args->help = true;
            break;
            CmdLnParser_printUsage( args->executableName, cliOptions, numCliOptions, POST_REND_NUM_MANDATORY_CMD_LINE_PARAMS );
            exit( 0 );
        default:
            fprintf( stderr, "Error: Incorrect or invalid command-line usage!\n" );
            return -1;
@@ -649,17 +625,11 @@ static CmdlnArgs parseCmdlnArgs(
{
    CmdlnArgs args = defaultArgs( argv[0] );

    if ( CmdLnParser_parseArgs( argc, argv, cliOptions, numCliOptions, &args, parseOption, args.numMandatoryCmdLineParams ) != 0 )
    if ( CmdLnParser_parseArgs( argc, argv, cliOptions, numCliOptions, &args, parseOption, POST_REND_NUM_MANDATORY_CMD_LINE_PARAMS ) != 0 )
    {
        exit( -1 ); /* Error printout handled by failing function */
    }

    if ( args.help )
    {
        CmdLnParser_printUsage( args.executableName, cliOptions, numCliOptions, args.numMandatoryCmdLineParams );
        exit( 0 );
    }

    if ( !checkRequiredArgs( args ) )
    {
        exit( -1 ); /* Error printout handled by failing function */
+1 −4
Original line number Diff line number Diff line
@@ -196,7 +196,6 @@ typedef struct
    uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS];
    AcousticEnvironmentSequence aeSequence;
    IVAS_ROOM_SIZE_T reverbRoomSize;
    int16_t numMandatoryCmdLineParams;
} CmdlnArgs;

typedef enum
@@ -2720,8 +2719,6 @@ static CmdlnArgs defaultArgs(

    args.reverbRoomSize = IVAS_ROOM_SIZE_AUTO;

    args.numMandatoryCmdLineParams = RENDERER_NUM_MANDATORY_CMD_LINE_PARAMS;

    return args;
}

@@ -2924,7 +2921,7 @@ static CmdlnArgs parseCmdlnArgs(
{
    CmdlnArgs args = defaultArgs( argv[0] );

    if ( CmdLnParser_parseArgs( argc, argv, cliOptions, numCliOptions, &args, parseOption, args.numMandatoryCmdLineParams ) != 0 )
    if ( CmdLnParser_parseArgs( argc, argv, cliOptions, numCliOptions, &args, parseOption, RENDERER_NUM_MANDATORY_CMD_LINE_PARAMS ) != 0 )
    {
        exit( -1 ); /* Error printout handled by failing function */
    }