diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2011-11-07 19:26:00 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2011-11-07 19:26:00 +0000 |
| commit | 0b7152dfe25d34899f0db73558f05064777f536b (patch) | |
| tree | 6e47401ddeec8de1720becd9fb0371c8d58e0ae4 /src/plugins/Input/aac/decoderaacfactory.cpp | |
| parent | 6e078f9a208f3ce31531d5ead6557cef11915e83 (diff) | |
| download | qmmp-0b7152dfe25d34899f0db73558f05064777f536b.tar.gz qmmp-0b7152dfe25d34899f0db73558f05064777f536b.tar.bz2 qmmp-0b7152dfe25d34899f0db73558f05064777f536b.zip | |
added content based detection for some decoders
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2502 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/aac/decoderaacfactory.cpp')
| -rw-r--r-- | src/plugins/Input/aac/decoderaacfactory.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/plugins/Input/aac/decoderaacfactory.cpp b/src/plugins/Input/aac/decoderaacfactory.cpp index 713e1b215..b316d4f27 100644 --- a/src/plugins/Input/aac/decoderaacfactory.cpp +++ b/src/plugins/Input/aac/decoderaacfactory.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2010 by Ilya Kotov * + * Copyright (C) 2008-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -34,8 +34,29 @@ bool DecoderAACFactory::supports(const QString &source) const return (source.right(4).toLower() == ".aac"); } -bool DecoderAACFactory::canDecode(QIODevice *) const +bool DecoderAACFactory::canDecode(QIODevice *input) const { + uchar buf[4096]; + qint64 buf_at = input->peek((char *) buf, 4096); + + int tag_size = 0; + if (!memcmp(buf, "ID3", 3)) //skip ID3 tag + { + /* high bit is not used */ + tag_size = (buf[6] << 21) | (buf[7] << 14) | + (buf[8] << 7) | (buf[9] << 0); + + tag_size += 10; + if (buf_at - tag_size < 4) + return false; + + memmove (buf, buf + tag_size, buf_at - tag_size); + } + //try to determnate header type; + if (buf[0] == 0xff && ((buf[1] & 0xf6) == 0xf0)) //ADTS header + return true; + else if (!memcmp(buf, "ADIF", 4)) //ADIF header + return true; return false; } |
