options: handle options with the same name in codecs and formats.
This will allow the incoming -timecode option to be handled in both encoders (mpeg12enc in that case) and demuxers (dv, mxf, etc.).
This commit is contained in:
committed by
Clément Bœsch
parent
6481a36010
commit
78da04384a
18
cmdutils.c
18
cmdutils.c
@ -284,17 +284,17 @@ unknown_opt:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FLAGS (o->type == FF_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
|
#define FLAGS(o) ((o)->type == FF_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
|
||||||
int opt_default(const char *opt, const char *arg)
|
int opt_default(const char *opt, const char *arg)
|
||||||
{
|
{
|
||||||
const AVOption *o;
|
const AVOption *oc, *of, *os;
|
||||||
if ((o = av_opt_find(avcodec_opts[0], opt, NULL, 0, AV_OPT_SEARCH_CHILDREN)) ||
|
if ((oc = av_opt_find(avcodec_opts[0], opt, NULL, 0, AV_OPT_SEARCH_CHILDREN)) ||
|
||||||
((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&
|
((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&
|
||||||
(o = av_opt_find(avcodec_opts[0], opt+1, NULL, 0, 0))))
|
(oc = av_opt_find(avcodec_opts[0], opt+1, NULL, 0, 0))))
|
||||||
av_dict_set(&codec_opts, opt, arg, FLAGS);
|
av_dict_set(&codec_opts, opt, arg, FLAGS(oc));
|
||||||
else if ((o = av_opt_find(avformat_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN)))
|
if ((of = av_opt_find(avformat_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN)))
|
||||||
av_dict_set(&format_opts, opt, arg, FLAGS);
|
av_dict_set(&format_opts, opt, arg, FLAGS(of));
|
||||||
else if ((o = av_opt_find(sws_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) {
|
if ((os = av_opt_find(sws_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) {
|
||||||
// XXX we only support sws_flags, not arbitrary sws options
|
// XXX we only support sws_flags, not arbitrary sws options
|
||||||
int ret = av_set_string3(sws_opts, opt, arg, 1, NULL);
|
int ret = av_set_string3(sws_opts, opt, arg, 1, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -303,7 +303,7 @@ int opt_default(const char *opt, const char *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o)
|
if (oc || of || os)
|
||||||
return 0;
|
return 0;
|
||||||
fprintf(stderr, "Unrecognized option '%s'\n", opt);
|
fprintf(stderr, "Unrecognized option '%s'\n", opt);
|
||||||
return AVERROR_OPTION_NOT_FOUND;
|
return AVERROR_OPTION_NOT_FOUND;
|
||||||
|
Reference in New Issue
Block a user