diff options
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r-- | libavformat/aviobuf.c | 34 |
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) { |