diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-10-04 14:50:00 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2011-10-12 16:51:17 +0200 |
commit | 7a6cd9957de27cbc8a69510f3d11dffea31f7ad8 (patch) | |
tree | 6ad2d4175869d9f15a5e5789b98ea2a520cdf855 | |
parent | 145f741e115c75eac511e0ceb7a3c44585e871e3 (diff) | |
download | ffmpeg-streaming-7a6cd9957de27cbc8a69510f3d11dffea31f7ad8.zip ffmpeg-streaming-7a6cd9957de27cbc8a69510f3d11dffea31f7ad8.tar.gz |
cmdutils/avtools: simplify show_help() by using av_opt_child_class_next()
-rw-r--r-- | avconv.c | 44 | ||||
-rw-r--r-- | avplay.c | 15 | ||||
-rw-r--r-- | avprobe.c | 4 | ||||
-rw-r--r-- | cmdutils.c | 10 | ||||
-rw-r--r-- | cmdutils.h | 6 |
5 files changed, 24 insertions, 55 deletions
@@ -3676,11 +3676,7 @@ static void show_usage(void) static void show_help(void) { - AVCodec *c; - AVOutputFormat *oformat = NULL; - AVInputFormat *iformat = NULL; - const AVClass *class; - + 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", @@ -3707,41 +3703,9 @@ static void show_help(void) OPT_GRAB, OPT_GRAB); printf("\n"); - class = avcodec_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - - /* individual codec options */ - c = NULL; - while ((c = av_codec_next(c))) { - if (c->priv_class) { - av_opt_show2(&c->priv_class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - } - } - - class = avformat_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - - /* individual muxer options */ - while ((oformat = av_oformat_next(oformat))) { - if (oformat->priv_class) { - av_opt_show2(&oformat->priv_class, NULL, AV_OPT_FLAG_ENCODING_PARAM, 0); - printf("\n"); - } - } - - /* individual demuxer options */ - while ((iformat = av_iformat_next(iformat))) { - if (iformat->priv_class) { - av_opt_show2(&iformat->priv_class, NULL, AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - } - } - - class = sws_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); + show_help_children(avcodec_get_class(), flags); + show_help_children(avformat_get_class(), flags); + show_help_children(sws_get_class(), flags); } static int opt_target(OptionsContext *o, const char *opt, const char *arg) @@ -2996,7 +2996,6 @@ static void show_usage(void) static void show_help(void) { - const AVClass *class; av_log_set_callback(log_callback_help); show_usage(); show_help_options(options, "Main options:\n", @@ -3004,18 +3003,10 @@ static void show_help(void) show_help_options(options, "\nAdvanced options:\n", OPT_EXPERT, OPT_EXPERT); printf("\n"); - class = avcodec_get_class(); - av_opt_show2(&class, NULL, - AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - class = avformat_get_class(); - av_opt_show2(&class, NULL, - AV_OPT_FLAG_DECODING_PARAM, 0); + show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM); + show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); #if !CONFIG_AVFILTER - printf("\n"); - class = sws_get_class(); - av_opt_show2(&class, NULL, - AV_OPT_FLAG_ENCODING_PARAM, 0); + show_help_children(sws_get_class(), AV_OPT_FLAG_ENCODING_PARAM); #endif printf("\nWhile playing:\n" "q, ESC quit\n" @@ -360,13 +360,11 @@ static void opt_input_file(void *optctx, const char *arg) static void show_help(void) { - 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); + show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); } static void opt_pretty(void) @@ -130,6 +130,16 @@ void show_help_options(const OptionDef *options, const char *msg, int mask, int } } +void show_help_children(const AVClass *class, int flags) +{ + const AVClass *child = NULL; + av_opt_show2(&class, NULL, flags, 0); + printf("\n"); + + while (child = av_opt_child_class_next(class, child)) + show_help_children(child, flags); +} + static const OptionDef* find_option(const OptionDef *po, const char *name){ const char *p = strchr(name, ':'); int len = p ? p - name : strlen(name); @@ -155,6 +155,12 @@ typedef struct { void show_help_options(const OptionDef *options, const char *msg, int mask, int value); /** + * Show help for all options with given flags in class and all its + * children. + */ +void show_help_children(const AVClass *class, int flags); + +/** * Parse the command line arguments. * * @param optctx an opaque options context |