demux_mkv: fix certain cases of recursive SeekHeads

Some shittily muxed files (by a certain HandBrake+libavformat combo)
contain a SeekHead pointing to a SeekHead at the end of the file, which
in turn points to track headers (also at the end of the file). This
failed because the demuxer didn't bother to actually read the elements
listed by the second SeekHead, so no track headers were read, and
playback broke.

Somehow commit 6fe75c38 broke this for no reason. It adds a "needed"
field, which seems completely pointless and replaced the "parsed" flag
in an incomplete way. In particular, the "needed" field was not set when
a _recursive_ SeekHead was read, so those elements were not read. Just
get rid of the field and use "parsed" instead.
This commit is contained in:
wm4 2018-04-12 22:35:34 +02:00 committed by Jan Ekström
parent 07915b1227
commit 4381753207
1 changed files with 1 additions and 4 deletions

View File

@ -193,7 +193,6 @@ typedef struct mkv_demuxer {
struct header_elem {
int32_t id;
int64_t pos;
bool needed;
bool parsed;
} *headers;
int num_headers;
@ -2079,7 +2078,6 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check)
}
continue;
}
elem->needed = true;
only_cue = only_cue < 0 && elem->id == MATROSKA_ID_CUES;
}
@ -2094,7 +2092,7 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check)
struct header_elem *lowest = NULL;
for (int n = 0; n < mkv_d->num_headers; n++) {
struct header_elem *elem = &mkv_d->headers[n];
if (!elem->needed)
if (elem->parsed)
continue;
if (!lowest || elem->pos < lowest->pos)
lowest = elem;
@ -2103,7 +2101,6 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check)
if (!lowest)
break;
lowest->needed = false;
if (read_deferred_element(demuxer, lowest) < 0)
return -1;
}