Browse Source

Merge commit '122de16dd8108a59a55d30543c9f28b5f61b02d1'

* commit '122de16dd8108a59a55d30543c9f28b5f61b02d1':
  Replace cmdutils_common_opts.h by a macro

Merged-by: Clément Bœsch <cboesch@gopro.com>
Clément Bœsch 7 years ago
parent
commit
b010843594
8 changed files with 58 additions and 45 deletions
  1. 1 2
      Makefile
  2. 53 0
      cmdutils.h
  3. 0 37
      cmdutils_common_opts.h
  4. 1 1
      ffmpeg_opt.c
  5. 1 1
      ffplay.c
  6. 1 1
      ffprobe.c
  7. 1 1
      ffserver.c
  8. 0 2
      tests/ref/fate/source

+ 1 - 2
Makefile

@@ -59,8 +59,7 @@ FFLIBS := avutil
 DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
 EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
 
-SKIPHEADERS = cmdutils_common_opts.h                                    \
-              compat/w32pthreads.h
+SKIPHEADERS = compat/w32pthreads.h
 
 # first so "all" becomes default target
 all: all-yes

+ 53 - 0
cmdutils.h

@@ -206,6 +206,59 @@ typedef struct OptionDef {
 void show_help_options(const OptionDef *options, const char *msg, int req_flags,
                        int rej_flags, int alt_flags);
 
+#if CONFIG_OPENCL
+#define CMDUTILS_COMMON_OPTIONS_OPENCL                                                                                  \
+    { "opencl_bench", OPT_EXIT, {.func_arg = opt_opencl_bench},                                                         \
+       "run benchmark on all OpenCL devices and show results" },                                                        \
+    { "opencl_options", HAS_ARG, {.func_arg = opt_opencl},                                                              \
+       "set OpenCL environment options" },                                                                              \
+
+#else
+#define CMDUTILS_COMMON_OPTIONS_OPENCL
+#endif
+
+#if CONFIG_AVDEVICE
+#define CMDUTILS_COMMON_OPTIONS_AVDEVICE                                                                                \
+    { "sources"    , OPT_EXIT | HAS_ARG, { .func_arg = show_sources },                                                  \
+      "list sources of the input device", "device" },                                                                   \
+    { "sinks"      , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks },                                                    \
+      "list sinks of the output device", "device" },                                                                    \
+
+#else
+#define CMDUTILS_COMMON_OPTIONS_AVDEVICE
+#endif
+
+#define CMDUTILS_COMMON_OPTIONS                                                                                         \
+    { "L",           OPT_EXIT,             { .func_arg = show_license },     "show license" },                          \
+    { "h",           OPT_EXIT,             { .func_arg = show_help },        "show help", "topic" },                    \
+    { "?",           OPT_EXIT,             { .func_arg = show_help },        "show help", "topic" },                    \
+    { "help",        OPT_EXIT,             { .func_arg = show_help },        "show help", "topic" },                    \
+    { "-help",       OPT_EXIT,             { .func_arg = show_help },        "show help", "topic" },                    \
+    { "version",     OPT_EXIT,             { .func_arg = show_version },     "show version" },                          \
+    { "buildconf",   OPT_EXIT,             { .func_arg = show_buildconf },   "show build configuration" },              \
+    { "formats",     OPT_EXIT,             { .func_arg = show_formats },     "show available formats" },                \
+    { "muxers",      OPT_EXIT,             { .func_arg = show_muxers },      "show available muxers" },                 \
+    { "demuxers",    OPT_EXIT,             { .func_arg = show_demuxers },    "show available demuxers" },               \
+    { "devices",     OPT_EXIT,             { .func_arg = show_devices },     "show available devices" },                \
+    { "codecs",      OPT_EXIT,             { .func_arg = show_codecs },      "show available codecs" },                 \
+    { "decoders",    OPT_EXIT,             { .func_arg = show_decoders },    "show available decoders" },               \
+    { "encoders",    OPT_EXIT,             { .func_arg = show_encoders },    "show available encoders" },               \
+    { "bsfs",        OPT_EXIT,             { .func_arg = show_bsfs },        "show available bit stream filters" },     \
+    { "protocols",   OPT_EXIT,             { .func_arg = show_protocols },   "show available protocols" },              \
+    { "filters",     OPT_EXIT,             { .func_arg = show_filters },     "show available filters" },                \
+    { "pix_fmts",    OPT_EXIT,             { .func_arg = show_pix_fmts },    "show available pixel formats" },          \
+    { "layouts",     OPT_EXIT,             { .func_arg = show_layouts },     "show standard channel layouts" },         \
+    { "sample_fmts", OPT_EXIT,             { .func_arg = show_sample_fmts }, "show available audio sample formats" },   \
+    { "colors",      OPT_EXIT,             { .func_arg = show_colors },      "show available color names" },            \
+    { "loglevel",    HAS_ARG,              { .func_arg = opt_loglevel },     "set logging level", "loglevel" },         \
+    { "v",           HAS_ARG,              { .func_arg = opt_loglevel },     "set logging level", "loglevel" },         \
+    { "report",      0,                    { (void*)opt_report },            "generate a report" },                     \
+    { "max_alloc",   HAS_ARG,              { .func_arg = opt_max_alloc },    "set maximum size of a single allocated block", "bytes" }, \
+    { "cpuflags",    HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags },     "force specific cpu flags", "flags" },     \
+    { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner},     "do not show program banner", "hide_banner" },          \
+    CMDUTILS_COMMON_OPTIONS_OPENCL                                                                                      \
+    CMDUTILS_COMMON_OPTIONS_AVDEVICE                                                                                    \
+
 /**
  * Show help for all options with given flags in class and all its
  * children.

+ 0 - 37
cmdutils_common_opts.h

@@ -1,37 +0,0 @@
-    { "L"          , OPT_EXIT, {.func_arg = show_license},      "show license" },
-    { "h"          , OPT_EXIT, {.func_arg = show_help},         "show help", "topic" },
-    { "?"          , OPT_EXIT, {.func_arg = show_help},         "show help", "topic" },
-    { "help"       , OPT_EXIT, {.func_arg = show_help},         "show help", "topic" },
-    { "-help"      , OPT_EXIT, {.func_arg = show_help},         "show help", "topic" },
-    { "version"    , OPT_EXIT, {.func_arg = show_version},      "show version" },
-    { "buildconf"  , OPT_EXIT, {.func_arg = show_buildconf},    "show build configuration" },
-    { "formats"    , OPT_EXIT, {.func_arg = show_formats  },    "show available formats" },
-    { "muxers"     , OPT_EXIT, {.func_arg = show_muxers   },    "show available muxers" },
-    { "demuxers"   , OPT_EXIT, {.func_arg = show_demuxers },    "show available demuxers" },
-    { "devices"    , OPT_EXIT, {.func_arg = show_devices  },    "show available devices" },
-    { "codecs"     , OPT_EXIT, {.func_arg = show_codecs   },    "show available codecs" },
-    { "decoders"   , OPT_EXIT, {.func_arg = show_decoders },    "show available decoders" },
-    { "encoders"   , OPT_EXIT, {.func_arg = show_encoders },    "show available encoders" },
-    { "bsfs"       , OPT_EXIT, {.func_arg = show_bsfs     },    "show available bit stream filters" },
-    { "protocols"  , OPT_EXIT, {.func_arg = show_protocols},    "show available protocols" },
-    { "filters"    , OPT_EXIT, {.func_arg = show_filters  },    "show available filters" },
-    { "pix_fmts"   , OPT_EXIT, {.func_arg = show_pix_fmts },    "show available pixel formats" },
-    { "layouts"    , OPT_EXIT, {.func_arg = show_layouts  },    "show standard channel layouts" },
-    { "sample_fmts", OPT_EXIT, {.func_arg = show_sample_fmts }, "show available audio sample formats" },
-    { "colors"     , OPT_EXIT, {.func_arg = show_colors },      "show available color names" },
-    { "loglevel"   , HAS_ARG,  {.func_arg = opt_loglevel},      "set logging level", "loglevel" },
-    { "v",           HAS_ARG,  {.func_arg = opt_loglevel},      "set logging level", "loglevel" },
-    { "report"     , 0,        {(void*)opt_report}, "generate a report" },
-    { "max_alloc"  , HAS_ARG,  {.func_arg = opt_max_alloc},     "set maximum size of a single allocated block", "bytes" },
-    { "cpuflags"   , HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" },
-    { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner},     "do not show program banner", "hide_banner" },
-#if CONFIG_OPENCL
-    { "opencl_bench", OPT_EXIT, {.func_arg = opt_opencl_bench}, "run benchmark on all OpenCL devices and show results" },
-    { "opencl_options", HAS_ARG, {.func_arg = opt_opencl},      "set OpenCL environment options" },
-#endif
-#if CONFIG_AVDEVICE
-    { "sources"    , OPT_EXIT | HAS_ARG, { .func_arg = show_sources },
-      "list sources of the input device", "device" },
-    { "sinks"      , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks },
-      "list sinks of the output device", "device" },
-#endif

+ 1 - 1
ffmpeg_opt.c

@@ -3291,7 +3291,7 @@ static int opt_progress(void *optctx, const char *opt, const char *arg)
 #define OFFSET(x) offsetof(OptionsContext, x)
 const OptionDef options[] = {
     /* main options */
-#include "cmdutils_common_opts.h"
+    CMDUTILS_COMMON_OPTIONS
     { "f",              HAS_ARG | OPT_STRING | OPT_OFFSET |
                         OPT_INPUT | OPT_OUTPUT,                      { .off       = OFFSET(format) },
         "force format", "fmt" },

+ 1 - 1
ffplay.c

@@ -3512,7 +3512,7 @@ static int opt_codec(void *optctx, const char *opt, const char *arg)
 static int dummy;
 
 static const OptionDef options[] = {
-#include "cmdutils_common_opts.h"
+    CMDUTILS_COMMON_OPTIONS
     { "x", HAS_ARG, { .func_arg = opt_width }, "force displayed width", "width" },
     { "y", HAS_ARG, { .func_arg = opt_height }, "force displayed height", "height" },
     { "s", HAS_ARG | OPT_VIDEO, { .func_arg = opt_frame_size }, "set frame size (WxH or abbreviation)", "size" },

+ 1 - 1
ffprobe.c

@@ -3379,7 +3379,7 @@ DEFINE_OPT_SHOW_SECTION(streams,          STREAMS)
 DEFINE_OPT_SHOW_SECTION(programs,         PROGRAMS)
 
 static const OptionDef real_options[] = {
-#include "cmdutils_common_opts.h"
+    CMDUTILS_COMMON_OPTIONS
     { "f", HAS_ARG, {.func_arg = opt_format}, "force format", "format" },
     { "unit", OPT_BOOL, {&show_value_unit}, "show unit of the displayed values" },
     { "prefix", OPT_BOOL, {&use_value_prefix}, "use SI prefixes for the displayed values" },

+ 1 - 1
ffserver.c

@@ -3950,7 +3950,7 @@ void show_help_default(const char *opt, const char *arg)
 }
 
 static const OptionDef options[] = {
-#include "cmdutils_common_opts.h"
+    CMDUTILS_COMMON_OPTIONS
     { "n", OPT_BOOL, {(void *)&no_launch }, "enable no-launch mode" },
     { "d", 0, {(void*)opt_debug}, "enable debug mode" },
     { "f", HAS_ARG | OPT_STRING, {(void*)&config.filename }, "use configfile instead of /etc/ffserver.conf", "configfile" },

+ 0 - 2
tests/ref/fate/source

@@ -1,5 +1,4 @@
 Files without standard license headers:
-cmdutils_common_opts.h
 compat/avisynth/windowsPorts/basicDataTypeConversions.h
 compat/avisynth/windowsPorts/windows2linux.h
 libavcodec/file_open.c
@@ -16,7 +15,6 @@ libswscale/log2_tab.c
 tools/uncoded_frame.c
 tools/yuvcmp.c
 Headers without standard inclusion guards:
-cmdutils_common_opts.h
 compat/avisynth/avisynth_c.h
 compat/avisynth/avs/capi.h
 compat/avisynth/avs/config.h