aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-01-23 12:38:27 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-01-26 03:43:31 +0100
commitf9d6b13a234022ee752a973102c6e4207f74f94c (patch)
tree64319aeca7a90869ac0ea8a2df44a7b76fdf149c /libavformat/aviobuf.c
parent744c1664223c7565ebf069803833dfa37709d3cf (diff)
downloadffmpeg-f9d6b13a234022ee752a973102c6e4207f74f94c.tar.gz
lavf: make a variant of ff_get_str16_nolen public
It will be useful in mp3 demuxer and hopeful some other places. Signed-off-by: Janne Grunau <janne-ffmpeg@jannau.net> (cherry picked from commit 93b78d12106112d7c5d9cfdcf96fc3dce9dc5f82)
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 5aeced1b9f..acea8111d9 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -602,6 +602,28 @@ int ff_get_line(ByteIOContext *s, char *buf, int maxlen)
return i;
}
+#define GET_STR16(type, read) \
+ int avio_get_str16 ##type(ByteIOContext *pb, int maxlen, char *buf, int buflen)\
+{\
+ char* q = buf;\
+ int ret = 0;\
+ while (ret + 1 < maxlen) {\
+ uint8_t tmp;\
+ uint32_t ch;\
+ GET_UTF16(ch, (ret += 2) <= maxlen ? read(pb) : 0, break;)\
+ if (!ch)\
+ break;\
+ PUT_UTF8(ch, tmp, if (q - buf < buflen - 1) *q++ = tmp;)\
+ }\
+ *q = 0;\
+ return ret;\
+}\
+
+GET_STR16(le, get_le16)
+GET_STR16(be, get_be16)
+
+#undef GET_STR16
+
uint64_t get_be64(ByteIOContext *s)
{
uint64_t val;