[FFmpeg-devel] [PATCH] ffprobe: add INI writer
Clément Bœsch
ubitux at gmail.com
Tue May 29 07:53:46 CEST 2012
On Tue, May 29, 2012 at 01:53:56AM +0200, Stefano Sabatini wrote:
[...]
> Thanks for the review, patch updated.
>
> I'll apply in a few days if there are no more comments.
> --
> FFmpeg = Frightening Fascinating Most Practical Easy Gem
> From 697168662c87c72a1d7ddef0dfef7a4e771b28d4 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Sun, 27 May 2012 01:24:19 +0200
> Subject: [PATCH] ffprobe: add INI writer
>
> Liberally based on the work of Luca Barbato <lu_zero at gentoo.org>, done
> for libav/avprobe.
> ---
> doc/ffprobe.texi | 39 ++++++++++++
> ffprobe.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 210 insertions(+), 1 deletions(-)
>
> diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
> index cde1d34..1f65668 100644
> --- a/doc/ffprobe.texi
> +++ b/doc/ffprobe.texi
> @@ -269,6 +269,45 @@ CSV format.
> This writer is equivalent to
> @code{compact=item_sep=,:nokey=1:escape=csv}.
>
> + at section ini
> +INI format output.
> +
> +Print output in an INI based format.
> +
> +The following conventions are adopted:
> +
> + at itemize
> + at item
> +all key and values are UTF-8
> + at item
> +'.' is the subgroup separator
> + at item
> +newline, '\t', '\f', '\b' and the following characters are escaped
> + at item
> +'\' is the escape character
> + at item
> +'#' is the comment indicator
> + at item
> +'=' is the key/value separator
> + at item
> +':' is not used but usually parsed as key/value separator
> + at end itemize
> +
> +This writer accepts options as a list of @var{key}=@var{value} pairs,
> +separated by ":".
> +
> +The description of the accepted options follows.
> +
> + at table @option
> + at item hierarchical, h
> +Specify if the section name specification should be hierarchical. If
> +set to 1, and if there is more than one section in the current
> +chapter, the section name will be prefixed by the name of the
> +chapter. A value of 0 will disable this behavior.
> +
> +Default value is 1.
Thanks :)
> + at end table
> +
> @section json
> JSON based format.
>
> diff --git a/ffprobe.c b/ffprobe.c
> index daea512..1bdb3e5 100644
> --- a/ffprobe.c
> +++ b/ffprobe.c
> @@ -713,6 +713,175 @@ static const Writer csv_writer = {
> .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS,
> };
>
> +/* INI format output */
> +
> +typedef struct {
> + const AVClass *class;
> + AVBPrint chapter_name, section_name;
> + int print_packets_and_frames;
> + int nb_frame;
> + int nb_packet;
> + int hierarchical;
> +} INIContext;
> +
> +#undef OFFSET
> +#define OFFSET(x) offsetof(INIContext, x)
> +
> +static const AVOption ini_options[] = {
> + {"hierachical", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_INT, {.dbl=1}, 0, 1 },
> + {"h", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_INT, {.dbl=1}, 0, 1 },
> + {NULL},
> +};
> +
> +static const char *ini_get_name(void *ctx)
> +{
> + return "xml";
"ini"
> +}
> +
> +static const AVClass ini_class = {
> + "INIContext",
> + ini_get_name,
> + ini_options
> +};
> +
> +static av_cold int ini_init(WriterContext *wctx, const char *args, void *opaque)
> +{
> + INIContext *ini = wctx->priv;
> + int err;
> +
> + av_bprint_init(&ini->chapter_name, 1, AV_BPRINT_SIZE_UNLIMITED);
> + av_bprint_init(&ini->section_name, 1, AV_BPRINT_SIZE_UNLIMITED);
> + ini->nb_frame = ini->nb_packet = 0;
> +
> + ini->class = &ini_class;
> + av_opt_set_defaults(ini);
> +
> + if (args &&
> + (err = (av_set_options_string(ini, args, "=", ":"))) < 0) {
It looks like you can drop a pair of parenthesis here.
The rest still LGTM.
--
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/20120529/b714c780/attachment.asc>
More information about the ffmpeg-devel
mailing list