Added support for bitrate management to LAME and OggEnc2 encoders.

This commit is contained in:
LoRd_MuldeR 2011-01-21 23:25:55 +01:00
parent 41d040e7aa
commit 3f0796d288
13 changed files with 168 additions and 11 deletions

View File

@ -413,6 +413,22 @@
<source>Better quality</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> Bitrate Management (LAME and OggEnc2) </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable Bitrate Management</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Minimum (kbps):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Maximum (kbps):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> Encode Now!</source>
<translation type="unfinished"></translation>

View File

@ -157,7 +157,7 @@
</message>
<message>
<source>The True Audio - Lossless Audio Codec</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
</context>
<context>
@ -896,35 +896,51 @@
</message>
<message>
<source> LAME Algorithm Quality </source>
<translation type="unfinished"></translation>
<translation>LAME Algorithmus Qualität</translation>
</message>
<message>
<source>Faster Processing</source>
<translation type="unfinished"></translation>
<translation>Schnellere Verarbeitung</translation>
</message>
<message>
<source>Better quality</source>
<translation type="unfinished"></translation>
<translation>Bessere Qualität</translation>
</message>
<message>
<source>Best Quality (Very Slow)</source>
<translation type="unfinished"></translation>
<translation>Beste Qualität (Sehr Langsam)</translation>
</message>
<message>
<source>High Quality (Recommended)</source>
<translation type="unfinished"></translation>
<translation>Höhere Qualität (Empfohlen)</translation>
</message>
<message>
<source>Average Quality (Default)</source>
<translation type="unfinished"></translation>
<translation>Mittlere Qualität (Standard)</translation>
</message>
<message>
<source>Low Quality (Fast)</source>
<translation type="unfinished"></translation>
<translation>Niedrige Qualität (Schnell)</translation>
</message>
<message>
<source>Poor Quality (Very Fast)</source>
<translation type="unfinished"></translation>
<translation>Miese Qualität (Sehr Schnell)</translation>
</message>
<message>
<source> Bitrate Management (LAME and OggEnc2) </source>
<translation>Bitraten Verwaltung (LAME und OggEnc2)</translation>
</message>
<message>
<source>Enable Bitrate Management</source>
<translation>Bitraten Verwaltung Aktivieren</translation>
</message>
<message>
<source>Minimum (kbps):</source>
<translation>Minimum (kbps):</translation>
</message>
<message>
<source>Maximum (kbps):</source>
<translation>Maximum (kbps):</translation>
</message>
</context>
<context>

View File

@ -926,6 +926,22 @@
<source>Poor Quality (Very Fast)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> Bitrate Management (LAME and OggEnc2) </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable Bitrate Management</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Minimum (kbps):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Maximum (kbps):</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -930,6 +930,22 @@ Votre dossier TEMP est situé ici:</translation>
<source>Poor Quality (Very Fast)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> Bitrate Management (LAME and OggEnc2) </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable Bitrate Management</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Minimum (kbps):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Maximum (kbps):</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -926,6 +926,22 @@
<source>Poor Quality (Very Fast)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> Bitrate Management (LAME and OggEnc2) </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable Bitrate Management</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Minimum (kbps):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Maximum (kbps):</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetaInfo</name>

View File

@ -1120,7 +1120,7 @@
</font>
</property>
<property name="title">
<string> Bitrate Management </string>
<string> Bitrate Management (LAME and OggEnc2) </string>
</property>
<layout class="QGridLayout" name="gridLayout_19">
<item row="0" column="0">
@ -1700,6 +1700,7 @@
<include location="../res/Icons.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Icons.qrc"/>
</resources>
<connections>
<connection>

Binary file not shown.

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0
#define VER_LAMEXP_BUILD 245
#define VER_LAMEXP_BUILD 246
#define VER_LAMEXP_SUFFIX Beta-1
/*

View File

@ -436,6 +436,10 @@ void ProcessingDialog::startNextJob(void)
mp3Encoder->setBitrate(m_settings->compressionBitrate());
mp3Encoder->setRCMode(m_settings->compressionRCMode());
mp3Encoder->setAlgoQuality(m_settings->lameAlgoQuality());
if(m_settings->bitrateManagementEnabled())
{
mp3Encoder->setBitrateLimits(m_settings->bitrateManagementMinRate(), m_settings->bitrateManagementMaxRate());
}
encoder = mp3Encoder;
}
break;
@ -444,6 +448,10 @@ void ProcessingDialog::startNextJob(void)
VorbisEncoder *vorbisEncoder = new VorbisEncoder();
vorbisEncoder->setBitrate(m_settings->compressionBitrate());
vorbisEncoder->setRCMode(m_settings->compressionRCMode());
if(m_settings->bitrateManagementEnabled())
{
vorbisEncoder->setBitrateLimits(m_settings->bitrateManagementMinRate(), m_settings->bitrateManagementMaxRate());
}
encoder = vorbisEncoder;
}
break;

View File

@ -42,6 +42,8 @@ MP3Encoder::MP3Encoder(void)
}
m_algorithmQuality = 3;
m_configBitrateMaximum = 0;
m_configBitrateMinimum = 0;
}
MP3Encoder::~MP3Encoder(void)
@ -73,6 +75,15 @@ bool MP3Encoder::encode(const QString &sourceFile, const AudioFileModel &metaInf
break;
}
if((m_configBitrateMaximum > 0) && (m_configBitrateMinimum > 0) && (m_configBitrateMinimum <= m_configBitrateMaximum))
{
if(m_configRCMode != SettingsModel::CBRMode)
{
args << "-b" << QString::number(clipBitrate(m_configBitrateMinimum));
args << "-B" << QString::number(clipBitrate(m_configBitrateMaximum));
}
}
if(!metaInfo.fileName().isEmpty()) args << (IS_UNICODE(metaInfo.fileName()) ? "--uTitle" : "--lTitle") << metaInfo.fileName();
if(!metaInfo.fileArtist().isEmpty()) args << (IS_UNICODE(metaInfo.fileArtist()) ? "--uArtist" : "--lArtist") << metaInfo.fileArtist();
if(!metaInfo.fileAlbum().isEmpty()) args << (IS_UNICODE(metaInfo.fileAlbum()) ? "--uAlbum" : "--lAlbum") << metaInfo.fileAlbum();
@ -188,3 +199,35 @@ void MP3Encoder::setAlgoQuality(int value)
{
m_algorithmQuality = value;
}
void MP3Encoder::setBitrateLimits(int minimumBitrate, int maximumBitrate)
{
m_configBitrateMinimum = minimumBitrate;
m_configBitrateMaximum = maximumBitrate;
}
int MP3Encoder::clipBitrate(int bitrate)
{
int targetBitrate = min(max(bitrate, 32), 320);
int minDiff = INT_MAX;
int minIndx = -1;
for(int i = 0; SettingsModel::mp3Bitrates[i] > 0; i++)
{
int currentDiff = abs(targetBitrate - SettingsModel::mp3Bitrates[i]);
if(currentDiff < minDiff)
{
minDiff = currentDiff;
minIndx = i;
}
}
if(minIndx >= 0)
{
return SettingsModel::mp3Bitrates[minIndx];
}
return targetBitrate;
}

View File

@ -40,8 +40,14 @@ public:
//Advanced options
virtual void setAlgoQuality(int value);
virtual void setBitrateLimits(int minimumBitrate, int maximumBitrate);
private:
const QString m_binary;
int m_algorithmQuality;
int m_configBitrateMaximum;
int m_configBitrateMinimum;
int clipBitrate(int bitrate);
};

View File

@ -41,6 +41,9 @@ VorbisEncoder::VorbisEncoder(void)
{
throw "Error initializing Vorbis encoder. Tool 'oggenc2.exe' is not registred!";
}
m_configBitrateMaximum = 0;
m_configBitrateMinimum = 0;
}
VorbisEncoder::~VorbisEncoder(void)
@ -68,6 +71,12 @@ bool VorbisEncoder::encode(const QString &sourceFile, const AudioFileModel &meta
break;
}
if((m_configBitrateMaximum > 0) && (m_configBitrateMinimum > 0) && (m_configBitrateMinimum <= m_configBitrateMaximum))
{
args << "--min-bitrate" << QString::number(min(max(m_configBitrateMinimum, 32), 500));
args << "--max-bitrate" << QString::number(min(max(m_configBitrateMaximum, 32), 500));
}
if(!metaInfo.fileName().isEmpty()) args << "-t" << metaInfo.fileName();
if(!metaInfo.fileArtist().isEmpty()) args << "-a" << metaInfo.fileArtist();
if(!metaInfo.fileAlbum().isEmpty()) args << "-l" << metaInfo.fileAlbum();
@ -167,3 +176,9 @@ bool VorbisEncoder::isFormatSupported(const QString &containerType, const QStrin
return false;
}
void VorbisEncoder::setBitrateLimits(int minimumBitrate, int maximumBitrate)
{
m_configBitrateMinimum = minimumBitrate;
m_configBitrateMaximum = maximumBitrate;
}

View File

@ -36,9 +36,13 @@ 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 void setBitrateLimits(int minimumBitrate, int maximumBitrate);
private:
const QString m_binary_i386;
const QString m_binary_sse2;
const QString m_binary_x64;
int m_configBitrateMaximum;
int m_configBitrateMinimum;
};