MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / opt_default

Function opt_default

fftools/cmdutils.c:599–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

597
598#define FLAGS ((o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0)
599int opt_default(void *optctx, const char *opt, const char *arg)
600{
601 const AVOption *o;
602 int consumed = 0;
603 char opt_stripped[128];
604 const char *p;
605 const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class();
606#if CONFIG_SWSCALE
607 const AVClass *sc = sws_get_class();
608#endif
609#if CONFIG_SWRESAMPLE
610 const AVClass *swr_class = swr_get_class();
611#endif
612
613 if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug"))
614 av_log_set_level(AV_LOG_DEBUG);
615
616 if (!(p = strchr(opt, ':')))
617 p = opt + strlen(opt);
618 av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1));
619
620 if ((o = opt_find(&cc, opt_stripped, NULL, 0,
621 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) ||
622 ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&
623 (o = opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) {
624 av_dict_set(&codec_opts, opt, arg, FLAGS);
625 consumed = 1;
626 }
627 if ((o = opt_find(&fc, opt, NULL, 0,
628 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
629 av_dict_set(&format_opts, opt, arg, FLAGS);
630 if (consumed)
631 av_log(NULL, AV_LOG_VERBOSE, "Routing option %s to both codec and muxer layer\n", opt);
632 consumed = 1;
633 }
634#if CONFIG_SWSCALE
635 if (!consumed && (o = opt_find(&sc, opt, NULL, 0,
636 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
637 if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") ||
638 !strcmp(opt, "dstw") || !strcmp(opt, "dsth") ||
639 !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) {
640 av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n");
641 return AVERROR(EINVAL);
642 }
643 av_dict_set(&sws_dict, opt, arg, FLAGS);
644
645 consumed = 1;
646 }
647#else
648 if (!consumed && !strcmp(opt, "sws_flags")) {
649 av_log(NULL, AV_LOG_WARNING, "Ignoring %s %s, due to disabled swscale\n", opt, arg);
650 consumed = 1;
651 }
652#endif
653#if CONFIG_SWRESAMPLE
654 if (!consumed && (o=opt_find(&swr_class, opt, NULL, 0,
655 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
656 av_dict_set(&swr_opts, opt, arg, FLAGS);

Callers 3

opt_targetFunction · 0.85
opt_default_newFunction · 0.85
split_commandlineFunction · 0.85

Calls 9

avcodec_get_classFunction · 0.85
avformat_get_classFunction · 0.85
sws_get_classFunction · 0.85
swr_get_classFunction · 0.85
av_log_set_levelFunction · 0.85
av_strlcpyFunction · 0.85
opt_findFunction · 0.85
av_dict_setFunction · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected