mirror of
https://github.com/mpv-player/mpv
synced 2025-02-04 14:11:53 +00:00
demux_mkv: check file type without actually reading data
Do a minimal check on data read with stream_peek(). This could help with probing from unseekable streams in some situations. (We could check the entire EBML and Matroska headers, but probably not worth the trouble. We could also seek back to the start, which demux.c doesn't do, but which would work usually - also not worth the trouble.)
This commit is contained in:
parent
78cbbb4c49
commit
4cf1843664
@ -1757,6 +1757,13 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check)
|
||||
int64_t start_pos;
|
||||
int64_t end_pos;
|
||||
|
||||
bstr start = stream_peek(s, 4);
|
||||
uint32_t start_id;
|
||||
for (int n = 0; n < start.len; n++)
|
||||
start_id = (start_id << 8) | start.start[n];
|
||||
if (start_id != EBML_ID_EBML)
|
||||
return -1;
|
||||
|
||||
if (!read_ebml_header(demuxer))
|
||||
return -1;
|
||||
MP_VERBOSE(demuxer, "Found the head...\n");
|
||||
|
Loading…
Reference in New Issue
Block a user