path: root/demux/demux_mkv.c
diff options
authorwm4 <wm4@nowhere>2018-04-12 22:35:34 +0200
committerJan Ekström <>2018-04-15 21:03:49 +0300
commit4381753207c0af92af480a25f403bdc8737071a6 (patch)
tree1956afff82e5fe3a98c2322292ba646d8b38634a /demux/demux_mkv.c
parent07915b12273a36bc7f104a5f3fc949a407d243dc (diff)
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.
Diffstat (limited to 'demux/demux_mkv.c')
1 files changed, 1 insertions, 4 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index a9944a188d..f836a6eff9 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -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)
- 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)
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)
- lowest->needed = false;
if (read_deferred_element(demuxer, lowest) < 0)
return -1;