From 79600a83543afd7c485e30e1e9958765aadf7882 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 11 Aug 2012 19:19:53 +0200 Subject: [PATCH 1/3] avconv: deprecate -isync. This option does not do anything. Also remove OPT_GRAB, since -isync is the last option using it. --- avconv_opt.c | 20 ++++++++------------ cmdutils.h | 1 - doc/avconv.texi | 7 ------- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/avconv_opt.c b/avconv_opt.c index e133278582..295cc27ba3 100644 --- a/avconv_opt.c +++ b/avconv_opt.c @@ -1795,28 +1795,24 @@ static int show_help(const char *opt, const char *arg) av_log_set_callback(log_callback_help); show_usage(); show_help_options(options, "Main options:\n", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE | OPT_GRAB, 0); + OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, 0); show_help_options(options, "\nAdvanced options:\n", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE | OPT_GRAB, + OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, OPT_EXPERT); show_help_options(options, "\nVideo options:\n", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB, + OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, OPT_VIDEO); show_help_options(options, "\nAdvanced Video options:\n", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB, + OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, OPT_VIDEO | OPT_EXPERT); show_help_options(options, "\nAudio options:\n", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB, + OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, OPT_AUDIO); show_help_options(options, "\nAdvanced Audio options:\n", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB, + OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, OPT_AUDIO | OPT_EXPERT); show_help_options(options, "\nSubtitle options:\n", - OPT_SUBTITLE | OPT_GRAB, - OPT_SUBTITLE); - show_help_options(options, "\nAudio/Video grab options:\n", - OPT_GRAB, - OPT_GRAB); + OPT_SUBTITLE, OPT_SUBTITLE); printf("\n"); show_help_children(avcodec_get_class(), flags); show_help_children(avformat_get_class(), flags); @@ -2008,7 +2004,7 @@ const OptionDef options[] = { , "force subtitle tag/fourcc", "fourcc/tag" }, /* grab options */ - { "isync", OPT_BOOL | OPT_EXPERT | OPT_GRAB, { &input_sync }, "sync read on input", "" }, + { "isync", OPT_BOOL | OPT_EXPERT, { &input_sync }, "this option is deprecated and does nothing", "" }, /* muxer options */ { "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, { .off = OFFSET(mux_max_delay) }, diff --git a/cmdutils.h b/cmdutils.h index a02d19d3be..6fb5a35093 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -130,7 +130,6 @@ typedef struct { #define OPT_STRING 0x0008 #define OPT_VIDEO 0x0010 #define OPT_AUDIO 0x0020 -#define OPT_GRAB 0x0040 #define OPT_INT 0x0080 #define OPT_FLOAT 0x0100 #define OPT_SUBTITLE 0x0200 diff --git a/doc/avconv.texi b/doc/avconv.texi index fc6402820b..9f06ddfeb2 100644 --- a/doc/avconv.texi +++ b/doc/avconv.texi @@ -595,13 +595,6 @@ Set the subtitle codec. This is an alias for @code{-codec:s}. Disable subtitle recording. @end table -@section Audio/Video grab options - -@table @option -@item -isync (@emph{global}) -Synchronize read on input. -@end table - @section Advanced options @table @option From dc4c24a3d35603957aecf2b075ac25902d18a190 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 11 Aug 2012 19:33:27 +0200 Subject: [PATCH 2/3] avtools: move some newlines to show_help_options(). Don't require every caller to supply them. --- avconv_opt.c | 14 +++++++------- avplay.c | 4 ++-- avprobe.c | 2 +- avserver.c | 2 +- cmdutils.c | 3 ++- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/avconv_opt.c b/avconv_opt.c index 295cc27ba3..8915a865c9 100644 --- a/avconv_opt.c +++ b/avconv_opt.c @@ -1794,24 +1794,24 @@ static int show_help(const char *opt, const char *arg) int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM; av_log_set_callback(log_callback_help); show_usage(); - show_help_options(options, "Main options:\n", + show_help_options(options, "Main options:", OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, 0); - show_help_options(options, "\nAdvanced options:\n", + show_help_options(options, "Advanced options:", OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, OPT_EXPERT); - show_help_options(options, "\nVideo options:\n", + show_help_options(options, "Video options:", OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, OPT_VIDEO); - show_help_options(options, "\nAdvanced Video options:\n", + show_help_options(options, "Advanced Video options:", OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, OPT_VIDEO | OPT_EXPERT); - show_help_options(options, "\nAudio options:\n", + show_help_options(options, "Audio options:", OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, OPT_AUDIO); - show_help_options(options, "\nAdvanced Audio options:\n", + show_help_options(options, "Advanced Audio options:", OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, OPT_AUDIO | OPT_EXPERT); - show_help_options(options, "\nSubtitle options:\n", + show_help_options(options, "Subtitle options:", OPT_SUBTITLE, OPT_SUBTITLE); printf("\n"); show_help_children(avcodec_get_class(), flags); diff --git a/avplay.c b/avplay.c index 593b38af66..bb10810492 100644 --- a/avplay.c +++ b/avplay.c @@ -2926,9 +2926,9 @@ static int show_help(const char *opt, const char *arg) { av_log_set_callback(log_callback_help); show_usage(); - show_help_options(options, "Main options:\n", + show_help_options(options, "Main options:", OPT_EXPERT, 0); - show_help_options(options, "\nAdvanced options:\n", + show_help_options(options, "Advanced options:", OPT_EXPERT, OPT_EXPERT); printf("\n"); show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM); diff --git a/avprobe.c b/avprobe.c index 996a138576..0116acb005 100644 --- a/avprobe.c +++ b/avprobe.c @@ -872,7 +872,7 @@ static int show_help(const char *opt, const char *arg) { av_log_set_callback(log_callback_help); show_usage(); - show_help_options(options, "Main options:\n", 0, 0); + show_help_options(options, "Main options:", 0, 0); printf("\n"); show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); return 0; diff --git a/avserver.c b/avserver.c index fabdd32b02..de050a6cce 100644 --- a/avserver.c +++ b/avserver.c @@ -4634,7 +4634,7 @@ static void show_help(void) printf("usage: avserver [options]\n" "Hyper fast multi format Audio/Video streaming server\n"); printf("\n"); - show_help_options(options, "Main options:\n", 0, 0); + show_help_options(options, "Main options:", 0, 0); } static const OptionDef options[] = { diff --git a/cmdutils.c b/cmdutils.c index 3b8ab3f44b..51077449b7 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -124,7 +124,7 @@ void show_help_options(const OptionDef *options, const char *msg, int mask, char buf[64]; if ((po->flags & mask) == value) { if (first) { - printf("%s", msg); + printf("%s\n", msg); first = 0; } av_strlcpy(buf, po->name, sizeof(buf)); @@ -135,6 +135,7 @@ void show_help_options(const OptionDef *options, const char *msg, int mask, printf("-%-17s %s\n", buf, po->help); } } + printf("\n"); } void show_help_children(const AVClass *class, int flags) From 7c5012127fb7e18f0616011257bb4248f6a8b608 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 11 Aug 2012 19:45:30 +0200 Subject: [PATCH 3/3] cmdutils: change semantics of show_help_options() and document it. Currently it takes a mask and value, such that options for which (flags & mask) == value. Change it to take required flags and forbidden flags instead. This is shorter and simpler to understand. --- avconv_opt.c | 19 +++++++------------ avplay.c | 6 ++---- cmdutils.c | 29 ++++++++++++++++------------- cmdutils.h | 12 ++++++++++-- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/avconv_opt.c b/avconv_opt.c index 8915a865c9..ac1a65ecfb 100644 --- a/avconv_opt.c +++ b/avconv_opt.c @@ -1795,24 +1795,19 @@ static int show_help(const char *opt, const char *arg) av_log_set_callback(log_callback_help); show_usage(); show_help_options(options, "Main options:", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, 0); + 0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE); show_help_options(options, "Advanced options:", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, - OPT_EXPERT); + OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE); show_help_options(options, "Video options:", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, - OPT_VIDEO); + OPT_VIDEO, OPT_EXPERT | OPT_AUDIO); show_help_options(options, "Advanced Video options:", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, - OPT_VIDEO | OPT_EXPERT); + OPT_EXPERT | OPT_VIDEO, OPT_AUDIO); show_help_options(options, "Audio options:", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, - OPT_AUDIO); + OPT_AUDIO, OPT_EXPERT | OPT_VIDEO); show_help_options(options, "Advanced Audio options:", - OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, - OPT_AUDIO | OPT_EXPERT); + OPT_EXPERT | OPT_AUDIO, OPT_VIDEO); show_help_options(options, "Subtitle options:", - OPT_SUBTITLE, OPT_SUBTITLE); + OPT_SUBTITLE, 0); printf("\n"); show_help_children(avcodec_get_class(), flags); show_help_children(avformat_get_class(), flags); diff --git a/avplay.c b/avplay.c index bb10810492..64d7b3da33 100644 --- a/avplay.c +++ b/avplay.c @@ -2926,10 +2926,8 @@ static int show_help(const char *opt, const char *arg) { av_log_set_callback(log_callback_help); show_usage(); - show_help_options(options, "Main options:", - OPT_EXPERT, 0); - show_help_options(options, "Advanced options:", - OPT_EXPERT, OPT_EXPERT); + show_help_options(options, "Main options:", 0, OPT_EXPERT); + show_help_options(options, "Advanced options:", OPT_EXPERT, 0); printf("\n"); show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM); show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); diff --git a/cmdutils.c b/cmdutils.c index 51077449b7..bc5cb8aae2 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -113,8 +113,8 @@ int64_t parse_time_or_die(const char *context, const char *timestr, return us; } -void show_help_options(const OptionDef *options, const char *msg, int mask, - int value) +void show_help_options(const OptionDef *options, const char *msg, int req_flags, + int rej_flags) { const OptionDef *po; int first; @@ -122,18 +122,21 @@ void show_help_options(const OptionDef *options, const char *msg, int mask, first = 1; for (po = options; po->name != NULL; po++) { char buf[64]; - if ((po->flags & mask) == value) { - if (first) { - printf("%s\n", msg); - first = 0; - } - av_strlcpy(buf, po->name, sizeof(buf)); - if (po->flags & HAS_ARG) { - av_strlcat(buf, " ", sizeof(buf)); - av_strlcat(buf, po->argname, sizeof(buf)); - } - printf("-%-17s %s\n", buf, po->help); + + if (((po->flags & req_flags) != req_flags) || + (po->flags & rej_flags)) + continue; + + if (first) { + printf("%s\n", msg); + first = 0; } + av_strlcpy(buf, po->name, sizeof(buf)); + if (po->flags & HAS_ARG) { + av_strlcat(buf, " ", sizeof(buf)); + av_strlcat(buf, po->argname, sizeof(buf)); + } + printf("-%-17s %s\n", buf, po->help); } printf("\n"); } diff --git a/cmdutils.h b/cmdutils.h index 6fb5a35093..eb8a22a003 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -153,8 +153,16 @@ typedef struct { const char *argname; } OptionDef; -void show_help_options(const OptionDef *options, const char *msg, int mask, - int value); +/** + * Print help for all options matching specified flags. + * + * @param options a list of options + * @param msg title of this group. Only printed if at least one option matches. + * @param req_flags print only options which have all those flags set. + * @param rej_flags don't print options which have any of those flags set. + */ +void show_help_options(const OptionDef *options, const char *msg, int req_flags, + int rej_flags); /** * Show help for all options with given flags in class and all its