From 92ba63079617f6579c276dd3ec54197b56378913 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 28 Feb 2016 19:14:23 +0100 Subject: demux: remove relative seeking Ever since a change in mplayer2 or so, relative seeks were translated to absolute seeks before sending them to the demuxer in most cases. The only exception in current mpv is DVD seeking. Remove the SEEK_ABSOLUTE flag; it's not the implied default. SEEK_FACTOR is kept, because it's sometimes slightly useful for seeking in things like transport streams. (And maybe mkv files without duration set?) DVD seeking is terrible because DVD and libdvdnav are terrible, but mostly because libdvdnav is terrible. libdvdnav does not expose seeking with seek tables. (Although I know xbmc/kodi use an undocumented API that is not declared in the headers by dladdr()ing it - I think the function is dvdnav_jump_to_sector_by_time().) With the current mpv policy if not giving a shit about DVD, just revert our half-working seek hacks and always use dvdnav_time_search(). Relative seeking might get stuck sometimes; in this case --hr-seek=always is recommended. --- player/loadfile.c | 2 +- player/playloop.c | 15 +++------------ player/sub.c | 2 +- 3 files changed, 5 insertions(+), 14 deletions(-) (limited to 'player') diff --git a/player/loadfile.c b/player/loadfile.c index 9ab930dfa7..b1e9cd2057 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -209,7 +209,7 @@ void reselect_demux_stream(struct MPContext *mpctx, struct track *track) double pts = get_current_time(mpctx); if (pts == MP_NOPTS_VALUE) pts = 0; - demux_seek(track->demuxer, pts, SEEK_ABSOLUTE); + demux_seek(track->demuxer, pts, 0); } } } diff --git a/player/playloop.c b/player/playloop.c index 3e68ee9027..07a21e462c 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -242,8 +242,7 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek) // Prefer doing absolute seeks, unless not possible. if ((seek.type == MPSEEK_FACTOR && !mpctx->demuxer->ts_resets_possible && - target_time != MP_NOPTS_VALUE) || - (seek.type == MPSEEK_RELATIVE && (!mpctx->demuxer->rel_seeks || hr_seek))) + target_time != MP_NOPTS_VALUE) || seek.type == MPSEEK_RELATIVE) { seek.type = MPSEEK_ABSOLUTE; seek.amount = target_time; @@ -253,15 +252,7 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek) double demuxer_amount = seek.amount; - int demuxer_style = 0; - switch (seek.type) { - case MPSEEK_FACTOR: - demuxer_style |= SEEK_ABSOLUTE | SEEK_FACTOR; - break; - case MPSEEK_ABSOLUTE: - demuxer_style |= SEEK_ABSOLUTE; - break; - } + int demuxer_style = seek.type == MPSEEK_FACTOR ? SEEK_FACTOR : 0; if (hr_seek || direction < 0) { demuxer_style |= SEEK_BACKWARD; } else if (direction > 0) { @@ -281,7 +272,7 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek) double main_new_pos = demuxer_amount; if (seek.type != MPSEEK_ABSOLUTE) main_new_pos = target_time; - demux_seek(track->demuxer, main_new_pos, SEEK_ABSOLUTE | SEEK_BACKWARD); + demux_seek(track->demuxer, main_new_pos, 0); } } diff --git a/player/sub.c b/player/sub.c index 6b2a3664dc..6892ac935b 100644 --- a/player/sub.c +++ b/player/sub.c @@ -103,7 +103,7 @@ static bool update_subtitle(struct MPContext *mpctx, double video_pts, { // Assume fully_read implies no interleaved audio/video streams. // (Reading packets will change the demuxer position.) - demux_seek(track->demuxer, 0, SEEK_ABSOLUTE); + demux_seek(track->demuxer, 0, 0); track->preloaded = sub_read_all_packets(track->d_sub); } -- cgit v1.2.3