Make it accept an optional parameter, e.g. -help codecs/formats/... is possible.
Make -formats/-codecs/... options aliases for -help <...>. Remove -filters, which will be reused as an option for specifying filters. -help filters should be used instead. --- avconv.c | 5 +++-- avplay.c | 6 ++---- avprobe.c | 4 ++-- avserver.c | 3 ++- cmdutils.c | 32 +++++++++++++++++++++++++++----- cmdutils.h | 40 ++++++++++------------------------------ cmdutils_common_opts.h | 17 ++++++++--------- doc/fftools-common-opts.texi | 9 ++++----- ffmpeg.c | 5 +++-- 9 files changed, 61 insertions(+), 60 deletions(-) diff --git a/avconv.c b/avconv.c index 6804a3b..f67906d 100644 --- a/avconv.c +++ b/avconv.c @@ -3737,14 +3737,13 @@ static void show_usage(void) printf("\n"); } -static void show_help(void) +int show_help(const char *opt, const char *arg) { AVCodec *c; AVOutputFormat *oformat = NULL; AVInputFormat *iformat = NULL; const AVClass *class; - 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); @@ -3805,6 +3804,8 @@ static void show_help(void) class = sws_get_class(); av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); + + return 0; } static int opt_target(OptionsContext *o, const char *opt, const char *arg) diff --git a/avplay.c b/avplay.c index 198dce1..17ce476 100644 --- a/avplay.c +++ b/avplay.c @@ -216,8 +216,6 @@ typedef struct VideoState { int refresh; } VideoState; -static void show_help(void); - /* options specified by the user */ static AVInputFormat *file_iformat; static const char *input_filename; @@ -2977,10 +2975,9 @@ static void show_usage(void) printf("\n"); } -static void show_help(void) +int show_help(const char *opt, const char *arg) { const AVClass *class; - av_log_set_callback(log_callback_help); show_usage(); show_help_options(options, "Main options:\n", OPT_EXPERT, 0); @@ -3013,6 +3010,7 @@ static void show_help(void) "down/up seek backward/forward 1 minute\n" "mouse click seek to percentage in file corresponding to fraction of width\n" ); + return 0; } static void opt_input_file(void *optctx, const char *filename) diff --git a/avprobe.c b/avprobe.c index 5e83916..437a84a 100644 --- a/avprobe.c +++ b/avprobe.c @@ -358,15 +358,15 @@ static void opt_input_file(void *optctx, const char *arg) input_filename = arg; } -static void show_help(void) +int show_help(const char *opt, const char *arg) { const AVClass *class = avformat_get_class(); - av_log_set_callback(log_callback_help); show_usage(); show_help_options(options, "Main options:\n", 0, 0); printf("\n"); av_opt_show2(&class, NULL, AV_OPT_FLAG_DECODING_PARAM, 0); + return 0; } static void opt_pretty(void) diff --git a/avserver.c b/avserver.c index df9d07d..01ec139 100644 --- a/avserver.c +++ b/avserver.c @@ -4648,12 +4648,13 @@ static void opt_debug(void) logfilename[0] = '-'; } -static void show_help(void) +int show_help(const char *opt, const char *arg) { 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); + return 0; } static const OptionDef options[] = { diff --git a/cmdutils.c b/cmdutils.c index 52ec96f..98e7bbb 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -524,7 +524,7 @@ void show_license(void) ); } -void show_formats(void) +static void show_formats(void) { AVInputFormat *ifmt=NULL; AVOutputFormat *ofmt=NULL; @@ -573,7 +573,7 @@ void show_formats(void) } } -void show_codecs(void) +static void show_codecs(void) { AVCodec *p=NULL, *p2; const char *last_name; @@ -649,7 +649,7 @@ void show_codecs(void) "worse.\n"); } -void show_bsfs(void) +static void show_bsfs(void) { AVBitStreamFilter *bsf=NULL; @@ -659,7 +659,7 @@ void show_bsfs(void) printf("\n"); } -void show_protocols(void) +static void show_protocols(void) { void *opaque = NULL; const char *name; @@ -673,7 +673,7 @@ void show_protocols(void) printf("%s\n", name); } -void show_filters(void) +static void show_filters(void) { AVFilter av_unused(**filter) = NULL; @@ -717,6 +717,28 @@ void show_pix_fmts(void) } } +int show_help_common(const char *opt, const char *arg) +{ + av_log_set_callback(log_callback_help); + + if (!strcmp(opt, "codecs") || (arg && !strcmp(arg, "codecs"))) + show_codecs(); + else if (!strcmp(opt, "formats") || (arg && !strcmp(arg, "formats"))) + show_formats(); + else if (!strcmp(opt, "bsfs") || (arg && !strcmp(arg, "bsfs"))) + show_bsfs(); + else if (!strcmp(opt, "protocols") || (arg && !strcmp(arg, "protocols"))) + show_protocols(); + else if (!strcmp(opt, "pix_fmts") || (arg && !strcmp(arg, "pix_fmts"))) + show_pix_fmts(); + else if (arg && !strcmp(arg, "filters")) + show_filters(); + else + show_help(opt, arg); + + return 0; +} + int read_yesno(void) { int c = getchar(); diff --git a/cmdutils.h b/cmdutils.h index 989d769..845daa9 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -155,6 +155,16 @@ typedef struct { void show_help_options(const OptionDef *options, const char *msg, int mask, int value); /** + * Tool's own specific help function. + */ +int show_help(const char *opt, const char *arg); + +/* + * Common help function. + */ +int show_help_common(const char *opt, const char *arg); + +/** * Parse the command line arguments. * * @param optctx an opaque options context @@ -242,36 +252,6 @@ void show_version(void); void show_license(void); /** - * Print a listing containing all the formats supported by the - * program. - */ -void show_formats(void); - -/** - * Print a listing containing all the codecs supported by the - * program. - */ -void show_codecs(void); - -/** - * Print a listing containing all the filters supported by the - * program. - */ -void show_filters(void); - -/** - * Print a listing containing all the bit stream filters supported by the - * program. - */ -void show_bsfs(void); - -/** - * Print a listing containing all the protocols supported by the - * program. - */ -void show_protocols(void); - -/** * Print a listing containing all the pixel formats supported by the * program. */ diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h index 9b5e5d2..4957788 100644 --- a/cmdutils_common_opts.h +++ b/cmdutils_common_opts.h @@ -1,13 +1,12 @@ { "L", OPT_EXIT, {(void*)show_license}, "show license" }, - { "h", OPT_EXIT, {(void*)show_help}, "show help" }, + { "h", OPT_EXIT, {.func_arg = show_help_common}, "show help" }, { "?", OPT_EXIT, {(void*)show_help}, "show help" }, - { "help", OPT_EXIT, {(void*)show_help}, "show help" }, - { "-help", OPT_EXIT, {(void*)show_help}, "show help" }, + { "help", OPT_EXIT, {.func_arg = show_help_common}, "show help" }, + { "-help", OPT_EXIT, {.func_arg = show_help_common}, "show help" }, { "version", OPT_EXIT, {(void*)show_version}, "show version" }, - { "formats" , OPT_EXIT, {(void*)show_formats }, "show available formats" }, - { "codecs" , OPT_EXIT, {(void*)show_codecs }, "show available codecs" }, - { "bsfs" , OPT_EXIT, {(void*)show_bsfs }, "show available bit stream filters" }, - { "protocols", OPT_EXIT, {(void*)show_protocols}, "show available protocols" }, - { "filters", OPT_EXIT, {(void*)show_filters }, "show available filters" }, - { "pix_fmts" , OPT_EXIT, {(void*)show_pix_fmts }, "show available pixel formats" }, + { "formats" , OPT_EXIT, {.func_arg = show_help_common}, "show available formats" }, + { "codecs" , OPT_EXIT, {.func_arg = show_help_common}, "show available codecs" }, + { "bsfs" , OPT_EXIT, {.func_arg = show_help_common}, "show available bit stream filters" }, + { "protocols", OPT_EXIT, {.func_arg = show_help_common}, "show available protocols" }, + { "pix_fmts" , OPT_EXIT, {.func_arg = show_help_common}, "show available pixel formats" }, { "loglevel", HAS_ARG, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" }, diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi index 8ffc329..f003cc8 100644 --- a/doc/fftools-common-opts.texi +++ b/doc/fftools-common-opts.texi @@ -20,8 +20,10 @@ These options are shared amongst the ff* tools. @item -L Show license. -@item -h, -?, -help, --help -Show help. +@item -h, -?, -help, --help [@var{item}] +Show help. If @var{item} is specified, show help on it. +@var{item} may be one of @code{formats}, @code{codecs}, @code{bsfs}, +@code{protocols}, @code{filters}, @code{pix_fmts}. @item -version Show version. @@ -62,9 +64,6 @@ Show available bitstream filters. @item -protocols Show available protocols. -@item -filters -Show available libavfilter filters. - @item -pix_fmts Show available pixel formats. diff --git a/ffmpeg.c b/ffmpeg.c index a440b9d..1f49618 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3921,14 +3921,13 @@ static void show_usage(void) printf("\n"); } -static void show_help(void) +int show_help(const char *opt, const char *arg) { AVCodec *c; AVOutputFormat *oformat = NULL; AVInputFormat *iformat = NULL; const AVClass *class; - 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); @@ -3989,6 +3988,8 @@ static void show_help(void) class = sws_get_class(); av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); + + return 0; } static int opt_target(const char *opt, const char *arg) -- 1.7.5.4 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel