diff options
author | wm4 <wm4@nowhere> | 2017-11-04 17:43:22 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-11-04 17:43:22 +0100 |
commit | 104e18214cdb0f95a2a9661a5cd475baa3f67a4e (patch) | |
tree | 9cd556fa5119c3cd9b4c3c8cf74648acbda1650c /demux | |
parent | c1f981f863cc92ab5c7ad5835bd549605296f6b8 (diff) | |
download | mpv-104e18214cdb0f95a2a9661a5cd475baa3f67a4e.tar.bz2 mpv-104e18214cdb0f95a2a9661a5cd475baa3f67a4e.tar.xz |
demux: avoid excessive readahead after cache seek
The base_ts field is used to guess the decoder position, and when set to
NOPTS, it just read ahead arbitrarily. Also demux_add_packet() sets
base_ts to the new timestamp when appending a packet, which would also
make it readahead by a too large amount.
Fix this by setting base_ts after a seek. This assumes that normally, a
cached seek target will always have the timestamp set. This is actually
not quite clear (as it calls recompute_keyframe_target_pts(), which
looks at multiple packets), but maybe it works well enough.
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/demux/demux.c b/demux/demux.c index 72758d0d8d..95aeb2435b 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -710,7 +710,7 @@ static bool read_packet(struct demux_internal *in) read_more |= (ds->active && !ds->reader_head) || ds->refreshing; bytes += ds->fw_bytes; if (ds->active && ds->last_ts != MP_NOPTS_VALUE && in->min_secs > 0 && - ds->last_ts >= ds->base_ts) + ds->base_ts != MP_NOPTS_VALUE && ds->last_ts >= ds->base_ts) prefetch_more |= ds->last_ts - ds->base_ts < in->min_secs; } MP_DBG(in, "bytes=%zd, active=%d, read_more=%d prefetch_more=%d\n", @@ -1769,6 +1769,8 @@ static bool try_seek_cache(struct demux_internal *in, double pts, int flags) ds->reader_head = target; ds->skip_to_keyframe = !target; recompute_buffers(ds); + if (ds->reader_head) + ds->base_ts = PTS_OR_DEF(ds->reader_head->pts, ds->reader_head->dts); MP_VERBOSE(in, "seeking stream %d (%s) to ", n, stream_type_name(ds->type)); |