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.
This commit is contained in:
wm4 2018-09-07 21:32:01 +02:00
parent b9be20b529
commit 0fa38121a6
1 changed files with 4 additions and 4 deletions

View File

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