[FFmpeg-devel] [PATCH 2/4] ffprobe: move packets_and_frames work to writer context.
Clément Bœsch
ubitux at gmail.com
Thu May 31 21:00:45 CEST 2012
On Wed, May 30, 2012 at 01:21:20AM +0200, Stefano Sabatini wrote:
> On date Tuesday 2012-05-29 23:24:40 +0200, Clément Bœsch encoded:
> > ---
> > ffprobe.c | 31 +++++++++++++++++++------------
> > 1 file changed, 19 insertions(+), 12 deletions(-)
> >
> > diff --git a/ffprobe.c b/ffprobe.c
> > index aa2b344..f2ddf6e 100644
> > --- a/ffprobe.c
> > +++ b/ffprobe.c
> > @@ -177,10 +177,14 @@ struct WriterContext {
> > void *priv; ///< private data for use by the filter
> > unsigned int nb_item; ///< number of the item printed in the given section, starting at 0
> > unsigned int nb_section; ///< number of the section printed in the given section sequence, starting at 0
>
> > + unsigned int nb_section_packet; ///< number of the packet section in case we are in "packets_and_frames" section
> > + unsigned int nb_section_frame; ///< number of the frame section in case we are in "packets_and_frames" section
> > + unsigned int nb_section_packet_frame; ///< nb_section_packet or nb_section_frame according if is_packets_and_frames
>
> Nit: maybe nb_packet and nb_frame to keep them short
>
The relationship with nb_section is more obvious that way I think. I'll
change if someone insists.
[...]
> > @@ -718,7 +732,6 @@ static const Writer csv_writer = {
> > typedef struct {
> > const AVClass *class;
> > AVBPrint chapter_name, section_name;
> > - int print_packets_and_frames;
>
> > int nb_frame;
> > int nb_packet;
>
> these two can be removed now
>
Ah true, fixed locally.
> > int hierarchical;
> > @@ -812,13 +825,13 @@ static void ini_print_chapter_header(WriterContext *wctx, const char *chapter)
> >
> > if (wctx->nb_chapter)
> > printf("\n");
> > - ini->print_packets_and_frames = !strcmp("packets_and_frames", chapter);
> > }
> >
> > static void ini_print_section_header(WriterContext *wctx, const char *section)
> > {
> > INIContext *ini = wctx->priv;
> > - int n;
> > + int n = wctx->is_packets_and_frames ? wctx->nb_section_packet_frame
> > + : wctx->nb_section;
> > if (wctx->nb_section)
> > printf("\n");
> > av_bprint_clear(&ini->section_name);
> > @@ -827,10 +840,6 @@ static void ini_print_section_header(WriterContext *wctx, const char *section)
> > av_bprintf(&ini->section_name, "%s.", ini->chapter_name.str);
> > av_bprintf(&ini->section_name, "%s", section);
> >
> > - if (ini->print_packets_and_frames)
> > - n = !strcmp(section, "packet") ? ini->nb_packet++ : ini->nb_frame++;
> > - else
> > - n = wctx->nb_section;
> > if (wctx->multiple_sections)
> > av_bprintf(&ini->section_name, ".%d", n);
> > printf("[%s]\n", ini->section_name.str);
> > @@ -885,7 +894,6 @@ static const Writer ini_writer = {
> >
> > typedef struct {
> > const AVClass *class;
> > - int print_packets_and_frames;
> > int indent_level;
> > int compact;
> > const char *item_sep, *item_start_end;
> > @@ -980,7 +988,6 @@ static void json_print_chapter_header(WriterContext *wctx, const char *chapter)
> > av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
> > printf("\"%s\": [\n", json_escape_str(&buf, chapter, wctx));
> > av_bprint_finalize(&buf, NULL);
> > - json->print_packets_and_frames = !strcmp(chapter, "packets_and_frames");
> > json->indent_level++;
> > }
> > }
> > @@ -1009,7 +1016,7 @@ static void json_print_section_header(WriterContext *wctx, const char *section)
> > printf("{%s", json->item_start_end);
> > json->indent_level++;
> > /* this is required so the parser can distinguish between packets and frames */
> > - if (json->print_packets_and_frames) {
> > + if (wctx->is_packets_and_frames) {
> > if (!json->compact)
> > JSON_INDENT();
> > printf("\"type\": \"%s\"%s", section, json->item_sep);
>
> Looks good otherwise, thanks.
Will be pushed when flat output is approved.
--
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/20120531/e1f47f40/attachment.asc>
More information about the ffmpeg-devel
mailing list