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

Michael Niedermayer michaelni at gmx.at
Sun Nov 25 17:39:37 CET 2012


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)
+{
+    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);
+        }
+
         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.');
         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.');
         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_FILTERING_PARAM)? 'F' : '.');
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list