• Martin Storsjö's avatar
    libavformat: Improve ff_configure_buffers_for_index for excessive deltas · c2210365
    Martin Storsjö authored
    Previously, the ff_configure_buffers_for_index function had
    upper sanity limits of 16 MB (1<<24) for buffer_size and
    8 MB (1<<23) for short_seek_threshold.
    
    However, if the index contained entries with a much larger
    delta, setting pos_delta to a value larger than the sanity
    limit, we would end up not increasing the buffer size at all.
    
    Instead, ignore the individual deltas that are excessive, but
    increase the buffer size based on the deltas that are below the
    sanity limit.
    
    Only count deltas that are below 1<<23, 8 MB; pos_delta gets doubled
    before setting the buffer size - this matches the previous maximum
    buffer size of 1<<24, 16 MB.
    
    This can happen e.g. with a mov file with some tracks containing
    some samples that belong in the start of the file, at the end of
    the mdat, while the rest of the file is mostly reasonably interleaved;
    previously those samples caused the maximum pos_delta to skyrocket,
    skipping any buffer size enlargement.
    Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
    c2210365
seek.c 25.4 KB