summaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorMark Reid <mindmark@gmail.com>2015-03-02 20:06:13 -0800
committerMichael Niedermayer <michaelni@gmx.at>2015-03-03 17:49:15 +0100
commit81a91269a2fbeb87de53e395c6bed0c70c310cae (patch)
tree03d0a9e3b5e3296018a4dbb07e00cfb9ee3f409f /libavformat/aviobuf.c
parent6394acaf36da3106f4793bda32730f8ff6b0ddb1 (diff)
libavformat/avio: added avio_put_str16be
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 8fd04668c0..537c11f6b4 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -342,7 +342,7 @@ int avio_put_str(AVIOContext *s, const char *str)
return len;
}
-int avio_put_str16le(AVIOContext *s, const char *str)
+static inline int put_str16(AVIOContext *s, const char *str, const int be)
{
const uint8_t *q = str;
int ret = 0;
@@ -353,19 +353,34 @@ int avio_put_str16le(AVIOContext *s, const char *str)
uint16_t tmp;
GET_UTF8(ch, *q++, goto invalid;)
- PUT_UTF16(ch, tmp, avio_wl16(s, tmp); ret += 2;)
+ PUT_UTF16(ch, tmp, be ? avio_wb16(s, tmp) : avio_wl16(s, tmp);
+ ret += 2;)
continue;
invalid:
- av_log(s, AV_LOG_ERROR, "Invaid UTF8 sequence in avio_put_str16le\n");
+ av_log(s, AV_LOG_ERROR, "Invaid UTF8 sequence in avio_put_str16%s\n", be ? "be" : "le");
err = AVERROR(EINVAL);
}
- avio_wl16(s, 0);
+ if (be)
+ avio_wb16(s, 0);
+ else
+ avio_wl16(s, 0);
if (err)
return err;
ret += 2;
return ret;
}
+#define PUT_STR16(type, big_endian) \
+int avio_put_str16 ## type(AVIOContext *s, const char *str) \
+{ \
+return put_str16(s, str, big_endian); \
+}
+
+PUT_STR16(le, 0)
+PUT_STR16(be, 1)
+
+#undef PUT_STR16
+
int ff_get_v_length(uint64_t val)
{
int i = 1;