diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/Input/sndfile/decodersndfilefactory.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/plugins/Input/sndfile/decodersndfilefactory.cpp b/src/plugins/Input/sndfile/decodersndfilefactory.cpp index d2cedb38c..7097fd87e 100644 --- a/src/plugins/Input/sndfile/decodersndfilefactory.cpp +++ b/src/plugins/Input/sndfile/decodersndfilefactory.cpp @@ -38,13 +38,45 @@ // DecoderSndFileFactory bool DecoderSndFileFactory::canDecode(QIODevice *input) const { - char buf[36]; + char buf[36] = {0}; if(input->peek(buf, sizeof(buf)) != sizeof(buf)) return false; if(!memcmp(buf + 8, "WAVE", 4) && (!memcmp(buf, "RIFF", 4) || !memcmp(buf, "RIFX", 4))) { - quint16 subformat = (quint16(buf[21]) << 8) + buf[20]; + quint16 subformat = 0; + + if(!memcmp(buf + 12, "fmt ", 4)) + { + subformat = (quint16(buf[21]) << 8) + buf[20]; + } + else if(!input->isSequential()) + { + input->seek(12); + //skip "JUNK" and "bext" chunks + while(!input->atEnd()) + { + if(input->peek(buf, sizeof(buf)) != sizeof(buf)) + return false; + + if(!memcmp(buf, "fmt ", 4)) + { + subformat = (quint16(buf[9]) << 8) + buf[8]; + break; + } + else if(!memcmp(buf, "JUNK", 4) || !memcmp(buf, "bext", 4)) + { + size_t size = buf[4] + (buf[5] << 8) + (buf[6] << 16) + (buf[7] << 24); + if(!input->seek(input->pos() + size + 8)) + break; + } + else + { + break; + } + } + input->seek(0); + } switch (subformat) { |
