Fixed detection of MPEG Audio files.

This commit is contained in:
LoRd_MuldeR 2017-12-02 14:55:40 +01:00
parent 3bcf6a686a
commit ec3632aa45
4 changed files with 33 additions and 11 deletions

View File

@ -34,8 +34,8 @@
#define VER_LAMEXP_MINOR_HI 1 #define VER_LAMEXP_MINOR_HI 1
#define VER_LAMEXP_MINOR_LO 6 #define VER_LAMEXP_MINOR_LO 6
#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 9 #define VER_LAMEXP_PATCH 10
#define VER_LAMEXP_BUILD 2056 #define VER_LAMEXP_BUILD 2058
#define VER_LAMEXP_CONFG 2002 #define VER_LAMEXP_CONFG 2002
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -139,19 +139,22 @@ 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) bool MP3Decoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
{ {
const QLatin1String mpegAudio("MPEG Audio"), waveAudio("Wave"); static const QLatin1String mpegAudio("MPEG Audio"), waveAudio("Wave");
if((containerType.compare(mpegAudio, Qt::CaseInsensitive) == 0) || (containerType.compare(waveAudio, Qt::CaseInsensitive) == 0)) if((containerType.compare(mpegAudio, Qt::CaseInsensitive) == 0) || (containerType.compare(waveAudio, Qt::CaseInsensitive) == 0))
{ {
if(formatType.compare(mpegAudio, Qt::CaseInsensitive) == 0) if(formatType.compare(mpegAudio, Qt::CaseInsensitive) == 0)
{ {
QMutexLocker lock(&m_regexMutex); QMutexLocker lock(&m_regexMutex);
if (m_regxLayer.isNull() || m_regxVersion.isNull()) if (m_regxLayer.isNull())
{ {
m_regxLayer.reset(new QRegExp("\\bLayer\\s+(1|2|3)\\b", Qt::CaseInsensitive)); m_regxLayer.reset(new QRegExp(L1S("\\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) if (m_regxLayer->indexIn(formatProfile) >= 0)
{ {
if (m_regxVersion.isNull())
{
m_regxVersion.reset(new QRegExp(L1S("\\b(Version\\s+)?(1|2|2\\.5)\\b"), Qt::CaseInsensitive));
}
return (m_regxVersion->indexIn(formatVersion) >= 0); return (m_regxVersion->indexIn(formatVersion) >= 0);
} }
} }

View File

@ -33,6 +33,10 @@ static const int g_lameAgorithmQualityLUT[5] = {7, 5, 2, 0, INT_MAX};
static const int g_mp3BitrateLUT[15] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1}; static const int g_mp3BitrateLUT[15] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1};
static const int g_lameVBRQualityLUT[11] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0, INT_MAX}; static const int g_lameVBRQualityLUT[11] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0, INT_MAX};
//Static
QScopedPointer<QRegExp> MP3Encoder::m_regxLayer, MP3Encoder::m_regxVersion;
QMutex MP3Encoder::m_regexMutex;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Encoder Info // Encoder Info
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -305,16 +309,28 @@ bool MP3Encoder::isFormatSupported(const QString &containerType, const QString &
return true; return true;
} }
} }
else if(containerType.compare(L1S("MPEG Audio"), Qt::CaseInsensitive) == 0)
static const QLatin1String mpegAudio("MPEG Audio"), waveAudio("Wave"), pcmFormat("PCM");
if ((containerType.compare(mpegAudio, Qt::CaseInsensitive) == 0) || (containerType.compare(waveAudio, Qt::CaseInsensitive) == 0))
{ {
if(formatType.compare(L1S("MPEG Audio"), Qt::CaseInsensitive) == 0) if (formatType.compare(pcmFormat, Qt::CaseInsensitive) == 0)
{ {
if(formatProfile.compare(L1S("Layer 3"), Qt::CaseInsensitive) == 0 || formatProfile.compare(L1S("Layer 2"), Qt::CaseInsensitive) == 0) return true;
}
else if (formatType.compare(mpegAudio, Qt::CaseInsensitive) == 0)
{
QMutexLocker lock(&m_regexMutex);
if (m_regxLayer.isNull())
{ {
if(formatVersion.compare(L1S("Version 1"), Qt::CaseInsensitive) == 0 || formatVersion.compare(L1S("Version 2"), Qt::CaseInsensitive) == 0) m_regxLayer.reset(new QRegExp(L1S("\\bLayer\\s+(1|2|3)\\b"), Qt::CaseInsensitive));
}
if (m_regxLayer->indexIn(formatProfile) >= 0)
{
if (m_regxVersion.isNull())
{ {
return true; m_regxVersion.reset(new QRegExp(L1S("\\b(Version\\s+)?(1|2|2\\.5)\\b"), Qt::CaseInsensitive));
} }
return (m_regxVersion->indexIn(formatVersion) >= 0);
} }
} }
} }

View File

@ -54,5 +54,8 @@ private:
int m_configBitrateMinimum; int m_configBitrateMinimum;
int m_configChannelMode; int m_configChannelMode;
static QMutex m_regexMutex;
static QScopedPointer<QRegExp> m_regxLayer, m_regxVersion;
int clipBitrate(int bitrate); int clipBitrate(int bitrate);
}; };