summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-02-28 19:14:23 +0100
committerwm4 <wm4@nowhere>2016-02-28 19:28:34 +0100
commit92ba63079617f6579c276dd3ec54197b56378913 (patch)
treefff93c447a045a03cbc51ac4a0bac3a360220054 /stream
parentb638a413c37e8c892fcf40ca4ae29693f4942d0c (diff)
downloadmpv-92ba63079617f6579c276dd3ec54197b56378913.tar.bz2
mpv-92ba63079617f6579c276dd3ec54197b56378913.tar.xz
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.
Diffstat (limited to 'stream')
-rw-r--r--stream/stream_dvdnav.c37
1 files changed, 4 insertions, 33 deletions
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index e2562dbcbc..d61ca5c937 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -332,8 +332,7 @@ static int control(stream_t *stream, int cmd, void *arg)
case STREAM_CTRL_SEEK_TO_TIME: {
double *args = arg;
double d = args[0]; // absolute target timestamp
- double r = args[1]; // if not SEEK_ABSOLUTE, the base time for d
- int flags = args[2]; // from SEEK_* flags (demux.h)
+ int flags = args[1]; // from SEEK_* flags (demux.h)
if (flags & SEEK_HR)
d -= 10; // fudge offset; it's a hack, because fuck libdvd*
int64_t tm = (int64_t)(d * 90000);
@@ -344,37 +343,9 @@ static int control(stream_t *stream, int cmd, void *arg)
uint32_t pos, len;
if (dvdnav_get_position(dvdnav, &pos, &len) != DVDNAV_STATUS_OK)
break;
- // The following is convoluted, because we have to translate between
- // dvdnav's block/CBR-based seeking bullshit, and the player's
- // timestamp-based high-level machinery.
- if (!(flags & SEEK_ABSOLUTE) && !(flags & SEEK_HR) && priv->duration > 0)
- {
- int dir = (flags & SEEK_BACKWARD) ? -1 : 1;
- // The user is making a relative seek (translated to absolute),
- // and we try not to get the user stuck on "boundaries". So try
- // to do block based seeks, which should workaround libdvdnav's
- // terrible CBR-based seeking.
- d -= r; // relative seek amount in seconds
- d = d / (priv->duration / 1000.0) * len; // d is now in blocks
- d += pos; // absolute target in blocks
- if (dir > 0)
- d = MPMAX(d, pos + 1.0);
- if (dir < 0)
- d = MPMIN(d, pos - 1.0);
- d += 0.5; // round
- uint32_t target = MPCLAMP(d, 0, len);
- MP_VERBOSE(stream, "seek from block %lu to %lu, dir=%d\n",
- (unsigned long)pos, (unsigned long)target, dir);
- if (dvdnav_sector_search(dvdnav, target, SEEK_SET) != DVDNAV_STATUS_OK)
- break;
- } else {
- // "old" method, should be good enough for large seeks. Used for
- // hr-seeks (with fudge offset), because I fear that block-based
- // seeking might be off too far for large jumps.
- MP_VERBOSE(stream, "seek to PTS %f (%"PRId64")\n", d, tm);
- if (dvdnav_time_search(dvdnav, tm) != DVDNAV_STATUS_OK)
- break;
- }
+ MP_VERBOSE(stream, "seek to PTS %f (%"PRId64")\n", d, tm);
+ if (dvdnav_time_search(dvdnav, tm) != DVDNAV_STATUS_OK)
+ break;
stream_drop_buffers(stream);
d = dvdnav_get_current_time(dvdnav) / 90000.0f;
MP_VERBOSE(stream, "landed at: %f\n", d);