summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-03-19 05:25:12 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-03-24 04:05:04 +0200
commit73fb23c1cfc40a9e0683f0a82cb1a669005eaa67 (patch)
treea67ac6e34674e8466149b2f15743171c08a8d7ee /mplayer.c
parent327940361170a4d830bc7c120503cdd0396a125a (diff)
downloadmpv-73fb23c1cfc40a9e0683f0a82cb1a669005eaa67.tar.bz2
mpv-73fb23c1cfc40a9e0683f0a82cb1a669005eaa67.tar.xz
Add improved relative seek mode
When the new mode is active relative seeks are converted to absolute ones (current video pts + relative seek amount) and forward/backward flag before being sent to the demuxer. This mode is used if the demuxer has set the accurate_seek field in the demuxer struct and there is a video stream. At the moment the mkv and lavf demuxers enable the flag. This change is useful for later Matroska ordered chapter support (and for more general timelime editing), but also fixes problems in existing functionality. The main problem with the old mode, where relative seeks are passed directly to the demuxer, is that the user wants to seek relative to the currently displayed position but the demuxer does not know what that position is. There can be an arbitrary amount of buffering between the demuxer read position and what is displayed on the screen. In some situations this makes small seeks fail to move backward at all (especially visible at high playback speed, when audio needs to be demuxed and decoded further ahead to fill the output buffers after resampling). Some container formats that can be used with the lavf demuxer do not always have reliable timestamps that could be used for unambiguous absolute seeking. However I made the demuxer always enable the new mode because it already converted all seeks to absolute ones before sending them to libavformat, so cases without reliable absolute seeks were failing already and this should only improve the working cases.
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/mplayer.c b/mplayer.c
index 1690f75ddb..a30fe21899 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -2463,6 +2463,16 @@ static void edl_update(MPContext *mpctx)
static int seek(MPContext *mpctx, double amount, int style)
{
current_module = "seek";
+ if (mpctx->demuxer->accurate_seek && mpctx->sh_video
+ && !(style & (SEEK_ABSOLUTE | SEEK_FACTOR))) {
+ style |= SEEK_ABSOLUTE;
+ if (amount > 0)
+ style |= SEEK_FORWARD;
+ else
+ style |= SEEK_BACKWARD;
+ amount += mpctx->sh_video->pts;
+ }
+
if (demux_seek(mpctx->demuxer, amount, audio_delay, style) == 0)
return -1;