Message ID | BYAPR04MB52227F59091854D64B9D1534BA110@BYAPR04MB5222.namprd04.prod.outlook.com |
---|---|
State | Superseded, archived |
Headers | show |
Series | [FFmpeg-devel] Print out numeric values of option constants | expand |
Context | Check | Description |
---|---|---|
andriy/ffmpeg-patchwork | fail | Failed to apply patch |
On Tue, Feb 18, 2020 at 02:40:49 +0000, Soft Works wrote: > It's often not obvious how option constants relate to numerical values. > Defaults are sometimes printed as numbers and from/to are always printed as numbers. > Printing the numeric values of options constants avoids this confusion. > It also allows to see which constants are equivalent. Was this resent by accident? It was already pushed as 9e0a071edec93a7bd23f389fb1724ec6b43f8304 quite a long time ago. Moritz
> -----Original Message----- > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of > Moritz Barsnick > Sent: Tuesday, February 25, 2020 8:54 AM > To: FFmpeg development discussions and patches <ffmpeg- > devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] Print out numeric values of option > constants > > On Tue, Feb 18, 2020 at 02:40:49 +0000, Soft Works wrote: > > It's often not obvious how option constants relate to numerical values. > > Defaults are sometimes printed as numbers and from/to are always > printed as numbers. > > Printing the numeric values of options constants avoids this confusion. > > It also allows to see which constants are equivalent. > > Was this resent by accident? It was already pushed as > 9e0a071edec93a7bd23f389fb1724ec6b43f8304 > quite a long time ago. Apologies, I had looked at the wrong place when checking whether it has been merged.
diff --git a/libavutil/opt.c b/libavutil/opt.c index 93d6c26c11..ed90808d6d 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1102,7 +1102,7 @@ static char *get_opt_flags_string(void *obj, const char *unit, int64_t value) } static void opt_list(void *obj, void *av_log_obj, const char *unit, - int req_flags, int rej_flags) + int req_flags, int rej_flags, enum AVOptionType parent_type) { const AVOption *opt = NULL; AVOptionRanges *r; @@ -1182,6 +1182,11 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<boolean>"); break; case AV_OPT_TYPE_CONST: + if (parent_type == AV_OPT_TYPE_INT) + av_log(av_log_obj, AV_LOG_INFO, "%-12d ", opt->default_val.i64); + else + av_log(av_log_obj, AV_LOG_INFO, "%-12s ", ""); + break; default: av_log(av_log_obj, AV_LOG_INFO, "%-12s ", ""); break; @@ -1286,7 +1291,7 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, av_log(av_log_obj, AV_LOG_INFO, "\n"); if (opt->unit && opt->type != AV_OPT_TYPE_CONST) - opt_list(obj, av_log_obj, opt->unit, req_flags, rej_flags); + opt_list(obj, av_log_obj, opt->unit, req_flags, rej_flags, opt->type); } } @@ -1297,7 +1302,7 @@ int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags) av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass **)obj)->class_name); - opt_list(obj, av_log_obj, NULL, req_flags, rej_flags); + opt_list(obj, av_log_obj, NULL, req_flags, rej_flags, -1); return 0; }
It's often not obvious how option constants relate to numerical values. Defaults are sometimes printed as numbers and from/to are always printed as numbers. Printing the numeric values of options constants avoids this confusion. It also allows to see which constants are equivalent. Before this patch: -segment_list_type <int> E........ set the segment list type (from -1 to 4) (default -1) flat E........ flat format csv E........ csv format ext E........ extended format ffconcat E........ ffconcat format m3u8 E........ M3U8 format hls E........ Apple HTTP Live Streaming compatible Afterwards: -segment_list_type <int> E........ set the segment list type (from -1 to 4) (default -1) flat 0 E........ flat format csv 1 E........ csv format ext 3 E........ extended format ffconcat 4 E........ ffconcat format m3u8 2 E........ M3U8 format hls 2 E........ Apple HTTP Live Streaming compatible Signed-off-by: softworkz <softworkz@hotmail.com> --- libavutil/opt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)