summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/config.cc66
-rw-r--r--src/lib/config.h74
-rw-r--r--src/lib/grok/context.h11
-rw-r--r--src/lib/grok_j2k_encoder_thread.cc4
-rw-r--r--src/lib/j2k_encoder.cc31
-rw-r--r--src/lib/j2k_encoder.h4
6 files changed, 104 insertions, 86 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc
index cf9198b37..9d39a7a8c 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -218,12 +218,9 @@ Config::set_defaults ()
set_notification_email_to_default ();
set_cover_sheet_to_default ();
- _gpu_binary_location = "";
- _enable_gpu = false;
- _selected_gpu = 0;
- _gpu_license_server = "";
- _gpu_license_port = 5000;
- _gpu_license = "";
+#ifdef DCPOMATIC_GROK
+ _grok = boost::none;
+#endif
_main_divider_sash_position = {};
_main_content_divider_sash_position = {};
@@ -647,12 +644,11 @@ try
_allow_smpte_bv20 = f.optional_bool_child("AllowSMPTEBv20").get_value_or(false);
_isdcf_name_part_length = f.optional_number_child<int>("ISDCFNamePartLength").get_value_or(14);
- _enable_gpu = f.optional_bool_child("EnableGPU").get_value_or(false);
- _gpu_binary_location = f.string_child("GPUBinaryLocation");
- _selected_gpu = f.number_child<int>("SelectedGPU");
- _gpu_license_server = f.string_child ("GPULicenseServer");
- _gpu_license_port = f.number_child<int> ("GPULicensePort");
- _gpu_license = f.string_child("GPULicense");
+#ifdef DCPOMATIC_GROK
+ if (auto grok = f.optional_node_child("Grok")) {
+ _grok = Grok(grok);
+ }
+#endif
_export.read(f.optional_node_child("Export"));
}
@@ -1140,12 +1136,11 @@ Config::write_config () const
/* [XML] ISDCFNamePartLength Maximum length of the "name" part of an ISDCF name, which should be 14 according to the standard */
root->add_child("ISDCFNamePartLength")->add_child_text(raw_convert<string>(_isdcf_name_part_length));
- root->add_child("GPUBinaryLocation")->add_child_text (_gpu_binary_location.string());
- root->add_child("EnableGPU")->add_child_text ((_enable_gpu ? "1" : "0"));
- root->add_child("SelectedGPU")->add_child_text (raw_convert<string> (_selected_gpu));
- root->add_child("GPULicenseServer")->add_child_text (_gpu_license_server);
- root->add_child("GPULicensePort")->add_child_text (raw_convert<string> (_gpu_license_port));
- root->add_child("GPULicense")->add_child_text (_gpu_license);
+#ifdef DCPOMATIC_GROK
+ if (_grok) {
+ _grok->as_xml(root->add_child("Grok"));
+ }
+#endif
_export.write(root->add_child("Export"));
@@ -1670,3 +1665,38 @@ Config::initial_path(string id) const
return iter->second;
}
+
+#ifdef DCPOMATIC_GROK
+
+Config::Grok::Grok(cxml::ConstNodePtr node)
+ : enable(node->bool_child("Enable"))
+ , binary_location(node->string_child("BinaryLocation"))
+ , selected(node->number_child<int>("Selected"))
+ , licence_server(node->string_child("LicenceServer"))
+ , licence_port(node->number_child<int>("LicencePort"))
+ , licence(node->string_child("Licence"))
+{
+
+}
+
+
+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(raw_convert<string>(selected));
+ node->add_child("LicenceServer")->add_child_text(licence_server);
+ node->add_child("LicencePort")->add_child_text(raw_convert<string>(licence_port));
+ node->add_child("Licence")->add_child_text(licence);
+}
+
+
+void
+Config::set_grok(Grok const& grok)
+{
+ _grok = grok;
+ changed(OTHER);
+}
+
+#endif
diff --git a/src/lib/config.h b/src/lib/config.h
index bd040f09a..f241e3819 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -619,27 +619,27 @@ public:
return _allow_smpte_bv20;
}
- boost::filesystem::path gpu_binary_location() const {
- return _gpu_binary_location;
- }
-
- bool enable_gpu () const {
- return _enable_gpu;
- }
-
- int selected_gpu () const {
- return _selected_gpu;
- }
- std::string gpu_license_server () const {
- return _gpu_license_server;
- }
+#ifdef DCPOMATIC_GROK
+ class Grok
+ {
+ public:
+ Grok() = default;
+ Grok(cxml::ConstNodePtr node);
+
+ void as_xml(xmlpp::Element* node) const;
+
+ bool enable = false;
+ boost::filesystem::path binary_location;
+ int selected = 0;
+ std::string licence_server;
+ int licence_port = 5000;
+ std::string licence;
+ };
- int gpu_license_port () const {
- return _gpu_license_port;
- }
- std::string gpu_license () const {
- return _gpu_license;
+ boost::optional<Grok> grok() const {
+ return _grok;
}
+#endif
int isdcf_name_part_length() const {
return _isdcf_name_part_length;
@@ -1222,29 +1222,9 @@ public:
maybe_set(_allow_smpte_bv20, allow, ALLOW_SMPTE_BV20);
}
- void set_gpu_binary_location(boost::filesystem::path location) {
- maybe_set (_gpu_binary_location, location);
- }
-
- void set_enable_gpu (bool enable) {
- maybe_set (_enable_gpu, enable);
- }
-
- void set_selected_gpu (int selected) {
- maybe_set (_selected_gpu, selected);
- }
-
- void set_gpu_license_server (std::string s) {
- maybe_set (_gpu_license_server, s);
- }
-
- void set_gpu_license_port (int p) {
- maybe_set (_gpu_license_port, p);
- }
-
- void set_gpu_license (std::string p) {
- maybe_set (_gpu_license, p);
- }
+#ifdef DCPOMATIC_GROK
+ void set_grok(Grok const& grok);
+#endif
void set_isdcf_name_part_length(int length) {
maybe_set(_isdcf_name_part_length, length, ISDCF_NAME_PART_LENGTH);
@@ -1492,13 +1472,9 @@ private:
bool _allow_smpte_bv20;
int _isdcf_name_part_length;
- /* GPU */
- bool _enable_gpu;
- boost::filesystem::path _gpu_binary_location;
- int _selected_gpu;
- std::string _gpu_license_server;
- int _gpu_license_port;
- std::string _gpu_license;
+#ifdef DCPOMATIC_GROK
+ boost::optional<Grok> _grok;
+#endif
ExportConfig _export;
diff --git a/src/lib/grok/context.h b/src/lib/grok/context.h
index d27caa5f6..521faae8d 100644
--- a/src/lib/grok/context.h
+++ b/src/lib/grok/context.h
@@ -112,7 +112,8 @@ public:
explicit GrokContext(DcpomaticContext* dcpomatic_context)
: _dcpomatic_context(dcpomatic_context)
{
- if (!Config::instance()->enable_gpu()) {
+ auto grok = Config::instance()->grok().get_value_or({});
+ if (!grok.enable) {
return;
}
@@ -214,7 +215,7 @@ public:
auto s = dcpv.get_size();
_dcpomatic_context->set_dimensions(s.width, s.height);
- auto config = Config::instance();
+ auto grok = Config::instance()->grok().get_value_or({});
if (!_messenger->launchGrok(
_dcpomatic_context->location,
_dcpomatic_context->width,
@@ -226,9 +227,9 @@ public:
_dcpomatic_context->film->resolution() == Resolution::FOUR_K,
_dcpomatic_context->film->video_frame_rate(),
_dcpomatic_context->film->j2k_bandwidth(),
- config->gpu_license_server(),
- config->gpu_license_port(),
- config->gpu_license())) {
+ grok.licence_server,
+ grok.licence_port,
+ grok.licence)) {
_launch_failed = true;
return false;
}
diff --git a/src/lib/grok_j2k_encoder_thread.cc b/src/lib/grok_j2k_encoder_thread.cc
index 9ed0913be..c3cd6f8dd 100644
--- a/src/lib/grok_j2k_encoder_thread.cc
+++ b/src/lib/grok_j2k_encoder_thread.cc
@@ -60,7 +60,9 @@ try
LOG_TIMING("encoder-pop thread=%1 frame=%2 eyes=%3", thread_id(), frame.index(), static_cast<int>(frame.eyes()));
- if (_context->launch(frame, Config::instance()->selected_gpu()) && _context->scheduleCompress(frame)) {
+ auto grok = Config::instance()->grok().get_value_or({});
+
+ if (_context->launch(frame, grok.selected) && _context->scheduleCompress(frame)) {
frame_guard.cancel();
}
}
diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc
index 795134d78..a9870da5d 100644
--- a/src/lib/j2k_encoder.cc
+++ b/src/lib/j2k_encoder.cc
@@ -95,11 +95,14 @@ J2KEncoder::J2KEncoder(shared_ptr<const Film> film, Writer& writer)
: _film (film)
, _history (200)
, _writer (writer)
+{
#ifdef DCPOMATIC_GROK
- , _dcpomatic_context(new grk_plugin::DcpomaticContext(film, writer, _history, Config::instance()->gpu_binary_location()))
- , _context(Config::instance()->enable_gpu() ? new grk_plugin::GrokContext(_dcpomatic_context) : nullptr)
+ auto grok = Config::instance()->grok().get_value_or({});
+ _dcpomatic_context = new grk_plugin::DcpomaticContext(film, writer, _history, grok.binary_location);
+ if (grok.enable) {
+ _context = new grk_plugin::GrokContext(_dcpomatic_context);
+ }
#endif
-{
}
@@ -120,9 +123,14 @@ void
J2KEncoder::servers_list_changed()
{
auto config = Config::instance();
+#ifdef DCPOMATIC_GROK
+ auto const grok_enable = config->grok().get_value_or({}).enable;
+#else
+ auto const grok_enable = false;
+#endif
- auto const cpu = (config->enable_gpu() || config->only_servers_encode()) ? 0 : config->master_encoding_threads();
- auto const gpu = config->enable_gpu() ? config->master_encoding_threads() : 0;
+ auto const cpu = (grok_enable || config->only_servers_encode()) ? 0 : config->master_encoding_threads();
+ auto const gpu = grok_enable ? config->master_encoding_threads() : 0;
remake_threads(cpu, gpu, EncodeServerFinder::instance()->servers());
}
@@ -141,16 +149,17 @@ J2KEncoder::begin ()
void
J2KEncoder::pause()
{
- if (!Config::instance()->enable_gpu()) {
+#ifdef DCPOMATIC_GROK
+ if (!Config::instance()->grok().get_value_or({}).enable) {
return;
}
+ return;
terminate_threads ();
/* Something might have been thrown during terminate_threads */
rethrow ();
-#ifdef DCPOMATIC_GROK
delete _context;
_context = nullptr;
#endif
@@ -159,14 +168,14 @@ J2KEncoder::pause()
void J2KEncoder::resume()
{
- if (!Config::instance()->enable_gpu()) {
+#ifdef DCPOMATIC_GROK
+ if (!Config::instance()->grok().get_value_or({}).enable) {
return;
}
-#ifdef DCPOMATIC_GROK
_context = new grk_plugin::GrokContext(_dcpomatic_context);
-#endif
servers_list_changed();
+#endif
}
@@ -203,7 +212,7 @@ J2KEncoder::end()
*/
for (auto & i: _queue) {
#ifdef DCPOMATIC_GROK
- if (Config::instance()->enable_gpu ()) {
+ if (Config::instance()->grok().get_value_or({}).enable) {
if (!_context->scheduleCompress(i)){
LOG_GENERAL (N_("[%1] J2KEncoder thread pushes frame %2 back onto queue after failure"), thread_id(), i.index());
// handle error
diff --git a/src/lib/j2k_encoder.h b/src/lib/j2k_encoder.h
index 0dbe654a4..6bfbaea49 100644
--- a/src/lib/j2k_encoder.h
+++ b/src/lib/j2k_encoder.h
@@ -127,8 +127,8 @@ private:
boost::signals2::scoped_connection _server_found_connection;
#ifdef DCPOMATIC_GROK
- grk_plugin::DcpomaticContext* _dcpomatic_context;
- grk_plugin::GrokContext *_context;
+ grk_plugin::DcpomaticContext* _dcpomatic_context = nullptr;
+ grk_plugin::GrokContext *_context = nullptr;
#endif
bool _ending = false;