[FFmpeg-devel] [PATCH] ffprobe: force display of missing fields, depending on writer.flags
Stefano Sabatini
stefasab at gmail.com
Wed Nov 16 00:34:05 CET 2011
On date Wednesday 2011-11-09 07:43:56 +0100, Clément Bœsch encoded:
> On Mon, Nov 07, 2011 at 05:58:36PM +0100, Stefano Sabatini wrote:
> > On date Monday 2011-10-24 02:39:46 +0200, Stefano Sabatini encoded:
> > > Add flags field to Writer, and define the
> > > WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS flag which forces the display of
> > > optional fields, for example non-available or invalid fields.
> > >
> > > Also set the flag in the default writer.
> > >
> > > This change is required since for some writers it is preferable to show
> > > all the fields (for example for avoiding a variable number of fields in
> > > CSV output), while for other formats (e.g. JSON, XML), it is better to
> > > leave invalid/unavailable fields unspecified and thus avoid parsing work
> > > to the deserializer.
> > > ---
> > > ffprobe.c | 130 +++++++++++++++++++++++++++++++++++++-----------------------
> > > 1 files changed, 80 insertions(+), 50 deletions(-)
> >
> > Updated, this is required by the compact writer.
> > --
> > FFmpeg = Faithful Fancy Muttering Portentous Eccentric Glue
>
> > From 3d8324175b34510291b48b21826f83ac4e0cb96c Mon Sep 17 00:00:00 2001
> > From: Stefano Sabatini <stefasab at gmail.com>
> > Date: Mon, 24 Oct 2011 01:23:22 +0200
> > Subject: [PATCH] ffprobe: force display of missing fields, depending on writer.flags
> >
> > Add flags field to Writer, and define the
> > WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS flag which forces the display of
> > optional fields, for example non-available or invalid fields.
> >
> > Also set the flag in the default writer.
> >
> > This change is required since for some writers it is preferable to show
> > all the fields (for example for avoiding a variable number of fields in
> > CSV output), while for other formats (e.g. JSON, XML), it is better to
> > leave invalid/unavailable fields unspecified and thus avoid parsing work
> > to the deserializer.
> > ---
> > ffprobe.c | 125 +++++++++++++++++++++++++++++++++++++-----------------------
> > 1 files changed, 77 insertions(+), 48 deletions(-)
> >
> [...]
> > @@ -450,7 +458,8 @@ static Writer default_writer = {
> > .print_section_footer = default_print_section_footer,
> > .print_integer = default_print_int,
> > .print_string = default_print_str,
> > - .show_tags = default_show_tags
> > + .show_tags = default_show_tags,
> > + .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS
>
> nit: please add a trailing coma so we don't have to edit that line again
> next time.
>
> > };
> >
> > /* JSON output */
> > @@ -626,15 +635,21 @@ static void writer_register_all(void)
> >
> > #define print_fmt(k, f, ...) do { \
> > if (fast_asprintf(&pbuf, f, __VA_ARGS__)) \
> > - writer_print_string(w, k, pbuf.s); \
> > + writer_print_string(w, k, pbuf.s, 0); \
> > +} while (0)
> > +
> > +#define print_fmt_opt(k, f, ...) do { \
> > + if (fast_asprintf(&pbuf, f, __VA_ARGS__)) \
> > + writer_print_string(w, k, pbuf.s, 1); \
> > } while (0)
> >
> > #define print_int(k, v) writer_print_integer(w, k, v)
> > -#define print_str(k, v) writer_print_string(w, k, v)
> > -#define print_ts(k, v) writer_print_string(w, k, ts_value_string (val_str, sizeof(val_str), v))
> > -#define print_time(k, v, tb) writer_print_string(w, k, time_value_string(val_str, sizeof(val_str), v, tb))
> > -#define print_val(k, v, u) writer_print_string(w, k, value_string (val_str, sizeof(val_str), \
> > - (struct unit_value){.val.i = v, .unit=u}))
> > +#define print_str(k, v) writer_print_string(w, k, v, 0)
> > +#define print_str_opt(k, v) writer_print_string(w, k, v, 1)
> > +#define print_time(k, v, tb) writer_print_time(w, k, v, tb)
> > +#define print_ts(k, v) writer_print_ts(w, k, v)
> > +#define print_val(k, v, u) writer_print_string(w, k, \
> > + value_string(val_str, sizeof(val_str), (struct unit_value){.val.i = v, .unit=u}), 1)
> > #define print_section_header(s) writer_print_section_header(w, s)
> > #define print_section_footer(s) writer_print_section_footer(w, s)
> > #define show_tags(metadata) writer_show_tags(w, metadata)
> > @@ -644,9 +659,12 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk
> > char val_str[128];
> > AVStream *st = fmt_ctx->streams[pkt->stream_index];
> > struct print_buf pbuf = {.s = NULL};
> > + const char *s;
> >
> > print_section_header("packet");
> > - print_str("codec_type", av_x_if_null(av_get_media_type_string(st->codec->codec_type), "unknown"));
> > + s = av_get_media_type_string(st->codec->codec_type);;
>
> Trailing ';'
>
> Looks OK otherwise.
Pushed.
--
FFmpeg = Faithful and Foolish Miracolous Pure Elected Geek
More information about the ffmpeg-devel
mailing list