From 2b6a61a8343d15e4e32c723491ec687c78a1964b Mon Sep 17 00:00:00 2001 From: TryTwo Date: Mon, 23 Dec 2024 16:56:48 -0700 Subject: [PATCH] AdvancedWidget: Change codec selection to a choice and add UTVideo. UTVideo was requrested by users based on its compatibility with video editing programs. --- .../Config/Graphics/AdvancedWidget.cpp | 60 +++++++++++++++---- .../Config/Graphics/AdvancedWidget.h | 5 ++ 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp index c64c8fca4001..2e8cffe7660c 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp @@ -185,13 +185,26 @@ void AdvancedWidget::CreateWidgets() dump_layout->addWidget(m_frame_dumps_resolution_type, 0, 1); #if defined(HAVE_FFMPEG) - m_dump_use_ffv1 = - new ConfigBool(tr("Use Lossless Codec (FFV1)"), Config::GFX_USE_FFV1, m_game_layer); + // Update EnableBitrate() if options are changed. + const std::vector> options{ + {tr("Auto"), QStringLiteral("")}, + {QStringLiteral("Xvid"), QStringLiteral("mpeg4")}, + {QStringLiteral("Ut Video"), QStringLiteral("utvideo")}, + {QStringLiteral("FFV1"), QStringLiteral("ffv1")}}; + + m_codec_choice = new ConfigStringChoice(options, Config::GFX_DUMP_CODEC, m_game_layer); + + if (m_codec_choice->currentIndex() == -1) + m_codec_choice->setCurrentIndex(Config::Get(Config::GFX_USE_FFV1) ? 4 : 0); + + dump_layout->addWidget(new QLabel(tr("Codec:")), 1, 0); + dump_layout->addWidget(m_codec_choice, 1, 1); + m_dump_bitrate = new ConfigInteger(0, 1000000, Config::GFX_BITRATE_KBPS, m_game_layer, 1000); - m_dump_bitrate->setEnabled(!m_dump_use_ffv1->isChecked()); - dump_layout->addWidget(m_dump_use_ffv1, 1, 0); dump_layout->addWidget(new QLabel(tr("Bitrate (kbps):")), 2, 0); dump_layout->addWidget(m_dump_bitrate, 2, 1); + + EnableBitrate(); #endif dump_layout->addWidget(new QLabel(tr("PNG Compression Level:")), 3, 0); @@ -263,11 +276,34 @@ void AdvancedWidget::ConnectWidgets() [this](bool checked) { emit Settings::Instance().EnableGfxModsChanged(checked); }); #if defined(HAVE_FFMPEG) - connect(m_dump_use_ffv1, &QCheckBox::toggled, this, - [this](bool checked) { m_dump_bitrate->setEnabled(!checked); }); + connect(m_codec_choice, &ConfigStringChoice::currentIndexChanged, this, + &AdvancedWidget::EnableBitrate); #endif } +#if defined(HAVE_FFMPEG) +void AdvancedWidget::EnableBitrate() +{ + const QString& choice = m_codec_choice->currentText(); + const bool enable = choice != QStringLiteral("Ut Video") && choice != QStringLiteral("FFV1"); + + if (m_game_layer) + { + m_dump_bitrate->setEnabled(enable); + return; + } + + // Toggle off depreciated Use FFV1 option, so it doesn't collide. + if (Config::Get(Config::GFX_USE_FFV1)) + { + auto layer = Config::GetActiveLayerForConfig(Config::GFX_USE_FFV1); + Config::Set(layer, Config::GFX_USE_FFV1, false); + } + + m_dump_bitrate->setEnabled(enable); +} +#endif + void AdvancedWidget::OnBackendChanged() { m_backend_multithreading->setEnabled(g_Config.backend_info.bSupportsMultithreading); @@ -391,9 +427,13 @@ void AdvancedWidget::AddDescriptions() "possible input for external editing software.

If unsure, leave " "this at \"Aspect Ratio Corrected Internal Resolution\"."); #if defined(HAVE_FFMPEG) - static const char TR_USE_FFV1_DESCRIPTION[] = - QT_TR_NOOP("Encodes frame dumps using the FFV1 codec.

If " - "unsure, leave this unchecked."); + static const char TR_CODEC_CHOICE_DESCRIPTION[] = + QT_TR_NOOP("Selects codec for encoding frame dumps." + "
Xvid: Lossy. Good compression. Can set bitrate." + "
Ut Video: Lossless. Fast. Poor compression (large file size). Good " + "compatibility with editing programs." + "
FFV1: Lossless. Good compression. Slow. Poor compatibility." + "

If unsure, leave this unchecked."); #endif static const char TR_PNG_COMPRESSION_LEVEL_DESCRIPTION[] = QT_TR_NOOP("Specifies the zlib compression level to use when saving PNG images (both for " @@ -483,7 +523,7 @@ void AdvancedWidget::AddDescriptions() m_enable_graphics_mods->SetDescription(tr(TR_LOAD_GRAPHICS_MODS_DESCRIPTION)); m_frame_dumps_resolution_type->SetDescription(tr(TR_FRAME_DUMPS_RESOLUTION_TYPE_DESCRIPTION)); #ifdef HAVE_FFMPEG - m_dump_use_ffv1->SetDescription(tr(TR_USE_FFV1_DESCRIPTION)); + m_codec_choice->SetDescription(tr(TR_CODEC_CHOICE_DESCRIPTION)); #endif m_png_compression_level->SetDescription(tr(TR_PNG_COMPRESSION_LEVEL_DESCRIPTION)); m_enable_cropping->SetDescription(tr(TR_CROPPING_DESCRIPTION)); diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h index e3b36885715a..42a2722786ae 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h @@ -8,6 +8,7 @@ class ConfigBool; class ConfigChoice; class ConfigInteger; +class ConfigStringChoice; class GameConfigWidget; class GraphicsWindow; @@ -27,6 +28,9 @@ class AdvancedWidget final : public QWidget void CreateWidgets(); void ConnectWidgets(); void AddDescriptions(); +#if defined(HAVE_FFMPEG) + void EnableBitrate(); +#endif void OnBackendChanged(); void OnEmulationStateChanged(bool running); @@ -62,6 +66,7 @@ class AdvancedWidget final : public QWidget // Frame dumping ConfigBool* m_dump_use_ffv1; ConfigChoice* m_frame_dumps_resolution_type; + ConfigStringChoice* m_codec_choice; ConfigInteger* m_dump_bitrate; ConfigInteger* m_png_compression_level;