diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 126264c09..a180d8f33 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -323,6 +323,7 @@ set(SOURCES transcoder/transcodedialog.cpp transcoder/transcoder.cpp transcoder/transcoderoptionsaac.cpp + transcoder/transcoderoptionsavaac.cpp transcoder/transcoderoptionsdialog.cpp transcoder/transcoderoptionserror.cpp transcoder/transcoderoptionsfdkaac.cpp @@ -630,6 +631,7 @@ set(HEADERS transcoder/transcodedialog.h transcoder/transcoder.h + transcoder/transcoderoptionsavaac.h transcoder/transcoderoptionsdialog.h transcoder/transcoderoptionsmp3.h transcoder/transcoderoptionsfdkaac.h @@ -763,6 +765,7 @@ set(UI transcoder/transcodedialog.ui transcoder/transcodelogdialog.ui transcoder/transcoderoptionsaac.ui + transcoder/transcoderoptionsavaac.ui transcoder/transcoderoptionsdialog.ui transcoder/transcoderoptionserror.ui transcoder/transcoderoptionsfdkaac.ui diff --git a/src/transcoder/transcoderoptionsavaac.cpp b/src/transcoder/transcoderoptionsavaac.cpp new file mode 100644 index 000000000..90a08ad8f --- /dev/null +++ b/src/transcoder/transcoderoptionsavaac.cpp @@ -0,0 +1,100 @@ +/* This file is part of Clementine. + Copyright 2021, Jim Broadus + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +/* + Settings for the avenc_aac gstreamer element. + https://gstreamer.freedesktop.org/documentation/libav/avenc_aac.html +*/ + +#include "transcoderoptionsavaac.h" + +#include + +#include "core/logging.h" +#include "ui_transcoderoptionsavaac.h" + +const char* TranscoderOptionsAvAAC::kSettingsGroup = "Transcoder/avenc_aac"; + +TranscoderOptionsAvAAC::TranscoderOptionsAvAAC(QWidget* parent) + : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsAvAAC) { + ui_->setupUi(this); + connect(ui_->bitrate_target, SIGNAL(toggled(bool)), + SLOT(TargetBitrateToggle(bool))); +} + +TranscoderOptionsAvAAC::~TranscoderOptionsAvAAC() { delete ui_; } + +void TranscoderOptionsAvAAC::Load() { + QSettings s; + s.beginGroup(kSettingsGroup + settings_postfix_); + + // The gst-libav defaults to "fast". ffmpeg's default is twoloop. + int encoder = s.value("aac-coder", 2).toInt(); + switch (encoder) { + case 0: + ui_->encoder_anmr->setChecked(true); + break; + case 1: + ui_->encoder_twoloop->setChecked(true); + break; + default: + qLog(Warning) << "Unknown encoder setting" << encoder; + // Fall through. + case 2: + ui_->encoder_fast->setChecked(true); + break; + } + + // If bitrate is set to 0 (default), then the codec default. + int bitrate = s.value("bitrate", 0).toInt(); + if (bitrate == 0) { + ui_->bitrate_default->setChecked(true); + ui_->bitrate_group->setEnabled(false); + } else { + ui_->bitrate_target->setChecked(true); + ui_->bitrate_slider->setValue(bitrate / 1000); + } +} + +void TranscoderOptionsAvAAC::Save() { + QSettings s; + s.beginGroup(kSettingsGroup + settings_postfix_); + + int encoder; + int strict = 0; + if (ui_->encoder_anmr->isChecked()) { + encoder = 0; + // Allow experimental + strict = -2; + } else if (ui_->encoder_twoloop->isChecked()) { + encoder = 1; + } else { + encoder = 2; + } + s.setValue("aac-coder", encoder); + s.setValue("strict", strict); + + if (ui_->bitrate_target->isChecked()) { + s.setValue("bitrate", ui_->bitrate_slider->value() * 1000); + } else { + s.setValue("bitrate", 0); + } +} + +void TranscoderOptionsAvAAC::TargetBitrateToggle(bool checked) { + ui_->bitrate_group->setEnabled(checked); +} diff --git a/src/transcoder/transcoderoptionsavaac.h b/src/transcoder/transcoderoptionsavaac.h new file mode 100644 index 000000000..cf83365a2 --- /dev/null +++ b/src/transcoder/transcoderoptionsavaac.h @@ -0,0 +1,44 @@ +/* This file is part of Clementine. + Copyright 2021, Jim Broadus + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#ifndef TRANSCODEROPTIONSAVAAC_H +#define TRANSCODEROPTIONSAVAAC_H + +#include "transcoderoptionsinterface.h" + +class Ui_TranscoderOptionsAvAAC; + +class TranscoderOptionsAvAAC : public TranscoderOptionsInterface { + Q_OBJECT + + public: + TranscoderOptionsAvAAC(QWidget* parent = nullptr); + ~TranscoderOptionsAvAAC(); + + void Load(); + void Save(); + + private slots: + void TargetBitrateToggle(bool checked); + + private: + static const char* kSettingsGroup; + + Ui_TranscoderOptionsAvAAC* ui_; +}; + +#endif // TRANSCODEROPTIONSAVAAC_H diff --git a/src/transcoder/transcoderoptionsavaac.ui b/src/transcoder/transcoderoptionsavaac.ui new file mode 100644 index 000000000..b649a0fbf --- /dev/null +++ b/src/transcoder/transcoderoptionsavaac.ui @@ -0,0 +1,151 @@ + + + TranscoderOptionsAvAAC + + + + 0 + 0 + 480 + 344 + + + + Form + + + + + + Encoder + + + + + + Fast search + + + + + + + Two loop searching method + + + + + + + ANMR method (experimental) + + + + + + + + + + Bitrate + + + + + + Use default bitrate + + + + + + + Set target rate + + + + + + + + + + + + + kbps + + + 8 + + + 320 + + + 8 + + + 128 + + + + + + + 8 + + + 320 + + + 128 + + + Qt::Horizontal + + + + + + + + + + + + + + + bitrate_slider + valueChanged(int) + bitrate_spinbox + setValue(int) + + + 170 + 29 + + + 445 + 24 + + + + + bitrate_spinbox + valueChanged(int) + bitrate_slider + setValue(int) + + + 407 + 18 + + + 191 + 29 + + + + + diff --git a/src/transcoder/transcoderoptionsdialog.cpp b/src/transcoder/transcoderoptionsdialog.cpp index 646851f46..2c5b23638 100644 --- a/src/transcoder/transcoderoptionsdialog.cpp +++ b/src/transcoder/transcoderoptionsdialog.cpp @@ -21,6 +21,7 @@ #include "core/utilities.h" #include "transcoder.h" #include "transcoderoptionsaac.h" +#include "transcoderoptionsavaac.h" #include "transcoderoptionserror.h" #include "transcoderoptionsfdkaac.h" #include "transcoderoptionsflac.h" @@ -76,7 +77,9 @@ TranscoderOptionsInterface* TranscoderOptionsDialog::MakeOptionsPage( QString element = Transcoder::GetEncoderFactoryForMimeType(mime_type); qLog(Debug) << "Options for element" << element; - if (element == "flacenc") { + if (element == "avenc_aac") { + return new TranscoderOptionsAvAAC(parent); + } else if (element == "flacenc") { return new TranscoderOptionsFlac(parent); } else if (element == "faac") { return new TranscoderOptionsAAC(parent);