From 0d2b16424f36d510f0d653bd991dd047627517b2 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Thu, 5 May 2011 12:27:25 +0200 Subject: [PATCH] Implemented encoding mode and bitrate selection for AC-3 encoder. Also support for custom parameters. --- etc/Translation/Blank.ts | 4 ++++ etc/Translation/LameXP_DE.ts | 4 ++++ etc/Translation/LameXP_ES.ts | 4 ++++ etc/Translation/LameXP_FR.ts | 4 ++++ etc/Translation/LameXP_IT.ts | 4 ++++ etc/Translation/LameXP_KR.ts | 4 ++++ etc/Translation/LameXP_RU.ts | 4 ++++ etc/Translation/LameXP_UK.ts | 4 ++++ gui/MainWindow.ui | 33 ++++++++++++++++++++++++++------- src/Config.h | 2 +- src/Dialog_MainWindow.cpp | 34 ++++++++++++++++++++++++++++++++++ src/Dialog_Processing.cpp | 2 +- src/Encoder_AC3.cpp | 24 +++++++++++++----------- src/Encoder_MP3.cpp | 4 ++-- src/Model_Settings.cpp | 3 +++ src/Model_Settings.h | 2 ++ 16 files changed, 114 insertions(+), 22 deletions(-) diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts index d106bb26..1c1895fe 100644 --- a/etc/Translation/Blank.ts +++ b/etc/Translation/Blank.ts @@ -1272,6 +1272,10 @@ The LameXP shell integration has been re-enabled. + + Aften A/52 + + MetaInfo diff --git a/etc/Translation/LameXP_DE.ts b/etc/Translation/LameXP_DE.ts index f3664926..cf374a41 100644 --- a/etc/Translation/LameXP_DE.ts +++ b/etc/Translation/LameXP_DE.ts @@ -1273,6 +1273,10 @@ LameXP will <i>not</i> check for Beta (pre-release) updates from now on. LameXP wird fortan <i>nicht</i> nach Beta (Entwickler) Updates suchen. + + Aften A/52 + + MetaInfo diff --git a/etc/Translation/LameXP_ES.ts b/etc/Translation/LameXP_ES.ts index 9bb127c6..a400b29e 100644 --- a/etc/Translation/LameXP_ES.ts +++ b/etc/Translation/LameXP_ES.ts @@ -1272,6 +1272,10 @@ LameXP will <i>not</i> check for Beta (pre-release) updates from now on. + + Aften A/52 + + MetaInfo diff --git a/etc/Translation/LameXP_FR.ts b/etc/Translation/LameXP_FR.ts index c89ee9d2..545b18cd 100644 --- a/etc/Translation/LameXP_FR.ts +++ b/etc/Translation/LameXP_FR.ts @@ -1282,6 +1282,10 @@ Ouvrir le dossier récursivement... LameXP will <i>not</i> check for Beta (pre-release) updates from now on. + + Aften A/52 + + MetaInfo diff --git a/etc/Translation/LameXP_IT.ts b/etc/Translation/LameXP_IT.ts index 1c2b12e6..7ab0fe7d 100644 --- a/etc/Translation/LameXP_IT.ts +++ b/etc/Translation/LameXP_IT.ts @@ -1273,6 +1273,10 @@ LameXP will <i>not</i> check for Beta (pre-release) updates from now on. + + Aften A/52 + + MetaInfo diff --git a/etc/Translation/LameXP_KR.ts b/etc/Translation/LameXP_KR.ts index 353b23e0..fc2923a9 100644 --- a/etc/Translation/LameXP_KR.ts +++ b/etc/Translation/LameXP_KR.ts @@ -1272,6 +1272,10 @@ LameXP will <i>not</i> check for Beta (pre-release) updates from now on. + + Aften A/52 + + MetaInfo diff --git a/etc/Translation/LameXP_RU.ts b/etc/Translation/LameXP_RU.ts index 1f189b09..6541ec4b 100644 --- a/etc/Translation/LameXP_RU.ts +++ b/etc/Translation/LameXP_RU.ts @@ -1274,6 +1274,10 @@ LameXP will <i>not</i> check for Beta (pre-release) updates from now on. + + Aften A/52 + + MetaInfo diff --git a/etc/Translation/LameXP_UK.ts b/etc/Translation/LameXP_UK.ts index e6130c4a..3cfd6033 100644 --- a/etc/Translation/LameXP_UK.ts +++ b/etc/Translation/LameXP_UK.ts @@ -1272,6 +1272,10 @@ LameXP will <i>not</i> check for Beta (pre-release) updates from now on. + + Aften A/52 + + MetaInfo diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui index 2a60f758..ac988334 100644 --- a/gui/MainWindow.ui +++ b/gui/MainWindow.ui @@ -30,7 +30,7 @@ - 3 + 0 false @@ -1067,8 +1067,8 @@ 0 0 - 602 - 1088 + 604 + 1117 @@ -2081,7 +2081,7 @@ - LAME: + Lame MP3: @@ -2154,7 +2154,7 @@ - + Qt::Vertical @@ -2170,7 +2170,7 @@ - + @@ -2197,7 +2197,7 @@ - + @@ -2216,6 +2216,22 @@ + + + + + Lucida Console + + + + + + + + Aften A/52: + + + @@ -3172,6 +3188,9 @@ + + + diff --git a/src/Config.h b/src/Config.h index 0ace89d4..86eccd7d 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 2 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 10 -#define VER_LAMEXP_BUILD 484 +#define VER_LAMEXP_BUILD 485 /////////////////////////////////////////////////////////////////////////////// // Tools versions diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 6047391a..b66a75c1 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -226,6 +226,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S lineEditCustomParamOggEnc->setText(m_settings->customParametersOggEnc()); lineEditCustomParamNeroAAC->setText(m_settings->customParametersNeroAAC()); lineEditCustomParamFLAC->setText(m_settings->customParametersFLAC()); + lineEditCustomParamAften->setText(m_settings->customParametersAften()); lineEditCustomTempFolder->setText(QDir::toNativeSeparators(m_settings->customTempPath())); connect(sliderLameAlgoQuality, SIGNAL(valueChanged(int)), this, SLOT(updateLameAlgoQuality(int))); connect(checkBoxBitrateManagement, SIGNAL(clicked(bool)), this, SLOT(bitrateManagementEnabledChanged(bool))); @@ -244,6 +245,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S connect(lineEditCustomParamOggEnc, SIGNAL(editingFinished()), this, SLOT(customParamsChanged())); connect(lineEditCustomParamNeroAAC, SIGNAL(editingFinished()), this, SLOT(customParamsChanged())); connect(lineEditCustomParamFLAC, SIGNAL(editingFinished()), this, SLOT(customParamsChanged())); + connect(lineEditCustomParamAften, SIGNAL(editingFinished()), this, SLOT(customParamsChanged())); connect(sliderMaxInstances, SIGNAL(valueChanged(int)), this, SLOT(updateMaximumInstances(int))); connect(checkBoxAutoDetectInstances, SIGNAL(clicked(bool)), this, SLOT(autoDetectInstancesChanged(bool))); connect(buttonBrowseCustomTempFolder, SIGNAL(clicked()), this, SLOT(browseCustomTempFolderButtonClicked())); @@ -1759,6 +1761,13 @@ void MainWindow::updateEncoder(int id) if(radioButtonConstBitrate->isChecked()) radioButtonModeQuality->setChecked(true); sliderBitrate->setEnabled(true); break; + case SettingsModel::AC3Encoder: + radioButtonModeQuality->setEnabled(true); + radioButtonModeQuality->setChecked(true); + radioButtonModeAverageBitrate->setEnabled(false); + radioButtonConstBitrate->setEnabled(true); + sliderBitrate->setEnabled(true); + break; case SettingsModel::FLACEncoder: radioButtonModeQuality->setEnabled(false); radioButtonModeQuality->setChecked(true); @@ -1819,6 +1828,19 @@ void MainWindow::updateRCMode(int id) break; } break; + case SettingsModel::AC3Encoder: + switch(m_settings->compressionRCMode()) + { + case SettingsModel::VBRMode: + sliderBitrate->setMinimum(0); + sliderBitrate->setMaximum(16); + break; + default: + sliderBitrate->setMinimum(0); + sliderBitrate->setMaximum(18); + break; + } + break; case SettingsModel::AACEncoder: switch(m_settings->compressionRCMode()) { @@ -1874,6 +1896,9 @@ void MainWindow::updateBitrate(int value) case SettingsModel::FLACEncoder: labelBitrate->setText(tr("Compression %1").arg(value)); break; + case SettingsModel::AC3Encoder: + labelBitrate->setText(tr("Quality Level %1").arg(min(1023, max(0, value * 64)))); + break; case SettingsModel::PCMEncoder: labelBitrate->setText(tr("Uncompressed")); break; @@ -1891,6 +1916,9 @@ void MainWindow::updateBitrate(int value) case SettingsModel::FLACEncoder: labelBitrate->setText(tr("Compression %1").arg(value)); break; + case SettingsModel::AC3Encoder: + labelBitrate->setText(QString("≈ %1 kbps").arg(SettingsModel::ac3Bitrates[value])); + break; case SettingsModel::PCMEncoder: labelBitrate->setText(tr("Uncompressed")); break; @@ -1908,6 +1936,9 @@ void MainWindow::updateBitrate(int value) case SettingsModel::FLACEncoder: labelBitrate->setText(tr("Compression %1").arg(value)); break; + case SettingsModel::AC3Encoder: + labelBitrate->setText(QString("≈ %1 kbps").arg(SettingsModel::ac3Bitrates[value])); + break; case SettingsModel::PCMEncoder: labelBitrate->setText(tr("Uncompressed")); break; @@ -2079,12 +2110,14 @@ void MainWindow::customParamsChanged(void) lineEditCustomParamOggEnc->setText(lineEditCustomParamOggEnc->text().simplified()); lineEditCustomParamNeroAAC->setText(lineEditCustomParamNeroAAC->text().simplified()); lineEditCustomParamFLAC->setText(lineEditCustomParamFLAC->text().simplified()); + lineEditCustomParamAften->setText(lineEditCustomParamAften->text().simplified()); bool customParamsUsed = false; if(!lineEditCustomParamLAME->text().isEmpty()) customParamsUsed = true; if(!lineEditCustomParamOggEnc->text().isEmpty()) customParamsUsed = true; if(!lineEditCustomParamNeroAAC->text().isEmpty()) customParamsUsed = true; if(!lineEditCustomParamFLAC->text().isEmpty()) customParamsUsed = true; + if(!lineEditCustomParamAften->text().isEmpty()) customParamsUsed = true; labelCustomParamsIcon->setVisible(customParamsUsed); labelCustomParamsText->setVisible(customParamsUsed); @@ -2094,6 +2127,7 @@ void MainWindow::customParamsChanged(void) m_settings->customParametersOggEnc(lineEditCustomParamOggEnc->text()); m_settings->customParametersNeroAAC(lineEditCustomParamNeroAAC->text()); m_settings->customParametersFLAC(lineEditCustomParamFLAC->text()); + m_settings->customParametersAften(lineEditCustomParamAften->text()); } /* diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index 95ba8e60..4b092dbb 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -606,7 +606,7 @@ void ProcessingDialog::startNextJob(void) AC3Encoder *ac3Encoder = new AC3Encoder(); ac3Encoder->setBitrate(m_settings->compressionBitrate()); ac3Encoder->setRCMode(m_settings->compressionRCMode()); - ac3Encoder->setCustomParams(m_settings->customParametersNeroAAC()); + ac3Encoder->setCustomParams(m_settings->customParametersAften()); encoder = ac3Encoder; } break; diff --git a/src/Encoder_AC3.cpp b/src/Encoder_AC3.cpp index 1f3cee22..7627cb6d 100644 --- a/src/Encoder_AC3.cpp +++ b/src/Encoder_AC3.cpp @@ -49,18 +49,20 @@ bool AC3Encoder::encode(const QString &sourceFile, const AudioFileModel &metaInf QProcess process; QStringList args; - //args << QString("-%1").arg(QString::number(max(0, min(8, m_configBitrate)))); + switch(m_configRCMode) + { + case SettingsModel::VBRMode: + args << "-q" << QString::number(max(0, min(1023, m_configBitrate * 64))); + break; + case SettingsModel::CBRMode: + args << "-b" << QString::number(SettingsModel::ac3Bitrates[max(0, min(18, m_configBitrate))]); + break; + default: + throw "Bad rate-control mode!"; + break; + } - //if(!metaInfo.fileName().isEmpty()) args << "-T" << QString("title=%1").arg(metaInfo.fileName()); - //if(!metaInfo.fileArtist().isEmpty()) args << "-T" << QString("artist=%1").arg(metaInfo.fileArtist()); - //if(!metaInfo.fileAlbum().isEmpty()) args << "-T" << QString("album=%1").arg(metaInfo.fileAlbum()); - //if(!metaInfo.fileGenre().isEmpty()) args << "-T" << QString("genre=%1").arg(metaInfo.fileGenre()); - //if(!metaInfo.fileComment().isEmpty()) args << "-T" << QString("comment=%1").arg(metaInfo.fileComment()); - //if(metaInfo.fileYear()) args << "-T" << QString("date=%1").arg(QString::number(metaInfo.fileYear())); - //if(metaInfo.filePosition()) args << "-T" << QString("track=%1").arg(QString::number(metaInfo.filePosition())); - //if(!metaInfo.fileCover().isEmpty()) args << QString("--picture=%1").arg(metaInfo.fileCover()); - - //if(!m_configCustomParams.isEmpty()) args << m_configCustomParams.split(" ", QString::SkipEmptyParts); + if(!m_configCustomParams.isEmpty()) args << m_configCustomParams.split(" ", QString::SkipEmptyParts); args << QDir::toNativeSeparators(sourceFile); args << QDir::toNativeSeparators(outputFile); diff --git a/src/Encoder_MP3.cpp b/src/Encoder_MP3.cpp index 99201934..9a6ee16d 100644 --- a/src/Encoder_MP3.cpp +++ b/src/Encoder_MP3.cpp @@ -64,11 +64,11 @@ bool MP3Encoder::encode(const QString &sourceFile, const AudioFileModel &metaInf args << "-V" << QString::number(9 - min(9, m_configBitrate)); break; case SettingsModel::ABRMode: - args << "--abr" << QString::number(SettingsModel::mp3Bitrates[min(13, m_configBitrate)]); + args << "--abr" << QString::number(SettingsModel::mp3Bitrates[max(0, min(13, m_configBitrate))]); break; case SettingsModel::CBRMode: args << "--cbr"; - args << "-b" << QString::number(SettingsModel::mp3Bitrates[min(13, m_configBitrate)]); + args << "-b" << QString::number(SettingsModel::mp3Bitrates[max(0, min(13, m_configBitrate))]); break; default: throw "Bad rate-control mode!"; diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp index 7358c1bc..5dd9827d 100644 --- a/src/Model_Settings.cpp +++ b/src/Model_Settings.cpp @@ -101,6 +101,7 @@ LAMEXP_MAKE_ID(toneAdjustTreble, "AdvancedOptions/ToneAdjustment/Treble"); LAMEXP_MAKE_ID(customParametersLAME, "AdvancedOptions/CustomParameters/LAME"); LAMEXP_MAKE_ID(customParametersOggEnc, "AdvancedOptions/CustomParameters/OggEnc"); LAMEXP_MAKE_ID(customParametersNeroAAC, "AdvancedOptions/CustomParameters/NeroAAC"); +LAMEXP_MAKE_ID(customParametersAften, "AdvancedOptions/CustomParameters/Aften"); LAMEXP_MAKE_ID(customParametersFLAC, "AdvancedOptions/CustomParameters/FLAC"); LAMEXP_MAKE_ID(metaInfoPosition, "MetaInformation/PlaylistPosition"); LAMEXP_MAKE_ID(maximumInstances, "AdvancedOptions/Threading/MaximumInstances"); @@ -109,6 +110,7 @@ LAMEXP_MAKE_ID(customTempPathEnabled, "AdvancedOptions/TempDirectory/UseCustomPa //LUT const int SettingsModel::mp3Bitrates[15] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1}; +const int SettingsModel::ac3Bitrates[20] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640, -1}; const int SettingsModel::samplingRates[8] = {0, 16000, 22050, 24000, 32000, 44100, 48000, -1}; //////////////////////////////////////////////////////////// @@ -283,6 +285,7 @@ LAMEXP_MAKE_OPTION_I(toneAdjustTreble, 0) LAMEXP_MAKE_OPTION_S(customParametersLAME, QString()); LAMEXP_MAKE_OPTION_S(customParametersOggEnc, QString()); LAMEXP_MAKE_OPTION_S(customParametersNeroAAC, QString()); +LAMEXP_MAKE_OPTION_S(customParametersAften, QString()); LAMEXP_MAKE_OPTION_S(customParametersFLAC, QString()); LAMEXP_MAKE_OPTION_U(metaInfoPosition, UINT_MAX); LAMEXP_MAKE_OPTION_U(maximumInstances, 0); diff --git a/src/Model_Settings.h b/src/Model_Settings.h index a4fb0c8b..0852a7ed 100644 --- a/src/Model_Settings.h +++ b/src/Model_Settings.h @@ -73,6 +73,7 @@ public: //Consts static const int mp3Bitrates[15]; + static const int ac3Bitrates[20]; static const int samplingRates[8]; //Getters & setters @@ -110,6 +111,7 @@ public: LAMEXP_MAKE_OPTION_S(customParametersLAME); LAMEXP_MAKE_OPTION_S(customParametersOggEnc); LAMEXP_MAKE_OPTION_S(customParametersNeroAAC); + LAMEXP_MAKE_OPTION_S(customParametersAften); LAMEXP_MAKE_OPTION_S(customParametersFLAC); LAMEXP_MAKE_OPTION_U(metaInfoPosition); LAMEXP_MAKE_OPTION_U(maximumInstances);