From 75538d19688ad8c29c5949de9bff9f044c713936 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 7 Nov 2018 23:26:51 +0000 Subject: [PATCH] Add button to force re-encode of J2K content. --- ChangeLog | 4 ++++ src/lib/film.cc | 10 ++++++++++ src/lib/film.h | 9 ++++++++- src/lib/j2k_encoder.cc | 2 +- src/wx/dcp_panel.cc | 37 ++++++++++++++++++++++++++----------- src/wx/dcp_panel.h | 2 ++ 6 files changed, 51 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24e276df3..a9d6d8bf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2018-11-07 Carl Hetherington + + * Add button to force re-encode of JPEG2000 content. + 2018-10-23 Carl Hetherington * Updated nl_NL translation from Rob van Nieuwkerk. diff --git a/src/lib/film.cc b/src/lib/film.cc index 807aeaf2f..2ff02d799 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -157,6 +157,7 @@ Film::Film (optional 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 (static_cast (_reel_type))); root->add_child("ReelLength")->add_child_text (raw_convert (_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 path) _reel_type = static_cast (f.optional_number_child("ReelType").get_value_or (static_cast(REELTYPE_SINGLE))); _reel_length = f.optional_number_child("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 notes; /* This method is the only one that can return notes (so far) */ @@ -943,6 +946,13 @@ Film::set_upload_after_make_dcp (bool u) _upload_after_make_dcp = u; } +void +Film::set_reencode_j2k (bool r) +{ + ChangeSignaller ch (this, REENCODE_J2K); + _reencode_j2k = r; +} + void Film::signal_change (ChangeType type, int p) { diff --git a/src/lib/film.h b/src/lib/film.h index 273077f8f..d251c7fcc 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -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 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; diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index e62e708cc..f92f23168 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -216,7 +216,7 @@ J2KEncoder::encode (shared_ptr 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 ()); diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 12345ace2..9d16b8c8f 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -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_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(_film)); } @@ -667,6 +671,16 @@ DCPPanel::three_d_changed () _film->set_three_d (_three_d->GetValue ()); } +void +DCPPanel::reencode_j2k_changed () +{ + if (!_film) { + return; + } + + _film->set_reencode_j2k (_reencode_j2k->GetValue()); +} + void DCPPanel::config_changed (Config::Property p) { @@ -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)); } } diff --git a/src/wx/dcp_panel.h b/src/wx/dcp_panel.h index 8c20dc174..c43311429 100644 --- a/src/wx/dcp_panel.h +++ b/src/wx/dcp_panel.h @@ -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; -- 2.30.2