diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-11-25 20:38:54 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-12-08 04:34:28 +0400 |
commit | f4ceca6261bd076cd12b2557b9fa645cc49d56d2 (patch) | |
tree | 932bbdd958342f9f88622d6a6fe9d385a2c8fc64 /libavutil | |
parent | a8e0d51bb8141bbe64d4e22aec72742199208192 (diff) |
opt: print ranges in opt_list()
The formating can and should be improved.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/opt.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c index f060bd1a48..c416887ec2 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) @@ -733,10 +735,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 log_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)) @@ -803,6 +826,25 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM ) ? 'A' : '.'); av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.'); + if(av_opt_query_ranges(&r, obj, opt->name, AV_OPT_SEARCH_FAKE_OBJ) >= 0) { + 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++) { + av_log(av_log_obj, AV_LOG_INFO, "["); + log_value(av_log_obj, AV_LOG_INFO, r->range[i]->value_min); + av_log(av_log_obj, AV_LOG_INFO, ", "); + log_value(av_log_obj, AV_LOG_INFO, r->range[i]->value_max); + av_log(av_log_obj, AV_LOG_INFO, "]"); + } + break; + } + av_opt_freep_ranges(&r); + } + if (opt->help) av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help); av_log(av_log_obj, AV_LOG_INFO, "\n"); |