diff --git a/src/Config.h b/src/Config.h index 7d3c0817..948aea6b 100644 --- a/src/Config.h +++ b/src/Config.h @@ -35,7 +35,7 @@ #define VER_LAMEXP_MINOR_LO 5 #define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_PATCH 5 -#define VER_LAMEXP_BUILD 1984 +#define VER_LAMEXP_BUILD 1985 #define VER_LAMEXP_CONFG 1934 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Decoder_MP3.cpp b/src/Decoder_MP3.cpp index 4be6d42b..5f386bde 100644 --- a/src/Decoder_MP3.cpp +++ b/src/Decoder_MP3.cpp @@ -33,6 +33,11 @@ #include #include #include +#include + +//Static +QScopedPointer MP3Decoder::m_regxLayer, MP3Decoder::m_regxVersion; +QMutex MP3Decoder::m_regexMutex; MP3Decoder::MP3Decoder(void) : @@ -134,16 +139,20 @@ bool MP3Decoder::decode(const QString &sourceFile, const QString &outputFile, QA bool MP3Decoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) { - if(containerType.compare("MPEG Audio", Qt::CaseInsensitive) == 0 || containerType.compare("Wave", Qt::CaseInsensitive) == 0) + const QLatin1String mpegAudio("MPEG Audio"), waveAudio("Wave"); + if(containerType.compare(mpegAudio, Qt::CaseInsensitive) == 0) || (containerType.compare(waveAudio, Qt::CaseInsensitive) == 0)) { - if(formatType.compare("MPEG Audio", Qt::CaseInsensitive) == 0) + if((formatType.compare(mpegAudio, Qt::CaseInsensitive) == 0) { - if(formatProfile.compare("Layer 3", Qt::CaseInsensitive) == 0 || formatProfile.compare("Layer 2", Qt::CaseInsensitive) == 0) + QMutexLocker lock(&m_regexMutex); + if (m_regxLayer.isNull() || m_regxVersion.isNull()) { - if(formatVersion.compare("Version 1", Qt::CaseInsensitive) == 0 || formatVersion.compare("Version 2", Qt::CaseInsensitive) == 0) - { - return true; - } + m_regxLayer.reset(new QRegExp("\\bLayer\\s+(1|2|3)\\b", Qt::CaseInsensitive)); + m_regxVersion.reset(new QRegExp("\\bVersion\\s+(1|2|2\\.5)\\b", Qt::CaseInsensitive)); + } + if (m_regxLayer->indexIn(formatProfile) >= 0) + { + return (m_regxVersion->indexIn(formatVersion) >= 0); } } } diff --git a/src/Decoder_MP3.h b/src/Decoder_MP3.h index 3ac0b8fd..bbc13066 100644 --- a/src/Decoder_MP3.h +++ b/src/Decoder_MP3.h @@ -36,4 +36,6 @@ public: private: const QString m_binary; + static QScopedPointer m_regxLayer, m_regxVersion; + static QMutex m_regexMutex; };