]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/aviobuf.c
blowfish: add av_blowfish_alloc()
[ffmpeg] / libavformat / aviobuf.c
index 59f807cbd3bb399b9e8bca952b4c9a9b5a553fdb..bb575ed8a36994fde2d3c8ca6591dd3d815de750 100644 (file)
@@ -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)
 {
@@ -496,6 +502,14 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
     return size1 - size;
 }
 
+int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
+{
+    int ret = avio_read(s, buf, size);
+    if (ret != size)
+        return AVERROR_INVALIDDATA;
+    return ret;
+}
+
 int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
 {
     if (s->buf_end - s->buf_ptr >= size && !s->write_flag) {
@@ -969,7 +983,7 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
 {
     DynBuffer *d;
     int size;
-    static const char padbuf[FF_INPUT_BUFFER_PADDING_SIZE] = {0};
+    static const char padbuf[AV_INPUT_BUFFER_PADDING_SIZE] = {0};
     int padding = 0;
 
     if (!s) {
@@ -980,7 +994,7 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
     /* don't attempt to pad fixed-size packet buffers */
     if (!s->max_packet_size) {
         avio_write(s, padbuf, sizeof(padbuf));
-        padding = FF_INPUT_BUFFER_PADDING_SIZE;
+        padding = AV_INPUT_BUFFER_PADDING_SIZE;
     }
 
     avio_flush(s);