aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/Input/aac/decoderaacfactory.cpp25
-rw-r--r--src/plugins/Input/flac/decoderflacfactory.cpp10
-rw-r--r--src/plugins/Input/mpc/decodermpcfactory.cpp14
-rw-r--r--src/plugins/Input/wavpack/decoderwavpackfactory.cpp5
4 files changed, 47 insertions, 7 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;
}
diff --git a/src/plugins/Input/flac/decoderflacfactory.cpp b/src/plugins/Input/flac/decoderflacfactory.cpp
index 002fe56ee..c1eee4480 100644
--- a/src/plugins/Input/flac/decoderflacfactory.cpp
+++ b/src/plugins/Input/flac/decoderflacfactory.cpp
@@ -41,7 +41,13 @@ bool DecoderFLACFactory::supports(const QString &source) const
bool DecoderFLACFactory::canDecode(QIODevice *input) const
{
- Q_UNUSED(input);
+ char buf[36];
+ if (input->peek(buf, 36) != 36)
+ return false;
+ if(!memcmp(buf, "fLaC", 4)) //native flac
+ return true;
+ if(!memcmp(buf, "OggS", 4) && !memcmp(buf + 29, "FLAC", 4)) //ogg flac
+ return true;
return false;
}
@@ -51,7 +57,7 @@ const DecoderProperties DecoderFLACFactory::properties() const
properties.name = tr("FLAC Plugin");
properties.filters << "*.flac" << "*.oga";
properties.description = tr("FLAC Files");
- //properties.contentType = ;
+ properties.contentTypes << "audio/x-flac";
properties.shortName = "flac";
properties.protocols << "flac";
properties.hasAbout = true;
diff --git a/src/plugins/Input/mpc/decodermpcfactory.cpp b/src/plugins/Input/mpc/decodermpcfactory.cpp
index f55a2d4e9..07fd9693b 100644
--- a/src/plugins/Input/mpc/decodermpcfactory.cpp
+++ b/src/plugins/Input/mpc/decodermpcfactory.cpp
@@ -36,8 +36,20 @@ bool DecoderMPCFactory::supports(const QString &source) const
return (source.right(4).toLower() == ".mpc");
}
-bool DecoderMPCFactory::canDecode(QIODevice *) const
+bool DecoderMPCFactory::canDecode(QIODevice *input) const
{
+ char buf[36];
+ if (input->peek(buf, 4) != 4)
+ return false;
+
+ if(!memcmp(buf, "MP+", 3))
+ return true;
+
+#ifndef MPC_OLD_API
+ if(!memcmp(buf, "MPCK", 4))
+ return true;
+#endif
+
return false;
}
diff --git a/src/plugins/Input/wavpack/decoderwavpackfactory.cpp b/src/plugins/Input/wavpack/decoderwavpackfactory.cpp
index 41df8dcce..c7276977f 100644
--- a/src/plugins/Input/wavpack/decoderwavpackfactory.cpp
+++ b/src/plugins/Input/wavpack/decoderwavpackfactory.cpp
@@ -33,9 +33,10 @@ bool DecoderWavPackFactory::supports(const QString &source) const
return (source.right(3).toLower() == ".wv");
}
-bool DecoderWavPackFactory::canDecode(QIODevice *) const
+bool DecoderWavPackFactory::canDecode(QIODevice *input) const
{
- return false;
+ char buf[4];
+ return (input->peek(buf, 4) == 4 && !memcmp(buf, "wvpk", 4));
}
const DecoderProperties DecoderWavPackFactory::properties() const