[FFmpeg-devel] [PATCH]New option -hide_banner

Stefano Sabatini stefasab at gmail.com
Sat Dec 28 02:59:17 CET 2013


On date Saturday 2013-12-28 02:00:42 +0100, Carl Eugen Hoyos encoded:
> Hi!
> 
> Actual patch with an improved option-name and documentation update.
> 
> Please push if ok, Carl Eugen

> From 8b11c4f1d5d7b263da7477b805c78de92444fe81 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <cehoyos at minerva.hye>
> Date: Sat, 28 Dec 2013 02:54:00 +0100
> Subject: [PATCH] Allow hiding the banner.

nit: cmdutils: allow hiding the banner

> 
> Fixes ticket #3246.
> ---
>  cmdutils.c                   |   12 +++++++++++-
>  cmdutils.h                   |    2 ++
>  cmdutils_common_opts.h       |    1 +
>  doc/fftools-common-opts.texi |    2 ++
>  4 files changed, 16 insertions(+), 1 deletions(-)
> 
> diff --git a/cmdutils.c b/cmdutils.c
> index fc4b424..6b0b2d5 100644
> --- a/cmdutils.c
> +++ b/cmdutils.c
> @@ -66,6 +66,7 @@ AVDictionary *swr_opts;
>  AVDictionary *format_opts, *codec_opts, *resample_opts;
>  
>  static FILE *report_file;
> +static int hide_banner = 0;
>  
>  void init_opts(void)
>  {
> @@ -491,6 +492,9 @@ void parse_loglevel(int argc, char **argv, const OptionDef *options)
>              fflush(report_file);
>          }
>      }
> +    idx = locate_option(argc, argv, options, "hide_banner");
> +    if (idx && argv[idx + 1])
> +        opt_hide_banner(NULL, "hide_banner", argv[idx + 1]);
>  }
>  
>  static const AVOption *opt_find(void *obj, const char *name, const char *unit,
> @@ -816,6 +820,12 @@ int opt_cpuflags(void *optctx, const char *opt, const char *arg)
>      return 0;
>  }
>  

> +int opt_hide_banner(void *optctx, const char *opt, const char *arg)
> +{
> +    hide_banner = strtol(arg, NULL, 10);

strtol is unreliable, but read below

> +    return 0;
> +}
> +
>  int opt_loglevel(void *optctx, const char *opt, const char *arg)
>  {
>      const struct { const char *name; int level; } log_levels[] = {
> @@ -1083,7 +1093,7 @@ static void print_buildconf(int flags, int level)
>  void show_banner(int argc, char **argv, const OptionDef *options)
>  {
>      int idx = locate_option(argc, argv, options, "version");
> -    if (idx)
> +    if (hide_banner || idx)
>          return;
>  
>      print_program_info (INDENT|SHOW_COPYRIGHT, AV_LOG_INFO);
> diff --git a/cmdutils.h b/cmdutils.h
> index f4f23ef..d87e0f0 100644
> --- a/cmdutils.h
> +++ b/cmdutils.h
> @@ -92,6 +92,8 @@ int opt_default(void *optctx, const char *opt, const char *arg);
>   */
>  int opt_loglevel(void *optctx, const char *opt, const char *arg);
>  
> +int opt_hide_banner(void *optctx, const char *opt, const char *arg);
> +
>  int opt_report(const char *opt);
>  
>  int opt_max_alloc(void *optctx, const char *opt, const char *arg);
> diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h
> index 685163e..a2afe74 100644
> --- a/cmdutils_common_opts.h
> +++ b/cmdutils_common_opts.h
> @@ -21,6 +21,7 @@
>      { "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", HAS_ARG,  {.func_arg = opt_hide_banner},   "do not show program banner", "hide_banner" },

boolean?

>  #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" },
> diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
> index ff6478a..0b03b8d 100644
> --- a/doc/fftools-common-opts.texi
> +++ b/doc/fftools-common-opts.texi
> @@ -194,6 +194,8 @@ to a plain @code{%}
>  Errors in parsing the environment variable are not fatal, and will not
>  appear in the report.
>  

> + at item -hide_report
> +

Please extend this to a bare minimum.
-- 
FFmpeg = Fostering & Fast Magical Perennial Elastic Generator


More information about the ffmpeg-devel mailing list