[FFmpeg-devel] [PATCH 1/8] options: handle options with the same name in codecs and formats.
Clément Bœsch
ubitux at gmail.com
Thu Jul 28 11:30:48 CEST 2011
On Thu, Jul 28, 2011 at 11:26:18AM +0200, Stefano Sabatini wrote:
> On date Wednesday 2011-07-27 18:45:11 +0200, Clément Bœsch encoded:
> > From: Clément Bœsch <clement.boesch at smartjog.com>
> >
> > ---
> > cmdutils.c | 18 +++++++++---------
> > 1 files changed, 9 insertions(+), 9 deletions(-)
> >
> > diff --git a/cmdutils.c b/cmdutils.c
> > index b323e91..247078c 100644
> > --- a/cmdutils.c
> > +++ b/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)
> > {
> > - const AVOption *o;
> > - if ((o = av_opt_find(avcodec_opts[0], opt, NULL, 0, AV_OPT_SEARCH_CHILDREN)) ||
> > + const AVOption *oc, *of, *os;
> > + if ((oc = av_opt_find(avcodec_opts[0], opt, NULL, 0, AV_OPT_SEARCH_CHILDREN)) ||
> > ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&
> > - (o = av_opt_find(avcodec_opts[0], opt+1, NULL, 0, 0))))
> > - av_dict_set(&codec_opts, opt, arg, FLAGS);
> > - else if ((o = av_opt_find(avformat_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN)))
> > - av_dict_set(&format_opts, opt, arg, FLAGS);
> > - else if ((o = av_opt_find(sws_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) {
> > + (oc = av_opt_find(avcodec_opts[0], opt+1, NULL, 0, 0))))
> > + av_dict_set(&codec_opts, opt, arg, FLAGS(oc));
> > + if ((of = av_opt_find(avformat_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN)))
> > + av_dict_set(&format_opts, opt, arg, FLAGS(of));
> > + if ((os = av_opt_find(sws_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) {
> > // XXX we only support sws_flags, not arbitrary sws options
> > int ret = av_set_string3(sws_opts, opt, arg, 1, NULL);
> > if (ret < 0) {
> > @@ -303,7 +303,7 @@ int opt_default(const char *opt, const char *arg)
> > }
> > }
> >
> > - if (o)
> > + if (oc || of || os)
> > return 0;
> > fprintf(stderr, "Unrecognized option '%s'\n", opt);
> > return AVERROR_OPTION_NOT_FOUND;
>
> Looks fine to me, but the commit message could be more explicative.
>
> What's exactly the problem which are you fixing?
I'm more specific in the 0-post: "-timecode option is added in the
mpeg12enc (lavc) and in some formats, so this allows the option to be
parsed in both". I can add a similar sentence in the patch description if
you want. Of course, without the next patches it doesn't make much sense.
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110728/33dab1ba/attachment.asc>
More information about the ffmpeg-devel
mailing list