1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-18 04:45:33 +00:00

demux_mkv: Adjust seeks a bit to catch inexact keyframe matches

Allow a seek to "time X or before" to match a keyframe at X plus 1 ms,
and correspondingly for seeks to "X or later". This allows seeks to a
known keyframe to succeed even if the time is not quite perfectly
exact.

The main motivation for this improvement was chapter seeking. Some
time ago things worked in practice because chapter times were slightly
below the exact target and demux_mkv seeked forward of the specified
position by default. Some commits ago demux_mkv started seeking
backward by default, which is generally a more desirable behavior, but
worked worse for the chapter times which happened to be slightly
behind a keyframe rather than ahead. After this commit chapter seeks
go to the desired keyframe again.
This commit is contained in:
Uoti Urpala 2009-03-31 19:30:14 +03:00
parent 7db6430959
commit 901ea8880a

View File

@ -2970,6 +2970,10 @@ demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int
else
flags |= SEEK_FORWARD;
}
// Adjust the target a little bit to catch cases where the target position
// specifies a keyframe with high, but not perfect, precision.
rel_seek_secs += flags & SEEK_FORWARD ? -0.001 : 0.001;
free_cached_dps (demuxer);
if (!(flags & SEEK_FACTOR)) /* time in secs */
{