int split_commandline(OptionParseContext *octx, int argc, char *argv[],

                      const OptionDef *options,

                      const OptionGroupDef *groups)

{

    int optindex = 1;



    /* perform system-dependent conversions for arguments list */

    prepare_app_arguments(&argc, &argv);



    init_parse_context(octx, groups);

    av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n");



    while (optindex < argc) {

        const char *opt = argv[optindex++], *arg;

        const OptionDef *po;

        int ret;



        av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt);



        /* unnamed group separators, e.g. output filename */

        if (opt[0] != '-' || !opt[1]) {

            finish_group(octx, 0, opt);

            av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", groups[0].name);

            continue;

        }

        opt++;



#define GET_ARG(arg)                                                           \

do {                                                                           \

    arg = argv[optindex++];                                                    \

    if (!arg) {                                                                \

        av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\

        return AVERROR(EINVAL);                                                \

    }                                                                          \

} while (0)



        /* named group separators, e.g. -i */

        if ((ret = match_group_separator(groups, opt)) >= 0) {

            GET_ARG(arg);

            finish_group(octx, ret, arg);

            av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n",

                   groups[ret].name, arg);

            continue;

        }



        /* normal options */

        po = find_option(options, opt);

        if (po->name) {

            if (po->flags & OPT_EXIT) {

                /* optional argument, e.g. -h */

                arg = argv[optindex++];

            } else if (po->flags & HAS_ARG) {

                GET_ARG(arg);

            } else {

                arg = "1";

            }



            add_opt(octx, po, opt, arg);

            av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "

                   "argument '%s'.\n", po->name, po->help, arg);

            continue;

        }



        /* AVOptions */

        if (argv[optindex]) {

            ret = opt_default(NULL, opt, argv[optindex]);

            if (ret >= 0) {

                av_log(NULL, AV_LOG_DEBUG, " matched as AVOption '%s' with "

                       "argument '%s'.\n", opt, argv[optindex]);

                optindex++;

                continue;

            } else if (ret != AVERROR_OPTION_NOT_FOUND) {

                av_log(NULL, AV_LOG_ERROR, "Error parsing option '%s' "

                       "with argument '%s'.\n", opt, argv[optindex]);

                return ret;

            }

        }



        /* boolean -nofoo options */

        if (opt[0] == 'n' && opt[1] == 'o' &&

            (po = find_option(options, opt + 2)) &&

            po->name && po->flags & OPT_BOOL) {

            add_opt(octx, po, opt, "0");

            av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "

                   "argument 0.\n", po->name, po->help);

            continue;

        }



        av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'.\n", opt);

        return AVERROR_OPTION_NOT_FOUND;

    }



    if (octx->cur_group.nb_opts || codec_opts || format_opts)

        av_log(NULL, AV_LOG_WARNING, "Trailing options were found on the "

               "commandline.\n");



    av_log(NULL, AV_LOG_DEBUG, "Finished splitting the commandline.\n");



    return 0;

}

int split_commandline(OptionParseContext *octx, int argc, char *argv[],

                      const OptionDef *options,

                      const OptionGroupDef *groups)

{

    int optindex = 1;



    

    prepare_app_arguments(&argc, &argv);



    init_parse_context(octx, groups);

    av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n");



    while (optindex < argc) {

        const char *opt = argv[optindex++], *arg;

        const OptionDef *po;

        int ret;



        av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt);



        

        if (opt[0] != '-' || !opt[1]) {

            finish_group(octx, 0, opt);

            av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", groups[0].name);

            continue;

        }

        opt++;



#define GET_ARG(arg)                                                           \

do {                                                                           \

    arg = argv[optindex++];                                                    \

    if (!arg) {                                                                \

        av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\

        return AVERROR(EINVAL);                                                \

    }                                                                          \

} while (0)



        

        if ((ret = match_group_separator(groups, opt)) >= 0) {

            GET_ARG(arg);

            finish_group(octx, ret, arg);

            av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n",

                   groups[ret].name, arg);

            continue;

        }



        

        po = find_option(options, opt);

        if (po->name) {

            if (po->flags & OPT_EXIT) {

                

                arg = argv[optindex++];

            } else if (po->flags & HAS_ARG) {

                GET_ARG(arg);

            } else {

                arg = "1";

            }



            add_opt(octx, po, opt, arg);

            av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "

                   "argument '%s'.\n", po->name, po->help, arg);

            continue;

        }



        

        if (argv[optindex]) {

            ret = opt_default(NULL, opt, argv[optindex]);

            if (ret >= 0) {

                av_log(NULL, AV_LOG_DEBUG, " matched as AVOption '%s' with "

                       "argument '%s'.\n", opt, argv[optindex]);

                optindex++;

                continue;

            } else if (ret != AVERROR_OPTION_NOT_FOUND) {

                av_log(NULL, AV_LOG_ERROR, "Error parsing option '%s' "

                       "with argument '%s'.\n", opt, argv[optindex]);

                return ret;

            }

        }



        

        if (opt[0] == 'n' && opt[1] == 'o' &&

            (po = find_option(options, opt + 2)) &&

            po->name && po->flags & OPT_BOOL) {

            add_opt(octx, po, opt, "0");

            av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "

                   "argument 0.\n", po->name, po->help);

            continue;

        }



        av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'.\n", opt);

        return AVERROR_OPTION_NOT_FOUND;

    }



    if (octx->cur_group.nb_opts || codec_opts || format_opts)

        av_log(NULL, AV_LOG_WARNING, "Trailing options were found on the "

               "commandline.\n");



    av_log(NULL, AV_LOG_DEBUG, "Finished splitting the commandline.\n");



    return 0;

}

int FUNC_0(OptionParseContext *VAR_0, int VAR_1, char *VAR_2[],

                      const OptionDef *VAR_3,

                      const OptionGroupDef *VAR_4)

{

    int VAR_5 = 1;



    

    prepare_app_arguments(&VAR_1, &VAR_2);



    init_parse_context(VAR_0, VAR_4);

    av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n");



    while (VAR_5 < VAR_1) {

        const char *VAR_6 = VAR_2[VAR_5++], *VAR_7;

        const OptionDef *VAR_8;

        int VAR_9;



        av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", VAR_6);



        

        if (VAR_6[0] != '-' || !VAR_6[1]) {

            finish_group(VAR_0, 0, VAR_6);

            av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", VAR_4[0].name);

            continue;

        }

        VAR_6++;



#define GET_ARG(VAR_7)                                                           \

do {                                                                           \

    VAR_7 = VAR_2[VAR_5++];                                                    \

    if (!VAR_7) {                                                                \

        av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", VAR_6);\

        return AVERROR(EINVAL);                                                \

    }                                                                          \

} while (0)



        

        if ((VAR_9 = match_group_separator(VAR_4, VAR_6)) >= 0) {

            GET_ARG(VAR_7);

            finish_group(VAR_0, VAR_9, VAR_7);

            av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n",

                   VAR_4[VAR_9].name, VAR_7);

            continue;

        }



        

        VAR_8 = find_option(VAR_3, VAR_6);

        if (VAR_8->name) {

            if (VAR_8->flags & OPT_EXIT) {

                

                VAR_7 = VAR_2[VAR_5++];

            } else if (VAR_8->flags & HAS_ARG) {

                GET_ARG(VAR_7);

            } else {

                VAR_7 = "1";

            }



            add_opt(VAR_0, VAR_8, VAR_6, VAR_7);

            av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "

                   "argument '%s'.\n", VAR_8->name, VAR_8->help, VAR_7);

            continue;

        }



        

        if (VAR_2[VAR_5]) {

            VAR_9 = opt_default(NULL, VAR_6, VAR_2[VAR_5]);

            if (VAR_9 >= 0) {

                av_log(NULL, AV_LOG_DEBUG, " matched as AVOption '%s' with "

                       "argument '%s'.\n", VAR_6, VAR_2[VAR_5]);

                VAR_5++;

                continue;

            } else if (VAR_9 != AVERROR_OPTION_NOT_FOUND) {

                av_log(NULL, AV_LOG_ERROR, "Error parsing option '%s' "

                       "with argument '%s'.\n", VAR_6, VAR_2[VAR_5]);

                return VAR_9;

            }

        }



        

        if (VAR_6[0] == 'n' && VAR_6[1] == 'o' &&

            (VAR_8 = find_option(VAR_3, VAR_6 + 2)) &&

            VAR_8->name && VAR_8->flags & OPT_BOOL) {

            add_opt(VAR_0, VAR_8, VAR_6, "0");

            av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "

                   "argument 0.\n", VAR_8->name, VAR_8->help);

            continue;

        }



        av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'.\n", VAR_6);

        return AVERROR_OPTION_NOT_FOUND;

    }



    if (VAR_0->cur_group.nb_opts || codec_opts || format_opts)

        av_log(NULL, AV_LOG_WARNING, "Trailing VAR_3 were found on the "

               "commandline.\n");



    av_log(NULL, AV_LOG_DEBUG, "Finished splitting the commandline.\n");



    return 0;

}

int FUNC_0(OptionParseContext *VAR_0, int VAR_1, char *VAR_2[],
const OptionDef *VAR_3,
const OptionGroupDef *VAR_4)
{ int VAR_5 = 1; prepare_app_arguments(&VAR_1, &VAR_2); init_parse_context(VAR_0, VAR_4); av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n"); while (VAR_5 < VAR_1) { const char *VAR_6 = VAR_2[VAR_5++], *VAR_7; const OptionDef *VAR_8; int VAR_9; av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", VAR_6); if (VAR_6[0] != '-' || !VAR_6[1]) { finish_group(VAR_0, 0, VAR_6); av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", VAR_4[0].name); continue; } VAR_6++; #define GET_ARG(VAR_7)                                                           \
do {                                                                           \ VAR_7 = VAR_2[VAR_5++];                                                    \ if (!VAR_7) {                                                                \ av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", VAR_6);\ return AVERROR(EINVAL);                                                \ }                                                                          \ } while (0) if ((VAR_9 = match_group_separator(VAR_4, VAR_6)) >= 0) { GET_ARG(VAR_7); finish_group(VAR_0, VAR_9, VAR_7); av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n",
VAR_4[VAR_9].name, VAR_7); continue; } VAR_8 = find_option(VAR_3, VAR_6); if (VAR_8->name) { if (VAR_8->flags & OPT_EXIT) { VAR_7 = VAR_2[VAR_5++]; } else if (VAR_8->flags & HAS_ARG) { GET_ARG(VAR_7); } else { VAR_7 = "1"; } add_opt(VAR_0, VAR_8, VAR_6, VAR_7); av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "
"argument '%s'.\n", VAR_8->name, VAR_8->help, VAR_7); continue; } if (VAR_2[VAR_5]) { VAR_9 = opt_default(NULL, VAR_6, VAR_2[VAR_5]); if (VAR_9 >= 0) { av_log(NULL, AV_LOG_DEBUG, " matched as AVOption '%s' with "
"argument '%s'.\n", VAR_6, VAR_2[VAR_5]); VAR_5++; continue; } else if (VAR_9 != AVERROR_OPTION_NOT_FOUND) { av_log(NULL, AV_LOG_ERROR, "Error parsing option '%s' "
"with argument '%s'.\n", VAR_6, VAR_2[VAR_5]); return VAR_9; } } if (VAR_6[0] == 'n' && VAR_6[1] == 'o' &&
(VAR_8 = find_option(VAR_3, VAR_6 + 2)) &&
VAR_8->name && VAR_8->flags & OPT_BOOL) { add_opt(VAR_0, VAR_8, VAR_6, "0"); av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "
"argument 0.\n", VAR_8->name, VAR_8->help); continue; } av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'.\n", VAR_6); return AVERROR_OPTION_NOT_FOUND; } if (VAR_0->cur_group.nb_opts || codec_opts || format_opts)
av_log(NULL, AV_LOG_WARNING, "Trailing VAR_3 were found on the "
"commandline.\n"); av_log(NULL, AV_LOG_DEBUG, "Finished splitting the commandline.\n"); return 0; }