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

Stefano Sabatini stefasab at gmail.com
Tue Nov 27 01:11:11 CET 2012


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

> +{
> +    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.
-- 
FFmpeg = Fiendish and Friendly Mastering Puritan Epic Gnome


More information about the ffmpeg-devel mailing list