From 0fa38121a6ce6baed277b17a1ca1e28f5978343f Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 7 Sep 2018 21:32:01 +0200 Subject: [PATCH] demux_timeline: fix off by one error, rearrange weird code This code set pkt->stream to a value which I'm not sure whether it's correct. A recent commit overwrote it with a value that is definitely correct. There appears to be an off by one error. No fucking clue whether this was somehow correct, but applying an apparent fix does not seem to break anything, so whatever. --- demux/demux_timeline.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/demux/demux_timeline.c b/demux/demux_timeline.c index c34619a6d2..d0c1740e9e 100644 --- a/demux/demux_timeline.c +++ b/demux/demux_timeline.c @@ -272,7 +272,7 @@ static bool d_read_packet(struct demuxer *demuxer, struct demux_packet **out_pkt return true; // reader will retry } - if (pkt->stream < 0 || pkt->stream > seg->num_stream_map) + if (pkt->stream < 0 || pkt->stream >= seg->num_stream_map) goto drop; if (!p->dash) { @@ -285,8 +285,8 @@ static bool d_read_packet(struct demuxer *demuxer, struct demux_packet **out_pkt pkt->end = seg->end; } - pkt->stream = seg->stream_map[pkt->stream]; - if (pkt->stream < 0) + int vs_index = seg->stream_map[pkt->stream]; + if (vs_index < 0) goto drop; // for refresh seeks, demux.c prefers monotonically increasing packet pos @@ -294,7 +294,7 @@ static bool d_read_packet(struct demuxer *demuxer, struct demux_packet **out_pkt if (pkt->pos >= 0) pkt->pos |= (seg->index & 0x7FFFULL) << 48; - struct virtual_stream *vs = p->streams[pkt->stream]; + struct virtual_stream *vs = p->streams[vs_index]; if (pkt->pts != MP_NOPTS_VALUE && pkt->pts >= seg->end) { // Trust the keyframe flag. Might not always be a good idea, but will