Detect EBML magic number to skip encoding detection for MKV

MKV loads slow after f733297499
This commit is contained in:
wangqr 2019-06-16 19:14:10 -04:00 committed by Thomas Goyne
parent d7139c40c0
commit bb5090ac3a

View file

@ -34,6 +34,15 @@ std::string Detect(agi::fs::path const& file) {
if (fp.size() > 100 * 1024 * 1024)
return "binary";
// FIXME: Dirty hack for Matroska. These 4 bytes are the magic
// number of EBML which is used by mkv and webm
if (fp.size() >= 4) {
const char* buf = fp.read(0, 4);
if (!strncmp(buf, "\x1a\x45\xdf\xa3", 4))
return "binary";
}
uint64_t binaryish = 0;
#ifdef WITH_UCHARDET