[libav-devel] [PATCH v2] avio: Do not flush the buffer if a constant packet size is requested

Luca Barbato lu_zero at gentoo.org
Thu Jan 31 13:09:20 CET 2019


---
Now w/out messing up the must_flush logic.

 libavformat/aviobuf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 98e35f776c..4d9e246e07 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -244,8 +244,10 @@ void avio_write(AVIOContext *s, const unsigned char *buf, int size)

 void avio_flush(AVIOContext *s)
 {
-    flush_buffer(s);
-    s->must_flush = 0;
+    if (!s->max_packet_size || s->buf_ptr - s->buffer >= s->max_packet_size) {
+        flush_buffer(s);
+        s->must_flush = 0;
+    }
 }

 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
--
2.12.2



More information about the libav-devel mailing list