Prepare to support audio encoders that only support specific bit-depths.
This commit is contained in:
parent
1d9aaf90ed
commit
2ad5c3068d
@ -30,7 +30,7 @@
|
|||||||
#define VER_LAMEXP_MINOR_LO 4
|
#define VER_LAMEXP_MINOR_LO 4
|
||||||
#define VER_LAMEXP_TYPE Alpha
|
#define VER_LAMEXP_TYPE Alpha
|
||||||
#define VER_LAMEXP_PATCH 11
|
#define VER_LAMEXP_PATCH 11
|
||||||
#define VER_LAMEXP_BUILD 822
|
#define VER_LAMEXP_BUILD 823
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Tool versions (minimum expected versions!)
|
// Tool versions (minimum expected versions!)
|
||||||
|
@ -179,7 +179,7 @@ QString AC3Encoder::extension(void)
|
|||||||
return "ac3";
|
return "ac3";
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int *AC3Encoder::requiresDownsample(void)
|
const unsigned int *AC3Encoder::supportedSamplerates(void)
|
||||||
{
|
{
|
||||||
static const unsigned int supportedRates[] = {48000, 44100, 32000, NULL};
|
static const unsigned int supportedRates[] = {48000, 44100, 32000, NULL};
|
||||||
return supportedRates;
|
return supportedRates;
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
virtual bool encode(const QString &sourceFile, const AudioFileModel &metaInfo, const QString &outputFile, volatile bool *abortFlag);
|
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 bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||||
virtual QString extension(void);
|
virtual QString extension(void);
|
||||||
virtual const unsigned int *requiresDownsample(void);
|
virtual const unsigned int *supportedSamplerates(void);
|
||||||
|
|
||||||
//Advanced options
|
//Advanced options
|
||||||
virtual void setAudioCodingMode(int value);
|
virtual void setAudioCodingMode(int value);
|
||||||
|
@ -53,7 +53,13 @@ bool AbstractEncoder::requiresDownmix(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Does encoder require the input to be downsampled? (NULL-terminated array of supported sampling rates)
|
// 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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -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 bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) = 0;
|
||||||
virtual QString extension(void) = 0;
|
virtual QString extension(void) = 0;
|
||||||
virtual bool requiresDownmix(void);
|
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
|
//Common setter methods
|
||||||
void setBitrate(int bitrate);
|
void setBitrate(int bitrate);
|
||||||
|
@ -128,18 +128,6 @@ void ProcessThread::processFile()
|
|||||||
return;
|
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();
|
QString sourceFile = m_audioFile.filePath();
|
||||||
|
|
||||||
//Decode source file
|
//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
|
//Apply all audio filters
|
||||||
if(bSuccess)
|
if(bSuccess)
|
||||||
{
|
{
|
||||||
@ -370,7 +380,7 @@ void ProcessThread::insertDownsampleFilter(void)
|
|||||||
//Now add the downsampling filter, if needed
|
//Now add the downsampling filter, if needed
|
||||||
if(applyDownsampling)
|
if(applyDownsampling)
|
||||||
{
|
{
|
||||||
const unsigned int *supportedRates = m_encoder->requiresDownsample();
|
const unsigned int *supportedRates = m_encoder->supportedSamplerates();
|
||||||
const unsigned int inputRate = m_audioFile.formatAudioSamplerate();
|
const unsigned int inputRate = m_audioFile.formatAudioSamplerate();
|
||||||
unsigned int currentDiff = UINT_MAX, minimumDiff = UINT_MAX, bestRate = UINT_MAX;
|
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)
|
void ProcessThread::insertDownmixFilter(void)
|
||||||
{
|
{
|
||||||
bool applyDownmixing = true;
|
bool applyDownmixing = true;
|
||||||
|
@ -70,6 +70,7 @@ private:
|
|||||||
QString generateTempFileName(void);
|
QString generateTempFileName(void);
|
||||||
void insertDownsampleFilter(void);
|
void insertDownsampleFilter(void);
|
||||||
void insertDownmixFilter(void);
|
void insertDownmixFilter(void);
|
||||||
|
void insertBitdepthFilter(void);
|
||||||
|
|
||||||
const QUuid m_jobId;
|
const QUuid m_jobId;
|
||||||
AudioFileModel m_audioFile;
|
AudioFileModel m_audioFile;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user