[libav-commits] avprobe: restore pseudo-INI old style format for compatibility.

Anton Khirnov git at libav.org
Sat May 26 21:34:28 CEST 2012


Module: libav
Branch: master
Commit: 8271f55bd7d6f4e06786dc8dd7c9538d83ad026a

Author:    Anton Khirnov <anton at khirnov.net>
Committer: Anton Khirnov <anton at khirnov.net>
Date:      Sat May 26 08:54:25 2012 +0200

avprobe: restore pseudo-INI old style format for compatibility.

---

 Changelog        |    3 ++-
 avprobe.c        |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 doc/avprobe.texi |   13 +++++++++++--
 3 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 822f062..358662b 100644
--- a/Changelog
+++ b/Changelog
@@ -21,7 +21,8 @@ version <next>:
 - add fps filter
 - audio split filter
 - audio mix filter
-- avprobe output is now standard INI or JSON.
+- avprobe output is now standard INI or JSON. The old format can still
+  be used with -of old.
 
 version 0.8:
 
diff --git a/avprobe.c b/avprobe.c
index acf0ab9..867d10d 100644
--- a/avprobe.c
+++ b/avprobe.c
@@ -281,6 +281,50 @@ static void json_print_string(const char *key, const char *value)
 }
 
 /*
+ * old-style pseudo-INI
+ */
+static void old_print_object_header(const char *name)
+{
+    char *str, *p;
+
+    if (!strcmp(name, "tags"))
+        return;
+
+    str = p = av_strdup(name);
+    while (*p) {
+        *p = toupper(*p);
+        p++;
+    }
+
+    avio_printf(probe_out, "[%s]\n", str);
+    av_freep(&str);
+}
+
+static void old_print_object_footer(const char *name)
+{
+    char *str, *p;
+
+    if (!strcmp(name, "tags"))
+        return;
+
+    str = p = av_strdup(name);
+    while (*p) {
+        *p = toupper(*p);
+        p++;
+    }
+
+    avio_printf(probe_out, "[/%s]\n", str);
+    av_freep(&str);
+}
+
+static void old_print_string(const char *key, const char *value)
+{
+    if (!strcmp(octx.prefix[octx.level - 1].name, "tags"))
+        avio_printf(probe_out, "TAG:");
+    ini_print_string(key, value);
+}
+
+/*
  * Simple Formatter for single entries.
  */
 
@@ -783,6 +827,12 @@ static int opt_output_format(const char *opt, const char *arg)
 
         print_integer = ini_print_integer;
         print_string  = ini_print_string;
+    } else if (!strcmp(arg, "old")) {
+        print_header        = NULL;
+        print_object_header = old_print_object_header;
+        print_object_footer = old_print_object_footer;
+
+        print_string        = old_print_string;
     } else {
         av_log(NULL, AV_LOG_ERROR, "Unsupported formatter %s\n", arg);
         return AVERROR(EINVAL);
diff --git a/doc/avprobe.texi b/doc/avprobe.texi
index 9c28125..7e6fedf 100644
--- a/doc/avprobe.texi
+++ b/doc/avprobe.texi
@@ -59,8 +59,17 @@ parsers.
 Force format to use.
 
 @item -of @var{formatter}
-Use a specific formatter to output the document, either @var{ini} or
- at var{json} available.
+Use a specific formatter to output the document. The following
+formatters are available
+ at table @option
+ at item ini
+
+ at item json
+
+ at item old
+Pseudo-INI format that used to be the only one available in old
+avprobe versions.
+ at end table
 
 @item -unit
 Show the unit of the displayed values.



More information about the libav-commits mailing list