[FFmpeg-devel] [PATCH 1/2] Move av_show_help_children() to avutil/opt

Michael Niedermayer michael at niedermayer.cc
Fri Nov 4 22:16:35 EET 2016


Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 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);
+
 /**
  * @}
  */
-- 
2.10.2



More information about the ffmpeg-devel mailing list