[FFmpeg-devel] [PATCH] ffprobe: implement -show_sections

Clément Bœsch ubitux at gmail.com
Tue Nov 20 21:13:47 CET 2012


On Tue, Nov 20, 2012 at 12:21:16AM +0100, Stefano Sabatini wrote:
> TODO: add Changelog entry for the new option
> ---
>  doc/ffprobe.texi |    4 ++++
>  ffprobe.c        |   31 +++++++++++++++++++++++++++++++
>  2 files changed, 35 insertions(+)
> 
> diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
> index 39322cd..127a80f 100644
> --- a/doc/ffprobe.texi
> +++ b/doc/ffprobe.texi
> @@ -222,6 +222,10 @@ Show information related to library versions.
>  Version information for each library is printed within a section with
>  name "LIBRARY_VERSION".
>  
> + at item show_sections
> +Show sections structure and section information, and exit. The output
> +is not meant to be parsed by a machine.
> +

Can you show how it looks like? (by mail, not in the patch)

>  @item -show_versions
>  Show information related to program and library versions. This is the
>  equivalent of setting both @option{-show_program_version} and
> diff --git a/ffprobe.c b/ffprobe.c
> index 5c3a47c..1777246 100644
> --- a/ffprobe.c
> +++ b/ffprobe.c
> @@ -2098,6 +2098,36 @@ static int opt_pretty(void *optctx, const char *opt, const char *arg)
>      return 0;
>  }
>  
> +static void show_section(SectionID id, int level)
> +{
> +    const SectionID *pid;
> +    const struct section *section = &sections[id];
> +    printf("%c%c%c",
> +           section->flags & SECTION_FLAG_IS_WRAPPER           ? 'W' : '.',
> +           section->flags & SECTION_FLAG_IS_ARRAY             ? 'A' : '.',
> +           section->flags & SECTION_FLAG_HAS_VARIABLE_FIELDS  ? 'V' : '.');
> +    printf("%*c", level * 4, ' ');
> +    printf("  %s", section->name);

You can squash at least the last two printf

> +    if (section->unique_name)
> +        printf("/%s", section->unique_name);
> +    printf("\n");
> +
> +    for (pid = section->children_ids; *pid != -1; pid++)
> +        show_section(*pid, level+1);
> +}
> +
> +static int opt_show_sections(void *optctx, const char *opt, const char *arg)
> +{
> +    printf("Sections:\n"
> +           "W.. = Section is a wrapper (contains other sections, no local entries)\n"
> +           ".A. = Section contains an array of elements of the same type\n"
> +           "..V = Section may contain a variable number of fields with variable keys\n"
> +           "FLAGS NAME/UNIQUE_NAME\n"
> +           "---\n");
> +    show_section(SECTION_ID_ROOT, 0);
> +    return 0;
> +}
> +
>  static int opt_show_versions(const char *opt, const char *arg)
>  {
>      mark_section_show_entries(SECTION_ID_PROGRAM_VERSION, 1, NULL);
> @@ -2144,6 +2174,7 @@ static const OptionDef real_options[] = {
>      { "show_entries", HAS_ARG, {.func_arg = opt_show_entries},
>        "show a set of specified entries", "entry_list" },
>      { "show_packets", 0, {(void*)&opt_show_packets}, "show packets info" },
> +    { "show_sections", OPT_EXIT, {.func_arg = opt_show_sections}, "show sections structure and section information, and exit" },

I don't like keeping the "show_" semantic for this option. -sections,
-sections_layout or something, but not please now something with a so
much different behaviour than the other -show_* options.

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121120/565856a0/attachment.asc>


More information about the ffmpeg-devel mailing list