[FFmpeg-devel] [PATCH] ffprobe: implement -show_sections
Stefano Sabatini
stefasab at gmail.com
Thu Nov 22 14:24:46 CET 2012
On date Wednesday 2012-11-21 20:31:58 +0100, Stefano Sabatini encoded:
> On date Tuesday 2012-11-20 21:13:47 +0100, Clément Bœsch encoded:
> > 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)
>
> Sections:
> W.. = Section is a wrapper (contains other sections, no local entries)
> .A. = Section contains an array of elements of the same type
> ..V = Section may contain a variable number of fields with variable keys
> FLAGS NAME/UNIQUE_NAME
> ---
> W.. root
> ... format
> ..V tags/format_tags
> .A. frames
> ... frame
> ..V tags/frame_tags
> .A. streams
> ... stream
> ... disposition/stream_disposition
> ..V tags/stream_tags
> .A. packets
> ... packet
> ... error
> ... program_version
> .A. library_versions
> ... library_version
>
> >
> > > @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 = §ions[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
>
> Fixed.
>
> > > + 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.
>
> Done, updated.
Pushed.
--
FFmpeg = Fast & Freak Miracolous Peaceless Exuberant Gadget
More information about the ffmpeg-devel
mailing list