diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/config.cc | 33 | ||||
| -rw-r--r-- | src/lib/config.h | 16 | ||||
| -rw-r--r-- | src/lib/encode_cli.cc | 14 | ||||
| -rw-r--r-- | src/lib/grok/context.h | 5 | ||||
| -rw-r--r-- | src/lib/j2k_encoder.cc | 18 | ||||
| -rw-r--r-- | src/tools/dcpomatic_verifier.cc | 1 | ||||
| -rw-r--r-- | src/wx/full_config_dialog.cc | 97 | ||||
| -rw-r--r-- | src/wx/grok/gpu_config_panel.h | 87 |
8 files changed, 181 insertions, 90 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index af97c7af7..12046d3c2 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -240,6 +240,7 @@ Config::set_defaults() #ifdef DCPOMATIC_GROK _grok = {}; #endif + _gpu_type = GPUType::NONE; _main_divider_sash_position = {}; _main_content_divider_sash_position = {}; @@ -679,9 +680,25 @@ try #ifdef DCPOMATIC_GROK if (auto grok = f.optional_node_child("Grok")) { _grok = Grok(grok); + /* We used to use an <Enable> tag in the <Grok> tag, but now we look at + * the _gpu_type. + */ + if (grok->optional_bool_child("Enable").get_value_or(false)) { + _gpu_type = GPUType::GROK; + } } #endif + if (auto gpu_type = f.optional_string_child("GPUType")) { + if (*gpu_type == "grok") { + _gpu_type = GPUType::GROK; + } else if (*gpu_type == "nvjpeg2k") { + _gpu_type = GPUType::NVJPEG2K; + } else { + _gpu_type = GPUType::NONE; + } + } + _export.read(f.optional_node_child("Export")); } catch (...) { @@ -1168,6 +1185,18 @@ Config::write_config() const #ifdef DCPOMATIC_GROK _grok.as_xml(cxml::add_child(root, "Grok")); #endif + /* [XML] GPUType none for no GPU accleration, grok to use Grok, nvjpeg2k to use the NVIDIA nvjpeg2k library */ + switch (_gpu_type) { + case GPUType::NONE: + cxml::add_text_child(root, "GPUType", "none"); + break; + case GPUType::GROK: + cxml::add_text_child(root, "GPUType", "grok"); + break; + case GPUType::NVJPEG2K: + cxml::add_text_child(root, "GPUType", "nvjpeg2k"); + break; + } _export.write(cxml::add_child(root, "Export")); @@ -1764,8 +1793,7 @@ Config::Grok::Grok() Config::Grok::Grok(cxml::ConstNodePtr node) - : enable(node->bool_child("Enable")) - , binary_location(node->string_child("BinaryLocation")) + : binary_location(node->string_child("BinaryLocation")) , selected(node->number_child<int>("Selected")) , licence_server(node->string_child("LicenceServer")) , licence(node->string_child("Licence")) @@ -1780,7 +1808,6 @@ void Config::Grok::as_xml(xmlpp::Element* node) const { node->add_child("BinaryLocation")->add_child_text(binary_location.string()); - node->add_child("Enable")->add_child_text((enable ? "1" : "0")); node->add_child("Selected")->add_child_text(fmt::to_string(selected)); node->add_child("LicenceServer")->add_child_text(licence_server); node->add_child("Licence")->add_child_text(licence); diff --git a/src/lib/config.h b/src/lib/config.h index d8ff70db8..4deaf7eb6 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -665,7 +665,6 @@ public: void as_xml(xmlpp::Element* node) const; - bool enable = false; boost::filesystem::path binary_location; int selected = 0; std::string licence_server; @@ -677,6 +676,16 @@ public: } #endif + enum class GPUType { + NONE, + GROK, + NVJPEG2K + }; + + GPUType gpu_type() const { + return _gpu_type; + } + int isdcf_name_part_length() const { return _isdcf_name_part_length; } @@ -1253,6 +1262,10 @@ public: void set_grok(Grok const& grok); #endif + void set_gpu_type(GPUType type) { + maybe_set(_gpu_type, type); + } + void set_isdcf_name_part_length(int length) { maybe_set(_isdcf_name_part_length, length, ISDCF_NAME_PART_LENGTH); } @@ -1526,6 +1539,7 @@ private: #ifdef DCPOMATIC_GROK Grok _grok; #endif + GPUType _gpu_type; ExportConfig _export; diff --git a/src/lib/encode_cli.cc b/src/lib/encode_cli.cc index cff6f3724..91e399439 100644 --- a/src/lib/encode_cli.cc +++ b/src/lib/encode_cli.cc @@ -422,17 +422,15 @@ encode_cli(int argc, char* argv[], function<void (string)> out, function<void () #ifdef DCPOMATIC_GROK config_params.push_back( - {"grok-enable", "1 to enable the Grok encoder, 0 to disable it", + {"gpu-type", "\"grok\" to enable the Grok encoder, \"none\" to disable it", [](Config* config, string value) -> optional<string> { - auto grok = config->grok(); - if (value == "1") { - grok.enable = true; - } else if (value == "0") { - grok.enable = false; + if (value == "grok") { + config->set_gpu_type(Config::GPUType::GROK); + } else if (value == "none") { + config->set_gpu_type(Config::GPUType::NONE); } else { - return fmt::format("Invalid value {} for grok-enable (use 1 to enable, 0 to disable)", value); + return fmt::format("Invalid value {} for gpu-type (use \"grok\" to enable the Grok encoder, \"none\" to disable it)", value); } - config->set_grok(grok); return {}; }}); config_params.push_back( diff --git a/src/lib/grok/context.h b/src/lib/grok/context.h index b31867cf6..bd1996b1f 100644 --- a/src/lib/grok/context.h +++ b/src/lib/grok/context.h @@ -99,11 +99,6 @@ public: explicit GrokContext(DcpomaticContext* dcpomatic_context) : _dcpomatic_context(dcpomatic_context) { - auto grok = Config::instance()->grok(); - if (!grok.enable) { - return; - } - boost::filesystem::path folder(_dcpomatic_context->location); boost::filesystem::path binary_path = folder / "grk_compress"; if (!boost::filesystem::exists(binary_path)) { diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 441e91827..07e4012b1 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -97,9 +97,9 @@ J2KEncoder::J2KEncoder(shared_ptr<const Film> film, Writer& writer) #endif { #ifdef DCPOMATIC_GROK - auto grok = Config::instance()->grok(); - _dcpomatic_context = new grk_plugin::DcpomaticContext(film, writer, _history, grok.binary_location); - if (grok.enable) { + auto config = Config::instance(); + _dcpomatic_context = new grk_plugin::DcpomaticContext(film, writer, _history, config->grok().binary_location); + if (config->gpu_type() == Config::GPUType::GROK) { _context = new grk_plugin::GrokContext(_dcpomatic_context); } #endif @@ -133,11 +133,7 @@ void J2KEncoder::servers_list_changed() { auto config = Config::instance(); -#ifdef DCPOMATIC_GROK - auto const grok_enable = config->grok().enable; -#else - auto const grok_enable = false; -#endif + auto const grok_enable = config->gpu_type() == Config::GPUType::GROK; auto const cpu = (grok_enable || config->only_servers_encode()) ? 0 : config->master_encoding_threads(); auto const gpu = grok_enable ? config->master_encoding_threads() : 0; @@ -161,7 +157,7 @@ void J2KEncoder::pause() { #ifdef DCPOMATIC_GROK - if (!Config::instance()->grok().enable) { + if (Config::instance()->gpu_type() != Config::GPUType::GROK) { return; } return; @@ -182,7 +178,7 @@ J2KEncoder::pause() void J2KEncoder::resume() { #ifdef DCPOMATIC_GROK - if (!Config::instance()->grok().enable) { + if (Config::instance()->gpu_type() != Config::GPUType::GROK) { return; } @@ -225,7 +221,7 @@ J2KEncoder::end() */ for (auto & i: _queue) { #ifdef DCPOMATIC_GROK - if (Config::instance()->grok().enable) { + if (Config::instance()->gpu_type() == Config::GPUType::GROK) { if (!_context->scheduleCompress(i)){ LOG_GENERAL (N_("[{}] J2KEncoder thread pushes frame {} back onto queue after failure"), thread_id(), i.index()); // handle error diff --git a/src/tools/dcpomatic_verifier.cc b/src/tools/dcpomatic_verifier.cc index 8a509529b..0402bcad2 100644 --- a/src/tools/dcpomatic_verifier.cc +++ b/src/tools/dcpomatic_verifier.cc @@ -41,6 +41,7 @@ #include "lib/verify_dcp_job.h" #include "lib/util.h" #include "lib/variant.h" +#include <dcp/html_formatter.h> #include <dcp/search.h> #include <dcp/text_formatter.h> #include <dcp/verify_report.h> diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index eff3fdee2..4439e7738 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -1337,7 +1337,7 @@ private: { auto config = Config::instance(); - switch(config->video_view_type()) { + switch (config->video_view_type()) { case Config::VIDEO_VIEW_SIMPLE: checked_set(_video_display_mode, 0); break; @@ -1469,6 +1469,99 @@ private: }; +#if defined(DCPOMATIC_GROK) || defined(DCPOMATIC_HAVE_NVJPEG2K) +class GPUPage : public preferences::Page +{ +public: + GPUPage(wxSize panel_size, int border) + : Page(panel_size, border) + {} + + wxString GetName() const override + { + return _("GPU"); + } + + void setup() override + { + auto table = new wxFlexGridSizer(2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + table->AddGrowableCol(1, 1); + _panel->GetSizer()->Add(table, 0, wxALL | wxEXPAND, _border); + + add_label_to_sizer(table, _panel, _("GPU acceleration"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); + + _gpu_type = new Choice(_panel); + _gpu_type->add_entry(_("None"), "none"); +#if defined(DCPOMATIC_GROK) + _gpu_type->add_entry(_("Grok"), "grok"); +#endif +#if defined(DCPOMATIC_HAVE_NVJPEG2K) + _gpu_type->add_entry(_("NVIDIA"), "nvjpeg2k"); +#endif + table->Add(_gpu_type); + +#if defined(DCPOMATIC_GROK) + _grok_panel = new GrokConfigPanel(_panel); + _panel->GetSizer()->Add(_grok_panel, 1, wxALL | wxEXPAND, _border); +#endif + + _gpu_type->bind(&GPUPage::gpu_type_changed, this); + } + + void config_changed() override + { + auto config = Config::instance(); + + switch (config->gpu_type()) { + case Config::GPUType::NONE: + _gpu_type->set_by_data("none"); +#if defined(DCPOMATIC_GROK) + _grok_panel->Hide(); +#endif + break; + case Config::GPUType::GROK: + _gpu_type->set_by_data("grok"); +#if defined(DCPOMATIC_GROK) + _grok_panel->Show(); + _panel->GetSizer()->Layout(); +#endif + break; + case Config::GPUType::NVJPEG2K: + _gpu_type->set_by_data("nvjpeg2k"); +#if defined(DCPOMATIC_GROK) + _grok_panel->Hide(); +#endif + break; + } + +#if defined(DCPOMATIC_GROK) + _grok_panel->config_changed(); +#endif + } + + +private: + void gpu_type_changed() + { + if (auto choice = _gpu_type->get_data()) { + if (*choice == "none") { + Config::instance()->set_gpu_type(Config::GPUType::NONE); + } else if (*choice == "grok") { + Config::instance()->set_gpu_type(Config::GPUType::GROK); + } else if (*choice == "nvjpeg2k") { + Config::instance()->set_gpu_type(Config::GPUType::NVJPEG2K); + } + } + } + + Choice* _gpu_type; +#if defined(DCPOMATIC_GROK) + GrokConfigPanel* _grok_panel; +#endif +}; +#endif + + wxPreferencesEditor* create_full_config_dialog() { @@ -1490,7 +1583,7 @@ create_full_config_dialog() e->AddPage(new preferences::SoundPage(ps, border, preferences::SoundPage::Purpose::MAIN)); e->AddPage(new DefaultsPage(ps, border)); e->AddPage(new EncodingServersPage(ps, border)); -#ifdef DCPOMATIC_GROK +#if defined(DCPOMATIC_GROK) || defined(DCPOMATIC_HAVE_NVJPEG2K) e->AddPage(new GPUPage(ps, border)); #endif e->AddPage(new preferences::KeysPage(ps, border)); diff --git a/src/wx/grok/gpu_config_panel.h b/src/wx/grok/gpu_config_panel.h index 34bf38f12..9d4904fb0 100644 --- a/src/wx/grok/gpu_config_panel.h +++ b/src/wx/grok/gpu_config_panel.h @@ -19,11 +19,14 @@ */ -#pragma once +#ifndef DCPOMATIC_GROK_GPU_CONFIG_PANEL +#define DCPOMATIC_GROK_GPU_CONFIG_PANEL #include "lib/grok/util.h" +#include <boost/bind/bind.hpp> #include <wx/filepicker.h> +#include <wx/wx.h> class GpuList : public wxPanel @@ -72,75 +75,44 @@ private: }; -class GPUPage : public dcpomatic::preferences::Page +class GrokConfigPanel : public wxPanel { public: - GPUPage(wxSize panel_size, int border) - : Page(panel_size, border) - {} - - wxString GetName() const override - { - return _("GPU"); - } - -#ifdef DCPOMATIC_OSX - /* XXX: this icon does not exist */ - wxBitmap GetLargeIcon() const override - { - return wxBitmap(icon_path("gpu"), wxBITMAP_TYPE_PNG); - } -#endif - -private: - void setup() override + GrokConfigPanel(wxWindow* parent) + : wxPanel(parent, wxID_ANY) { - _enable_gpu = new CheckBox(_panel, _("Enable GPU acceleration")); - _panel->GetSizer()->Add(_enable_gpu, 0, wxALL | wxEXPAND, _border); + auto sizer = new wxBoxSizer(wxVERTICAL); + SetSizer(sizer); - wxFlexGridSizer* table = new wxFlexGridSizer(2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + auto table = new wxFlexGridSizer(2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol(1, 1); - _panel->GetSizer()->Add(table, 1, wxALL | wxEXPAND, _border); + sizer->Add(table, 1, wxEXPAND); - add_label_to_sizer(table, _panel, _("Acceleration binary folder"), true, 0, wxLEFT | wxLEFT | wxALIGN_CENTRE_VERTICAL); - _binary_location = new wxDirPickerCtrl(_panel, wxDD_DIR_MUST_EXIST); + add_label_to_sizer(table, this, _("Acceleration binary folder"), true, 0, wxLEFT | wxLEFT | wxALIGN_CENTRE_VERTICAL); + _binary_location = new wxDirPickerCtrl(this, wxDD_DIR_MUST_EXIST); table->Add(_binary_location, 1, wxEXPAND); - add_label_to_sizer(table, _panel, _("GPU selection"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - _gpu_list_control = new GpuList(_panel); + add_label_to_sizer(table, this, _("GPU selection"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); + _gpu_list_control = new GpuList(this); table->Add(_gpu_list_control, 1, wxEXPAND); - add_label_to_sizer(table, _panel, _("License server"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - _server = new wxTextCtrl(_panel, wxID_ANY); + add_label_to_sizer(table, this, _("License server"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); + _server = new wxTextCtrl(this, wxID_ANY); table->Add(_server, 1, wxEXPAND | wxALL); - add_label_to_sizer(table, _panel, _("License"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - _licence = new PasswordEntry(_panel); + add_label_to_sizer(table, this, _("License"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); + _licence = new PasswordEntry(this); table->Add(_licence->get_panel(), 1, wxEXPAND | wxALL); - _enable_gpu->bind(&GPUPage::enable_gpu_changed, this); - _binary_location->Bind(wxEVT_DIRPICKER_CHANGED, boost::bind (&GPUPage::binary_location_changed, this)); - _server->Bind(wxEVT_TEXT, boost::bind(&GPUPage::server_changed, this)); - _licence->Changed.connect(boost::bind(&GPUPage::licence_changed, this)); - - setup_sensitivity(); - } - - void setup_sensitivity() - { - auto grok = Config::instance()->grok(); - - _binary_location->Enable(grok.enable); - _gpu_list_control->Enable(grok.enable); - _server->Enable(grok.enable); - _licence->get_panel()->Enable(grok.enable); + _binary_location->Bind(wxEVT_DIRPICKER_CHANGED, boost::bind(&GrokConfigPanel::binary_location_changed, this)); + _server->Bind(wxEVT_TEXT, boost::bind(&GrokConfigPanel::server_changed, this)); + _licence->Changed.connect(boost::bind(&GrokConfigPanel::licence_changed, this)); } - void config_changed() override + void config_changed() { auto grok = Config::instance()->grok(); - checked_set(_enable_gpu, grok.enable); _binary_location->SetPath(std_to_wx(grok.binary_location.string())); _gpu_list_control->update(); _gpu_list_control->set_selection(grok.selected); @@ -148,15 +120,6 @@ private: checked_set(_licence, grok.licence); } - void enable_gpu_changed() - { - auto grok = Config::instance()->grok(); - grok.enable = _enable_gpu->GetValue(); - Config::instance()->set_grok(grok); - - setup_sensitivity(); - } - void binary_location_changed() { auto grok = Config::instance()->grok(); @@ -192,3 +155,7 @@ private: wxTextCtrl* _server = nullptr; PasswordEntry* _licence = nullptr; }; + + +#endif + |
