avformat/aviobuf: Only downscale the buffer once it has been used
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 19 May 2017 18:52:44 +0000 (20:52 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 19 May 2017 19:14:26 +0000 (21:14 +0200)
The code mistook the first iteration sometimes as the end

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/aviobuf.c

index 0a7c39e..1667e9f 100644 (file)
@@ -542,7 +542,7 @@ static void fill_buffer(AVIOContext *s)
 
     /* make buffer smaller in case it ended up large after probing */
     if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size) {
-        if (dst == s->buffer) {
+        if (dst == s->buffer && s->buf_ptr != dst) {
             int ret = ffio_set_buf_size(s, s->orig_buffer_size);
             if (ret < 0)
                 av_log(s, AV_LOG_WARNING, "Failed to decrease buffer size\n");