Prepare to support audio encoders that only support specific bit-depths.

This commit is contained in:
LoRd_MuldeR 2011-12-21 01:23:21 +01:00
parent 1d9aaf90ed
commit 2ad5c3068d
7 changed files with 41 additions and 18 deletions

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 4
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 11
#define VER_LAMEXP_BUILD 822
#define VER_LAMEXP_BUILD 823
///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!)

View File

@ -179,7 +179,7 @@ QString AC3Encoder::extension(void)
return "ac3";
}
const unsigned int *AC3Encoder::requiresDownsample(void)
const unsigned int *AC3Encoder::supportedSamplerates(void)
{
static const unsigned int supportedRates[] = {48000, 44100, 32000, NULL};
return supportedRates;

View File

@ -36,7 +36,7 @@ public:
virtual bool encode(const QString &sourceFile, const AudioFileModel &metaInfo, const QString &outputFile, volatile bool *abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
virtual QString extension(void);
virtual const unsigned int *requiresDownsample(void);
virtual const unsigned int *supportedSamplerates(void);
//Advanced options
virtual void setAudioCodingMode(int value);

View File

@ -53,7 +53,13 @@ bool AbstractEncoder::requiresDownmix(void)
}
// Does encoder require the input to be downsampled? (NULL-terminated array of supported sampling rates)
const unsigned int *AbstractEncoder::requiresDownsample(void)
const unsigned int *AbstractEncoder::supportedSamplerates(void)
{
return NULL;
}
// What bitdepths does the encoder support as input? (NULL-terminated array of supported bits per sample)
const unsigned int *AbstractEncoder::supportedBitdepths(void)
{
return NULL;
}

View File

@ -41,7 +41,8 @@ public:
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) = 0;
virtual QString extension(void) = 0;
virtual bool requiresDownmix(void);
virtual const unsigned int *requiresDownsample(void);
virtual const unsigned int *supportedSamplerates(void);
virtual const unsigned int *supportedBitdepths(void);
//Common setter methods
void setBitrate(int bitrate);

View File

@ -128,18 +128,6 @@ void ProcessThread::processFile()
return;
}
//Do we need to take care of downsampling the input?
if(m_encoder->requiresDownsample())
{
insertDownsampleFilter();
}
//Do we need Stereo downmix?
if(m_encoder->requiresDownmix())
{
insertDownmixFilter();
}
QString sourceFile = m_audioFile.filePath();
//Decode source file
@ -173,6 +161,28 @@ void ProcessThread::processFile()
}
}
//Check audio properties
if(bSuccess)
{
//Do we need to take care of downsampling the input?
if(m_encoder->supportedSamplerates())
{
insertDownsampleFilter();
}
//Do we need to change the bits per sample of the input?
if(m_encoder->supportedBitdepths())
{
insertBitdepthFilter();
}
//Do we need Stereo downmix?
if(m_encoder->requiresDownmix())
{
insertDownmixFilter();
}
}
//Apply all audio filters
if(bSuccess)
{
@ -370,7 +380,7 @@ void ProcessThread::insertDownsampleFilter(void)
//Now add the downsampling filter, if needed
if(applyDownsampling)
{
const unsigned int *supportedRates = m_encoder->requiresDownsample();
const unsigned int *supportedRates = m_encoder->supportedSamplerates();
const unsigned int inputRate = m_audioFile.formatAudioSamplerate();
unsigned int currentDiff = UINT_MAX, minimumDiff = UINT_MAX, bestRate = UINT_MAX;
@ -393,6 +403,11 @@ void ProcessThread::insertDownsampleFilter(void)
}
}
void ProcessThread::insertBitdepthFilter(void)
{
qFatal("ProcessThread::insertBitdepthFilter not implemented yet!");
}
void ProcessThread::insertDownmixFilter(void)
{
bool applyDownmixing = true;

View File

@ -70,6 +70,7 @@ private:
QString generateTempFileName(void);
void insertDownsampleFilter(void);
void insertDownmixFilter(void);
void insertBitdepthFilter(void);
const QUuid m_jobId;
AudioFileModel m_audioFile;