2 Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "audio_dialog.h"
23 #include "check_box.h"
24 #include "check_box.h"
25 #include "dcp_panel.h"
26 #include "dcpomatic_button.h"
27 #include "dcpomatic_choice.h"
28 #include "dcpomatic_spin_ctrl.h"
29 #include "focus_manager.h"
30 #include "interop_metadata_dialog.h"
31 #include "language_tag_dialog.h"
32 #include "markers_dialog.h"
33 #include "smpte_metadata_dialog.h"
34 #include "static_text.h"
36 #include "lib/audio_content.h"
37 #include "lib/audio_processor.h"
38 #include "lib/config.h"
39 #include "lib/dcp_content.h"
40 #include "lib/dcp_content_type.h"
41 #include "lib/ffmpeg_content.h"
43 #include "lib/ratio.h"
44 #include "lib/text_content.h"
46 #include "lib/video_content.h"
47 #include <dcp/locale_convert.h>
48 #include <dcp/warnings.h>
49 LIBDCP_DISABLE_WARNINGS
50 #include <wx/gbsizer.h>
51 #include <wx/notebook.h>
52 #include <wx/spinctrl.h>
54 LIBDCP_ENABLE_WARNINGS
55 #include <boost/lexical_cast.hpp>
62 using std::shared_ptr;
66 using boost::lexical_cast;
67 #if BOOST_VERSION >= 106100
68 using namespace boost::placeholders;
70 using dcp::locale_convert;
73 DCPPanel::DCPPanel(wxNotebook* n, shared_ptr<Film> film, FilmViewer& viewer)
76 , _generally_sensitive (true)
78 _panel = new wxPanel (n);
79 _sizer = new wxBoxSizer (wxVERTICAL);
80 _panel->SetSizer (_sizer);
82 _grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
83 _sizer->Add (_grid, 0, wxEXPAND | wxALL, 8);
85 _name_label = create_label (_panel, _("Name"), true);
86 _name = new wxTextCtrl (_panel, wxID_ANY);
87 FocusManager::instance()->add(_name);
89 _use_isdcf_name = new CheckBox (_panel, _("Use ISDCF name"));
90 _copy_isdcf_name_button = new Button (_panel, _("Copy as name"));
92 /* wxST_ELLIPSIZE_MIDDLE works around a bug in GTK2 and/or wxWidgets, see
93 http://trac.wxwidgets.org/ticket/12539
95 _dcp_name = new StaticText (
96 _panel, wxT (""), wxDefaultPosition, wxDefaultSize,
97 wxALIGN_CENTRE_HORIZONTAL | wxST_NO_AUTORESIZE | wxST_ELLIPSIZE_MIDDLE
100 _dcp_content_type_label = create_label (_panel, _("Content Type"), true);
101 _dcp_content_type = new Choice(_panel);
103 _encrypted = new CheckBox (_panel, _("Encrypted"));
105 wxClientDC dc (_panel);
106 auto size = dc.GetTextExtent (wxT ("GGGGGGGG..."));
109 _reels_label = create_label (_panel, _("Reels"), true);
110 _reel_type = new Choice(_panel);
112 _reel_length_label = create_label (_panel, _("Reel length"), true);
113 _reel_length = new SpinCtrl (_panel, DCPOMATIC_SPIN_CTRL_WIDTH);
114 _reel_length_gb_label = create_label (_panel, _("GB"), false);
116 _standard_label = create_label (_panel, _("Standard"), true);
117 _standard = new Choice(_panel);
119 _markers = new Button (_panel, _("Markers..."));
120 _metadata = new Button (_panel, _("Metadata..."));
122 _notebook = new wxNotebook (_panel, wxID_ANY);
123 _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6);
125 _notebook->AddPage (make_video_panel (), _("Video"), false);
126 _notebook->AddPage (make_audio_panel (), _("Audio"), false);
128 _name->Bind (wxEVT_TEXT, boost::bind(&DCPPanel::name_changed, this));
129 _use_isdcf_name->bind(&DCPPanel::use_isdcf_name_toggled, this);
130 _copy_isdcf_name_button->Bind(wxEVT_BUTTON, boost::bind(&DCPPanel::copy_isdcf_name_button_clicked, this));
131 _dcp_content_type->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::dcp_content_type_changed, this));
132 _encrypted->bind(&DCPPanel::encrypted_toggled, this);
133 _reel_type->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::reel_type_changed, this));
134 _reel_length->Bind (wxEVT_SPINCTRL, boost::bind(&DCPPanel::reel_length_changed, this));
135 _standard->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::standard_changed, this));
136 _markers->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::markers_clicked, this));
137 _metadata->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::metadata_clicked, this));
138 for (auto i: DCPContentType::all()) {
139 _dcp_content_type->add(i->pretty_name());
142 _reel_type->add(_("Single reel"));
143 _reel_type->add(_("Split by video content"));
144 _reel_type->add(S_("Split by maximum reel size"));
145 _reel_type->SetToolTip(_("How the DCP should be split into parts internally. If in doubt, choose 'Single reel'"));
147 _reel_length->SetRange (1, 64);
150 _standard->SetToolTip(_("The standard that the DCP should use. Interop is older, and SMPTE is the newer (current) standard. If in doubt, choose 'SMPTE'"));
152 Config::instance()->Changed.connect (boost::bind(&DCPPanel::config_changed, this, _1));
159 DCPPanel::add_standards()
161 _standard->add(_("SMPTE"), N_("smpte"));
162 if (Config::instance()->allow_smpte_bv20() || (_film && _film->limit_to_smpte_bv20())) {
163 _standard->add(_("SMPTE (Bv2.0 only)"), N_("smpte-bv20"));
165 _standard->add(_("Interop"), N_("interop"));
171 DCPPanel::set_standard()
173 DCPOMATIC_ASSERT(_film);
174 DCPOMATIC_ASSERT(!_film->limit_to_smpte_bv20() || _standard->GetCount() == 3);
176 if (_film->interop()) {
177 checked_set(_standard, "interop");
179 checked_set(_standard, _film->limit_to_smpte_bv20() ? "smpte-bv20" : "smpte");
185 DCPPanel::standard_changed ()
187 if (!_film || !_standard->get()) {
191 auto const data = _standard->get_data();
196 if (*data == N_("interop")) {
197 _film->set_interop(true);
198 _film->set_limit_to_smpte_bv20(false);
199 } else if (*data == N_("smpte")) {
200 _film->set_interop(false);
201 _film->set_limit_to_smpte_bv20(false);
202 } else if (*data == N_("smpte-bv20")) {
203 _film->set_interop(false);
204 _film->set_limit_to_smpte_bv20(true);
210 DCPPanel::add_to_grid ()
214 auto name_sizer = new wxBoxSizer (wxHORIZONTAL);
215 name_sizer->Add (_name_label, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
216 name_sizer->Add (_name, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
217 _grid->Add (name_sizer, wxGBPosition(r, 0), wxGBSpan(1, 2), wxRIGHT | wxEXPAND, DCPOMATIC_DIALOG_BORDER);
220 int flags = wxALIGN_CENTER_VERTICAL;
222 flags |= wxALIGN_RIGHT;
225 _grid->Add (_use_isdcf_name, wxGBPosition(r, 0), wxDefaultSpan, flags);
227 auto s = new wxBoxSizer (wxHORIZONTAL);
228 s->Add (_copy_isdcf_name_button, 0, wxLEFT, DCPOMATIC_SIZER_X_GAP);
229 _grid->Add (s, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxBOTTOM, DCPOMATIC_CHECKBOX_BOTTOM_PAD);
233 _grid->Add (_dcp_name, wxGBPosition(r, 0), wxGBSpan(1, 2), wxALIGN_CENTER_VERTICAL | wxEXPAND);
236 add_label_to_sizer (_grid, _dcp_content_type_label, true, wxGBPosition(r, 0));
237 _grid->Add (_dcp_content_type, wxGBPosition(r, 1));
240 _grid->Add (_encrypted, wxGBPosition(r, 0), wxGBSpan(1, 2));
243 add_label_to_sizer (_grid, _reels_label, true, wxGBPosition(r, 0));
244 _grid->Add (_reel_type, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
247 add_label_to_sizer (_grid, _reel_length_label, true, wxGBPosition(r, 0));
249 auto s = new wxBoxSizer (wxHORIZONTAL);
250 s->Add (_reel_length);
251 add_label_to_sizer (s, _reel_length_gb_label, false, 0, wxLEFT | wxALIGN_CENTER_VERTICAL);
252 _grid->Add (s, wxGBPosition(r, 1));
256 add_label_to_sizer (_grid, _standard_label, true, wxGBPosition(r, 0));
257 _grid->Add (_standard, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
260 auto extra = new wxBoxSizer (wxHORIZONTAL);
261 extra->Add (_markers, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
262 extra->Add (_metadata, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
263 _grid->Add (extra, wxGBPosition(r, 0), wxGBSpan(1, 2));
269 DCPPanel::name_changed ()
275 _film->set_name (string(_name->GetValue().mb_str()));
280 DCPPanel::j2k_bandwidth_changed ()
286 _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
291 DCPPanel::encrypted_toggled ()
297 _film->set_encrypted (_encrypted->GetValue());
301 /** Called when the frame rate choice widget has been changed */
303 DCPPanel::frame_rate_choice_changed ()
305 if (!_film || !_frame_rate_choice->get()) {
309 _film->set_video_frame_rate (
310 boost::lexical_cast<int>(
311 wx_to_std(_frame_rate_choice->GetString(*_frame_rate_choice->get()))
318 /** Called when the frame rate spin widget has been changed */
320 DCPPanel::frame_rate_spin_changed ()
326 _film->set_video_frame_rate (_frame_rate_spin->GetValue());
331 DCPPanel::audio_channels_changed ()
337 _film->set_audio_channels(locale_convert<int>(string_client_data(_audio_channels->GetClientObject(*_audio_channels->get()))));
342 DCPPanel::resolution_changed ()
344 if (!_film || !_resolution->get()) {
348 _film->set_resolution(*_resolution->get() == 0 ? Resolution::TWO_K : Resolution::FOUR_K);
353 DCPPanel::markers_clicked ()
355 _markers_dialog.reset(_panel, _film, _viewer);
356 _markers_dialog->Show();
361 DCPPanel::metadata_clicked ()
363 if (_film->interop()) {
364 _interop_metadata_dialog.reset(_panel, _film);
365 _interop_metadata_dialog->setup ();
366 _interop_metadata_dialog->Show ();
368 _smpte_metadata_dialog.reset(_panel, _film);
369 _smpte_metadata_dialog->setup ();
370 _smpte_metadata_dialog->Show ();
376 DCPPanel::film_changed(FilmProperty p)
379 case FilmProperty::NONE:
381 case FilmProperty::CONTAINER:
384 case FilmProperty::NAME:
385 checked_set (_name, _film->name());
388 case FilmProperty::DCP_CONTENT_TYPE:
390 auto index = DCPContentType::as_index(_film->dcp_content_type());
391 DCPOMATIC_ASSERT (index);
392 checked_set (_dcp_content_type, *index);
396 case FilmProperty::ENCRYPTED:
397 checked_set (_encrypted, _film->encrypted ());
399 case FilmProperty::RESOLUTION:
400 checked_set (_resolution, _film->resolution() == Resolution::TWO_K ? 0 : 1);
404 case FilmProperty::J2K_BANDWIDTH:
405 checked_set (_j2k_bandwidth, _film->j2k_bandwidth() / 1000000);
407 case FilmProperty::USE_ISDCF_NAME:
409 checked_set (_use_isdcf_name, _film->use_isdcf_name());
410 if (_film->use_isdcf_name()) {
411 /* We are going back to using an ISDCF name. Remove anything after a _ in the current name,
412 in case the user has clicked 'Copy as name' then re-ticked 'Use ISDCF name' (#1513).
414 string const name = _film->name ();
415 string::size_type const u = name.find("_");
416 if (u != string::npos) {
417 _film->set_name (name.substr(0, u));
423 case FilmProperty::VIDEO_FRAME_RATE:
426 for (unsigned int i = 0; i < _frame_rate_choice->GetCount(); ++i) {
427 if (wx_to_std(_frame_rate_choice->GetString(i)) == boost::lexical_cast<string>(_film->video_frame_rate())) {
428 checked_set (_frame_rate_choice, i);
435 checked_set (_frame_rate_choice, -1);
438 checked_set (_frame_rate_spin, _film->video_frame_rate ());
440 _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
444 case FilmProperty::AUDIO_CHANNELS:
445 if (_film->audio_channels() < minimum_allowed_audio_channels()) {
446 _film->set_audio_channels (minimum_allowed_audio_channels());
448 checked_set (_audio_channels, locale_convert<string>(max(minimum_allowed_audio_channels(), _film->audio_channels())));
452 case FilmProperty::THREE_D:
453 checked_set (_three_d, _film->three_d());
456 case FilmProperty::REENCODE_J2K:
457 checked_set (_reencode_j2k, _film->reencode_j2k());
459 case FilmProperty::INTEROP:
462 _markers->Enable (!_film->interop());
464 case FilmProperty::LIMIT_TO_SMPTE_BV20:
467 case FilmProperty::AUDIO_PROCESSOR:
468 if (_film->audio_processor()) {
469 checked_set (_audio_processor, _film->audio_processor()->id());
471 checked_set (_audio_processor, 0);
473 setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels());
474 film_changed (FilmProperty::AUDIO_CHANNELS);
476 case FilmProperty::REEL_TYPE:
477 checked_set (_reel_type, static_cast<int>(_film->reel_type()));
478 _reel_length->Enable (_film->reel_type() == ReelType::BY_LENGTH);
480 case FilmProperty::REEL_LENGTH:
481 checked_set (_reel_length, _film->reel_length() / 1000000000LL);
483 case FilmProperty::CONTENT:
485 setup_sensitivity ();
486 /* Maybe we now have ATMOS content which changes our minimum_allowed_audio_channels */
487 setup_audio_channels_choice(_audio_channels, minimum_allowed_audio_channels());
488 film_changed(FilmProperty::AUDIO_CHANNELS);
490 case FilmProperty::AUDIO_LANGUAGE:
492 auto al = _film->audio_language();
493 checked_set (_enable_audio_language, static_cast<bool>(al));
494 checked_set (_audio_language, al ? std_to_wx(al->to_string()) : wxT(""));
496 setup_sensitivity ();
497 _audio_panel_sizer->Layout();
500 case FilmProperty::AUDIO_FRAME_RATE:
501 if (_audio_sample_rate) {
502 checked_set (_audio_sample_rate, _film->audio_frame_rate() == 48000 ? 0 : 1);
505 case FilmProperty::CONTENT_VERSIONS:
506 case FilmProperty::VERSION_NUMBER:
507 case FilmProperty::RELEASE_TERRITORY:
508 case FilmProperty::RATINGS:
509 case FilmProperty::FACILITY:
510 case FilmProperty::STUDIO:
511 case FilmProperty::TEMP_VERSION:
512 case FilmProperty::PRE_RELEASE:
513 case FilmProperty::RED_BAND:
514 case FilmProperty::TWO_D_VERSION_OF_THREE_D:
515 case FilmProperty::CHAIN:
516 case FilmProperty::LUMINANCE:
517 case FilmProperty::TERRITORY_TYPE:
527 DCPPanel::film_content_changed (int property)
529 if (property == AudioContentProperty::STREAMS ||
530 property == TextContentProperty::USE ||
531 property == TextContentProperty::BURN ||
532 property == TextContentProperty::LANGUAGE ||
533 property == TextContentProperty::LANGUAGE_IS_ADDITIONAL ||
534 property == TextContentProperty::TYPE ||
535 property == TextContentProperty::DCP_TRACK ||
536 property == VideoContentProperty::CUSTOM_RATIO ||
537 property == VideoContentProperty::CUSTOM_SIZE ||
538 property == VideoContentProperty::BURNT_SUBTITLE_LANGUAGE ||
539 property == VideoContentProperty::CROP ||
540 property == DCPContentProperty::REFERENCE_VIDEO ||
541 property == DCPContentProperty::REFERENCE_AUDIO ||
542 property == DCPContentProperty::REFERENCE_TEXT) {
544 setup_sensitivity ();
550 DCPPanel::setup_container ()
553 auto ratios = Ratio::containers ();
554 auto i = ratios.begin ();
555 while (i != ratios.end() && *i != _film->container()) {
560 if (i == ratios.end()) {
561 checked_set (_container, -1);
562 checked_set (_container_size, wxT(""));
564 checked_set (_container, n);
565 auto const size = fit_ratio_within (_film->container()->ratio(), _film->full_frame ());
566 checked_set (_container_size, wxString::Format("%dx%d", size.width, size.height));
573 /** Called when the container widget has been changed */
575 DCPPanel::container_changed ()
581 if (auto const container = _container->get()) {
582 auto ratios = Ratio::containers ();
583 DCPOMATIC_ASSERT(*container < int(ratios.size()));
584 _film->set_container(ratios[*container]);
589 /** Called when the DCP content type widget has been changed */
591 DCPPanel::dcp_content_type_changed ()
597 if (auto const type = _dcp_content_type->get()) {
598 _film->set_dcp_content_type(DCPContentType::from_index(*type));
604 DCPPanel::set_film (shared_ptr<Film> film)
606 /* We are changing film, so destroy any dialogs for the old one */
607 _audio_dialog.reset();
608 _markers_dialog.reset();
609 _interop_metadata_dialog.reset();
610 _smpte_metadata_dialog.reset();
615 /* Really should all the film_changed below but this might be enough */
616 checked_set (_dcp_name, wxT(""));
617 set_general_sensitivity (false);
624 film_changed(FilmProperty::NAME);
625 film_changed(FilmProperty::USE_ISDCF_NAME);
626 film_changed(FilmProperty::CONTENT);
627 film_changed(FilmProperty::DCP_CONTENT_TYPE);
628 film_changed(FilmProperty::CONTAINER);
629 film_changed(FilmProperty::RESOLUTION);
630 film_changed(FilmProperty::ENCRYPTED);
631 film_changed(FilmProperty::J2K_BANDWIDTH);
632 film_changed(FilmProperty::VIDEO_FRAME_RATE);
633 film_changed(FilmProperty::AUDIO_CHANNELS);
634 film_changed(FilmProperty::SEQUENCE);
635 film_changed(FilmProperty::THREE_D);
636 film_changed(FilmProperty::INTEROP);
637 film_changed(FilmProperty::AUDIO_PROCESSOR);
638 film_changed(FilmProperty::REEL_TYPE);
639 film_changed(FilmProperty::REEL_LENGTH);
640 film_changed(FilmProperty::REENCODE_J2K);
641 film_changed(FilmProperty::AUDIO_LANGUAGE);
642 film_changed(FilmProperty::AUDIO_FRAME_RATE);
643 film_changed(FilmProperty::LIMIT_TO_SMPTE_BV20);
645 set_general_sensitivity(static_cast<bool>(_film));
650 DCPPanel::set_general_sensitivity (bool s)
652 _generally_sensitive = s;
653 setup_sensitivity ();
658 DCPPanel::setup_sensitivity ()
660 _name->Enable (_generally_sensitive);
661 _use_isdcf_name->Enable (_generally_sensitive);
662 _dcp_content_type->Enable (_generally_sensitive);
663 _copy_isdcf_name_button->Enable (_generally_sensitive);
664 _enable_audio_language->Enable (_generally_sensitive);
665 _audio_language->Enable (_enable_audio_language->GetValue());
666 _edit_audio_language->Enable (_enable_audio_language->GetValue());
667 _encrypted->Enable (_generally_sensitive);
668 _reel_type->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->references_dcp_audio());
669 _reel_length->Enable (_generally_sensitive && _film && _film->reel_type() == ReelType::BY_LENGTH);
670 _markers->Enable (_generally_sensitive && _film && !_film->interop());
671 _metadata->Enable (_generally_sensitive);
672 _frame_rate_choice->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->contains_atmos_content());
673 _frame_rate_spin->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->contains_atmos_content());
674 _audio_channels->Enable (_generally_sensitive && _film && !_film->references_dcp_audio());
675 _audio_processor->Enable (_generally_sensitive && _film && !_film->references_dcp_audio());
676 _j2k_bandwidth->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
677 _container->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
678 _best_frame_rate->Enable (
679 _generally_sensitive &&
681 _film->best_video_frame_rate () != _film->video_frame_rate() &&
682 !_film->references_dcp_video() &&
683 !_film->contains_atmos_content()
685 _resolution->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
686 _three_d->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
689 _generally_sensitive &&
691 !_film->references_dcp_video() &&
692 !_film->references_dcp_audio() &&
693 !_film->contains_atmos_content()
696 _reencode_j2k->Enable (_generally_sensitive && _film);
697 _show_audio->Enable (_generally_sensitive && _film);
702 DCPPanel::use_isdcf_name_toggled ()
708 _film->set_use_isdcf_name (_use_isdcf_name->GetValue());
712 DCPPanel::setup_dcp_name ()
718 _dcp_name->SetLabel (std_to_wx(_film->dcp_name(true)));
719 _dcp_name->SetToolTip (std_to_wx(_film->dcp_name(true)));
724 DCPPanel::best_frame_rate_clicked ()
730 _film->set_video_frame_rate (_film->best_video_frame_rate());
735 DCPPanel::three_d_changed ()
741 _film->set_three_d (_three_d->GetValue());
746 DCPPanel::reencode_j2k_changed ()
752 _film->set_reencode_j2k (_reencode_j2k->GetValue());
757 DCPPanel::config_changed (Config::Property p)
759 _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
760 setup_frame_rate_widget ();
762 if (p == Config::SHOW_EXPERIMENTAL_AUDIO_PROCESSORS) {
763 _audio_processor->Clear ();
764 add_audio_processors ();
766 film_changed(FilmProperty::AUDIO_PROCESSOR);
768 } else if (p == Config::ALLOW_SMPTE_BV20) {
772 film_changed(FilmProperty::INTEROP);
773 film_changed(FilmProperty::LIMIT_TO_SMPTE_BV20);
775 } else if (p == Config::ISDCF_NAME_PART_LENGTH) {
782 DCPPanel::setup_frame_rate_widget ()
784 if (Config::instance()->allow_any_dcp_frame_rate()) {
785 _frame_rate_choice->Hide ();
786 _frame_rate_spin->Show ();
788 _frame_rate_choice->Show ();
789 _frame_rate_spin->Hide ();
791 _frame_rate_sizer->Layout();
796 DCPPanel::make_video_panel ()
798 auto panel = new wxPanel (_notebook);
799 auto sizer = new wxBoxSizer (wxVERTICAL);
800 _video_grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
801 sizer->Add (_video_grid, 0, wxALL, 8);
802 panel->SetSizer (sizer);
804 _container_label = create_label (panel, _("Container"), true);
805 _container = new Choice(panel);
806 _container_size = new StaticText (panel, wxT (""));
808 _resolution_label = create_label (panel, _("Resolution"), true);
809 _resolution = new Choice(panel);
811 _frame_rate_label = create_label (panel, _("Frame Rate"), true);
812 _frame_rate_choice = new Choice(panel);
813 _frame_rate_spin = new SpinCtrl (panel, DCPOMATIC_SPIN_CTRL_WIDTH);
814 _best_frame_rate = new Button (panel, _("Use best"));
816 _three_d = new CheckBox (panel, _("3D"));
818 _j2k_bandwidth_label = create_label (panel, _("JPEG2000 bandwidth\nfor newly-encoded data"), true);
819 _j2k_bandwidth = new SpinCtrl (panel, DCPOMATIC_SPIN_CTRL_WIDTH);
820 _mbits_label = create_label (panel, _("Mbit/s"), false);
822 _reencode_j2k = new CheckBox (panel, _("Re-encode JPEG2000 data from input"));
824 _container->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::container_changed, this));
825 _frame_rate_choice->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::frame_rate_choice_changed, this));
826 _frame_rate_spin->Bind (wxEVT_SPINCTRL, boost::bind(&DCPPanel::frame_rate_spin_changed, this));
827 _best_frame_rate->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::best_frame_rate_clicked, this));
828 _j2k_bandwidth->Bind (wxEVT_SPINCTRL, boost::bind(&DCPPanel::j2k_bandwidth_changed, this));
829 /* Also listen to wxEVT_TEXT so that typing numbers directly in is always noticed */
830 _j2k_bandwidth->Bind (wxEVT_TEXT, boost::bind(&DCPPanel::j2k_bandwidth_changed, this));
831 _resolution->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::resolution_changed, this));
832 _three_d->bind(&DCPPanel::three_d_changed, this);
833 _reencode_j2k->bind(&DCPPanel::reencode_j2k_changed, this);
835 for (auto i: Ratio::containers()) {
836 _container->add(i->container_nickname());
839 for (auto i: Config::instance()->allowed_dcp_frame_rates()) {
840 _frame_rate_choice->add(boost::lexical_cast<string>(i));
843 _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
844 _frame_rate_spin->SetRange (1, 480);
846 _resolution->add(_("2K"));
847 _resolution->add(_("4K"));
849 add_video_panel_to_grid ();
850 setup_frame_rate_widget();
857 DCPPanel::add_video_panel_to_grid ()
861 add_label_to_sizer (_video_grid, _container_label, true, wxGBPosition (r, 0));
863 auto s = new wxBoxSizer (wxHORIZONTAL);
864 s->Add (_container, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP);
865 s->Add (_container_size, 1, wxLEFT | wxALIGN_CENTER_VERTICAL);
866 _video_grid->Add (s, wxGBPosition(r, 1));
870 add_label_to_sizer (_video_grid, _resolution_label, true, wxGBPosition (r, 0));
871 _video_grid->Add (_resolution, wxGBPosition (r, 1));
874 add_label_to_sizer (_video_grid, _frame_rate_label, true, wxGBPosition (r, 0));
876 _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
877 _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
878 _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
879 _frame_rate_sizer->Add (_best_frame_rate, 1, wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
880 _video_grid->Add (_frame_rate_sizer, wxGBPosition (r, 1));
884 _video_grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
887 add_label_to_sizer (_video_grid, _j2k_bandwidth_label, true, wxGBPosition (r, 0));
888 auto s = new wxBoxSizer (wxHORIZONTAL);
889 s->Add (_j2k_bandwidth, 0, wxALIGN_CENTER_VERTICAL);
890 add_label_to_sizer (s, _mbits_label, false, 0, wxLEFT | wxALIGN_CENTER_VERTICAL);
891 _video_grid->Add (s, wxGBPosition(r, 1), wxDefaultSpan);
893 _video_grid->Add (_reencode_j2k, wxGBPosition(r, 0), wxGBSpan(1, 2));
898 DCPPanel::minimum_allowed_audio_channels () const
902 if (_film->audio_processor()) {
903 min = _film->audio_processor()->out_channels();
905 if (_film->contains_atmos_content()) {
906 min = std::max(min, 14);
919 DCPPanel::make_audio_panel ()
921 auto panel = new wxPanel (_notebook);
922 _audio_panel_sizer = new wxBoxSizer (wxVERTICAL);
923 _audio_grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
924 _audio_panel_sizer->Add (_audio_grid, 0, wxALL, 8);
925 panel->SetSizer (_audio_panel_sizer);
927 _channels_label = create_label (panel, _("Channels"), true);
928 _audio_channels = new Choice(panel);
929 setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels ());
931 if (Config::instance()->allow_96khz_audio()) {
932 _audio_sample_rate_label = create_label (panel, _("Sample rate"), true);
933 _audio_sample_rate = new wxChoice (panel, wxID_ANY);
936 _processor_label = create_label (panel, _("Processor"), true);
937 _audio_processor = new Choice(panel);
938 add_audio_processors ();
940 _enable_audio_language = new CheckBox(panel, _("Language"));
941 _audio_language = new wxStaticText(panel, wxID_ANY, wxT(""));
942 _edit_audio_language = new Button(panel, _("Edit..."));
944 _show_audio = new Button (panel, _("Show graph of audio levels..."));
946 _audio_channels->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::audio_channels_changed, this));
947 if (_audio_sample_rate) {
948 _audio_sample_rate->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::audio_sample_rate_changed, this));
950 _audio_processor->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::audio_processor_changed, this));
952 _enable_audio_language->bind(&DCPPanel::enable_audio_language_toggled, this);
953 _edit_audio_language->Bind(wxEVT_BUTTON, boost::bind(&DCPPanel::edit_audio_language_clicked, this));
955 _show_audio->Bind (wxEVT_BUTTON, boost::bind (&DCPPanel::show_audio_clicked, this));
957 if (_audio_sample_rate) {
958 _audio_sample_rate->Append (_("48kHz"));
959 _audio_sample_rate->Append (_("96kHz"));
962 add_audio_panel_to_grid ();
969 DCPPanel::add_audio_panel_to_grid ()
973 add_label_to_sizer (_audio_grid, _channels_label, true, wxGBPosition (r, 0));
974 _audio_grid->Add (_audio_channels, wxGBPosition (r, 1));
977 if (_audio_sample_rate_label && _audio_sample_rate) {
978 add_label_to_sizer (_audio_grid, _audio_sample_rate_label, true, wxGBPosition(r, 0));
979 _audio_grid->Add (_audio_sample_rate, wxGBPosition(r, 1));
983 add_label_to_sizer (_audio_grid, _processor_label, true, wxGBPosition (r, 0));
984 _audio_grid->Add (_audio_processor, wxGBPosition (r, 1));
988 auto s = new wxBoxSizer (wxHORIZONTAL);
989 s->Add(_enable_audio_language, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
990 s->Add(_audio_language, 1, wxALIGN_CENTER_VERTICAL | wxBOTTOM, DCPOMATIC_CHECKBOX_BOTTOM_PAD);
991 s->Add(DCPOMATIC_SIZER_X_GAP, 0);
992 s->Add(_edit_audio_language, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, DCPOMATIC_CHECKBOX_BOTTOM_PAD);
993 _audio_grid->Add(s, wxGBPosition(r, 0), wxGBSpan(1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL);
997 _audio_grid->Add (_show_audio, wxGBPosition (r, 0), wxGBSpan (1, 2));
1003 DCPPanel::copy_isdcf_name_button_clicked ()
1005 _film->set_name (_film->isdcf_name (true));
1006 _film->set_use_isdcf_name (false);
1011 DCPPanel::audio_processor_changed ()
1013 if (!_film || !_audio_processor->get()) {
1017 auto const s = string_client_data(_audio_processor->GetClientObject(*_audio_processor->get()));
1018 _film->set_audio_processor (AudioProcessor::from_id (s));
1023 DCPPanel::show_audio_clicked ()
1029 _audio_dialog.reset(_panel, _film, _viewer);
1030 _audio_dialog->Show();
1035 DCPPanel::reel_type_changed ()
1037 if (!_film || !_reel_type->get()) {
1041 _film->set_reel_type(static_cast<ReelType>(*_reel_type->get()));
1046 DCPPanel::reel_length_changed ()
1052 _film->set_reel_length (_reel_length->GetValue() * 1000000000LL);
1057 DCPPanel::add_audio_processors ()
1059 _audio_processor->add(_("None"), new wxStringClientData(N_("none")));
1060 for (auto ap: AudioProcessor::visible()) {
1061 _audio_processor->add(std_to_wx(ap->name()), new wxStringClientData(std_to_wx(ap->id())));
1063 _audio_panel_sizer->Layout();
1068 DCPPanel::enable_audio_language_toggled ()
1070 setup_sensitivity ();
1071 if (_enable_audio_language->GetValue()) {
1072 auto al = wx_to_std (_audio_language->GetLabel());
1073 _film->set_audio_language (al.empty() ? dcp::LanguageTag("en-US") : dcp::LanguageTag(al));
1075 _film->set_audio_language (boost::none);
1081 DCPPanel::edit_audio_language_clicked ()
1083 DCPOMATIC_ASSERT (_film->audio_language());
1084 auto d = make_wx<LanguageTagDialog>(_panel, *_film->audio_language());
1085 if (d->ShowModal() == wxID_OK) {
1086 _film->set_audio_language(d->get());
1092 DCPPanel::audio_sample_rate_changed ()
1094 if (_audio_sample_rate) {
1095 _film->set_audio_frame_rate (_audio_sample_rate->GetSelection() == 0 ? 48000 : 96000);