On Sat, 19 May 2012 11:46:04 -0700, Luca Barbato <[email protected]> wrote:
> Make the output valid INI serialization.
> ---
> avprobe.c | 507
> ++++++++++++++++++++++++++++++++++++++++++++++---------------
> 1 files changed, 387 insertions(+), 120 deletions(-)
>
> diff --git a/avprobe.c b/avprobe.c
> index 6182875..543bf26 100644
> --- a/avprobe.c
> +++ b/avprobe.c
> @@ -64,6 +64,257 @@ void exit_program(int ret)
> exit(ret);
> }
>
> +#define MAX_INDENT 4
> +
> +static int print_object_separator;
> +static int print_array_separator;
> +static int print_item_separator;
> +static int indent_level;
> +
> +AVIOContext *avp_out = NULL;
static?
> +
> +#define AVP_INDENT() avio_printf(avp_out, "%*c", indent_level * 2, ' ')
> +
> +/*
> + * Default format, INI
> + *
> + * - all key and values are utf8
> + * - '.' is the subgroup separator
> + * - newlines and the following characters are escaped
> + * - '\' is the escape character
> + * - '#' is the comment
> + * - '=' is the key/value separators
> + * - ':' is not used but usually parsed as key/value separator
> + */
> +
> +static void ini_print_header(void)
> +{
> + avio_printf(avp_out, "# avprobe output\n\n");
> +}
> +static void ini_print_footer(void)
> +{
> + avio_w8(avp_out, '\n');
> +}
> +
> +static void ini_escape_print(const char *s)
> +{
> + int i = 0;
> + char c = 0;
> +
> + while (c = s[i++]) {
> + switch (c) {
> + case '\r': avio_printf(avp_out, "%s", "\\r"); break;
> + case '\n': avio_printf(avp_out, "%s", "\\n"); break;
> + case '\\': avio_printf(avp_out, "%s", "\\\\"); break;
> + case '\f': avio_printf(avp_out, "%s", "\\f"); break;
> + case '\b': avio_printf(avp_out, "%s", "\\b"); break;
> + case '\t': avio_printf(avp_out, "%s", "\\t"); break;
> + case '#':
> + case '=':
> + case ':': avio_w8(avp_out, '\\');
> + default:
> + if ((unsigned char)c < 32)
> + avio_printf(avp_out, "\\x00%02x", c & 0xff);
> + else
> + avio_w8(avp_out, c);
> + break;
> + }
> + }
> +}
> +
> +static char const **prefix;
> +static int group_index = -1;
> +static int in_object;
After the horror that avconv used to be, I would strongly prefer to
avoid this kind of globals. Please add some kind of writer-specific
private data and store those there.
Writer descriptions themselves might also be easier to follow if they
were put together in a struct.
--
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel