Treat Wave files with IEEE Float (32-Bit) sample format separately from Wave files with 32-Bit Integer sample format. For example, the Opus encoder accepts 32-Bit IEEE Float just fine, but does NOT like 32-Bit Integer as input.

This commit is contained in:
LoRd_MuldeR 2012-08-22 23:52:55 +02:00
parent 0a28e39309
commit 2878dc7ad0
7 changed files with 50 additions and 17 deletions

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 5 #define VER_LAMEXP_MINOR_LO 5
#define VER_LAMEXP_TYPE RC #define VER_LAMEXP_TYPE RC
#define VER_LAMEXP_PATCH 2 #define VER_LAMEXP_PATCH 2
#define VER_LAMEXP_BUILD 1096 #define VER_LAMEXP_BUILD 1097
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!) // Tool versions (minimum expected versions!)

View File

@ -233,7 +233,8 @@ const unsigned int *OpusEncoder::supportedChannelCount(void)
const unsigned int *OpusEncoder::supportedBitdepths(void) const unsigned int *OpusEncoder::supportedBitdepths(void)
{ {
return NULL; static const unsigned int supportedBPS[] = {8, 16, 24, AudioFileModel::BITDEPTH_IEEE_FLOAT32, NULL};
return supportedBPS;
} }
const bool OpusEncoder::needsTimingInfo(void) const bool OpusEncoder::needsTimingInfo(void)

View File

@ -25,9 +25,12 @@
#include <QObject> #include <QObject>
#include <QMutexLocker> #include <QMutexLocker>
#include <QFile> #include <QFile>
#include <limits.h>
#define U16Str(X) QString::fromUtf16(reinterpret_cast<const unsigned short*>(L##X)) #define U16Str(X) QString::fromUtf16(reinterpret_cast<const unsigned short*>(L##X))
const unsigned int AudioFileModel::BITDEPTH_IEEE_FLOAT32 = UINT_MAX-1;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Constructor & Destructor // Constructor & Destructor
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -288,7 +291,14 @@ const QString AudioFileModel::formatAudioBaseInfo(void) const
if(m_formatAudioBitdepth) if(m_formatAudioBitdepth)
{ {
if(!info.isEmpty()) info.append(", "); if(!info.isEmpty()) info.append(", ");
info.append(QString("%1: %2 Bit").arg(tr("Bitdepth"), QString::number(m_formatAudioBitdepth))); if(m_formatAudioBitdepth == BITDEPTH_IEEE_FLOAT32)
{
info.append(QString("%1: %2 Bit (IEEE Float)").arg(tr("Bitdepth"), QString::number(32)));
}
else
{
info.append(QString("%1: %2 Bit").arg(tr("Bitdepth"), QString::number(m_formatAudioBitdepth)));
}
} }
return info; return info;
} }

View File

@ -45,6 +45,8 @@ public:
BitrateModeVariable = 2, BitrateModeVariable = 2,
}; };
static const unsigned int BITDEPTH_IEEE_FLOAT32;
//----------------------- //-----------------------
//Getters //Getters
//----------------------- //-----------------------

View File

@ -339,6 +339,11 @@ const AudioFileModel AnalyzeTask::analyzeFile(const QString &filePath, int *type
retrieveCover(audioFile, coverType, coverData); retrieveCover(audioFile, coverType, coverData);
} }
if((audioFile.formatAudioType().compare("PCM", Qt::CaseInsensitive) == 0) && (audioFile.formatAudioProfile().compare("Float", Qt::CaseInsensitive) == 0))
{
if(audioFile.formatAudioBitdepth() == 32) audioFile.setFormatAudioBitdepth(AudioFileModel::BITDEPTH_IEEE_FLOAT32);
}
return audioFile; return audioFile;
} }

View File

@ -444,25 +444,40 @@ void ProcessThread::insertDownsampleFilter(void)
/* Adjust bit depth (word size) */ /* Adjust bit depth (word size) */
if(m_encoder->supportedBitdepths() && m_audioFile.formatAudioBitdepth()) if(m_encoder->supportedBitdepths() && m_audioFile.formatAudioBitdepth())
{ {
const unsigned int *supportedBPS = m_encoder->supportedBitdepths();
const unsigned int inputBPS = m_audioFile.formatAudioBitdepth(); const unsigned int inputBPS = m_audioFile.formatAudioBitdepth();
unsigned int currentDiff = UINT_MAX, minimumDiff = UINT_MAX, bestBPS = UINT_MAX; const unsigned int *supportedBPS = m_encoder->supportedBitdepths();
//Find the most suitable supported bit depth bool bAdjustBitdepth = true;
//Is the input bit depth supported exactly? (inclduing IEEE Float)
for(int i = 0; supportedBPS[i]; i++) for(int i = 0; supportedBPS[i]; i++)
{ {
currentDiff = DIFF(inputBPS, supportedBPS[i]); if(supportedBPS[i] == inputBPS) bAdjustBitdepth = false;
if((currentDiff < minimumDiff) || ((currentDiff == minimumDiff) && (bestBPS < supportedBPS[i])))
{
bestBPS = supportedBPS[i];
minimumDiff = currentDiff;
if(!(minimumDiff > 0)) break;
}
} }
if(bestBPS != inputBPS) if(bAdjustBitdepth)
{ {
targetBitDepth = (bestBPS != UINT_MAX) ? bestBPS : supportedBPS[0]; unsigned int currentDiff = UINT_MAX, minimumDiff = UINT_MAX, bestBPS = UINT_MAX;
const unsigned int originalBPS = (inputBPS == AudioFileModel::BITDEPTH_IEEE_FLOAT32) ? 32 : inputBPS;
//Find the most suitable supported bit depth
for(int i = 0; supportedBPS[i]; i++)
{
if(supportedBPS[i] == AudioFileModel::BITDEPTH_IEEE_FLOAT32) continue;
currentDiff = DIFF(originalBPS, supportedBPS[i]);
if((currentDiff < minimumDiff) || ((currentDiff == minimumDiff) && (bestBPS < supportedBPS[i])))
{
bestBPS = supportedBPS[i];
minimumDiff = currentDiff;
if(!(minimumDiff > 0)) break;
}
}
if(bestBPS != originalBPS)
{
targetBitDepth = (bestBPS != UINT_MAX) ? bestBPS : supportedBPS[0];
}
} }
} }

View File

@ -96,7 +96,7 @@ bool WaveProperties::detect(const QString &sourceFile, AudioFileModel *info, vol
{ {
bool ok = false; bool ok = false;
unsigned int tmp = regExp_encoding.cap(1).toUInt(&ok); unsigned int tmp = regExp_encoding.cap(1).toUInt(&ok);
if(ok) info->setFormatAudioBitdepth(tmp); if(ok) info->setFormatAudioBitdepth((tmp == 32) ? AudioFileModel::BITDEPTH_IEEE_FLOAT32 : tmp);
emit statusUpdated(qMin(progress += 25, 100)); emit statusUpdated(qMin(progress += 25, 100));
} }
if(regExp_samplerate.lastIndexIn(text) >= 0) if(regExp_samplerate.lastIndexIn(text) >= 0)