summaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2015-06-05 23:21:18 +0200
committerLuca Barbato <lu_zero@gentoo.org>2015-06-07 10:14:45 +0200
commit252d6200c36e7eaa79f8d5205b7d731179e94897 (patch)
tree4afda34da70fd2d66bd6cacce8caf030db8a897f /libavformat/aviobuf.c
parent9b56ac74b170d12027fbc81f581a451a709f1105 (diff)
avio: Add avio_put_str16be
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index d3e3452954..6716772464 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)
{