mirror of https://github.com/mpv-player/mpv
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:
parent
07915b1227
commit
4381753207
|
@ -193,7 +193,6 @@ typedef struct mkv_demuxer {
|
||||||
struct header_elem {
|
struct header_elem {
|
||||||
int32_t id;
|
int32_t id;
|
||||||
int64_t pos;
|
int64_t pos;
|
||||||
bool needed;
|
|
||||||
bool parsed;
|
bool parsed;
|
||||||
} *headers;
|
} *headers;
|
||||||
int num_headers;
|
int num_headers;
|
||||||
|
@ -2079,7 +2078,6 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check)
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
elem->needed = true;
|
|
||||||
only_cue = only_cue < 0 && elem->id == MATROSKA_ID_CUES;
|
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;
|
struct header_elem *lowest = NULL;
|
||||||
for (int n = 0; n < mkv_d->num_headers; n++) {
|
for (int n = 0; n < mkv_d->num_headers; n++) {
|
||||||
struct header_elem *elem = &mkv_d->headers[n];
|
struct header_elem *elem = &mkv_d->headers[n];
|
||||||
if (!elem->needed)
|
if (elem->parsed)
|
||||||
continue;
|
continue;
|
||||||
if (!lowest || elem->pos < lowest->pos)
|
if (!lowest || elem->pos < lowest->pos)
|
||||||
lowest = elem;
|
lowest = elem;
|
||||||
|
@ -2103,7 +2101,6 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check)
|
||||||
if (!lowest)
|
if (!lowest)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
lowest->needed = false;
|
|
||||||
if (read_deferred_element(demuxer, lowest) < 0)
|
if (read_deferred_element(demuxer, lowest) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue