• Marton Balint's avatar
    avformat/aviobuf: discard part of the IO buffer in ffio_ensure_seekback if needed · da74a740
    Marton Balint authored
    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: 's avatarMarton Balint <cus@passwd.hu>
    da74a740
avio_internal.h 6.66 KB