summaryrefslogtreecommitdiffstats
path: root/demux/packet.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-11-04 23:02:25 +0100
committerwm4 <wm4@nowhere>2017-11-04 23:18:42 +0100
commit10d0963d851fad338d5d4457172fb20e76bc88aa (patch)
treea585270483bc5f923ea69481d10c714046f0d54c /demux/packet.c
parent6e998be7bed7d25e98bfe1c7d6ca079f081da7d1 (diff)
downloadmpv-10d0963d851fad338d5d4457172fb20e76bc88aa.tar.bz2
mpv-10d0963d851fad338d5d4457172fb20e76bc88aa.tar.xz
demux: improve and optimize cache pruning and seek range determination
The main purpose of this commit is avoiding any hidden O(n^2) algorithms in the code for pruning the demuxer cache, and for determining the seekable boundaries of the cache. The old code could loop over the whole packet queue on every packet pruned in certain corner cases. There are two ways how to reach the goal: 1) commit a cardinal sin 2) do everything incrementally The cardinal sin is adding an extra field to demux_packet, which caches the determined seekable range for a keyframe range. demux_packet is a rather general data structure and thus shouldn't have any fields that are not inherent to its use, and are only needed as an implementation detail of code using it. But what are you gonna do, sue me? In the future, demux.c might have its own packet struct though. Then the other existing cardinal sin (the "next" field, from MPlayer times) could be removed as well. This commit also changes slightly how the seek end is determined. There is a note on the manpage in case anyone finds the new behavior confusing. It's somewhat cleaner and might be needed for supporting multiple ranges (although that's unclear).
Diffstat (limited to 'demux/packet.c')
-rw-r--r--demux/packet.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/demux/packet.c b/demux/packet.c
index 0a13b0e6a5..156222737c 100644
--- a/demux/packet.c
+++ b/demux/packet.c
@@ -54,6 +54,7 @@ struct demux_packet *new_demux_packet_from_avpacket(struct AVPacket *avpkt)
.end = MP_NOPTS_VALUE,
.stream = -1,
.avpacket = talloc_zero(dp, AVPacket),
+ .kf_seek_pts = MP_NOPTS_VALUE,
};
av_init_packet(dp->avpacket);
int r = -1;