[FFmpeg-cvslog] avio: Add avio_put_str16be

Luca Barbato git at videolan.org
Mon Jun 8 01:19:12 CEST 2015


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Fri Jun  5 23:21:18 2015 +0200| [252d6200c36e7eaa79f8d5205b7d731179e94897] | committer: Luca Barbato

avio: Add avio_put_str16be

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=252d6200c36e7eaa79f8d5205b7d731179e94897
---

 doc/APIchanges        |    3 +++
 libavformat/avio.h    |   12 ++++++++++++
 libavformat/aviobuf.c |   34 ++++++++++++++++++++--------------
 libavformat/version.h |    2 +-
 4 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 2c443b0..0ddfb11 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:     2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxxxxxx - lavf 56.20.0 - avio.h
+  Add avio_put_str16be.
+
 2015-xx-xx - xxxxxxx - lavu 54.14.0 - cpu.h
   Add AV_CPU_FLAG_AVXSLOW.
 
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 3360e82..a1497d9 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -178,11 +178,23 @@ int avio_put_str(AVIOContext *s, const char *str);
 
 /**
  * Convert an UTF-8 string to UTF-16LE and write it.
+ * @param s the AVIOContext
+ * @param str NULL-terminated UTF-8 string
+ *
  * @return number of bytes written.
  */
 int avio_put_str16le(AVIOContext *s, const char *str);
 
 /**
+ * Convert an UTF-8 string to UTF-16BE and write it.
+ * @param s the AVIOContext
+ * @param str NULL-terminated UTF-8 string
+ *
+ * @return number of bytes written.
+ */
+int avio_put_str16be(AVIOContext *s, const char *str);
+
+/**
  * Passing this as the "whence" parameter to a seek function causes it to
  * return the filesize without seeking anywhere. Supporting this is optional.
  * If it is not supported then the seek function will return <0.
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index d3e3452..6716772 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -284,22 +284,28 @@ int avio_put_str(AVIOContext *s, const char *str)
     return len;
 }
 
-int avio_put_str16le(AVIOContext *s, const char *str)
-{
-    const uint8_t *q = str;
-    int ret = 0;
+#define PUT_STR16(type, write)                                   \
+    int avio_put_str16 ## type(AVIOContext * s, const char *str) \
+    {                                                            \
+        const uint8_t *q = str;                                  \
+        int ret          = 0;                                    \
+                                                                 \
+        while (*q) {                                             \
+            uint32_t ch;                                         \
+            uint16_t tmp;                                        \
+                                                                 \
+            GET_UTF8(ch, *q++, break; )                          \
+            PUT_UTF16(ch, tmp, write(s, tmp); ret += 2; )        \
+        }                                                        \
+        write(s, 0);                                             \
+        ret += 2;                                                \
+        return ret;                                              \
+    }
 
-    while (*q) {
-        uint32_t ch;
-        uint16_t tmp;
+PUT_STR16(le, avio_wl16)
+PUT_STR16(be, avio_wb16)
 
-        GET_UTF8(ch, *q++, break;)
-        PUT_UTF16(ch, tmp, avio_wl16(s, tmp); ret += 2;)
-    }
-    avio_wl16(s, 0);
-    ret += 2;
-    return ret;
-}
+#undef PUT_STR16
 
 int ff_get_v_length(uint64_t val)
 {
diff --git a/libavformat/version.h b/libavformat/version.h
index 714ec72..3be6fc6 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFORMAT_VERSION_MAJOR 56
-#define LIBAVFORMAT_VERSION_MINOR 19
+#define LIBAVFORMAT_VERSION_MINOR 20
 #define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list