[FFmpeg-devel] [PATCH 2/2] opt: print ranges in opt_list()

Michael Niedermayer michaelni at gmx.at
Tue Dec 4 20:42:53 CET 2012


On Tue, Nov 27, 2012 at 01:11:11AM +0100, Stefano Sabatini wrote:
> On date Sunday 2012-11-25 17:39:37 +0100, Michael Niedermayer encoded:
> > The formating can and should be improved.
> > 
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  libavutil/opt.c |   42 ++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 42 insertions(+)
> > 
> > diff --git a/libavutil/opt.c b/libavutil/opt.c
> > index d1825fd..800d96b 100644
> > --- a/libavutil/opt.c
> > +++ b/libavutil/opt.c
> > @@ -37,6 +37,8 @@
> >  #include "mathematics.h"
> >  #include "samplefmt.h"
> >  
> > +#include <float.h>
> > +
> >  #if FF_API_FIND_OPT
> >  //FIXME order them and do a bin search
> >  const AVOption *av_find_opt(void *v, const char *name, const char *unit, int mask, int flags)
> > @@ -609,10 +611,31 @@ int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
> >      return res & flag->default_val.i64;
> >  }
> >  
> > +static void print_value(void *av_log_obj, int level, double d)
> 
> nit: log_value since it is logging

fixed


> 
> > +{
> > +    if      (d == INT_MAX) {
> > +        av_log(av_log_obj, level, "INT_MAX");
> > +    } else if (d == INT_MIN) {
> > +        av_log(av_log_obj, level, "INT_MIN");
> > +    } else if (d == (double)INT64_MAX) {
> > +        av_log(av_log_obj, level, "I64_MAX");
> > +    } else if (d == INT64_MIN) {
> > +        av_log(av_log_obj, level, "I64_MIN");
> > +    } else if (d == FLT_MAX) {
> > +        av_log(av_log_obj, level, "FLT_MAX");
> > +    } else if (d == FLT_MIN) {
> > +        av_log(av_log_obj, level, "FLT_MIN");
> > +    } else {
> > +        av_log(av_log_obj, level, "%7.2g", d);
> > +    }
> > +}
> > +
> >  static void opt_list(void *obj, void *av_log_obj, const char *unit,
> >                       int req_flags, int rej_flags)
> >  {
> >      const AVOption *opt=NULL;
> > +    AVOptionRanges *r;
> > +    int i;
> >  
> >      while ((opt = av_opt_next(obj, opt))) {
> >          if (!(opt->flags & req_flags) || (opt->flags & rej_flags))
> > @@ -672,6 +695,25 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit,
> >                  av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "");
> >                  break;
> >          }
> > +        r = av_opt_query_ranges(obj, opt->name, 0);
> > +        if(r) {
> > +            switch (opt->type) {
> > +            case AV_OPT_TYPE_INT:
> > +            case AV_OPT_TYPE_INT64:
> > +            case AV_OPT_TYPE_DOUBLE:
> > +            case AV_OPT_TYPE_FLOAT:
> > +            case AV_OPT_TYPE_RATIONAL:
> > +                for (i=0; i<r->nb_ranges; i++) {
> > +                    print_value(av_log_obj, AV_LOG_INFO, r->range[i]->value[0].dbl);
> > +                    av_log(av_log_obj, AV_LOG_INFO, "-");
> > +                    print_value(av_log_obj, AV_LOG_INFO, r->range[i]->value[1].dbl);
> > +                    av_log(av_log_obj, AV_LOG_INFO, " ");
> > +                }
> > +                break;
> > +            }
> > +            av_opt_freep_ranges(&r);
> > +        }
> 
> Can you show the output? Also maybe enclosing MIN/MAX in [] (like
>  "[MIN - MAX]") may be more readable.

opt_list produces quite poor output prior to the patch, the alignment
is not correct:

amovie AVOptions:
-format_name       <string> ..F... set format name
-f                 <string> ..F... set format name
-streams           <string> ..F... set streams
-s                 <string> ..F... set streams
-si                <int>   ..F... set stream index
-stream_index      <int>   ..F... set stream index
-seek_point        <double> ..F... set seekpoint (seconds)
-sp                <double> ..F... set seekpoint (seconds)
-loop              <int>   ..F... set loop count

after the new patch that ill post in a moment this looks like this:

amovie AVOptions:
-format_name       <string> ..F... set format name
-f                 <string> ..F... set format name
-streams           <string> ..F... set streams
-s                 <string> ..F... set streams
-si                <int>   ..F...     -1-INT_MAX  set stream index
-stream_index      <int>   ..F...     -1-INT_MAX  set stream index
-seek_point        <double> ..F...      0-9.2e+12  set seekpoint (seconds)
-sp                <double> ..F...      0-9.2e+12  set seekpoint (seconds)
-loop              <int>   ..F...      0-INT_MAX  set loop count



[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- 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/20121204/57c78d06/attachment.asc>


More information about the ffmpeg-devel mailing list