From 901ea8880ada6ba6d3468fc5a4d8b45d72872237 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Tue, 31 Mar 2009 19:30:14 +0300 Subject: 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. --- libmpdemux/demux_mkv.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libmpdemux/demux_mkv.c') 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 */ { -- cgit v1.2.3