On Wed, 29 Apr 2015, Luca Barbato wrote:
--- avprobe.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)diff --git a/avprobe.c b/avprobe.c index d969257..a22cb8f 100644 --- a/avprobe.c +++ b/avprobe.c @@ -104,6 +104,10 @@ typedef struct PrintContext { void (*print_integer) (const char *key, int64_t value); void (*print_string) (const char *key, const char *value); + + void (*print_array_int) (const char *key, + const int *array, + const int size); } PrintContext; static AVIOContext *probe_out = NULL; @@ -201,6 +205,21 @@ static void ini_print_string(const char *key, const char *value) avio_w8(probe_out, '\n'); } +static void ini_print_array_int(const char *key, + const int *array, + const int size) +{ + int i; + if (size < 1) + return; + + ini_escape_print(key); + avio_printf(probe_out, "=%d", array[0]); + for (i = 1; i < size; i++) + avio_printf(probe_out, ", %d", array[i]); + avio_w8(probe_out, '\n'); +} + /* * Alternate format, JSON */ @@ -255,6 +274,22 @@ static void json_print_integer(const char *key, int64_t value) avio_printf(probe_out, "\"%s\" : %"PRId64"", key, value); } +static void json_print_array_int(const char *key, + const int *array, + const int size) +{ + int i; + if (size < 1) + return; + if (octx.prefix[octx.level -1].nb_elems) + avio_printf(probe_out, ",\n"); + AVP_INDENT(); + avio_printf(probe_out, "\"%s\" : [ %d", key, array[0]); + for (i = 1; i < size; i++) + avio_printf(probe_out, ", %d", array[i]); + avio_printf(probe_out, " ]\n"); +}
For json, you shouldn't terminate this with a \n, it is added by whoever writes the next value (since there may come a , before the newline).
// Martin _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
