r3d: do not create the audio stream until we know the sample rate
[ffmpeg.git] / libavformat / aviobuf.c
index d3e3452..bb575ed 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)
 {
@@ -977,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) {
@@ -988,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);