diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts index e6ab29c9..85558098 100644 --- a/etc/Translation/Blank.ts +++ b/etc/Translation/Blank.ts @@ -413,6 +413,22 @@ Better quality + + Bitrate Management (LAME and OggEnc2) + + + + Enable Bitrate Management + + + + Minimum (kbps): + + + + Maximum (kbps): + + Encode Now! diff --git a/etc/Translation/LameXP_DE.ts b/etc/Translation/LameXP_DE.ts index 2fac9d0c..e47f569b 100644 --- a/etc/Translation/LameXP_DE.ts +++ b/etc/Translation/LameXP_DE.ts @@ -157,7 +157,7 @@ The True Audio - Lossless Audio Codec - + @@ -896,35 +896,51 @@ LAME Algorithm Quality - + LAME Algorithmus Qualität Faster Processing - + Schnellere Verarbeitung Better quality - + Bessere Qualität Best Quality (Very Slow) - + Beste Qualität (Sehr Langsam) High Quality (Recommended) - + Höhere Qualität (Empfohlen) Average Quality (Default) - + Mittlere Qualität (Standard) Low Quality (Fast) - + Niedrige Qualität (Schnell) Poor Quality (Very Fast) - + Miese Qualität (Sehr Schnell) + + + Bitrate Management (LAME and OggEnc2) + Bitraten Verwaltung (LAME und OggEnc2) + + + Enable Bitrate Management + Bitraten Verwaltung Aktivieren + + + Minimum (kbps): + Minimum (kbps): + + + Maximum (kbps): + Maximum (kbps): diff --git a/etc/Translation/LameXP_ES.ts b/etc/Translation/LameXP_ES.ts index e3b0db4a..63f03e9d 100644 --- a/etc/Translation/LameXP_ES.ts +++ b/etc/Translation/LameXP_ES.ts @@ -926,6 +926,22 @@ Poor Quality (Very Fast) + + Bitrate Management (LAME and OggEnc2) + + + + Enable Bitrate Management + + + + Minimum (kbps): + + + + Maximum (kbps): + + MetaInfo diff --git a/etc/Translation/LameXP_FR.ts b/etc/Translation/LameXP_FR.ts index e8a3af9f..de4113e1 100644 --- a/etc/Translation/LameXP_FR.ts +++ b/etc/Translation/LameXP_FR.ts @@ -930,6 +930,22 @@ Votre dossier TEMP est situé ici: Poor Quality (Very Fast) + + Bitrate Management (LAME and OggEnc2) + + + + Enable Bitrate Management + + + + Minimum (kbps): + + + + Maximum (kbps): + + MetaInfo diff --git a/etc/Translation/LameXP_IT.ts b/etc/Translation/LameXP_IT.ts index d7d98e33..702a4557 100644 --- a/etc/Translation/LameXP_IT.ts +++ b/etc/Translation/LameXP_IT.ts @@ -926,6 +926,22 @@ Poor Quality (Very Fast) + + Bitrate Management (LAME and OggEnc2) + + + + Enable Bitrate Management + + + + Minimum (kbps): + + + + Maximum (kbps): + + MetaInfo diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui index e534e418..dfc051aa 100644 --- a/gui/MainWindow.ui +++ b/gui/MainWindow.ui @@ -1120,7 +1120,7 @@ - Bitrate Management + Bitrate Management (LAME and OggEnc2) @@ -1700,6 +1700,7 @@ + diff --git a/res/localization/LameXP_DE.qm b/res/localization/LameXP_DE.qm index 98b7e604..46ecf0cc 100644 Binary files a/res/localization/LameXP_DE.qm and b/res/localization/LameXP_DE.qm differ diff --git a/src/Config.h b/src/Config.h index b2bafa15..a4f824f8 100644 --- a/src/Config.h +++ b/src/Config.h @@ -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 /* diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index ba4f1b62..53eab6fd 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -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; diff --git a/src/Encoder_MP3.cpp b/src/Encoder_MP3.cpp index 27b4930b..4d223b49 100644 --- a/src/Encoder_MP3.cpp +++ b/src/Encoder_MP3.cpp @@ -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; +} + diff --git a/src/Encoder_MP3.h b/src/Encoder_MP3.h index e5b12369..9079b3fd 100644 --- a/src/Encoder_MP3.h +++ b/src/Encoder_MP3.h @@ -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); }; diff --git a/src/Encoder_Vorbis.cpp b/src/Encoder_Vorbis.cpp index bfd96590..6bc17fb1 100644 --- a/src/Encoder_Vorbis.cpp +++ b/src/Encoder_Vorbis.cpp @@ -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; +} diff --git a/src/Encoder_Vorbis.h b/src/Encoder_Vorbis.h index 80e64f1f..71f5185b 100644 --- a/src/Encoder_Vorbis.h +++ b/src/Encoder_Vorbis.h @@ -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; + };