Updated file format detection routines. Also fixes WMA and "raw" AAC detection.
This commit is contained in:
parent
2f446a3462
commit
1fb5160ec1
@ -86,14 +86,13 @@ bool AACDecoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
||||
|
||||
bool AACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("ADTS", Qt::CaseInsensitive) == 0 || containerType.compare("MPEG-4", Qt::CaseInsensitive) == 0)
|
||||
if((containerType.compare(QLatin1String("ADTS"), Qt::CaseInsensitive) == 0) || (containerType.compare(QLatin1String("MPEG-4"), Qt::CaseInsensitive) == 0))
|
||||
{
|
||||
if(formatType.compare("AAC", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(QLatin1String("AAC"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
QStringList profileParts = formatProfile.split(" ", QString::SkipEmptyParts);
|
||||
if(profileParts.contains("LC", Qt::CaseInsensitive) || profileParts.contains("HE-AAC", Qt::CaseInsensitive) || profileParts.contains("HE-AACv2", Qt::CaseInsensitive))
|
||||
if((formatProfile.compare(QLatin1String("LC"), Qt::CaseInsensitive) == 0) || (formatProfile.compare(QLatin1String("HE-AAC"), Qt::CaseInsensitive) == 0) || (formatProfile.compare(QLatin1String("HE-AACv2"), Qt::CaseInsensitive) == 0))
|
||||
{
|
||||
if(formatVersion.compare("Version 2", Qt::CaseInsensitive) == 0 || formatVersion.compare("Version 4", Qt::CaseInsensitive) == 0 || formatVersion.isEmpty())
|
||||
if((formatVersion.compare(QLatin1String("2"), Qt::CaseInsensitive) == 0) || (formatVersion.compare(QLatin1String("4"), Qt::CaseInsensitive) == 0) || formatVersion.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -86,30 +86,32 @@ bool AC3Decoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
||||
|
||||
bool AC3Decoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("AC-3", Qt::CaseInsensitive) == 0)
|
||||
static const QLatin1String ac3("AC-3"), eac3("E-AC-3"), dts("DTS");
|
||||
if(containerType.compare(ac3, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("AC-3", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(ac3, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(containerType.compare("E-AC-3", Qt::CaseInsensitive) == 0)
|
||||
if(containerType.compare(eac3, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("E-AC-3", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(eac3, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(containerType.compare("DTS", Qt::CaseInsensitive) == 0)
|
||||
|
||||
else if(containerType.compare(dts, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("DTS", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(dts, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
else if(containerType.compare(QLatin1String("Wave"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("AC-3", Qt::CaseInsensitive) == 0 || formatType.compare("E-AC-3", Qt::CaseInsensitive) == 0 || formatType.compare("DTS", Qt::CaseInsensitive) == 0)
|
||||
if((formatType.compare(ac3, Qt::CaseInsensitive) == 0) || (formatType.compare(eac3, Qt::CaseInsensitive) == 0) || (formatType.compare(dts, Qt::CaseInsensitive) == 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -88,17 +88,17 @@ bool ADPCMDecoder::decode(const QString &sourceFile, const QString &outputFile,
|
||||
|
||||
bool ADPCMDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
if(containerType.compare(QLatin1String("Wave"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("ADPCM", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(QLatin1String("ADPCM"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(containerType.compare("AIFF", Qt::CaseInsensitive) == 0 || containerType.compare("AU", Qt::CaseInsensitive) == 0)
|
||||
if((containerType.compare(QLatin1String("AIFF"), Qt::CaseInsensitive) == 0) ||( containerType.compare(QLatin1String("AU"), Qt::CaseInsensitive) == 0))
|
||||
{
|
||||
if(formatType.compare("PCM", Qt::CaseInsensitive) == 0 || formatType.compare("ADPCM", Qt::CaseInsensitive) == 0)
|
||||
if((formatType.compare(QLatin1String("PCM"), Qt::CaseInsensitive) == 0) || (formatType.compare(QLatin1String("ADPCM"), Qt::CaseInsensitive) == 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -89,9 +89,9 @@ bool ALACDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
|
||||
|
||||
bool ALACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("MPEG-4", Qt::CaseInsensitive) == 0)
|
||||
if(containerType.compare(QLatin1String("MPEG-4"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("ALAC", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(QLatin1String("ALAC"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -87,9 +87,10 @@ bool AvisynthDecoder::decode(const QString &sourceFile, const QString &outputFil
|
||||
|
||||
bool AvisynthDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Avisynth", Qt::CaseInsensitive) == 0)
|
||||
static const QLatin1String avs("Avisynth");
|
||||
if(containerType.compare(avs, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("Avisynth", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(avs, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -87,9 +87,10 @@ bool FLACDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
|
||||
|
||||
bool FLACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("FLAC", Qt::CaseInsensitive) == 0 || containerType.compare("OGG", Qt::CaseInsensitive) == 0)
|
||||
static const QLatin1String flac("FLAC");
|
||||
if((containerType.compare(flac, Qt::CaseInsensitive) == 0) || (containerType.compare(QLatin1String("OGG"), Qt::CaseInsensitive) == 0))
|
||||
{
|
||||
if(formatType.compare("FLAC", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(flac, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -87,9 +87,10 @@ bool MACDecoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
||||
|
||||
bool MACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Monkey's Audio", Qt::CaseInsensitive) == 0)
|
||||
static const QLatin1String mac("Monkey's Audio");
|
||||
if(containerType.compare(mac, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("Monkey's Audio", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(mac, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -36,8 +36,15 @@
|
||||
#include <QMutexLocker>
|
||||
|
||||
//Static
|
||||
QScopedPointer<QRegExp> MP3Decoder::m_regxLayer, MP3Decoder::m_regxVersion;
|
||||
QMutex MP3Decoder::m_regexMutex;
|
||||
MUtils::Lazy<QRegExp> MP3Decoder::m_regxLayer([]
|
||||
{
|
||||
return new QRegExp(L1S("^Layer\\s+(1|2|3)\\b"), Qt::CaseInsensitive);
|
||||
});
|
||||
MUtils::Lazy<QRegExp> MP3Decoder::m_regxVersion([]
|
||||
{
|
||||
return new QRegExp(L1S("^(Version\\s+)?(1|2|2\\.5)\\b"), Qt::CaseInsensitive);
|
||||
});
|
||||
|
||||
MP3Decoder::MP3Decoder(void)
|
||||
:
|
||||
@ -103,17 +110,9 @@ bool MP3Decoder::isFormatSupported(const QString &containerType, const QString &
|
||||
if(formatType.compare(mpegAudio, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
QMutexLocker lock(&m_regexMutex);
|
||||
if (m_regxLayer.isNull())
|
||||
if ((*m_regxLayer).indexIn(formatProfile) >= 0)
|
||||
{
|
||||
m_regxLayer.reset(new QRegExp(L1S("^Layer\\s+(1|2|3)\\b"), Qt::CaseInsensitive));
|
||||
}
|
||||
if (m_regxLayer->indexIn(formatProfile) >= 0)
|
||||
{
|
||||
if (m_regxVersion.isNull())
|
||||
{
|
||||
m_regxVersion.reset(new QRegExp(L1S("^(Version\\s+)?(1|2|2\\.5)\\b"), Qt::CaseInsensitive));
|
||||
}
|
||||
return (m_regxVersion->indexIn(formatVersion) >= 0);
|
||||
return ((*m_regxVersion).indexIn(formatVersion) >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Decoder_Abstract.h"
|
||||
#include <MUtils/Lazy.h>
|
||||
|
||||
class MP3Decoder : public AbstractDecoder
|
||||
{
|
||||
@ -36,6 +37,6 @@ public:
|
||||
|
||||
private:
|
||||
const QString m_binary;
|
||||
static QScopedPointer<QRegExp> m_regxLayer, m_regxVersion;
|
||||
static MUtils::Lazy<QRegExp> m_regxLayer, m_regxVersion;
|
||||
static QMutex m_regexMutex;
|
||||
};
|
||||
|
@ -88,9 +88,10 @@ bool MusepackDecoder::decode(const QString &sourceFile, const QString &outputFil
|
||||
|
||||
bool MusepackDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Musepack SV8", Qt::CaseInsensitive) == 0 || containerType.compare("Musepack SV7", Qt::CaseInsensitive) == 0)
|
||||
static const QLatin1String mpc_sv8("Musepack SV8"), mpc_sv7("Musepack SV7");
|
||||
if((containerType.compare(mpc_sv8, Qt::CaseInsensitive) == 0) || (containerType.compare(mpc_sv7, Qt::CaseInsensitive) == 0))
|
||||
{
|
||||
if(formatType.compare("Musepack SV8", Qt::CaseInsensitive) == 0 || formatType.compare("Musepack SV7", Qt::CaseInsensitive) == 0)
|
||||
if((formatType.compare(mpc_sv8, Qt::CaseInsensitive) == 0) || (formatType.compare(mpc_sv7, Qt::CaseInsensitive) == 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -96,9 +96,9 @@ bool OpusDecoder::decode(const QString &sourceFile, const QString &outputFile, Q
|
||||
|
||||
bool OpusDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("OGG", Qt::CaseInsensitive) == 0)
|
||||
if(containerType.compare(QLatin1String("OGG"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("Opus", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(QLatin1String("Opus"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
{
|
||||
return true;
|
||||
|
@ -70,9 +70,10 @@ bool ShortenDecoder::decode(const QString &sourceFile, const QString &outputFile
|
||||
|
||||
bool ShortenDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Shorten", Qt::CaseInsensitive) == 0)
|
||||
static const QLatin1String shorten("Shorten");
|
||||
if(containerType.compare(shorten, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("Shorten", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(shorten, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -77,9 +77,10 @@ bool SpeexDecoder::decode(const QString &sourceFile, const QString &outputFile,
|
||||
|
||||
bool SpeexDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Speex", Qt::CaseInsensitive) == 0 || containerType.compare("OGG", Qt::CaseInsensitive) == 0)
|
||||
static const QLatin1String speex("Speex");
|
||||
if(containerType.compare(speex, Qt::CaseInsensitive) == 0 || containerType.compare(QLatin1String("OGG"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("Speex", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(speex, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -88,9 +88,10 @@ bool TTADecoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
||||
|
||||
bool TTADecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("TTA", Qt::CaseInsensitive) == 0)
|
||||
static const QLatin1String tta("TTA");
|
||||
if(containerType.compare(tta, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("TTA", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(tta, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -87,9 +87,9 @@ bool VorbisDecoder::decode(const QString &sourceFile, const QString &outputFile,
|
||||
|
||||
bool VorbisDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("OGG", Qt::CaseInsensitive) == 0)
|
||||
if(containerType.compare(QLatin1String("OGG"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("Vorbis", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(QLatin1String("Vorbis"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -88,11 +88,11 @@ bool WMADecoder::decode(const QString &sourceFile, const QString &outputFile, QA
|
||||
|
||||
bool WMADecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Windows Media", Qt::CaseInsensitive) == 0)
|
||||
if(containerType.compare(QLatin1String("Windows Media"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("WMA", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(QLatin1String("WMA"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatVersion.compare("Version 1", Qt::CaseInsensitive) == 0 || formatVersion.compare("Version 2", Qt::CaseInsensitive) == 0 || formatVersion.compare("Version 3", Qt::CaseInsensitive) == 0 || formatProfile.compare("Pro", Qt::CaseInsensitive) == 0 || formatProfile.compare("Lossless", Qt::CaseInsensitive) == 0)
|
||||
if((formatVersion.compare(QLatin1String("1"), Qt::CaseInsensitive) == 0) || (formatVersion.compare(QLatin1String("2"), Qt::CaseInsensitive) == 0) || (formatVersion.compare(QLatin1String("3"), Qt::CaseInsensitive) == 0) || (formatProfile.compare(QLatin1String("Pro"), Qt::CaseInsensitive) == 0) || (formatProfile.compare(QLatin1String("Lossless"), Qt::CaseInsensitive) == 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -87,9 +87,10 @@ bool WavPackDecoder::decode(const QString &sourceFile, const QString &outputFile
|
||||
|
||||
bool WavPackDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("WavPack", Qt::CaseInsensitive) == 0)
|
||||
static const QLatin1String wavPack("WavPack");
|
||||
if(containerType.compare(wavPack, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("WavPack", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(wavPack, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -85,9 +85,9 @@ void WaveDecoder::updateProgress(const double &progress)
|
||||
|
||||
bool WaveDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
if(containerType.compare(QLatin1String("Wave"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("PCM", Qt::CaseInsensitive) == 0)
|
||||
if(formatType.compare(QLatin1String("PCM"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user