From f821b2ea276ebe7ecd854fbef9e3acd691bbf074 Mon Sep 17 00:00:00 2001 From: Vittorio Giovara Date: Wed, 4 Apr 2018 17:29:34 +0200 Subject: [PATCH 1/2] avprobe: Support printing strings with empty keys --- avtools/avprobe.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/avtools/avprobe.c b/avtools/avprobe.c index a9ca1934ca..d6809042f7 100644 --- a/avtools/avprobe.c +++ b/avtools/avprobe.c @@ -235,10 +235,14 @@ static void ini_print_integer(const char *key, int64_t value) static void ini_print_string(const char *key, const char *value) { - ini_escape_print(key); - avio_printf(probe_out, "="); - ini_escape_print(value); - avio_w8(probe_out, '\n'); + if (key) { + ini_escape_print(key); + avio_printf(probe_out, "=%s\n", value); + } else { + if (octx.prefix[octx.level -1].nb_elems) + avio_printf(probe_out, ","); + avio_printf(probe_out, "%s", value); + } } /* @@ -329,14 +333,24 @@ static void json_escape_print(const char *s) static void json_print_string(const char *key, const char *value) { - if (octx.prefix[octx.level -1].nb_elems) - avio_printf(probe_out, ",\n"); - AVP_INDENT(); - avio_w8(probe_out, '\"'); - json_escape_print(key); - avio_printf(probe_out, "\" : \""); - json_escape_print(value); - avio_w8(probe_out, '\"'); + if (key) { + if (octx.prefix[octx.level -1].nb_elems) + avio_printf(probe_out, ",\n"); + AVP_INDENT(); + avio_w8(probe_out, '\"'); + json_escape_print(key); + avio_printf(probe_out, "\" : \""); + json_escape_print(value); + avio_w8(probe_out, '\"'); + } else { + if (octx.prefix[octx.level -1].nb_elems) + avio_printf(probe_out, ", "); + else + AVP_INDENT(); + avio_w8(probe_out, '\"'); + json_escape_print(value); + avio_w8(probe_out, '\"'); + } } /* From c31f6b1d61759436ef50c094e7f4c8005e97614a Mon Sep 17 00:00:00 2001 From: Vittorio Giovara Date: Wed, 4 Apr 2018 17:29:35 +0200 Subject: [PATCH 2/2] avprobe: Print a user-friendly version of the display matrix Shift fixed point numbers to be actual decimal numbers. --- avtools/avprobe.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/avtools/avprobe.c b/avtools/avprobe.c index d6809042f7..0ea9ff46fd 100644 --- a/avtools/avprobe.c +++ b/avtools/avprobe.c @@ -131,6 +131,7 @@ typedef struct PrintContext { static AVIOContext *probe_out = NULL; static PrintContext octx; #define AVP_INDENT() avio_printf(probe_out, "%*c", octx.level * 2, ' ') +#define CONV_FP(x,fp) ((double) (x)) / (1 << fp) /* * Default format, INI @@ -816,6 +817,15 @@ static void show_stream(InputFile *ifile, InputStream *ist) for (j = 0; j < 9; j++) probe_int(NULL, ((int32_t *)sd->data)[j]); probe_array_footer("matrix", 1); + probe_array_header("matrix_str", 1); + for (j = 0; j < 9; j++) { + char buf[32]; + int fp = (j == 2 || j == 5 || j == 8) ? 30 : 16; + int32_t val = ((int32_t *)sd->data)[j]; + value_string(buf, sizeof(buf), CONV_FP(val, fp), ""); + probe_str(NULL, buf); + } + probe_array_footer("matrix_str", 1); probe_int("rotation", av_display_rotation_get((int32_t *)sd->data)); probe_object_footer("displaymatrix");