[FFmpeg-devel] [PATCH] cmdutils: apply option to codec and format contexts if possible.

Michael Niedermayer michaelni at gmx.at
Thu Oct 18 10:33:33 CEST 2012


On Thu, Oct 18, 2012 at 09:58:39AM +0200, Clément Bœsch wrote:
> On Thu, Oct 18, 2012 at 02:20:58AM +0200, Michael Niedermayer wrote:
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  cmdutils.c |   19 +++++++++++++------
> >  1 file changed, 13 insertions(+), 6 deletions(-)
> > 
> > diff --git a/cmdutils.c b/cmdutils.c
> > index 0163faf..40b6c31 100644
> > --- a/cmdutils.c
> > +++ b/cmdutils.c
> > @@ -436,6 +436,7 @@ void parse_loglevel(int argc, char **argv, const OptionDef *options)
> >  int opt_default(void *optctx, const char *opt, const char *arg)
> >  {
> >      const AVOption *o;
> > +    int consumed = 0;
> >      char opt_stripped[128];
> >      const char *p;
> >      const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(), *sc, *swr_class;
> > @@ -447,14 +448,18 @@ int opt_default(void *optctx, const char *opt, const char *arg)
> >      if ((o = av_opt_find(&cc, opt_stripped, NULL, 0,
> >                           AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) ||
> >          ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&
> > -         (o = av_opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ))))
> > +         (o = av_opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) {
> >          av_dict_set(&codec_opts, opt, arg, FLAGS);
> > -    else if ((o = av_opt_find(&fc, opt, NULL, 0,
> > -                              AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)))
> > +        consumed = 1;
> > +    }
> > +    if ((o = av_opt_find(&fc, opt, NULL, 0,
> > +                              AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
> >          av_dict_set(&format_opts, opt, arg, FLAGS);
> > +        consumed = 1;
> > +    }
> >  #if CONFIG_SWSCALE
> >      sc = sws_get_class();
> > -    if (!o && (o = av_opt_find(&sc, opt, NULL, 0,
> > +    if (!consumed && (o = av_opt_find(&sc, opt, NULL, 0,
> >                           AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
> >          // XXX we only support sws_flags, not arbitrary sws options
> >          int ret = av_opt_set(sws_opts, opt, arg, 0);
> > @@ -462,21 +467,23 @@ int opt_default(void *optctx, const char *opt, const char *arg)
> >              av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
> >              return ret;
> >          }
> > +        consumed = 1;
> >      }
> >  #endif
> >  #if CONFIG_SWRESAMPLE
> >      swr_class = swr_get_class();
> > -    if (!o && (o = av_opt_find(&swr_class, opt, NULL, 0,
> > +    if (!consumed && (o = av_opt_find(&swr_class, opt, NULL, 0,
> >                                 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
> >          int ret = av_opt_set(swr_opts, opt, arg, 0);
> >          if (ret < 0) {
> >              av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
> >              return ret;
> >          }
> > +        consumed = 1;
> >      }
> >  #endif
> >  
> > -    if (o)
> > +    if (consumed)
> >          return 0;
> >      av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt);
> >      return AVERROR_OPTION_NOT_FOUND;
> 
> Reminds me the timecode thing, which I finally reverted after making in
> distinction between the them; so what is the common
> formats/codecs/whatever options namespace clash this time?

-err_detect

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121018/c558f133/attachment.asc>


More information about the ffmpeg-devel mailing list