0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

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.
This commit is contained in:
wm4 2017-11-10 12:11:33 +01:00
parent 968a24772e
commit 2485b899c3

View File

@ -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;