From patchwork Fri Nov 4 20:16:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 1298 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp12611vsb; Fri, 4 Nov 2016 13:16:59 -0700 (PDT) X-Received: by 10.28.175.77 with SMTP id y74mr115143wme.114.1478290619542; Fri, 04 Nov 2016 13:16:59 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ko7si17184424wjc.59.2016.11.04.13.16.58; Fri, 04 Nov 2016 13:16:59 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6C571689E24; Fri, 4 Nov 2016 22:16:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-3.mx.upcmail.net (vie01a-dmta-pe03-3.mx.upcmail.net [62.179.121.162]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 044AF689E07 for ; Fri, 4 Nov 2016 22:16:38 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1c2kun-0005o1-B5 for ffmpeg-devel@ffmpeg.org; Fri, 04 Nov 2016 21:16:41 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 3wGg1u00T0S5wYM01wGhlx; Fri, 04 Nov 2016 21:16:41 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 4 Nov 2016 21:16:35 +0100 Message-Id: <20161104201636.22631-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161104201636.22631-1-michael@niedermayer.cc> References: <20161104201636.22631-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 1/2] Move av_show_help_children() to avutil/opt X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Michael Niedermayer --- cmdutils.c | 20 ++++---------------- cmdutils.h | 5 ----- ffmpeg_opt.c | 10 +++++----- ffplay.c | 8 ++++---- ffprobe.c | 2 +- libavutil/opt.c | 12 ++++++++++++ libavutil/opt.h | 7 +++++++ 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 44fe64c..9f58b14 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -202,18 +202,6 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, printf("\n"); } -void show_help_children(const AVClass *class, int flags) -{ - const AVClass *child = NULL; - if (class->option) { - 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, ':'); @@ -1421,7 +1409,7 @@ static void print_codec(const AVCodec *c) 0, GET_CH_LAYOUT_DESC); if (c->priv_class) { - show_help_children(c->priv_class, + av_show_help_children(c->priv_class, AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_DECODING_PARAM); } @@ -1805,7 +1793,7 @@ static void show_help_demuxer(const char *name) printf(" Common extensions: %s.\n", fmt->extensions); if (fmt->priv_class) - show_help_children(fmt->priv_class, AV_OPT_FLAG_DECODING_PARAM); + av_show_help_children(fmt->priv_class, AV_OPT_FLAG_DECODING_PARAM); } static void show_help_muxer(const char *name) @@ -1838,7 +1826,7 @@ static void show_help_muxer(const char *name) } if (fmt->priv_class) - show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM); + av_show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM); } #if CONFIG_AVFILTER @@ -1886,7 +1874,7 @@ static void show_help_filter(const char *name) printf(" none (sink filter)\n"); if (f->priv_class) - show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | + av_show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM); if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) printf("This filter has support for timeline through the 'enable' option.\n"); diff --git a/cmdutils.h b/cmdutils.h index e75d8d3..38589cd 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -206,11 +206,6 @@ typedef struct OptionDef { void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags); -/** - * Show help for all options with given flags in class and all its - * children. - */ -void show_help_children(const AVClass *class, int flags); /** * Per-fftool specific help handler. Implemented in each diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 6346ecf..343453f 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -3101,13 +3101,13 @@ void show_help_default(const char *opt, const char *arg) if (show_avoptions) { int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM; - show_help_children(avcodec_get_class(), flags); - show_help_children(avformat_get_class(), flags); + av_show_help_children(avcodec_get_class(), flags); + av_show_help_children(avformat_get_class(), flags); #if CONFIG_SWSCALE - show_help_children(sws_get_class(), flags); + av_show_help_children(sws_get_class(), flags); #endif - show_help_children(swr_get_class(), AV_OPT_FLAG_AUDIO_PARAM); - show_help_children(avfilter_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM); + av_show_help_children(swr_get_class(), AV_OPT_FLAG_AUDIO_PARAM); + av_show_help_children(avfilter_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM); } } diff --git a/ffplay.c b/ffplay.c index 79dc768..6b83ba2 100644 --- a/ffplay.c +++ b/ffplay.c @@ -3617,12 +3617,12 @@ void show_help_default(const char *opt, const char *arg) show_help_options(options, "Main options:", 0, OPT_EXPERT, 0); show_help_options(options, "Advanced options:", OPT_EXPERT, 0, 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); + av_show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM); + av_show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); #if !CONFIG_AVFILTER - show_help_children(sws_get_class(), AV_OPT_FLAG_ENCODING_PARAM); + av_show_help_children(sws_get_class(), AV_OPT_FLAG_ENCODING_PARAM); #else - show_help_children(avfilter_get_class(), AV_OPT_FLAG_FILTERING_PARAM); + av_show_help_children(avfilter_get_class(), AV_OPT_FLAG_FILTERING_PARAM); #endif printf("\nWhile playing:\n" "q, ESC quit\n" diff --git a/ffprobe.c b/ffprobe.c index a2980b3..6492f6e 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -2979,7 +2979,7 @@ void show_help_default(const char *opt, const char *arg) show_help_options(options, "Main options:", 0, 0, 0); printf("\n"); - show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); + av_show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); } /** diff --git a/libavutil/opt.c b/libavutil/opt.c index cd16bd1..1b8dae2 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1992,3 +1992,15 @@ int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer, av_bprint_finalize(&bprint, buffer); return 0; } + +void av_show_help_children(const AVClass *class, int flags) +{ + const AVClass *child = NULL; + if (class->option) { + av_opt_show2(&class, NULL, flags, 0); + printf("\n"); + } + + while (child = av_opt_child_class_next(class, child)) + av_show_help_children(child, flags); +} diff --git a/libavutil/opt.h b/libavutil/opt.h index 9430b98..2379662 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -858,6 +858,13 @@ int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_fla */ int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer, const char key_val_sep, const char pairs_sep); + +/** + * Show help for all options with given flags in class and all its + * children. + */ +void av_show_help_children(const AVClass *class, int flags); + /** * @} */