diff options
author | wm4 <wm4@nowhere> | 2017-11-10 12:11:33 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-11-10 12:11:33 +0100 |
commit | 2485b899c303f60a837baaaf704a3c8eb631ed9b (patch) | |
tree | 98104eecabd2d30d63daad6df1072a092b56bc6f | |
parent | 968a24772e649e6f19b4e924c2e25f08de1e7875 (diff) | |
download | mpv-2485b899c303f60a837baaaf704a3c8eb631ed9b.tar.bz2 mpv-2485b899c303f60a837baaaf704a3c8eb631ed9b.tar.xz |
demux: avoid wasting time by stopping packet search as early as possible
The packet queue is sorted, so we can stop the search if we have found a
packet, and the next packet in the queue has a higher PTS than the seek
PTS (for the sake of SEEK_FORWARD, we still consider the first packet
with a higher PTS).
Also, as a mostly cosmetic change, but which might be "faster", check
target for NULL, instead of target_diff for a magic float value.
-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 42d083fea3..6070fd74a8 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -2131,7 +2131,7 @@ static struct demux_packet *find_seek_target(struct demux_queue *queue, if (diff > 0) continue; } - if (target_diff != MP_NOPTS_VALUE) { + if (target) { if (diff <= 0) { if (target_diff <= 0 && diff <= target_diff) continue; @@ -2140,6 +2140,8 @@ static struct demux_packet *find_seek_target(struct demux_queue *queue, } target_diff = diff; target = dp; + if (range_pts > pts) + break; } return target; |