[FFmpeg-cvslog] avformat/aviobuf: fix checks in ffio_ensure_seekback

Marton Balint git at videolan.org
Fri Oct 9 22:25:18 EEST 2020


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sun Sep 20 00:01:48 2020 +0200| [a3943c48472ebbef62034c4449462b5126c07007] | committer: Marton Balint

avformat/aviobuf: fix checks in ffio_ensure_seekback

The new buf_size was detemined too conservatively, maybe because of the
off-by-one issue which was fixed recently in fill_buffer. We can safely
substract 1 more from the new buffer size, because max_buffer_size space must
only be guaranteed when we are reading the last byte of the requested window.

Comparing the new buf_size against filled did not make a lot of sense, what
makes sense is that we want to reallocate the buffer if the new buf_size is
bigger than the old, therefore the change in the check.

Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a3943c48472ebbef62034c4449462b5126c07007
---

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

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index d94be478ac..aa1d6c0830 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -1002,9 +1002,9 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
     if (buf_size <= s->buf_end - s->buf_ptr)
         return 0;
 
-    buf_size += s->buf_ptr - s->buffer + max_buffer_size;
+    buf_size += s->buf_ptr - s->buffer + max_buffer_size - 1;
 
-    if (buf_size < filled || s->seekable || !s->read_packet)
+    if (buf_size <= s->buffer_size || s->seekable || !s->read_packet)
         return 0;
     av_assert0(!s->write_flag);
 



More information about the ffmpeg-cvslog mailing list