diff options
author | Clément Bœsch <u@pkh.me> | 2015-10-24 15:14:33 +0200 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2015-10-25 22:47:16 +0100 |
commit | 6b5412cbfa557f7e741293ec69c81eaad5e24def (patch) | |
tree | 0d8cbe193c582a16f3db826f8650fb3d3a2b6fc1 /libavutil/opt.c | |
parent | 559603dae1f67b851cea52cbfc0525bf8fa6b8c2 (diff) | |
download | ffmpeg-6b5412cbfa557f7e741293ec69c81eaad5e24def.tar.gz |
avutil/opt: print more meaningful default flags values
Example:
% ./ffmpeg -h encoder=gif
[...]
GIF encoder AVOptions:
-gifflags <flags> E..V.... set GIF flags (default offsetting+transdiff)
offsetting E..V.... enable picture offsetting
transdiff E..V.... enable transparency detection between frames
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r-- | libavutil/opt.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c index 36eeeb09e2..da1eb1647f 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -941,6 +941,27 @@ static const char *get_opt_const_name(void *obj, const char *unit, int64_t value return NULL; } +static char *get_opt_flags_string(void *obj, const char *unit, int64_t value) +{ + const AVOption *opt = NULL; + char flags[512]; + + flags[0] = 0; + if (!unit) + return NULL; + while ((opt = av_opt_next(obj, opt))) { + if (opt->type == AV_OPT_TYPE_CONST && !strcmp(opt->unit, unit) && + opt->default_val.i64 & value) { + if (flags[0]) + av_strlcatf(flags, sizeof(flags), "+"); + av_strlcatf(flags, sizeof(flags), "%s", opt->name); + } + } + if (flags[0]) + return av_strdup(flags); + return NULL; +} + static void opt_list(void *obj, void *av_log_obj, const char *unit, int req_flags, int rej_flags) { @@ -1066,9 +1087,16 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, case AV_OPT_TYPE_BOOL: av_log(av_log_obj, AV_LOG_INFO, "%s", (char *)av_x_if_null(get_bool_name(opt->default_val.i64), "invalid")); break; - case AV_OPT_TYPE_FLAGS: - av_log(av_log_obj, AV_LOG_INFO, "%"PRIX64, opt->default_val.i64); + case AV_OPT_TYPE_FLAGS: { + char *def_flags = get_opt_flags_string(obj, opt->unit, opt->default_val.i64); + if (def_flags) { + av_log(av_log_obj, AV_LOG_INFO, "%s", def_flags); + av_freep(&def_flags); + } else { + av_log(av_log_obj, AV_LOG_INFO, "%"PRIX64, opt->default_val.i64); + } break; + } case AV_OPT_TYPE_DURATION: log_value(av_log_obj, AV_LOG_INFO, opt->default_val.i64); break; |