]> git.sesse.net Git - ffmpeg/commit
avformat/aviobuf: discard part of the IO buffer in ffio_ensure_seekback if needed
authorMarton Balint <cus@passwd.hu>
Mon, 28 Sep 2020 21:48:34 +0000 (23:48 +0200)
committerMarton Balint <cus@passwd.hu>
Fri, 9 Oct 2020 19:07:18 +0000 (21:07 +0200)
commitda74a740617be53bc83b6b952cfb9b8866ccc222
treef9eaf744eadfb35fa2b88cb1add5064f9ee17779
parent1490a682dc06d868c5170635cad92948c7f28cfb
avformat/aviobuf: discard part of the IO buffer in ffio_ensure_seekback if needed

Previously ffio_ensure_seekback never flushed the buffer, so successive
ffio_ensure_seekback calls were all respected. This could eventually cause
unlimited memory and CPU usage if a demuxer called ffio_ensure_seekback on all
it's read data.

Most demuxers however only rely on being able to seek back till the position of
the last ffio_ensure_seekback call, therefore we change the semantics of
ffio_ensure_seekback so that a new call can invalidate seek guarantees of the
old. In order to support some level of "nested" ffio_ensure_seekback calls, we
document that the function only invalidates the old window (and potentially
discards the already read data from the IO buffer), if the newly requested
window does not fit into the old one.

This way we limit the memory usage for ffio_ensure_seekback calls requesting
consecutive data windows.

Signed-off-by: Marton Balint <cus@passwd.hu>
libavformat/avio_internal.h
libavformat/aviobuf.c