[FFmpeg-devel] [PATCH 1/2] cmdutils: add -layouts option.

Stefano Sabatini stefasab at gmail.com
Mon Aug 27 10:26:09 CEST 2012


On date Saturday 2012-08-25 21:06:08 +0200, Nicolas George encoded:
> Extract of the output:
> 
> | Individual channels:
> | NAME        DESCRIPTION
> | FL          front left
> | FR          front right
> | <snip>
> | SDR         surround direct right
> |
> | Standard channel layouts:
> | NAME        DECOMPOSITION
> | mono        FC
> | stereo      FL+FR
> | <snip>
> | octagonal   FL+FR+FC+BL+BR+BC+SL+SR
> | downmix     DL+DR
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  cmdutils.c                   |   29 +++++++++++++++++++++++++++++
>  cmdutils.h                   |    7 +++++++
>  cmdutils_common_opts.h       |    1 +
>  doc/avtools-common-opts.texi |    3 +++
>  4 files changed, 40 insertions(+)
> 
> 

> Rebased and adapted to the new API. Still a single option: as it was pointed
> out, it is easy to add new options reusing the code to have the list
> separated. And that is simpler for the script that comes next.

I still don't like this approach, on the ground that:
1. output is not easily parsable (two lists with logically different
   fields, and headers to be kept into account)
2. the two lists are semantically distinct

I won't oppose this patch if you insist with it, but I relaunch the
idea of using a global "-list" option, which could work taking a list
of things to print, e.g.:
-list channels,layouts

and could be extended to list the other listable things in ff*.

> 
> 
> diff --git a/cmdutils.c b/cmdutils.c
> index a5871c3..619a4a8 100644
> --- a/cmdutils.c
> +++ b/cmdutils.c
> @@ -1087,6 +1087,35 @@ int show_pix_fmts(const char *opt, const char *arg)
>      return 0;
>  }
>  
> +int show_layouts(const char *opt, const char *arg)
> +{
> +    int i = 0;
> +    uint64_t layout, j;
> +    const char *name, *descr;
> +
> +    printf("Individual channels:\n"
> +           "NAME        DESCRIPTION\n");
> +    for (i = 0; i < 63; i++) {
> +        name = av_get_channel_name((uint64_t)1 << i);
> +        if (!name)
> +            continue;
> +        descr = av_get_channel_description((uint64_t)1 << i);
> +        printf("%-12s%s\n", name, descr);
> +    }

> +    printf("\nStandard channel layouts:\n"
> +           "NAME        DECOMPOSITION\n");

for easier parsing the header could be print to stderr (but keep
consistency in each case).


> +    for (i = 0; !av_get_standard_channel_layout(i, &layout, &name); i++) {
> +        if (name) {
> +            printf("%-12s", name);
> +            for (j = 1; j; j <<= 1)
> +                if ((layout & j))
> +                    printf("%s%s", (layout & (j - 1)) ? "+" : "", av_get_channel_name(j));
> +            printf("\n");
> +        }
> +    }
> +    return 0;
> +}
> +
>  int show_sample_fmts(const char *opt, const char *arg)
>  {
>      int i;
> diff --git a/cmdutils.h b/cmdutils.h
> index fc36331..e3638a9 100644
> --- a/cmdutils.h
> +++ b/cmdutils.h
> @@ -360,6 +360,13 @@ int show_protocols(const char *opt, const char *arg);
>  int show_pix_fmts(const char *opt, const char *arg);
>  
>  /**
> + * Print a listing containing all the standard channel layouts supported by
> + * the program.
> + * This option processing function does not utilize the arguments.
> + */
> +int show_layouts(const char *opt, const char *arg);
> +
> +/**
>   * Print a listing containing all the sample formats supported by the
>   * program.
>   */
> diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h
> index b4892bb..bfd71fe 100644
> --- a/cmdutils_common_opts.h
> +++ b/cmdutils_common_opts.h
> @@ -12,6 +12,7 @@
>      { "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" },
>      { "loglevel"   , HAS_ARG,  {.func_arg = opt_loglevel},      "set libav* logging level", "loglevel" },
>      { "v",           HAS_ARG,  {.func_arg = opt_loglevel},      "set libav* logging level", "loglevel" },
> diff --git a/doc/avtools-common-opts.texi b/doc/avtools-common-opts.texi
> index 805064c..a9dfd6b 100644
> --- a/doc/avtools-common-opts.texi
> +++ b/doc/avtools-common-opts.texi
> @@ -119,6 +119,9 @@ Show available pixel formats.
>  @item -sample_fmts
>  Show available sample formats.
>  

> + at item -layouts
> +Show standard channel layouts.

Mention that it prints also information about the single channels.

[...]
-- 
FFmpeg = Fancy & Fiendish MultiPurpose Enigmatic Guru


More information about the ffmpeg-devel mailing list