Add button to force re-encode of J2K content.
authorCarl Hetherington <cth@carlh.net>
Wed, 7 Nov 2018 23:26:51 +0000 (23:26 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 7 Nov 2018 23:26:51 +0000 (23:26 +0000)
ChangeLog
src/lib/film.cc
src/lib/film.h
src/lib/j2k_encoder.cc
src/wx/dcp_panel.cc
src/wx/dcp_panel.h

index 24e276d..a9d6d8b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-11-07  Carl Hetherington  <cth@carlh.net>
+
+       * Add button to force re-encode of JPEG2000 content.
+
 2018-10-23  Carl Hetherington  <cth@carlh.net>
 
        * Updated nl_NL translation from Rob van Nieuwkerk.
index 807aeaf..2ff02d7 100644 (file)
@@ -157,6 +157,7 @@ Film::Film (optional<boost::filesystem::path> dir)
        , _reel_type (REELTYPE_SINGLE)
        , _reel_length (2000000000)
        , _upload_after_make_dcp (Config::instance()->default_upload_after_make_dcp())
+       , _reencode_j2k (false)
        , _state_version (current_state_version)
        , _dirty (false)
 {
@@ -398,6 +399,7 @@ Film::metadata (bool with_content_paths) const
        root->add_child("ReelType")->add_child_text (raw_convert<string> (static_cast<int> (_reel_type)));
        root->add_child("ReelLength")->add_child_text (raw_convert<string> (_reel_length));
        root->add_child("UploadAfterMakeDCP")->add_child_text (_upload_after_make_dcp ? "1" : "0");
+       root->add_child("ReencodeJ2K")->add_child_text (_reencode_j2k ? "1" : "0");
        _playlist->as_xml (root->add_child ("Playlist"), with_content_paths);
 
        return doc;
@@ -512,6 +514,7 @@ Film::read_metadata (optional<boost::filesystem::path> path)
        _reel_type = static_cast<ReelType> (f.optional_number_child<int>("ReelType").get_value_or (static_cast<int>(REELTYPE_SINGLE)));
        _reel_length = f.optional_number_child<int64_t>("ReelLength").get_value_or (2000000000);
        _upload_after_make_dcp = f.optional_bool_child("UploadAfterMakeDCP").get_value_or (false);
+       _reencode_j2k = f.optional_bool_child("ReencodeJ2K").get_value_or(false);
 
        list<string> notes;
        /* This method is the only one that can return notes (so far) */
@@ -944,6 +947,13 @@ Film::set_upload_after_make_dcp (bool u)
 }
 
 void
+Film::set_reencode_j2k (bool r)
+{
+       ChangeSignaller<Film> ch (this, REENCODE_J2K);
+       _reencode_j2k = r;
+}
+
+void
 Film::signal_change (ChangeType type, int p)
 {
        signal_change (type, static_cast<Property>(p));
index 273077f..d251c7f 100644 (file)
@@ -204,7 +204,8 @@ public:
                AUDIO_PROCESSOR,
                REEL_TYPE,
                REEL_LENGTH,
-               UPLOAD_AFTER_MAKE_DCP
+               UPLOAD_AFTER_MAKE_DCP,
+               REENCODE_J2K
        };
 
 
@@ -296,6 +297,10 @@ public:
                return _context_id;
        }
 
+       bool reencode_j2k () const {
+               return _reencode_j2k;
+       }
+
 
        /* SET */
 
@@ -326,6 +331,7 @@ public:
        void set_reel_type (ReelType);
        void set_reel_length (int64_t);
        void set_upload_after_make_dcp (bool);
+       void set_reencode_j2k (bool);
 
        /** Emitted when some property has of the Film is about to change or has changed */
        mutable boost::signals2::signal<void (ChangeType, Property)> Change;
@@ -399,6 +405,7 @@ private:
        /** Desired reel length in bytes, if _reel_type == REELTYPE_BY_LENGTH */
        int64_t _reel_length;
        bool _upload_after_make_dcp;
+       bool _reencode_j2k;
 
        int _state_version;
 
index e62e708..f92f231 100644 (file)
@@ -216,7 +216,7 @@ J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time)
                LOG_DEBUG_ENCODE("Frame @ %1 FAKE", to_string(time));
                _writer->fake_write (position, pv->eyes ());
                frame_done ();
-       } else if (pv->has_j2k ()) {
+       } else if (pv->has_j2k() && !_film->reencode_j2k()) {
                LOG_DEBUG_ENCODE("Frame @ %1 J2K", to_string(time));
                /* This frame already has J2K data, so just write it */
                _writer->write (pv->j2k(), position, pv->eyes ());
index 12345ac..9d16b8c 100644 (file)
@@ -442,6 +442,9 @@ DCPPanel::film_changed (int p)
                checked_set (_three_d, _film->three_d ());
                setup_dcp_name ();
                break;
+       case Film::REENCODE_J2K:
+               checked_set (_reencode_j2k, _film->reencode_j2k());
+               break;
        case Film::INTEROP:
                checked_set (_standard, _film->interop() ? 1 : 0);
                setup_dcp_name ();
@@ -573,6 +576,7 @@ DCPPanel::set_film (shared_ptr<Film> film)
        film_changed (Film::REEL_TYPE);
        film_changed (Film::REEL_LENGTH);
        film_changed (Film::UPLOAD_AFTER_MAKE_DCP);
+       film_changed (Film::REENCODE_J2K);
 
        set_general_sensitivity(static_cast<bool>(_film));
 }
@@ -668,6 +672,16 @@ DCPPanel::three_d_changed ()
 }
 
 void
+DCPPanel::reencode_j2k_changed ()
+{
+       if (!_film) {
+               return;
+       }
+
+       _film->set_reencode_j2k (_reencode_j2k->GetValue());
+}
+
+void
 DCPPanel::config_changed (Config::Property p)
 {
        _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
@@ -712,8 +726,6 @@ DCPPanel::make_video_panel ()
        sizer->Add (_video_grid, 0, wxALL, 8);
        panel->SetSizer (sizer);
 
-       int r = 0;
-
        _container_label = create_label (panel, _("Container"), true);
        _container = new wxChoice (panel, wxID_ANY);
        _container_size = new wxStaticText (panel, wxID_ANY, wxT (""));
@@ -732,21 +744,23 @@ DCPPanel::make_video_panel ()
        _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
 
        _three_d = new wxCheckBox (panel, wxID_ANY, _("3D"));
-       ++r;
 
        _j2k_bandwidth_label = create_label (panel, _("JPEG2000 bandwidth\nfor newly-encoded data"), true);
        _j2k_bandwidth = new wxSpinCtrl (panel, wxID_ANY);
        _mbits_label = create_label (panel, _("Mbit/s"), false);
 
-       _container->Bind        (wxEVT_CHOICE,        boost::bind (&DCPPanel::container_changed, this));
-       _frame_rate_choice->Bind(wxEVT_CHOICE,        boost::bind (&DCPPanel::frame_rate_choice_changed, this));
-       _frame_rate_spin->Bind  (wxEVT_SPINCTRL,      boost::bind (&DCPPanel::frame_rate_spin_changed, this));
-       _best_frame_rate->Bind  (wxEVT_BUTTON,        boost::bind (&DCPPanel::best_frame_rate_clicked, this));
-       _j2k_bandwidth->Bind    (wxEVT_SPINCTRL,      boost::bind (&DCPPanel::j2k_bandwidth_changed, this));
+       _reencode_j2k = new wxCheckBox (panel, wxID_ANY, _("Re-encode JPEG2000 data from input"));
+
+       _container->Bind         (wxEVT_CHOICE,   boost::bind(&DCPPanel::container_changed, this));
+       _frame_rate_choice->Bind (wxEVT_CHOICE,   boost::bind(&DCPPanel::frame_rate_choice_changed, this));
+       _frame_rate_spin->Bind   (wxEVT_SPINCTRL, boost::bind(&DCPPanel::frame_rate_spin_changed, this));
+       _best_frame_rate->Bind   (wxEVT_BUTTON,   boost::bind(&DCPPanel::best_frame_rate_clicked, this));
+       _j2k_bandwidth->Bind     (wxEVT_SPINCTRL, boost::bind(&DCPPanel::j2k_bandwidth_changed, this));
        /* Also listen to wxEVT_TEXT so that typing numbers directly in is always noticed */
-       _j2k_bandwidth->Bind    (wxEVT_TEXT,          boost::bind (&DCPPanel::j2k_bandwidth_changed, this));
-       _resolution->Bind       (wxEVT_CHOICE,        boost::bind (&DCPPanel::resolution_changed, this));
-       _three_d->Bind          (wxEVT_CHECKBOX,      boost::bind (&DCPPanel::three_d_changed, this));
+       _j2k_bandwidth->Bind     (wxEVT_TEXT,     boost::bind(&DCPPanel::j2k_bandwidth_changed, this));
+       _resolution->Bind        (wxEVT_CHOICE,   boost::bind(&DCPPanel::resolution_changed, this));
+       _three_d->Bind           (wxEVT_CHECKBOX, boost::bind(&DCPPanel::three_d_changed, this));
+       _reencode_j2k->Bind      (wxEVT_CHECKBOX, boost::bind(&DCPPanel::reencode_j2k_changed, this));
 
        BOOST_FOREACH (Ratio const * i, Ratio::containers()) {
                _container->Append (std_to_wx(i->container_nickname()));
@@ -811,6 +825,7 @@ DCPPanel::add_video_panel_to_grid ()
                add_label_to_sizer (s, _mbits_label, false);
                _video_grid->Add (s, wxGBPosition (r, 1));
                ++r;
+               _video_grid->Add (_reencode_j2k, wxGBPosition(r, 0), wxGBSpan(1, 2));
        }
 }
 
index 8c20dc1..c433114 100644 (file)
@@ -77,6 +77,7 @@ private:
        void reel_type_changed ();
        void reel_length_changed ();
        void upload_after_make_dcp_changed ();
+       void reencode_j2k_changed ();
 
        void setup_frame_rate_widget ();
        void setup_container ();
@@ -127,6 +128,7 @@ private:
        wxButton* _show_audio;
        wxButton* _best_frame_rate;
        wxCheckBox* _three_d;
+       wxCheckBox* _reencode_j2k;
        wxStaticText* _resolution_label;
        wxChoice* _resolution;
        wxStaticText* _standard_label;