MCPcopy Index your code
hub / github.com/byhook/ffmpeg4android / split_commandline

Function split_commandline

ffmpeg-single-cmd/src/main/cpp/cmdutils.c:753–857  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

751}
752
753int split_commandline(OptionParseContext *octx, int argc, char *argv[],
754 const OptionDef *options,
755 const OptionGroupDef *groups, int nb_groups)
756{
757 int optindex = 1;
758 int dashdash = -2;
759
760 /* perform system-dependent conversions for arguments list */
761 prepare_app_arguments(&argc, &argv);
762
763 init_parse_context(octx, groups, nb_groups);
764 av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n");
765
766 while (optindex < argc) {
767 const char *opt = argv[optindex++], *arg;
768 const OptionDef *po;
769 int ret;
770
771 av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt);
772
773 if (opt[0] == '-' && opt[1] == '-' && !opt[2]) {
774 dashdash = optindex;
775 continue;
776 }
777 /* unnamed group separators, e.g. output filename */
778 if (opt[0] != '-' || !opt[1] || dashdash+1 == optindex) {
779 finish_group(octx, 0, opt);
780 av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", groups[0].name);
781 continue;
782 }
783 opt++;
784
785#define GET_ARG(arg) \
786do { \
787 arg = argv[optindex++]; \
788 if (!arg) { \
789 av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\
790 return AVERROR(EINVAL); \
791 } \
792} while (0)
793
794 /* named group separators, e.g. -i */
795 if ((ret = match_group_separator(groups, nb_groups, opt)) >= 0) {
796 GET_ARG(arg);
797 finish_group(octx, ret, arg);
798 av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n",
799 groups[ret].name, arg);
800 continue;
801 }
802
803 /* normal options */
804 po = find_option(options, opt);
805 if (po->name) {
806 if (po->flags & OPT_EXIT) {
807 /* optional argument, e.g. -h */
808 arg = argv[optindex++];
809 } else if (po->flags & HAS_ARG) {
810 GET_ARG(arg);

Callers 1

ffmpeg_parse_optionsFunction · 0.85

Calls 7

prepare_app_argumentsFunction · 0.85
init_parse_contextFunction · 0.85
finish_groupFunction · 0.85
match_group_separatorFunction · 0.85
find_optionFunction · 0.85
add_optFunction · 0.85
opt_defaultFunction · 0.85

Tested by

no test coverage detected