diff mbox series

[FFmpeg-devel] avformat/aviobuf: fix broken logic in ffio_ensure_seekback()

Message ID 20200916193745.25188-1-onemda@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel] avformat/aviobuf: fix broken logic in ffio_ensure_seekback()
Related show

Checks

Context Check Description
andriy/default pending
andriy/make_warn warning New warnings during build
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Paul B Mahol Sept. 16, 2020, 7:37 p.m. UTC
This removes big CPU overhead for demuxing chained ogg streams.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/aviobuf.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Andreas Rheinhardt Sept. 16, 2020, 7:49 p.m. UTC | #1
Paul B Mahol:
> This removes big CPU overhead for demuxing chained ogg streams.
> 
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavformat/aviobuf.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index a77517d712..88cc0b4030 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -999,8 +999,6 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
>      int filled = s->buf_end - s->buffer;
>      ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - s->buffer : -1;
>  
> -    buf_size += s->buf_ptr - s->buffer + max_buffer_size;
> -
>      if (buf_size < filled || s->seekable || !s->read_packet)
>          return 0;
>      av_assert0(!s->write_flag);
> 
This will make the buffer smaller (even very small) if not enough data
is in the buffer (and if it is unseekable). There are several users of
this function that use quite small numbers and if the buffer got shrunk,
future I/O operations will be really slow.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index a77517d712..88cc0b4030 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -999,8 +999,6 @@  int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
     int filled = s->buf_end - s->buffer;
     ptrdiff_t checksum_ptr_offset = s->checksum_ptr ? s->checksum_ptr - s->buffer : -1;
 
-    buf_size += s->buf_ptr - s->buffer + max_buffer_size;
-
     if (buf_size < filled || s->seekable || !s->read_packet)
         return 0;
     av_assert0(!s->write_flag);