aboutsummaryrefslogtreecommitdiffhomepage
path: root/demux
diff options
context:
space:
mode:
Diffstat (limited to 'demux')
-rw-r--r--demux/demux_mkv.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index d19d50aab1..f46203111b 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -1035,9 +1035,6 @@ static int demux_mkv_read_seekhead(demuxer_t *demuxer)
struct ebml_seek_head seekhead = {0};
struct ebml_parse_ctx parse_ctx = {demuxer->log};
- int64_t end = 0;
- stream_control(s, STREAM_CTRL_GET_SIZE, &end);
-
MP_VERBOSE(demuxer, "/---- [ parsing seek head ] ---------\n");
if (ebml_read_element(s, &parse_ctx, &seekhead, &ebml_seek_head_desc) < 0) {
res = -1;
@@ -1052,16 +1049,7 @@ static int demux_mkv_read_seekhead(demuxer_t *demuxer)
uint64_t pos = seek->seek_position + mkv_d->segment_start;
MP_DBG(demuxer, "Element 0x%x at %"PRIu64".\n",
(unsigned)seek->seek_id, pos);
- struct header_elem *elem = get_header_element(demuxer, seek->seek_id, pos);
- // Warn against incomplete files.
- if (elem && pos >= end) {
- elem->parsed = true; // don't bother
- if (!mkv_d->eof_warning) {
- MP_WARN(demuxer, "SeekHead position beyond "
- "end of file - incomplete file?\n");
- mkv_d->eof_warning = true;
- }
- }
+ get_header_element(demuxer, seek->seek_id, pos);
}
out:
MP_VERBOSE(demuxer, "\\---- [ parsing seek head ] ---------\n");
@@ -1809,12 +1797,26 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check)
return -1;
}
+ int64_t end = 0;
+ stream_control(s, STREAM_CTRL_GET_SIZE, &end);
+
// Read headers that come after the first cluster (i.e. require seeking).
// Note: reading might increase ->num_headers.
// Likewise, ->headers might be reallocated.
for (int n = 0; n < mkv_d->num_headers; n++) {
struct header_elem *elem = &mkv_d->headers[n];
- if (elem->id == MATROSKA_ID_CUES && !elem->parsed) {
+ if (elem->parsed)
+ continue;
+ // Warn against incomplete files.
+ if (elem->pos >= end) {
+ elem->parsed = true; // don't bother if file is incomplete
+ if (!mkv_d->eof_warning) {
+ MP_WARN(demuxer, "SeekHead position beyond "
+ "end of file - incomplete file?\n");
+ mkv_d->eof_warning = true;
+ }
+ }
+ if (elem->id == MATROSKA_ID_CUES) {
// Read cues when they are needed, to avoid seeking on opening.
MP_VERBOSE(demuxer, "Deferring reading cues.\n");
continue;