Only build grok for Ubuntu 22.04.
authorCarl Hetherington <cth@carlh.net>
Sun, 24 Sep 2023 10:09:16 +0000 (12:09 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 28 Jan 2024 01:01:57 +0000 (02:01 +0100)
cscript
src/lib/j2k_encoder.cc
src/lib/j2k_encoder.h
src/lib/writer.h
src/lib/wscript
src/tools/dcpomatic.cc
src/tools/dcpomatic_batch.cc
src/tools/dcpomatic_server.cc
src/tools/dcpomatic_server_cli.cc
src/wx/full_config_dialog.cc
wscript

diff --git a/cscript b/cscript
index dad81a18d6d306c856ae6ec1574336f81edc7405..8fce3b4eee5592c8f9caf40fff7ebeb81e31d0a0 100644 (file)
--- a/cscript
+++ b/cscript
@@ -563,6 +563,9 @@ def configure_options(target, options, for_package=False):
     if target.platform == 'osx' and target.arch == 'arm64':
         opt += ' --target-macos-arm64 --wx-config=%s/wx-config' % target.bin
 
+    if target.platform == 'linux' and target.distro == 'ubuntu' and target.version in ['22.04']:
+        opt += ' --enable-grok'
+
     return opt
 
 def build(target, options, for_package):
index c023e4bf366ab087f5c26d2a2a098cd1cd85dd54..7d695245a05a68032e5a6bb3fa73ec81ea9803cc 100644 (file)
@@ -33,7 +33,9 @@
 #include "encode_server_finder.h"
 #include "film.h"
 #include "cpu_j2k_encoder_thread.h"
+#ifdef DCPOMATIC_GROK
 #include "grok_j2k_encoder_thread.h"
+#endif
 #include "remote_j2k_encoder_thread.h"
 #include "j2k_encoder.h"
 #include "log.h"
@@ -65,8 +67,10 @@ J2KEncoder::J2KEncoder(shared_ptr<const Film> film, Writer& writer)
        : _film (film)
        , _history (200)
        , _writer (writer)
+#ifdef DCPOMATIC_GROK
        , _dcpomatic_context(film, writer, _history, Config::instance()->gpu_binary_location())
        , _context(Config::instance()->enable_gpu() ? new grk_plugin::GrokContext(_dcpomatic_context) : nullptr)
+#endif
 {
 }
 
@@ -77,7 +81,9 @@ J2KEncoder::~J2KEncoder ()
 
        terminate_threads();
 
+#ifdef DCPOMATIC_GROK
        delete _context;
+#endif
 }
 
 
@@ -115,8 +121,10 @@ J2KEncoder::pause()
        /* Something might have been thrown during terminate_threads */
        rethrow ();
 
+#ifdef DCPOMATIC_GROK
        delete _context;
        _context = nullptr;
+#endif
 }
 
 
@@ -126,7 +134,9 @@ void J2KEncoder::resume()
                return;
        }
 
+#ifdef DCPOMATIC_GROK
        _context = new grk_plugin::GrokContext(_dcpomatic_context);
+#endif
        servers_list_changed();
 }
 
@@ -163,13 +173,16 @@ J2KEncoder::end()
             So just mop up anything left in the queue here.
        */
        for (auto & i: _queue) {
+#ifdef DCPOMATIC_GROK
                if (Config::instance()->enable_gpu ()) {
                        if (!_context->scheduleCompress(i)){
                                LOG_GENERAL (N_("[%1] J2KEncoder thread pushes frame %2 back onto queue after failure"), thread_id(), i.index());
                                // handle error
                        }
-               }
-               else {
+               } else {
+#else
+               {
+#endif
                        LOG_GENERAL(N_("Encode left-over frame %1"), i.index());
                        try {
                                _writer.write(
@@ -184,8 +197,10 @@ J2KEncoder::end()
                }
        }
 
+#ifdef DCPOMATIC_GROK
        delete _context;
        _context = nullptr;
+#endif
 }
 
 
@@ -311,7 +326,11 @@ J2KEncoder::terminate_threads ()
 
 
 void
+#ifdef DCPOMATIC_GROK
 J2KEncoder::remake_threads(int cpu, int gpu, list<EncodeServerDescription> servers)
+#else
+J2KEncoder::remake_threads(int cpu, int, list<EncodeServerDescription> servers)
+#endif
 {
        boost::mutex::scoped_lock lm (_threads_mutex);
        if (_ending) {
@@ -345,7 +364,7 @@ J2KEncoder::remake_threads(int cpu, int gpu, list<EncodeServerDescription> serve
 
        remove_threads(cpu, current_cpu_threads, is_cpu_thread);
 
-
+#ifdef DCPOMATIC_GROK
        /* GPU */
 
        auto const is_grok_thread = [](shared_ptr<J2KEncoderThread> thread) {
@@ -361,7 +380,7 @@ J2KEncoder::remake_threads(int cpu, int gpu, list<EncodeServerDescription> serve
        }
 
        remove_threads(gpu, current_gpu_threads, is_grok_thread);
-
+#endif
 
        /* Remote */
 
index a6e190dcfc9cea95b886bd5880699c56e886f1d8..9d9d8589447baf83195438062f2c37f996821263 100644 (file)
  */
 
 
-#include "grok/context.h"
 #include "cross.h"
 #include "enum_indexed_vector.h"
 #include "event_history.h"
 #include "exception_store.h"
+#ifdef DCPOMATIC_GROK
+#include "grok/context.h"
+#endif
 #include "j2k_encoder_thread.h"
 #include "writer.h"
 #include <boost/optional.hpp>
@@ -122,8 +124,10 @@ private:
 
        boost::signals2::scoped_connection _server_found_connection;
 
+#ifdef DCPOMATIC_GROK
        grk_plugin::DcpomaticContext _dcpomatic_context;
        grk_plugin::GrokContext *_context;
+#endif
 
        bool _ending = false;
 };
index efb6a17d8d54448b740e2b3fc238010c6abff01f..1cd278221738397523b1d6f1bcdc2e2c0aea8c3d 100644 (file)
@@ -34,6 +34,7 @@
 #include "exception_store.h"
 #include "font_id_map.h"
 #include "player_text.h"
+#include "text_type.h"
 #include "weak_film.h"
 #include <dcp/atmos_frame.h>
 #include <boost/thread.hpp>
index 00d50b2792d547591c0d831eb51046d96ad6477a..89a7531b0c54168489aa01326660f1172c96f223 100644 (file)
@@ -123,7 +123,6 @@ sources = """
           font_id_map.cc
           frame_interval_checker.cc
           frame_rate_change.cc
-          grok_j2k_encoder_thread.cc
           guess_crop.cc
           hints.cc
           internet.cc
@@ -248,6 +247,9 @@ def build(bld):
         if bld.env.TARGET_LINUX:
             obj.uselib += ' POLKIT'
 
+    if bld.env.ENABLE_GROK:
+        obj.source += ' grok_j2k_encoder_thread.cc'
+
     if bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32:
         obj.uselib += ' WINSOCK2 DBGHELP SHLWAPI MSWSOCK BOOST_LOCALE SETUPAPI OLE32 UUID'
         obj.source += ' cross_windows.cc'
index e5c2841d0569026bd42fa8b5b8257ac0b2f07013..01d81e0d0b575b754db3d8a1e60a51022eb0742a 100644 (file)
@@ -76,7 +76,9 @@
 #include "lib/ffmpeg_encoder.h"
 #include "lib/film.h"
 #include "lib/font_config.h"
+#ifdef DCPOMATIC_GROK
 #include "lib/grok/context.h"
+#endif
 #include "lib/hints.h"
 #include "lib/job_manager.h"
 #include "lib/kdm_with_metadata.h"
@@ -1724,7 +1726,9 @@ private:
                                notes.ShowModal();
                        }
 
+#ifdef DCPOMATIC_GROK
                        grk_plugin::setMessengerLogger(new grk_plugin::GrokLogger("[GROK] "));
+#endif
                }
                catch (exception& e)
                {
index 66262f2eb4dcb0e5097bb1d25fe9d21cef0ff479..273078b8922c6aa832ed2244058f2d39c82e3fc6 100644 (file)
@@ -32,7 +32,9 @@
 #include "lib/config.h"
 #include "lib/dcpomatic_socket.h"
 #include "lib/film.h"
+#ifdef DCPOMATIC_GROK
 #include "lib/grok/context.h"
+#endif
 #include "lib/job.h"
 #include "lib/job_manager.h"
 #include "lib/make_dcp.h"
@@ -500,7 +502,9 @@ class App : public wxApp
                        }
                }
 
+#ifdef DCPOMATIC_GROK
                grk_plugin::setMessengerLogger(new grk_plugin::GrokLogger("[GROK] "));
+#endif
 
                return true;
        }
index ff6341579849f3981b4cacf66bb25194e3fea77c..10af7472860cc200af49eec9367e6341222b57f7 100644 (file)
@@ -23,7 +23,9 @@
 #include "wx/wx_signal_manager.h"
 #include "wx/wx_util.h"
 #include "lib/config.h"
+#ifdef DCPOMATIC_GROK
 #include "lib/grok/context.h"
+#endif
 #include "lib/log.h"
 #include "lib/signaller.h"
 #include "lib/cross.h"
@@ -330,7 +332,9 @@ private:
 
                SetExitOnFrameDelete (false);
 
+#ifdef DCPOMATIC_GROK
                grk_plugin::setMessengerLogger(new grk_plugin::GrokLogger("[GROK] "));
+#endif
 
                return true;
        }
index 30f119a5e0cb21bf9a0739a1d5fef638e8ac8ce6..9e4a8814f41cdfadd51863f359ec2ece64a5798e 100644 (file)
@@ -25,7 +25,9 @@
 #include "lib/config.h"
 #include "lib/image.h"
 #include "lib/file_log.h"
+#ifdef DCPOMATIC_GROK
 #include "lib/grok/context.h"
+#endif
 #include "lib/null_log.h"
 #include "lib/version.h"
 #include "lib/encode_server.h"
@@ -110,7 +112,9 @@ main (int argc, char* argv[])
                dcpomatic_log.reset (new FileLog("dcpomatic_server_cli.log"));
        }
 
+#ifdef DCPOMATIC_GROK
        setMessengerLogger(new grk_plugin::GrokLogger("[GROK] "));
+#endif
 
        EncodeServer server (verbose, num_threads);
 
index ecee8733e668f3e70198cfe464240f082b99260c..c24871f39203279c23f3d4ac28206034af3aa65a 100644 (file)
@@ -45,7 +45,9 @@
 #include "send_test_email_dialog.h"
 #include "server_dialog.h"
 #include "static_text.h"
+#ifdef DCPOMATIC_GROK
 #include "grok/gpu_config_panel.h"
+#endif
 #include "wx_util.h"
 #include "lib/config.h"
 #include "lib/cross.h"
@@ -1947,7 +1949,9 @@ create_full_config_dialog ()
        e->AddPage (new SoundPage          (ps, border));
        e->AddPage (new DefaultsPage       (ps, border));
        e->AddPage (new EncodingServersPage(ps, border));
+#ifdef DCPOMATIC_GROK
        e->AddPage (new GPUPage            (ps, border));
+#endif
        e->AddPage (new KeysPage           (ps, border));
        e->AddPage (new TMSPage            (ps, border));
        e->AddPage (new EmailPage          (ps, border));
diff --git a/wscript b/wscript
index 87dd60c747c1c98dc8fffad9526f8a5500a0b203..1c329954c5e3a7fa3e8170ba345711be17d38f29 100644 (file)
--- a/wscript
+++ b/wscript
@@ -76,6 +76,7 @@ def options(opt):
     opt.add_option('--workaround-gssapi', action='store_true', default=False, help='link to gssapi_krb5')
     opt.add_option('--use-lld',           action='store_true', default=False, help='use lld linker')
     opt.add_option('--enable-disk',       action='store_true', default=False, help='build dcpomatic2_disk tool; requires Boost process, lwext4 and nanomsg libraries')
+    opt.add_option('--enable-grok',       action='store_true', default=False, help='build with support for grok J2K encoder')
     opt.add_option('--warnings-are-errors', action='store_true', default=False, help='build with -Werror')
     opt.add_option('--wx-config',         help='path to wx-config')
 
@@ -96,6 +97,7 @@ def configure(conf):
     conf.env.DEBUG = conf.options.enable_debug
     conf.env.STATIC_DCPOMATIC = conf.options.static_dcpomatic
     conf.env.ENABLE_DISK = conf.options.enable_disk
+    conf.env.ENABLE_GROK = conf.options.enable_grok
     if conf.options.destdir == '':
         conf.env.INSTALL_PREFIX = conf.options.prefix
     else:
@@ -140,6 +142,9 @@ def configure(conf):
     if conf.options.enable_disk:
         conf.env.append_value('CXXFLAGS', '-DDCPOMATIC_DISK')
 
+    if conf.options.enable_grok:
+        conf.env.append_value('CXXFLAGS', '-DDCPOMATIC_GROK')
+
     if conf.options.use_lld:
         try:
             conf.find_program('ld.lld')