summaryrefslogtreecommitdiffstats
path: root/libmpdemux/demux_mkv.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-03-31 19:30:14 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-04-02 06:51:26 +0300
commit901ea8880ada6ba6d3468fc5a4d8b45d72872237 (patch)
treea66b77dd13fca0d93f004930e5d650cd5b7b3cf3 /libmpdemux/demux_mkv.c
parent7db643095995ddf625af670f6e07a61bf25d3a94 (diff)
downloadmpv-901ea8880ada6ba6d3468fc5a4d8b45d72872237.tar.bz2
mpv-901ea8880ada6ba6d3468fc5a4d8b45d72872237.tar.xz
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.
Diffstat (limited to 'libmpdemux/demux_mkv.c')
-rw-r--r--libmpdemux/demux_mkv.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c
index ac10a41cb0..4ed8bd5c15 100644
--- a/libmpdemux/demux_mkv.c
+++ b/libmpdemux/demux_mkv.c
@@ -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 */
{