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 "dcp_timeline_dialog.h"
27 #include "dcpomatic_button.h"
28 #include "dcpomatic_choice.h"
29 #include "dcpomatic_spin_ctrl.h"
30 #include "focus_manager.h"
31 #include "interop_metadata_dialog.h"
32 #include "language_tag_dialog.h"
33 #include "markers_dialog.h"
34 #include "smpte_metadata_dialog.h"
35 #include "static_text.h"
37 #include "lib/audio_content.h"
38 #include "lib/audio_processor.h"
39 #include "lib/config.h"
40 #include "lib/dcp_content.h"
41 #include "lib/dcp_content_type.h"
42 #include "lib/ffmpeg_content.h"
44 #include "lib/ratio.h"
45 #include "lib/text_content.h"
47 #include "lib/video_content.h"
48 #include <dcp/locale_convert.h>
49 #include <dcp/warnings.h>
50 LIBDCP_DISABLE_WARNINGS
51 #include <wx/gbsizer.h>
52 #include <wx/notebook.h>
53 #include <wx/spinctrl.h>
55 LIBDCP_ENABLE_WARNINGS
56 #include <boost/lexical_cast.hpp>
63 using std::shared_ptr;
67 using boost::lexical_cast;
68 #if BOOST_VERSION >= 106100
69 using namespace boost::placeholders;
71 using dcp::locale_convert;
74 DCPPanel::DCPPanel(wxNotebook* n, shared_ptr<Film> film, FilmViewer& viewer)
77 , _generally_sensitive (true)
79 _panel = new wxPanel (n);
80 _sizer = new wxBoxSizer (wxVERTICAL);
81 _panel->SetSizer (_sizer);
83 _grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
84 _sizer->Add (_grid, 0, wxEXPAND | wxALL, 8);
86 _name_label = create_label (_panel, _("Name"), true);
87 _name = new wxTextCtrl (_panel, wxID_ANY);
88 FocusManager::instance()->add(_name);
90 _use_isdcf_name = new CheckBox (_panel, _("Use ISDCF name"));
91 _copy_isdcf_name_button = new Button (_panel, _("Copy as name"));
93 /* wxST_ELLIPSIZE_MIDDLE works around a bug in GTK2 and/or wxWidgets, see
94 http://trac.wxwidgets.org/ticket/12539
96 _dcp_name = new StaticText (
97 _panel, wxT (""), wxDefaultPosition, wxDefaultSize,
98 wxALIGN_CENTRE_HORIZONTAL | wxST_NO_AUTORESIZE | wxST_ELLIPSIZE_MIDDLE
101 _dcp_content_type_label = create_label (_panel, _("Content Type"), true);
102 _dcp_content_type = new Choice(_panel);
104 _encrypted = new CheckBox (_panel, _("Encrypted"));
106 wxClientDC dc (_panel);
107 auto size = dc.GetTextExtent (wxT ("GGGGGGGG..."));
110 _standard_label = create_label (_panel, _("Standard"), true);
111 _standard = new Choice(_panel);
113 _markers = new Button (_panel, _("Markers..."));
114 _metadata = new Button (_panel, _("Metadata..."));
115 _reels = new Button(_panel, _("Reels..."));
117 _notebook = new wxNotebook (_panel, wxID_ANY);
118 _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6);
120 _notebook->AddPage (make_video_panel (), _("Video"), false);
121 _notebook->AddPage (make_audio_panel (), _("Audio"), false);
123 _name->Bind (wxEVT_TEXT, boost::bind(&DCPPanel::name_changed, this));
124 _use_isdcf_name->bind(&DCPPanel::use_isdcf_name_toggled, this);
125 _copy_isdcf_name_button->Bind(wxEVT_BUTTON, boost::bind(&DCPPanel::copy_isdcf_name_button_clicked, this));
126 _dcp_content_type->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::dcp_content_type_changed, this));
127 _encrypted->bind(&DCPPanel::encrypted_toggled, this);
128 _standard->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::standard_changed, this));
129 _markers->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::markers_clicked, this));
130 _metadata->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::metadata_clicked, this));
131 _reels->Bind(wxEVT_BUTTON, boost::bind(&DCPPanel::reels_clicked, this));
133 for (auto i: DCPContentType::all()) {
134 _dcp_content_type->add(i->pretty_name());
138 _standard->SetToolTip(_("The standard that the DCP should use. Interop is older, and SMPTE is the newer (current) standard. If in doubt, choose 'SMPTE'"));
140 Config::instance()->Changed.connect (boost::bind(&DCPPanel::config_changed, this, _1));
147 DCPPanel::add_standards()
149 _standard->add(_("SMPTE"), N_("smpte"));
150 if (Config::instance()->allow_smpte_bv20() || (_film && _film->limit_to_smpte_bv20())) {
151 _standard->add(_("SMPTE (Bv2.0 only)"), N_("smpte-bv20"));
153 _standard->add(_("Interop"), N_("interop"));
154 _standard->add(_("MPEG2 Interop"), N_("mpeg2-interop"));
160 DCPPanel::set_standard()
162 DCPOMATIC_ASSERT(_film);
163 DCPOMATIC_ASSERT(!_film->limit_to_smpte_bv20() || _standard->GetCount() == 3);
165 if (_film->interop()) {
166 if (_film->video_encoding() == VideoEncoding::JPEG2000) {
167 checked_set(_standard, "interop");
169 checked_set(_standard, "mpeg2-interop");
172 checked_set(_standard, _film->limit_to_smpte_bv20() ? "smpte-bv20" : "smpte");
178 DCPPanel::standard_changed ()
180 if (!_film || !_standard->get()) {
184 auto const data = _standard->get_data();
189 if (*data == N_("interop")) {
190 _film->set_interop(true);
191 _film->set_limit_to_smpte_bv20(false);
192 _film->set_video_encoding(VideoEncoding::JPEG2000);
193 } else if (*data == N_("smpte")) {
194 _film->set_interop(false);
195 _film->set_limit_to_smpte_bv20(false);
196 _film->set_video_encoding(VideoEncoding::JPEG2000);
197 } else if (*data == N_("smpte-bv20")) {
198 _film->set_interop(false);
199 _film->set_limit_to_smpte_bv20(true);
200 _film->set_video_encoding(VideoEncoding::JPEG2000);
201 } else if (*data == N_("mpeg2-interop")) {
202 _film->set_interop(true);
203 _film->set_video_encoding(VideoEncoding::MPEG2);
209 DCPPanel::add_to_grid ()
213 auto name_sizer = new wxBoxSizer (wxHORIZONTAL);
214 name_sizer->Add (_name_label, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
215 name_sizer->Add (_name, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
216 _grid->Add (name_sizer, wxGBPosition(r, 0), wxGBSpan(1, 2), wxRIGHT | wxEXPAND, DCPOMATIC_DIALOG_BORDER);
219 int flags = wxALIGN_CENTER_VERTICAL;
221 flags |= wxALIGN_RIGHT;
224 _grid->Add (_use_isdcf_name, wxGBPosition(r, 0), wxDefaultSpan, flags);
226 auto s = new wxBoxSizer (wxHORIZONTAL);
227 s->Add (_copy_isdcf_name_button, 0, wxLEFT, DCPOMATIC_SIZER_X_GAP);
228 _grid->Add (s, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxBOTTOM, DCPOMATIC_CHECKBOX_BOTTOM_PAD);
232 _grid->Add (_dcp_name, wxGBPosition(r, 0), wxGBSpan(1, 2), wxALIGN_CENTER_VERTICAL | wxEXPAND);
235 add_label_to_sizer (_grid, _dcp_content_type_label, true, wxGBPosition(r, 0));
236 _grid->Add (_dcp_content_type, wxGBPosition(r, 1));
239 _grid->Add (_encrypted, wxGBPosition(r, 0), wxGBSpan(1, 2));
242 add_label_to_sizer (_grid, _standard_label, true, wxGBPosition(r, 0));
243 _grid->Add (_standard, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
246 auto extra = new wxBoxSizer (wxHORIZONTAL);
247 extra->Add (_markers, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
248 extra->Add (_metadata, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
249 extra->Add(_reels, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
250 _grid->Add (extra, wxGBPosition(r, 0), wxGBSpan(1, 2));
256 DCPPanel::name_changed ()
262 _film->set_name (string(_name->GetValue().mb_str()));
267 DCPPanel::video_bit_rate_changed()
273 _film->set_video_bit_rate(_video_bit_rate->GetValue() * 1000000);
278 DCPPanel::encrypted_toggled ()
284 _film->set_encrypted (_encrypted->GetValue());
288 /** Called when the frame rate choice widget has been changed */
290 DCPPanel::frame_rate_choice_changed ()
292 if (!_film || !_frame_rate_choice->get()) {
296 _film->set_video_frame_rate (
297 boost::lexical_cast<int>(
298 wx_to_std(_frame_rate_choice->GetString(*_frame_rate_choice->get()))
305 /** Called when the frame rate spin widget has been changed */
307 DCPPanel::frame_rate_spin_changed ()
313 _film->set_video_frame_rate (_frame_rate_spin->GetValue());
318 DCPPanel::audio_channels_changed ()
324 _film->set_audio_channels(locale_convert<int>(string_client_data(_audio_channels->GetClientObject(*_audio_channels->get()))));
329 DCPPanel::resolution_changed ()
331 if (!_film || !_resolution->get()) {
335 _film->set_resolution(*_resolution->get() == 0 ? Resolution::TWO_K : Resolution::FOUR_K);
340 DCPPanel::markers_clicked ()
342 _markers_dialog.reset(_panel, _film, _viewer);
343 _markers_dialog->Show();
348 DCPPanel::metadata_clicked ()
350 if (_film->interop()) {
351 _interop_metadata_dialog.reset(_panel, _film);
352 _interop_metadata_dialog->setup ();
353 _interop_metadata_dialog->Show ();
355 _smpte_metadata_dialog.reset(_panel, _film);
356 _smpte_metadata_dialog->setup ();
357 _smpte_metadata_dialog->Show ();
363 DCPPanel::reels_clicked()
365 _dcp_timeline.reset(_panel, _film);
366 _dcp_timeline->Show();
371 DCPPanel::film_changed(FilmProperty p)
374 case FilmProperty::NONE:
376 case FilmProperty::CONTAINER:
379 case FilmProperty::NAME:
380 checked_set (_name, _film->name());
383 case FilmProperty::DCP_CONTENT_TYPE:
385 auto index = DCPContentType::as_index(_film->dcp_content_type());
386 DCPOMATIC_ASSERT (index);
387 checked_set (_dcp_content_type, *index);
391 case FilmProperty::ENCRYPTED:
392 checked_set (_encrypted, _film->encrypted ());
394 case FilmProperty::RESOLUTION:
395 checked_set (_resolution, _film->resolution() == Resolution::TWO_K ? 0 : 1);
399 case FilmProperty::VIDEO_BIT_RATE:
400 checked_set(_video_bit_rate, _film->video_bit_rate() / 1000000);
402 case FilmProperty::USE_ISDCF_NAME:
404 checked_set (_use_isdcf_name, _film->use_isdcf_name());
405 if (_film->use_isdcf_name()) {
406 /* We are going back to using an ISDCF name. Remove anything after a _ in the current name,
407 in case the user has clicked 'Copy as name' then re-ticked 'Use ISDCF name' (#1513).
409 string const name = _film->name ();
410 string::size_type const u = name.find("_");
411 if (u != string::npos) {
412 _film->set_name (name.substr(0, u));
418 case FilmProperty::VIDEO_FRAME_RATE:
421 for (unsigned int i = 0; i < _frame_rate_choice->GetCount(); ++i) {
422 if (wx_to_std(_frame_rate_choice->GetString(i)) == boost::lexical_cast<string>(_film->video_frame_rate())) {
423 checked_set (_frame_rate_choice, i);
430 checked_set (_frame_rate_choice, -1);
433 checked_set (_frame_rate_spin, _film->video_frame_rate ());
435 _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
439 case FilmProperty::AUDIO_CHANNELS:
440 if (_film->audio_channels() < minimum_allowed_audio_channels()) {
441 _film->set_audio_channels (minimum_allowed_audio_channels());
443 checked_set (_audio_channels, locale_convert<string>(max(minimum_allowed_audio_channels(), _film->audio_channels())));
447 case FilmProperty::THREE_D:
448 checked_set (_three_d, _film->three_d());
451 case FilmProperty::REENCODE_J2K:
452 checked_set (_reencode_j2k, _film->reencode_j2k());
454 case FilmProperty::INTEROP:
457 _markers->Enable (!_film->interop());
459 case FilmProperty::VIDEO_ENCODING:
462 case FilmProperty::LIMIT_TO_SMPTE_BV20:
465 case FilmProperty::AUDIO_PROCESSOR:
466 if (_film->audio_processor()) {
467 checked_set (_audio_processor, _film->audio_processor()->id());
469 checked_set (_audio_processor, 0);
471 setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels());
472 film_changed (FilmProperty::AUDIO_CHANNELS);
474 case FilmProperty::CONTENT:
476 setup_sensitivity ();
477 /* Maybe we now have ATMOS content which changes our minimum_allowed_audio_channels */
478 setup_audio_channels_choice(_audio_channels, minimum_allowed_audio_channels());
479 film_changed(FilmProperty::AUDIO_CHANNELS);
481 case FilmProperty::AUDIO_LANGUAGE:
483 auto al = _film->audio_language();
484 checked_set (_enable_audio_language, static_cast<bool>(al));
485 checked_set (_audio_language, al ? std_to_wx(al->to_string()) : wxT(""));
487 setup_sensitivity ();
488 _audio_panel_sizer->Layout();
491 case FilmProperty::AUDIO_FRAME_RATE:
492 if (_audio_sample_rate) {
493 checked_set (_audio_sample_rate, _film->audio_frame_rate() == 48000 ? 0 : 1);
496 case FilmProperty::CONTENT_VERSIONS:
497 case FilmProperty::VERSION_NUMBER:
498 case FilmProperty::RELEASE_TERRITORY:
499 case FilmProperty::RATINGS:
500 case FilmProperty::FACILITY:
501 case FilmProperty::STUDIO:
502 case FilmProperty::TEMP_VERSION:
503 case FilmProperty::PRE_RELEASE:
504 case FilmProperty::RED_BAND:
505 case FilmProperty::TWO_D_VERSION_OF_THREE_D:
506 case FilmProperty::CHAIN:
507 case FilmProperty::LUMINANCE:
508 case FilmProperty::TERRITORY_TYPE:
518 DCPPanel::film_content_changed (int property)
520 if (property == AudioContentProperty::STREAMS ||
521 property == TextContentProperty::USE ||
522 property == TextContentProperty::BURN ||
523 property == TextContentProperty::LANGUAGE ||
524 property == TextContentProperty::LANGUAGE_IS_ADDITIONAL ||
525 property == TextContentProperty::TYPE ||
526 property == TextContentProperty::DCP_TRACK ||
527 property == VideoContentProperty::CUSTOM_RATIO ||
528 property == VideoContentProperty::CUSTOM_SIZE ||
529 property == VideoContentProperty::BURNT_SUBTITLE_LANGUAGE ||
530 property == VideoContentProperty::CROP ||
531 property == DCPContentProperty::REFERENCE_VIDEO ||
532 property == DCPContentProperty::REFERENCE_AUDIO ||
533 property == DCPContentProperty::REFERENCE_TEXT) {
535 setup_sensitivity ();
541 DCPPanel::setup_container ()
544 auto ratios = Ratio::containers ();
545 auto i = ratios.begin ();
546 while (i != ratios.end() && *i != _film->container()) {
551 if (i == ratios.end()) {
552 checked_set (_container, -1);
553 checked_set (_container_size, wxT(""));
555 checked_set (_container, n);
556 auto const size = fit_ratio_within (_film->container()->ratio(), _film->full_frame ());
557 checked_set (_container_size, wxString::Format("%dx%d", size.width, size.height));
564 /** Called when the container widget has been changed */
566 DCPPanel::container_changed ()
572 if (auto const container = _container->get()) {
573 auto ratios = Ratio::containers ();
574 DCPOMATIC_ASSERT(*container < int(ratios.size()));
575 _film->set_container(ratios[*container]);
580 /** Called when the DCP content type widget has been changed */
582 DCPPanel::dcp_content_type_changed ()
588 if (auto const type = _dcp_content_type->get()) {
589 _film->set_dcp_content_type(DCPContentType::from_index(*type));
595 DCPPanel::set_film (shared_ptr<Film> film)
597 /* We are changing film, so destroy any dialogs for the old one */
598 _audio_dialog.reset();
599 _markers_dialog.reset();
600 _interop_metadata_dialog.reset();
601 _smpte_metadata_dialog.reset();
606 /* Really should all the film_changed below but this might be enough */
607 checked_set (_dcp_name, wxT(""));
608 set_general_sensitivity (false);
615 film_changed(FilmProperty::NAME);
616 film_changed(FilmProperty::USE_ISDCF_NAME);
617 film_changed(FilmProperty::CONTENT);
618 film_changed(FilmProperty::DCP_CONTENT_TYPE);
619 film_changed(FilmProperty::CONTAINER);
620 film_changed(FilmProperty::RESOLUTION);
621 film_changed(FilmProperty::ENCRYPTED);
622 film_changed(FilmProperty::VIDEO_BIT_RATE);
623 film_changed(FilmProperty::VIDEO_FRAME_RATE);
624 film_changed(FilmProperty::AUDIO_CHANNELS);
625 film_changed(FilmProperty::SEQUENCE);
626 film_changed(FilmProperty::THREE_D);
627 film_changed(FilmProperty::INTEROP);
628 film_changed(FilmProperty::AUDIO_PROCESSOR);
629 film_changed(FilmProperty::REEL_TYPE);
630 film_changed(FilmProperty::REEL_LENGTH);
631 film_changed(FilmProperty::REENCODE_J2K);
632 film_changed(FilmProperty::AUDIO_LANGUAGE);
633 film_changed(FilmProperty::AUDIO_FRAME_RATE);
634 film_changed(FilmProperty::LIMIT_TO_SMPTE_BV20);
636 set_general_sensitivity(static_cast<bool>(_film));
641 DCPPanel::set_general_sensitivity (bool s)
643 _generally_sensitive = s;
644 setup_sensitivity ();
649 DCPPanel::setup_sensitivity ()
651 _name->Enable (_generally_sensitive);
652 _use_isdcf_name->Enable (_generally_sensitive);
653 _dcp_content_type->Enable (_generally_sensitive);
654 _copy_isdcf_name_button->Enable (_generally_sensitive);
655 _enable_audio_language->Enable (_generally_sensitive);
656 _audio_language->Enable (_enable_audio_language->GetValue());
657 _edit_audio_language->Enable (_enable_audio_language->GetValue());
658 _encrypted->Enable (_generally_sensitive);
659 _markers->Enable (_generally_sensitive && _film && !_film->interop());
660 _metadata->Enable (_generally_sensitive);
661 _reels->Enable (_generally_sensitive && _film);
662 _frame_rate_choice->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->contains_atmos_content());
663 _frame_rate_spin->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->contains_atmos_content());
664 _audio_channels->Enable (_generally_sensitive && _film && !_film->references_dcp_audio());
665 _audio_processor->Enable (_generally_sensitive && _film && !_film->references_dcp_audio());
666 _video_bit_rate->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
667 _container->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
668 _best_frame_rate->Enable (
669 _generally_sensitive &&
671 _film->best_video_frame_rate () != _film->video_frame_rate() &&
672 !_film->references_dcp_video() &&
673 !_film->contains_atmos_content()
675 _resolution->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
676 _three_d->Enable (_generally_sensitive && _film && !_film->references_dcp_video());
679 _generally_sensitive &&
681 !_film->references_dcp_video() &&
682 !_film->references_dcp_audio() &&
683 !_film->contains_atmos_content()
686 _reencode_j2k->Enable (_generally_sensitive && _film);
687 _show_audio->Enable (_generally_sensitive && _film);
692 DCPPanel::use_isdcf_name_toggled ()
698 _film->set_use_isdcf_name (_use_isdcf_name->GetValue());
702 DCPPanel::setup_dcp_name ()
708 _dcp_name->SetLabel (std_to_wx(_film->dcp_name(true)));
709 _dcp_name->SetToolTip (std_to_wx(_film->dcp_name(true)));
714 DCPPanel::best_frame_rate_clicked ()
720 _film->set_video_frame_rate (_film->best_video_frame_rate());
725 DCPPanel::three_d_changed ()
731 _film->set_three_d (_three_d->GetValue());
736 DCPPanel::reencode_j2k_changed ()
742 _film->set_reencode_j2k (_reencode_j2k->GetValue());
747 DCPPanel::config_changed (Config::Property p)
749 _video_bit_rate->SetRange(1, Config::instance()->maximum_video_bit_rate() / 1000000);
750 setup_frame_rate_widget ();
752 if (p == Config::SHOW_EXPERIMENTAL_AUDIO_PROCESSORS) {
753 _audio_processor->Clear ();
754 add_audio_processors ();
756 film_changed(FilmProperty::AUDIO_PROCESSOR);
758 } else if (p == Config::ALLOW_SMPTE_BV20) {
762 film_changed(FilmProperty::INTEROP);
763 film_changed(FilmProperty::LIMIT_TO_SMPTE_BV20);
765 } else if (p == Config::ISDCF_NAME_PART_LENGTH) {
772 DCPPanel::setup_frame_rate_widget ()
774 if (Config::instance()->allow_any_dcp_frame_rate()) {
775 _frame_rate_choice->Hide ();
776 _frame_rate_spin->Show ();
778 _frame_rate_choice->Show ();
779 _frame_rate_spin->Hide ();
781 _frame_rate_sizer->Layout();
786 DCPPanel::make_video_panel ()
788 auto panel = new wxPanel (_notebook);
789 auto sizer = new wxBoxSizer (wxVERTICAL);
790 _video_grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
791 sizer->Add (_video_grid, 0, wxALL, 8);
792 panel->SetSizer (sizer);
794 _container_label = create_label (panel, _("Container"), true);
795 _container = new Choice(panel);
796 _container_size = new StaticText (panel, wxT (""));
798 _resolution_label = create_label (panel, _("Resolution"), true);
799 _resolution = new Choice(panel);
801 _frame_rate_label = create_label (panel, _("Frame Rate"), true);
802 _frame_rate_choice = new Choice(panel);
803 _frame_rate_spin = new SpinCtrl (panel, DCPOMATIC_SPIN_CTRL_WIDTH);
804 _best_frame_rate = new Button (panel, _("Use best"));
806 _three_d = new CheckBox (panel, _("3D"));
808 _video_bit_rate_label = create_label(panel, _("Video bit rate\nfor newly-encoded data"), true);
809 _video_bit_rate = new SpinCtrl(panel, DCPOMATIC_SPIN_CTRL_WIDTH);
810 _mbits_label = create_label (panel, _("Mbit/s"), false);
812 _reencode_j2k = new CheckBox (panel, _("Re-encode JPEG2000 data from input"));
814 _container->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::container_changed, this));
815 _frame_rate_choice->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::frame_rate_choice_changed, this));
816 _frame_rate_spin->Bind (wxEVT_SPINCTRL, boost::bind(&DCPPanel::frame_rate_spin_changed, this));
817 _best_frame_rate->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::best_frame_rate_clicked, this));
818 _video_bit_rate->Bind (wxEVT_SPINCTRL, boost::bind(&DCPPanel::video_bit_rate_changed, this));
819 /* Also listen to wxEVT_TEXT so that typing numbers directly in is always noticed */
820 _video_bit_rate->Bind (wxEVT_TEXT, boost::bind(&DCPPanel::video_bit_rate_changed, this));
821 _resolution->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::resolution_changed, this));
822 _three_d->bind(&DCPPanel::three_d_changed, this);
823 _reencode_j2k->bind(&DCPPanel::reencode_j2k_changed, this);
825 for (auto i: Ratio::containers()) {
826 _container->add(i->container_nickname());
829 for (auto i: Config::instance()->allowed_dcp_frame_rates()) {
830 _frame_rate_choice->add(boost::lexical_cast<string>(i));
833 _video_bit_rate->SetRange(1, Config::instance()->maximum_video_bit_rate() / 1000000);
834 _frame_rate_spin->SetRange (1, 480);
836 _resolution->add(_("2K"));
837 _resolution->add(_("4K"));
839 add_video_panel_to_grid ();
840 setup_frame_rate_widget();
847 DCPPanel::add_video_panel_to_grid ()
851 add_label_to_sizer (_video_grid, _container_label, true, wxGBPosition (r, 0));
853 auto s = new wxBoxSizer (wxHORIZONTAL);
854 s->Add (_container, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP);
855 s->Add (_container_size, 1, wxLEFT | wxALIGN_CENTER_VERTICAL);
856 _video_grid->Add (s, wxGBPosition(r, 1));
860 add_label_to_sizer (_video_grid, _resolution_label, true, wxGBPosition (r, 0));
861 _video_grid->Add (_resolution, wxGBPosition (r, 1));
864 add_label_to_sizer (_video_grid, _frame_rate_label, true, wxGBPosition (r, 0));
866 _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
867 _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
868 _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
869 _frame_rate_sizer->Add (_best_frame_rate, 1, wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
870 _video_grid->Add (_frame_rate_sizer, wxGBPosition (r, 1));
874 _video_grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
877 add_label_to_sizer(_video_grid, _video_bit_rate_label, true, wxGBPosition (r, 0));
878 auto s = new wxBoxSizer (wxHORIZONTAL);
879 s->Add(_video_bit_rate, 0, wxALIGN_CENTER_VERTICAL);
880 add_label_to_sizer (s, _mbits_label, false, 0, wxLEFT | wxALIGN_CENTER_VERTICAL);
881 _video_grid->Add (s, wxGBPosition(r, 1), wxDefaultSpan);
883 _video_grid->Add (_reencode_j2k, wxGBPosition(r, 0), wxGBSpan(1, 2));
888 DCPPanel::minimum_allowed_audio_channels () const
892 if (_film->audio_processor()) {
893 min = _film->audio_processor()->out_channels();
895 if (_film->contains_atmos_content()) {
896 min = std::max(min, 14);
909 DCPPanel::make_audio_panel ()
911 auto panel = new wxPanel (_notebook);
912 _audio_panel_sizer = new wxBoxSizer (wxVERTICAL);
913 _audio_grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
914 _audio_panel_sizer->Add (_audio_grid, 0, wxALL, 8);
915 panel->SetSizer (_audio_panel_sizer);
917 _channels_label = create_label (panel, _("Channels"), true);
918 _audio_channels = new Choice(panel);
919 setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels ());
921 if (Config::instance()->allow_96khz_audio()) {
922 _audio_sample_rate_label = create_label (panel, _("Sample rate"), true);
923 _audio_sample_rate = new wxChoice (panel, wxID_ANY);
926 _processor_label = create_label (panel, _("Processor"), true);
927 _audio_processor = new Choice(panel);
928 add_audio_processors ();
930 _enable_audio_language = new CheckBox(panel, _("Language"));
931 _audio_language = new wxStaticText(panel, wxID_ANY, wxT(""));
932 _edit_audio_language = new Button(panel, _("Edit..."));
934 _show_audio = new Button (panel, _("Show graph of audio levels..."));
936 _audio_channels->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::audio_channels_changed, this));
937 if (_audio_sample_rate) {
938 _audio_sample_rate->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::audio_sample_rate_changed, this));
940 _audio_processor->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::audio_processor_changed, this));
942 _enable_audio_language->bind(&DCPPanel::enable_audio_language_toggled, this);
943 _edit_audio_language->Bind(wxEVT_BUTTON, boost::bind(&DCPPanel::edit_audio_language_clicked, this));
945 _show_audio->Bind (wxEVT_BUTTON, boost::bind (&DCPPanel::show_audio_clicked, this));
947 if (_audio_sample_rate) {
948 _audio_sample_rate->Append (_("48kHz"));
949 _audio_sample_rate->Append (_("96kHz"));
952 add_audio_panel_to_grid ();
959 DCPPanel::add_audio_panel_to_grid ()
963 add_label_to_sizer (_audio_grid, _channels_label, true, wxGBPosition (r, 0));
964 _audio_grid->Add (_audio_channels, wxGBPosition (r, 1));
967 if (_audio_sample_rate_label && _audio_sample_rate) {
968 add_label_to_sizer (_audio_grid, _audio_sample_rate_label, true, wxGBPosition(r, 0));
969 _audio_grid->Add (_audio_sample_rate, wxGBPosition(r, 1));
973 add_label_to_sizer (_audio_grid, _processor_label, true, wxGBPosition (r, 0));
974 _audio_grid->Add (_audio_processor, wxGBPosition (r, 1));
978 auto s = new wxBoxSizer (wxHORIZONTAL);
979 s->Add(_enable_audio_language, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
980 s->Add(_audio_language, 1, wxALIGN_CENTER_VERTICAL | wxBOTTOM, DCPOMATIC_CHECKBOX_BOTTOM_PAD);
981 s->Add(DCPOMATIC_SIZER_X_GAP, 0);
982 s->Add(_edit_audio_language, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, DCPOMATIC_CHECKBOX_BOTTOM_PAD);
983 _audio_grid->Add(s, wxGBPosition(r, 0), wxGBSpan(1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL);
987 _audio_grid->Add (_show_audio, wxGBPosition (r, 0), wxGBSpan (1, 2));
993 DCPPanel::copy_isdcf_name_button_clicked ()
995 _film->set_name (_film->isdcf_name (true));
996 _film->set_use_isdcf_name (false);
1001 DCPPanel::audio_processor_changed ()
1003 if (!_film || !_audio_processor->get()) {
1007 auto const s = string_client_data(_audio_processor->GetClientObject(*_audio_processor->get()));
1008 _film->set_audio_processor (AudioProcessor::from_id (s));
1013 DCPPanel::show_audio_clicked ()
1019 _audio_dialog.reset(_panel, _film, _viewer);
1020 _audio_dialog->Show();
1025 DCPPanel::add_audio_processors ()
1027 _audio_processor->add(_("None"), new wxStringClientData(N_("none")));
1028 for (auto ap: AudioProcessor::visible()) {
1029 _audio_processor->add(std_to_wx(ap->name()), new wxStringClientData(std_to_wx(ap->id())));
1031 _audio_panel_sizer->Layout();
1036 DCPPanel::enable_audio_language_toggled ()
1038 setup_sensitivity ();
1039 if (_enable_audio_language->GetValue()) {
1040 auto al = wx_to_std (_audio_language->GetLabel());
1041 _film->set_audio_language (al.empty() ? dcp::LanguageTag("en-US") : dcp::LanguageTag(al));
1043 _film->set_audio_language (boost::none);
1049 DCPPanel::edit_audio_language_clicked ()
1051 DCPOMATIC_ASSERT (_film->audio_language());
1052 auto d = make_wx<LanguageTagDialog>(_panel, *_film->audio_language());
1053 if (d->ShowModal() == wxID_OK) {
1054 _film->set_audio_language(d->get());
1060 DCPPanel::audio_sample_rate_changed ()
1062 if (_audio_sample_rate) {
1063 _film->set_audio_frame_rate (_audio_sample_rate->GetSelection() == 0 ? 48000 : 96000);