summaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-01-23 12:38:27 +0100
committerJanne Grunau <janne-ffmpeg@jannau.net>2011-01-25 21:48:03 +0100
commit93b78d12106112d7c5d9cfdcf96fc3dce9dc5f82 (patch)
tree3e5e25a025258e0ca817390e24c6a96d64428452 /libavformat/aviobuf.c
parentd0f0f6287c7fd29474e58fe1b86db2885f20c457 (diff)
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>
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;