]> git.sesse.net Git - ffmpeg/commitdiff
libavformat/avio: Add avio_get_dyn_buf function
authorsoftworkz <softworkz@hotmail.com>
Thu, 5 Jan 2017 00:33:26 +0000 (01:33 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 7 Jan 2017 12:04:05 +0000 (13:04 +0100)
This commit adds the avio_get_dyn_buf function which allows accessing
the
content of a DynBuffer without destroying it.

This is required in matroskaenc for preliminary writing (correct) mkv
headers.

Context for this change is fixing regression bug #5977.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
doc/APIchanges
libavformat/avio.h
libavformat/aviobuf.c
libavformat/version.h

index fbeae7a5658aac2fa780b00765a132119d0347c4..3279563d4770fb1488e2c3b2c2bede323b7f4107 100644 (file)
@@ -15,6 +15,9 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2017-01-06 - xxxxxxx - lavf 57.62.100- avio.h
+  Add avio_get_dyn_buf()
+
 2016-12-10 - xxxxxxx - lavu xx.xx.100- imgutils.h
   Add av_image_check_size2()
 
index b1ce1d1c72ec6f8fb0f2e44d00ebb06ee93dc230..e2cb4af7a270e03603e0dfe3bce76167d7463fd4 100644 (file)
@@ -703,6 +703,18 @@ int avio_closep(AVIOContext **s);
  */
 int avio_open_dyn_buf(AVIOContext **s);
 
+/**
+ * Return the written size and a pointer to the buffer.
+ * The AVIOContext stream is left intact.
+ * The buffer must NOT be freed.
+ * No padding is added to the buffer.
+ *
+ * @param s IO context
+ * @param pbuffer pointer to a byte buffer
+ * @return the length of the byte buffer
+ */
+int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
+
 /**
  * Return the written size and a pointer to the buffer. The buffer
  * must be freed with av_free().
index 134d627a6e0b07a2aebcf8137978e87528aec98f..bf7e5f85a00e003af2ccc3bfae8665fb5d4db805 100644 (file)
@@ -1277,6 +1277,23 @@ int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
     return url_open_dyn_buf_internal(s, max_packet_size);
 }
 
+int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
+{
+    DynBuffer *d;
+
+    if (!s) {
+        *pbuffer = NULL;
+        return 0;
+    }
+
+    avio_flush(s);
+
+    d = s->opaque;
+    *pbuffer = d->buffer;
+
+    return d->size;
+}
+
 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
 {
     DynBuffer *d;
index 65e6a4ccb7f1d6f991fcb604496b2a72af5187be..21cc8a99c7f619508380b22ef1c003050db14d71 100644 (file)
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  57
-#define LIBAVFORMAT_VERSION_MINOR  61
+#define LIBAVFORMAT_VERSION_MINOR  62
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \