Fix AC-3 encoding with non-standard sampling rates. Aften needs input at 48, 44.1 or 32 kHz, so insert Resampling filter, if needed.

This commit is contained in:
LoRd_MuldeR 2011-05-06 17:51:49 +02:00
parent 0d2b16424f
commit 4ce167e709
21 changed files with 174 additions and 35 deletions

View File

@ -199,6 +199,10 @@
<source>n/a</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aften &amp;minus; A/52 audio encoder</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -596,10 +600,6 @@
<source> Custom Encoder Parameters </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LAME:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>OggEnc2:</source>
<translation type="unfinished"></translation>
@ -1276,6 +1276,14 @@
<source>Aften A/52</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lame MP3:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aften A/52:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -199,6 +199,10 @@
<source>Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.</source>
<translation>Hinweise: Diese Demo (Test) Version von LameXP läuft am %1 ab. Noch %2 Tage übrig.</translation>
</message>
<message>
<source>Aften &amp;minus; A/52 audio encoder</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -1133,10 +1137,6 @@
<source> Custom Encoder Parameters </source>
<translation> Benutzerdefinierte Parameter </translation>
</message>
<message>
<source>LAME:</source>
<translation></translation>
</message>
<message>
<source>OggEnc2:</source>
<translation></translation>
@ -1277,6 +1277,14 @@
<source>Aften A/52</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lame MP3:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aften A/52:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -199,6 +199,10 @@
<source>Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.</source>
<translation>Nota: Esta es una versión demo (pre-final) de LameXP que expirará el %1. Quedan %2 días restantes.</translation>
</message>
<message>
<source>Aften &amp;minus; A/52 audio encoder</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -1132,10 +1136,6 @@
<source> Custom Encoder Parameters </source>
<translation>Personalizar parámetros de codificación</translation>
</message>
<message>
<source>LAME:</source>
<translation>LAME:</translation>
</message>
<message>
<source>OggEnc2:</source>
<translation>QggEnc2:</translation>
@ -1276,6 +1276,14 @@
<source>Aften A/52</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lame MP3:</source>
<translation type="unfinished">Lame MP3:</translation>
</message>
<message>
<source>Aften A/52:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -203,6 +203,10 @@
<source>Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aften &amp;minus; A/52 audio encoder</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -1141,10 +1145,6 @@ Sélection automatique (par défaut)</translation>
<source> Custom Encoder Parameters </source>
<translation>Paramètres d&apos;encodage personnalisés</translation>
</message>
<message>
<source>LAME:</source>
<translation>LAME :</translation>
</message>
<message>
<source>OggEnc2:</source>
<translation>OggEnc2 :</translation>
@ -1286,6 +1286,14 @@ Ouvrir le dossier récursivement...</translation>
<source>Aften A/52</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lame MP3:</source>
<translation type="unfinished">Lame MP3:</translation>
</message>
<message>
<source>Aften A/52:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -199,6 +199,10 @@
<source>Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aften &amp;minus; A/52 audio encoder</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -1133,10 +1137,6 @@
<source> Custom Encoder Parameters </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LAME:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>OggEnc2:</source>
<translation type="unfinished"></translation>
@ -1277,6 +1277,14 @@
<source>Aften A/52</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lame MP3:</source>
<translation type="unfinished">Lame MP3:</translation>
</message>
<message>
<source>Aften A/52:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -199,6 +199,10 @@
<source>Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aften &amp;minus; A/52 audio encoder</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -596,10 +600,6 @@
<source> Custom Encoder Parameters </source>
<translation type="unfinished"> </translation>
</message>
<message>
<source>LAME:</source>
<translation type="unfinished">LAME:</translation>
</message>
<message>
<source>OggEnc2:</source>
<translation type="unfinished">OggEnc2:</translation>
@ -1276,6 +1276,14 @@
<source>Aften A/52</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lame MP3:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aften A/52:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -199,6 +199,10 @@
<source>Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aften &amp;minus; A/52 audio encoder</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -596,10 +600,6 @@
<source> Custom Encoder Parameters </source>
<translation type="unfinished">Пользовательские параметры кодера</translation>
</message>
<message>
<source>LAME:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>OggEnc2:</source>
<translation type="unfinished"></translation>
@ -1278,6 +1278,14 @@
<source>Aften A/52</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lame MP3:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aften A/52:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -199,6 +199,10 @@
<source>Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aften &amp;minus; A/52 audio encoder</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -1132,10 +1136,6 @@
<source> Custom Encoder Parameters </source>
<translation type="unfinished">Користувацькі параметри кодування </translation>
</message>
<message>
<source>LAME:</source>
<translation type="unfinished">LAME:</translation>
</message>
<message>
<source>OggEnc2:</source>
<translation type="unfinished">OggEnc2:</translation>
@ -1276,6 +1276,14 @@
<source>Aften A/52</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lame MP3:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Aften A/52:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -29,8 +29,8 @@
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 2
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 10
#define VER_LAMEXP_BUILD 485
#define VER_LAMEXP_PATCH 12
#define VER_LAMEXP_BUILD 488
///////////////////////////////////////////////////////////////////////////////
// Tools versions

View File

@ -135,6 +135,12 @@ QString AC3Encoder::extension(void)
return "ac3";
}
const unsigned int *AC3Encoder::requiresDownsample(void)
{
static const unsigned int supportedRates[] = {48000, 44100, 32000, NULL};
return supportedRates;
}
bool AC3Encoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
{
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)

View File

@ -36,6 +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);
private:
const QString m_binary;

View File

@ -45,11 +45,19 @@ void AbstractEncoder::setCustomParams(const QString &customParams) { m_configCus
/*
* Default implementation
*/
// Does encoder require the input to be downmixed to stereo?
bool AbstractEncoder::requiresDownmix(void)
{
return false;
}
// Does encoder require the input to be downsampled? (NULL-terminated array of supported sampling rates)
const unsigned int *AbstractEncoder::requiresDownsample(void)
{
return NULL;
}
/*
* Helper functions
*/

View File

@ -41,6 +41,7 @@ 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);
//Common setter methods
void setBitrate(int bitrate);

View File

@ -28,6 +28,7 @@
#include "Decoder_Abstract.h"
#include "Filter_Abstract.h"
#include "Filter_Downmix.h"
#include "Filter_Resample.h"
#include "Registry_Decoder.h"
#include "Model_Settings.h"
@ -40,6 +41,9 @@
#include <limits.h>
#include <time.h>
#include <stdlib.h>
#define DIFF(X,Y) ((X > Y) ? (X-Y) : (Y-X))
QMutex *ProcessThread::m_mutex_genFileName = NULL;
@ -83,6 +87,10 @@ ProcessThread::~ProcessThread(void)
LAMEXP_DELETE(m_encoder);
}
////////////////////////////////////////////////////////////
// Thread Entry Point
////////////////////////////////////////////////////////////
void ProcessThread::run()
{
try
@ -117,7 +125,13 @@ void ProcessThread::processFile()
emit processStateFinished(m_jobId, outFileName, false);
return;
}
//Do we need to take of downsampling the input?
if(m_encoder->requiresDownsample())
{
insertDownsampleFilter();
}
//Do we need Stereo downmix?
if(m_audioFile.formatAudioChannels() > 2 && m_encoder->requiresDownmix())
{
@ -324,6 +338,50 @@ QString ProcessThread::generateTempFileName(void)
return tempFileName;
}
void ProcessThread::insertDownsampleFilter(void)
{
bool applyDownsampling = true;
//Check if downsampling filter is already in the chain
for(int i = 0; i < m_filters.count(); i++)
{
if(dynamic_cast<ResampleFilter*>(m_filters.at(i)))
{
qWarning("Encoder requires downsampling, but user has already set resamling filter!");
applyDownsampling = false;
}
}
//Now add the downsampling filter, if needed
if(applyDownsampling)
{
const unsigned int *supportedRates = m_encoder->requiresDownsample();
const unsigned int inputRate = m_audioFile.formatAudioSamplerate();
unsigned int currentDiff = UINT_MAX, minimumDiff = UINT_MAX, bestRate = UINT_MAX;
//Find the most suitable supported sampling rate
for(int i = 0; supportedRates[i]; i++)
{
currentDiff = DIFF(inputRate, supportedRates[i]);
if(currentDiff < minimumDiff)
{
bestRate = supportedRates[i];
minimumDiff = currentDiff;
if(!(minimumDiff > 0)) break;
}
}
if(bestRate != inputRate)
{
m_filters.prepend(new ResampleFilter((bestRate != UINT_MAX) ? bestRate : supportedRates[0]));
}
}
}
////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS
////////////////////////////////////////////////////////////
void ProcessThread::addFilter(AbstractFilter *filter)
{
m_filters.append(filter);

View File

@ -67,6 +67,7 @@ private:
void processFile();
QString generateOutFileName(void);
QString generateTempFileName(void);
void insertDownsampleFilter(void);
const QUuid m_jobId;
AudioFileModel m_audioFile;