summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-10-23 19:05:39 +0200
committerwm4 <wm4@nowhere>2017-10-23 19:05:39 +0200
commitdbd22f43be49059c0ec801389103d5d16229bf26 (patch)
tree078acbfe7af703120b5e38a6bad285c4182dceec /demux/demux.c
parent26b46950a101612073d83e782fbe3c1a5fd03aca (diff)
downloadmpv-dbd22f43be49059c0ec801389103d5d16229bf26.tar.bz2
mpv-dbd22f43be49059c0ec801389103d5d16229bf26.tar.xz
demux: drop redundant SEEK_BACKWARD flag
Seems like most code dealing with this was for setting it in redundant cases. Now SEEK_BACKWARD is redundant, and SEEK_FORWARD is the odd one out. Also fix that SEEK_FORWARD was not correctly unset in try_seek_cache(). In demux_mkv_seek(), make the arbitrary decision that a video stream is not required for the subtitle prefetch logic to be active. We might want subtitles with long duration even with audio only playback, or if the file is used as external subtitle.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 2ebed5a3e7..35e7059426 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -721,7 +721,7 @@ static bool read_packet(struct demux_internal *in)
if (refresh_seek) {
MP_VERBOSE(in, "refresh seek to %f\n", seek_pts);
- demux->desc->seek(demux, seek_pts, SEEK_BACKWARD | SEEK_HR);
+ demux->desc->seek(demux, seek_pts, SEEK_HR);
}
bool eof = true;
@@ -1608,8 +1608,8 @@ static struct demux_packet *find_seek_target(struct demux_stream *ds,
if (range_pts == MP_NOPTS_VALUE)
continue;
- double diff = pts - range_pts;
- if (flags & SEEK_BACKWARD)
+ double diff = range_pts - pts;
+ if (flags & SEEK_FORWARD)
diff = -diff;
if (target_diff != MP_NOPTS_VALUE) {
if (diff <= 0) {
@@ -1671,8 +1671,7 @@ static bool try_seek_cache(struct demux_internal *in, double pts, int flags)
// (We assume the find_seek_target() will return the
// same target for the video stream.)
pts = target_pts;
- flags &= SEEK_FORWARD;
- flags |= SEEK_BACKWARD;
+ flags &= ~SEEK_FORWARD;
}
}
break;
@@ -1713,9 +1712,6 @@ int demux_seek(demuxer_t *demuxer, double seek_pts, int flags)
if (seek_pts == MP_NOPTS_VALUE)
return 0;
- if (!(flags & SEEK_FORWARD))
- flags |= SEEK_BACKWARD;
-
pthread_mutex_lock(&in->lock);
MP_VERBOSE(in, "queuing seek to %f%s\n", seek_pts,
@@ -1949,7 +1945,7 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
// new packets if we seek there and also last_ts is the hightest
// DTS or PTS, while ts_min should be as accurate as possible, as
// we would have to trigger a real seek if it's off and we seeked
- // there with SEEK_BACKWARD)
+ // there)
r->ts_max = MP_PTS_MAX(r->ts_max, ds->last_ts);
r->ts_min = MP_PTS_MAX(r->ts_min, ds->back_pts);
if (ds->queue_head) {