2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/film_editor.cc
21 * @brief A wx widget to edit a film's metadata, and perform various functions.
27 #include <wx/notebook.h>
28 #include <boost/thread.hpp>
29 #include <boost/filesystem.hpp>
30 #include <boost/lexical_cast.hpp>
31 #include "lib/format.h"
33 #include "lib/transcode_job.h"
34 #include "lib/exceptions.h"
35 #include "lib/ab_transcode_job.h"
36 #include "lib/job_manager.h"
37 #include "lib/filter.h"
38 #include "lib/config.h"
39 #include "lib/ffmpeg_decoder.h"
41 #include "filter_dialog.h"
43 #include "film_editor.h"
44 #include "gain_calculator_dialog.h"
45 #include "sound_processor.h"
46 #include "dci_metadata_dialog.h"
48 #include "audio_dialog.h"
52 using std::stringstream;
55 using std::setprecision;
58 using boost::shared_ptr;
59 using boost::dynamic_pointer_cast;
61 /** @param f Film to edit */
62 FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
65 , _generally_sensitive (true)
68 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
70 _notebook = new wxNotebook (this, wxID_ANY);
71 s->Add (_notebook, 1);
74 _notebook->AddPage (_film_panel, _("Film"), true);
76 _notebook->AddPage (_video_panel, _("Video"), false);
78 _notebook->AddPage (_audio_panel, _("Audio"), false);
79 make_subtitle_panel ();
80 _notebook->AddPage (_subtitle_panel, _("Subtitles"), false);
83 connect_to_widgets ();
85 JobManager::instance()->ActiveJobsChanged.connect (
86 bind (&FilmEditor::active_jobs_changed, this, _1)
94 FilmEditor::make_film_panel ()
96 _film_panel = new wxPanel (_notebook);
97 _film_sizer = new wxBoxSizer (wxVERTICAL);
98 _film_panel->SetSizer (_film_sizer);
100 wxGridBagSizer* grid = new wxGridBagSizer (DVDOMATIC_SIZER_X_GAP, DVDOMATIC_SIZER_Y_GAP);
101 _film_sizer->Add (grid, 0, wxALL, 8);
105 add_label_to_grid_bag_sizer (grid, _film_panel, _("Name"), true, wxGBPosition (r, 0));
106 _name = new wxTextCtrl (_film_panel, wxID_ANY);
107 grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxLEFT | wxRIGHT);
110 add_label_to_grid_bag_sizer (grid, _film_panel, _("DCP Name"), true, wxGBPosition (r, 0));
111 _dcp_name = new wxStaticText (_film_panel, wxID_ANY, wxT (""));
112 grid->Add (_dcp_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
115 int flags = wxALIGN_CENTER_VERTICAL;
117 flags |= wxALIGN_RIGHT;
120 _use_dci_name = new wxCheckBox (_film_panel, wxID_ANY, _("Use DCI name"));
121 grid->Add (_use_dci_name, wxGBPosition (r, 0), wxDefaultSpan, flags);
122 _edit_dci_button = new wxButton (_film_panel, wxID_ANY, _("Details..."));
123 grid->Add (_edit_dci_button, wxGBPosition (r, 1), wxDefaultSpan);
126 add_label_to_grid_bag_sizer (grid, _film_panel, _("Content"), true, wxGBPosition (r, 0));
127 _content = new wxFilePickerCtrl (_film_panel, wxID_ANY, wxT (""), _("Select Content File"), wxT("*.*"));
128 grid->Add (_content, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
131 _trust_content_header = new wxCheckBox (_film_panel, wxID_ANY, _("Trust content's header"));
132 video_control (_trust_content_header);
133 grid->Add (_trust_content_header, wxGBPosition (r, 0), wxGBSpan(1, 2));
136 add_label_to_grid_bag_sizer (grid, _film_panel, _("Content Type"), true, wxGBPosition (r, 0));
137 _dcp_content_type = new wxChoice (_film_panel, wxID_ANY);
138 grid->Add (_dcp_content_type, wxGBPosition (r, 1));
141 video_control (add_label_to_grid_bag_sizer (grid, _film_panel, _("Original Frame Rate"), true, wxGBPosition (r, 0)));
142 _source_frame_rate = new wxStaticText (_film_panel, wxID_ANY, wxT (""));
143 grid->Add (video_control (_source_frame_rate), wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
147 add_label_to_grid_bag_sizer (grid, _film_panel, _("DCP Frame Rate"), true, wxGBPosition (r, 0));
148 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
149 _dcp_frame_rate = new wxChoice (_film_panel, wxID_ANY);
150 s->Add (_dcp_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
151 _best_dcp_frame_rate = new wxButton (_film_panel, wxID_ANY, _("Use best"));
152 s->Add (_best_dcp_frame_rate, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 6);
153 grid->Add (s, wxGBPosition (r, 1));
157 _frame_rate_description = new wxStaticText (_film_panel, wxID_ANY, wxT ("\n \n "), wxDefaultPosition, wxDefaultSize);
158 grid->Add (video_control (_frame_rate_description), wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
159 wxFont font = _frame_rate_description->GetFont();
160 font.SetStyle(wxFONTSTYLE_ITALIC);
161 font.SetPointSize(font.GetPointSize() - 1);
162 _frame_rate_description->SetFont(font);
165 video_control (add_label_to_grid_bag_sizer (grid, _film_panel, _("Length"), true, wxGBPosition (r, 0)));
166 _length = new wxStaticText (_film_panel, wxID_ANY, wxT (""));
167 grid->Add (video_control (_length), wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
172 video_control (add_label_to_grid_bag_sizer (grid, _film_panel, _("Trim frames"), true, wxGBPosition (r, 0)));
173 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
174 video_control (add_label_to_sizer (s, _film_panel, _("Start"), true));
175 _trim_start = new wxSpinCtrl (_film_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
176 s->Add (video_control (_trim_start));
177 video_control (add_label_to_sizer (s, _film_panel, _("End"), true));
178 _trim_end = new wxSpinCtrl (_film_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
179 s->Add (video_control (_trim_end));
181 grid->Add (s, wxGBPosition (r, 1));
185 video_control (add_label_to_grid_bag_sizer (grid, _film_panel, _("Trim method"), true, wxGBPosition (r, 0)));
186 _trim_type = new wxChoice (_film_panel, wxID_ANY);
187 grid->Add (video_control (_trim_type), wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
190 _dcp_ab = new wxCheckBox (_film_panel, wxID_ANY, _("A/B"));
191 video_control (_dcp_ab);
192 grid->Add (_dcp_ab, wxGBPosition (r, 0));
195 /* STILL-only stuff */
197 still_control (add_label_to_grid_bag_sizer (grid, _film_panel, _("Duration"), true, wxGBPosition (r, 0)));
198 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
199 _still_duration = new wxSpinCtrl (_film_panel);
200 still_control (_still_duration);
201 s->Add (_still_duration, 1, wxEXPAND);
202 /// TRANSLATORS: `s' here is an abbreviation for seconds, the unit of time
203 still_control (add_label_to_sizer (s, _film_panel, _("s"), false));
204 grid->Add (s, wxGBPosition (r, 1));
208 vector<DCPContentType const *> const ct = DCPContentType::all ();
209 for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
210 _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
213 list<int> const dfr = Config::instance()->allowed_dcp_frame_rates ();
214 for (list<int>::const_iterator i = dfr.begin(); i != dfr.end(); ++i) {
215 _dcp_frame_rate->Append (std_to_wx (boost::lexical_cast<string> (*i)));
218 _trim_type->Append (_("encode all frames and play the subset"));
219 _trim_type->Append (_("encode only the subset"));
223 FilmEditor::connect_to_widgets ()
225 _name->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (FilmEditor::name_changed), 0, this);
226 _use_dci_name->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::use_dci_name_toggled), 0, this);
227 _edit_dci_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this);
228 _format->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this);
229 _content->Connect (wxID_ANY, wxEVT_COMMAND_FILEPICKER_CHANGED, wxCommandEventHandler (FilmEditor::content_changed), 0, this);
230 _trust_content_header->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::trust_content_header_changed), 0, this);
231 _left_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this);
232 _right_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::right_crop_changed), 0, this);
233 _top_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::top_crop_changed), 0, this);
234 _bottom_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::bottom_crop_changed), 0, this);
235 _filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_filters_clicked), 0, this);
236 _scaler->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::scaler_changed), 0, this);
237 _dcp_content_type->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::dcp_content_type_changed), 0, this);
238 _dcp_frame_rate->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::dcp_frame_rate_changed), 0, this);
239 _best_dcp_frame_rate->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::best_dcp_frame_rate_clicked), 0, this);
240 _pad_with_silence->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::pad_with_silence_toggled), 0, this);
241 _minimum_audio_channels->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::minimum_audio_channels_changed), 0, this);
242 _dcp_ab->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::dcp_ab_toggled), 0, this);
243 _still_duration->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::still_duration_changed), 0, this);
244 _trim_start->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::trim_start_changed), 0, this);
245 _trim_end->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::trim_end_changed), 0, this);
246 _trim_type->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::trim_type_changed), 0, this);
247 _with_subtitles->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::with_subtitles_toggled), 0, this);
248 _subtitle_offset->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_offset_changed), 0, this);
249 _subtitle_scale->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_scale_changed), 0, this);
250 _colour_lut->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::colour_lut_changed), 0, this);
251 _j2k_bandwidth->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::j2k_bandwidth_changed), 0, this);
252 _subtitle_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::subtitle_stream_changed), 0, this);
253 _audio_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this);
254 _audio_gain->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_gain_changed), 0, this);
255 _audio_gain_calculate_button->Connect (
256 wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::audio_gain_calculate_button_clicked), 0, this
258 _show_audio->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::show_audio_clicked), 0, this);
259 _audio_delay->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
260 _use_content_audio->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (FilmEditor::use_audio_changed), 0, this);
261 _use_external_audio->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (FilmEditor::use_audio_changed), 0, this);
262 for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
263 _external_audio[i]->Connect (
264 wxID_ANY, wxEVT_COMMAND_FILEPICKER_CHANGED, wxCommandEventHandler (FilmEditor::external_audio_changed), 0, this
270 FilmEditor::make_video_panel ()
272 _video_panel = new wxPanel (_notebook);
273 _video_sizer = new wxBoxSizer (wxVERTICAL);
274 _video_panel->SetSizer (_video_sizer);
276 wxGridBagSizer* grid = new wxGridBagSizer (DVDOMATIC_SIZER_X_GAP, DVDOMATIC_SIZER_Y_GAP);
277 _video_sizer->Add (grid, 0, wxALL, 8);
280 add_label_to_grid_bag_sizer (grid, _video_panel, _("Format"), true, wxGBPosition (r, 0));
281 _format = new wxChoice (_video_panel, wxID_ANY);
282 grid->Add (_format, wxGBPosition (r, 1));
285 add_label_to_grid_bag_sizer (grid, _video_panel, _("Left crop"), true, wxGBPosition (r, 0));
286 _left_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
287 grid->Add (_left_crop, wxGBPosition (r, 1));
290 add_label_to_grid_bag_sizer (grid, _video_panel, _("Right crop"), true, wxGBPosition (r, 0));
291 _right_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
292 grid->Add (_right_crop, wxGBPosition (r, 1));
295 add_label_to_grid_bag_sizer (grid, _video_panel, _("Top crop"), true, wxGBPosition (r, 0));
296 _top_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
297 grid->Add (_top_crop, wxGBPosition (r, 1));
300 add_label_to_grid_bag_sizer (grid, _video_panel, _("Bottom crop"), true, wxGBPosition (r, 0));
301 _bottom_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
302 grid->Add (_bottom_crop, wxGBPosition (r, 1));
305 _scaling_description = new wxStaticText (_video_panel, wxID_ANY, wxT ("\n \n \n \n"), wxDefaultPosition, wxDefaultSize);
306 grid->Add (_scaling_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
307 wxFont font = _scaling_description->GetFont();
308 font.SetStyle(wxFONTSTYLE_ITALIC);
309 font.SetPointSize(font.GetPointSize() - 1);
310 _scaling_description->SetFont(font);
313 /* VIDEO-only stuff */
315 video_control (add_label_to_grid_bag_sizer (grid, _video_panel, _("Filters"), true, wxGBPosition (r, 0)));
316 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
317 _filters = new wxStaticText (_video_panel, wxID_ANY, _("None"));
318 video_control (_filters);
319 s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
320 _filters_button = new wxButton (_video_panel, wxID_ANY, _("Edit..."));
321 video_control (_filters_button);
322 s->Add (_filters_button, 0, wxALIGN_CENTER_VERTICAL);
323 grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
327 video_control (add_label_to_grid_bag_sizer (grid, _video_panel, _("Scaler"), true, wxGBPosition (r, 0)));
328 _scaler = new wxChoice (_video_panel, wxID_ANY);
329 grid->Add (video_control (_scaler), wxGBPosition (r, 1));
332 vector<Scaler const *> const sc = Scaler::all ();
333 for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
334 _scaler->Append (std_to_wx ((*i)->name()));
337 add_label_to_grid_bag_sizer (grid, _video_panel, _("Colour look-up table"), true, wxGBPosition (r, 0));
338 _colour_lut = new wxChoice (_video_panel, wxID_ANY);
339 for (int i = 0; i < 2; ++i) {
340 _colour_lut->Append (std_to_wx (colour_lut_index_to_name (i)));
342 _colour_lut->SetSelection (0);
343 grid->Add (_colour_lut, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
347 add_label_to_grid_bag_sizer (grid, _video_panel, _("JPEG2000 bandwidth"), true, wxGBPosition (r, 0));
348 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
349 _j2k_bandwidth = new wxSpinCtrl (_video_panel, wxID_ANY);
350 s->Add (_j2k_bandwidth, 1);
351 add_label_to_sizer (s, _video_panel, _("MBps"), false);
352 grid->Add (s, wxGBPosition (r, 1));
356 _left_crop->SetRange (0, 1024);
357 _top_crop->SetRange (0, 1024);
358 _right_crop->SetRange (0, 1024);
359 _bottom_crop->SetRange (0, 1024);
360 _still_duration->SetRange (1, 60 * 60);
361 _trim_start->SetRange (0, 24 * 60 * 60);
362 _trim_end->SetRange (0, 24 * 60 * 60);
363 _j2k_bandwidth->SetRange (50, 250);
367 FilmEditor::make_audio_panel ()
369 _audio_panel = new wxPanel (_notebook);
370 _audio_sizer = new wxBoxSizer (wxVERTICAL);
371 _audio_panel->SetSizer (_audio_sizer);
373 wxFlexGridSizer* grid = new wxFlexGridSizer (2, DVDOMATIC_SIZER_X_GAP, DVDOMATIC_SIZER_Y_GAP);
374 _audio_sizer->Add (grid, 0, wxALL, 8);
376 _show_audio = new wxButton (_audio_panel, wxID_ANY, _("Show Audio..."));
377 grid->Add (_show_audio, 1);
381 video_control (add_label_to_sizer (grid, _audio_panel, _("Audio Gain"), true));
382 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
383 _audio_gain = new wxSpinCtrl (_audio_panel);
384 s->Add (video_control (_audio_gain), 1);
385 video_control (add_label_to_sizer (s, _audio_panel, _("dB"), false));
386 _audio_gain_calculate_button = new wxButton (_audio_panel, wxID_ANY, _("Calculate..."));
387 video_control (_audio_gain_calculate_button);
388 s->Add (_audio_gain_calculate_button, 1, wxEXPAND);
393 video_control (add_label_to_sizer (grid, _audio_panel, _("Audio Delay"), true));
394 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
395 _audio_delay = new wxSpinCtrl (_audio_panel);
396 s->Add (video_control (_audio_delay), 1);
397 /// TRANSLATORS: this is an abbreviation for milliseconds, the unit of time
398 video_control (add_label_to_sizer (s, _audio_panel, _("ms"), false));
403 _pad_with_silence = new wxCheckBox (_audio_panel, wxID_ANY, _("Pad with silence to"));
404 grid->Add (_pad_with_silence);
405 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
406 _minimum_audio_channels = new wxSpinCtrl (_audio_panel);
407 s->Add (_minimum_audio_channels, 1);
408 add_label_to_sizer (s, _audio_panel, _("channels"));
413 _use_content_audio = new wxRadioButton (_audio_panel, wxID_ANY, _("Use content's audio"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
414 grid->Add (video_control (_use_content_audio));
415 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
416 _audio_stream = new wxChoice (_audio_panel, wxID_ANY);
417 s->Add (video_control (_audio_stream), 1);
418 _audio = new wxStaticText (_audio_panel, wxID_ANY, wxT (""));
419 s->Add (video_control (_audio), 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 8);
423 _use_external_audio = new wxRadioButton (_audio_panel, wxID_ANY, _("Use external audio"));
424 grid->Add (_use_external_audio);
427 for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
428 add_label_to_sizer (grid, _audio_panel, std_to_wx (audio_channel_name (i)), true);
429 _external_audio[i] = new wxFilePickerCtrl (_audio_panel, wxID_ANY, wxT (""), _("Select Audio File"), wxT ("*.wav"));
430 grid->Add (_external_audio[i], 1, wxEXPAND);
433 _audio_gain->SetRange (-60, 60);
434 _audio_delay->SetRange (-1000, 1000);
435 _minimum_audio_channels->SetRange (0, MAX_AUDIO_CHANNELS);
439 FilmEditor::make_subtitle_panel ()
441 _subtitle_panel = new wxPanel (_notebook);
442 _subtitle_sizer = new wxBoxSizer (wxVERTICAL);
443 _subtitle_panel->SetSizer (_subtitle_sizer);
444 wxFlexGridSizer* grid = new wxFlexGridSizer (2, DVDOMATIC_SIZER_X_GAP, DVDOMATIC_SIZER_Y_GAP);
445 _subtitle_sizer->Add (grid, 0, wxALL, 8);
447 _with_subtitles = new wxCheckBox (_subtitle_panel, wxID_ANY, _("With Subtitles"));
448 video_control (_with_subtitles);
449 grid->Add (_with_subtitles, 1);
451 _subtitle_stream = new wxChoice (_subtitle_panel, wxID_ANY);
452 grid->Add (video_control (_subtitle_stream));
455 video_control (add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Offset"), true));
456 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
457 _subtitle_offset = new wxSpinCtrl (_subtitle_panel);
458 s->Add (_subtitle_offset);
459 video_control (add_label_to_sizer (s, _subtitle_panel, _("pixels"), false));
464 video_control (add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Scale"), true));
465 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
466 _subtitle_scale = new wxSpinCtrl (_subtitle_panel);
467 s->Add (video_control (_subtitle_scale));
468 video_control (add_label_to_sizer (s, _subtitle_panel, _("%"), false));
472 _subtitle_offset->SetRange (-1024, 1024);
473 _subtitle_scale->SetRange (1, 1000);
476 /** Called when the left crop widget has been changed */
478 FilmEditor::left_crop_changed (wxCommandEvent &)
484 _film->set_left_crop (_left_crop->GetValue ());
487 /** Called when the right crop widget has been changed */
489 FilmEditor::right_crop_changed (wxCommandEvent &)
495 _film->set_right_crop (_right_crop->GetValue ());
498 /** Called when the top crop widget has been changed */
500 FilmEditor::top_crop_changed (wxCommandEvent &)
506 _film->set_top_crop (_top_crop->GetValue ());
509 /** Called when the bottom crop value has been changed */
511 FilmEditor::bottom_crop_changed (wxCommandEvent &)
517 _film->set_bottom_crop (_bottom_crop->GetValue ());
520 /** Called when the content filename has been changed */
522 FilmEditor::content_changed (wxCommandEvent &)
529 _film->set_content (wx_to_std (_content->GetPath ()));
530 } catch (std::exception& e) {
531 _content->SetPath (std_to_wx (_film->directory ()));
532 error_dialog (this, wxString::Format (_("Could not set content: %s"), std_to_wx (e.what()).data()));
537 FilmEditor::trust_content_header_changed (wxCommandEvent &)
543 _film->set_trust_content_header (_trust_content_header->GetValue ());
546 /** Called when the DCP A/B switch has been toggled */
548 FilmEditor::dcp_ab_toggled (wxCommandEvent &)
554 _film->set_dcp_ab (_dcp_ab->GetValue ());
557 /** Called when the name widget has been changed */
559 FilmEditor::name_changed (wxCommandEvent &)
565 _film->set_name (string (_name->GetValue().mb_str()));
569 FilmEditor::subtitle_offset_changed (wxCommandEvent &)
575 _film->set_subtitle_offset (_subtitle_offset->GetValue ());
579 FilmEditor::subtitle_scale_changed (wxCommandEvent &)
585 _film->set_subtitle_scale (_subtitle_scale->GetValue() / 100.0);
589 FilmEditor::colour_lut_changed (wxCommandEvent &)
595 _film->set_colour_lut (_colour_lut->GetSelection ());
599 FilmEditor::j2k_bandwidth_changed (wxCommandEvent &)
605 _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1e6);
609 FilmEditor::dcp_frame_rate_changed (wxCommandEvent &)
615 _film->set_dcp_frame_rate (
616 boost::lexical_cast<int> (
617 wx_to_std (_dcp_frame_rate->GetString (_dcp_frame_rate->GetSelection ()))
623 /** Called when the metadata stored in the Film object has changed;
624 * so that we can update the GUI.
625 * @param p Property of the Film that has changed.
628 FilmEditor::film_changed (Film::Property p)
642 checked_set (_content, _film->content ());
645 setup_subtitle_control_sensitivity ();
647 setup_show_audio_sensitivity ();
648 setup_frame_rate_description ();
649 setup_minimum_audio_channels ();
651 case Film::TRUST_CONTENT_HEADER:
652 checked_set (_trust_content_header, _film->trust_content_header ());
654 case Film::SUBTITLE_STREAMS:
655 setup_subtitle_control_sensitivity ();
658 case Film::CONTENT_AUDIO_STREAMS:
660 setup_show_audio_sensitivity ();
661 setup_frame_rate_description ();
662 setup_minimum_audio_channels ();
667 vector<Format const *>::iterator i = _formats.begin ();
668 while (i != _formats.end() && *i != _film->format ()) {
672 if (i == _formats.end()) {
673 checked_set (_format, -1);
675 checked_set (_format, n);
678 setup_scaling_description ();
682 checked_set (_left_crop, _film->crop().left);
683 checked_set (_right_crop, _film->crop().right);
684 checked_set (_top_crop, _film->crop().top);
685 checked_set (_bottom_crop, _film->crop().bottom);
686 setup_scaling_description ();
690 pair<string, string> p = Filter::ffmpeg_strings (_film->filters ());
691 if (p.first.empty () && p.second.empty ()) {
692 _filters->SetLabel (_("None"));
694 string const b = p.first + " " + p.second;
695 _filters->SetLabel (std_to_wx (b));
697 _film_sizer->Layout ();
701 checked_set (_name, _film->name());
704 case Film::SOURCE_FRAME_RATE:
705 s << fixed << setprecision(2) << _film->source_frame_rate();
706 _source_frame_rate->SetLabel (std_to_wx (s.str ()));
707 setup_frame_rate_description ();
710 setup_scaling_description ();
713 if (_film->source_frame_rate() > 0 && _film->length()) {
714 s << _film->length().get() << " "
715 << wx_to_std (_("frames")) << "; " << seconds_to_hms (_film->length().get() / _film->source_frame_rate());
716 } else if (_film->length()) {
717 s << _film->length().get() << " "
718 << wx_to_std (_("frames"));
720 _length->SetLabel (std_to_wx (s.str ()));
721 if (_film->length()) {
722 _trim_start->SetRange (0, _film->length().get());
723 _trim_end->SetRange (0, _film->length().get());
726 case Film::DCP_CONTENT_TYPE:
727 checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
731 checked_set (_dcp_ab, _film->dcp_ab ());
734 checked_set (_scaler, Scaler::as_index (_film->scaler ()));
736 case Film::TRIM_START:
737 checked_set (_trim_start, _film->trim_start());
740 checked_set (_trim_end, _film->trim_end());
742 case Film::TRIM_TYPE:
743 checked_set (_trim_type, _film->trim_type() == Film::CPL ? 0 : 1);
745 case Film::AUDIO_GAIN:
746 checked_set (_audio_gain, _film->audio_gain ());
748 case Film::AUDIO_DELAY:
749 checked_set (_audio_delay, _film->audio_delay ());
751 case Film::STILL_DURATION:
752 checked_set (_still_duration, _film->still_duration ());
754 case Film::WITH_SUBTITLES:
755 checked_set (_with_subtitles, _film->with_subtitles ());
756 setup_subtitle_control_sensitivity ();
759 case Film::SUBTITLE_OFFSET:
760 checked_set (_subtitle_offset, _film->subtitle_offset ());
762 case Film::SUBTITLE_SCALE:
763 checked_set (_subtitle_scale, _film->subtitle_scale() * 100);
765 case Film::COLOUR_LUT:
766 checked_set (_colour_lut, _film->colour_lut ());
768 case Film::J2K_BANDWIDTH:
769 checked_set (_j2k_bandwidth, double (_film->j2k_bandwidth()) / 1e6);
771 case Film::USE_DCI_NAME:
772 checked_set (_use_dci_name, _film->use_dci_name ());
775 case Film::DCI_METADATA:
778 case Film::CONTENT_AUDIO_STREAM:
779 if (_film->content_audio_stream()) {
780 checked_set (_audio_stream, _film->content_audio_stream()->to_string());
783 setup_audio_details ();
784 setup_audio_control_sensitivity ();
785 setup_show_audio_sensitivity ();
786 setup_frame_rate_description ();
787 setup_minimum_audio_channels ();
789 case Film::USE_CONTENT_AUDIO:
790 _film->log()->log (String::compose ("Film::USE_CONTENT_AUDIO changed; setting GUI using %1", _film->use_content_audio ()));
791 checked_set (_use_content_audio, _film->use_content_audio());
792 checked_set (_use_external_audio, !_film->use_content_audio());
794 setup_audio_details ();
795 setup_audio_control_sensitivity ();
796 setup_show_audio_sensitivity ();
797 setup_frame_rate_description ();
798 setup_minimum_audio_channels ();
800 case Film::SUBTITLE_STREAM:
801 if (_film->subtitle_stream()) {
802 checked_set (_subtitle_stream, _film->subtitle_stream()->to_string());
805 case Film::EXTERNAL_AUDIO:
807 vector<string> a = _film->external_audio ();
808 for (size_t i = 0; i < a.size() && i < MAX_AUDIO_CHANNELS; ++i) {
809 checked_set (_external_audio[i], a[i]);
811 setup_audio_details ();
812 setup_show_audio_sensitivity ();
813 setup_frame_rate_description ();
814 setup_minimum_audio_channels ();
817 case Film::DCP_FRAME_RATE:
818 for (unsigned int i = 0; i < _dcp_frame_rate->GetCount(); ++i) {
819 if (wx_to_std (_dcp_frame_rate->GetString(i)) == boost::lexical_cast<string> (_film->dcp_frame_rate())) {
820 if (_dcp_frame_rate->GetSelection() != int(i)) {
821 _dcp_frame_rate->SetSelection (i);
827 if (_film->source_frame_rate()) {
828 _best_dcp_frame_rate->Enable (best_dcp_frame_rate (_film->source_frame_rate ()) != _film->dcp_frame_rate ());
830 _best_dcp_frame_rate->Disable ();
833 setup_frame_rate_description ();
834 case Film::MINIMUM_AUDIO_CHANNELS:
835 checked_set (_minimum_audio_channels, _film->minimum_audio_channels ());
836 setup_minimum_audio_channels ();
842 FilmEditor::setup_frame_rate_description ()
847 if (_film->source_frame_rate()) {
848 d << std_to_wx (FrameRateConversion (_film->source_frame_rate(), _film->dcp_frame_rate()).description);
850 #ifdef HAVE_SWRESAMPLE
851 if (_film->audio_stream() && _film->audio_stream()->sample_rate() != _film->target_audio_sample_rate ()) {
852 d << wxString::Format (
853 _("Audio will be resampled from %dHz to %dHz\n"),
854 _film->audio_stream()->sample_rate(),
855 _film->target_audio_sample_rate()
862 for (int i = lines; i < 2; ++i) {
866 _frame_rate_description->SetLabel (d);
869 /** Called when the format widget has been changed */
871 FilmEditor::format_changed (wxCommandEvent &)
877 int const n = _format->GetSelection ();
879 assert (n < int (_formats.size()));
880 _film->set_format (_formats[n]);
884 /** Called when the DCP content type widget has been changed */
886 FilmEditor::dcp_content_type_changed (wxCommandEvent &)
892 int const n = _dcp_content_type->GetSelection ();
893 if (n != wxNOT_FOUND) {
894 _film->set_dcp_content_type (DCPContentType::from_index (n));
898 /** Sets the Film that we are editing */
900 FilmEditor::set_film (shared_ptr<Film> f)
904 set_things_sensitive (_film != 0);
907 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
911 FileChanged (_film->directory ());
917 _audio_dialog->set_film (_film);
920 film_changed (Film::NAME);
921 film_changed (Film::USE_DCI_NAME);
922 film_changed (Film::CONTENT);
923 film_changed (Film::TRUST_CONTENT_HEADER);
924 film_changed (Film::DCP_CONTENT_TYPE);
925 film_changed (Film::FORMAT);
926 film_changed (Film::CROP);
927 film_changed (Film::FILTERS);
928 film_changed (Film::SCALER);
929 film_changed (Film::TRIM_START);
930 film_changed (Film::TRIM_END);
931 film_changed (Film::TRIM_TYPE);
932 film_changed (Film::DCP_AB);
933 film_changed (Film::CONTENT_AUDIO_STREAM);
934 film_changed (Film::EXTERNAL_AUDIO);
935 film_changed (Film::USE_CONTENT_AUDIO);
936 film_changed (Film::AUDIO_GAIN);
937 film_changed (Film::AUDIO_DELAY);
938 film_changed (Film::STILL_DURATION);
939 film_changed (Film::WITH_SUBTITLES);
940 film_changed (Film::SUBTITLE_OFFSET);
941 film_changed (Film::SUBTITLE_SCALE);
942 film_changed (Film::COLOUR_LUT);
943 film_changed (Film::J2K_BANDWIDTH);
944 film_changed (Film::DCI_METADATA);
945 film_changed (Film::SIZE);
946 film_changed (Film::LENGTH);
947 film_changed (Film::CONTENT_AUDIO_STREAMS);
948 film_changed (Film::SUBTITLE_STREAMS);
949 film_changed (Film::SOURCE_FRAME_RATE);
950 film_changed (Film::DCP_FRAME_RATE);
953 /** Updates the sensitivity of lots of widgets to a given value.
954 * @param s true to make sensitive, false to make insensitive.
957 FilmEditor::set_things_sensitive (bool s)
959 _generally_sensitive = s;
962 _use_dci_name->Enable (s);
963 _edit_dci_button->Enable (s);
965 _content->Enable (s);
966 _trust_content_header->Enable (s);
967 _left_crop->Enable (s);
968 _right_crop->Enable (s);
969 _top_crop->Enable (s);
970 _bottom_crop->Enable (s);
971 _filters_button->Enable (s);
973 _audio_stream->Enable (s);
974 _dcp_content_type->Enable (s);
975 _dcp_frame_rate->Enable (s);
976 _trim_start->Enable (s);
977 _trim_end->Enable (s);
978 _trim_type->Enable (s);
980 _colour_lut->Enable (s);
981 _j2k_bandwidth->Enable (s);
982 _audio_gain->Enable (s);
983 _audio_gain_calculate_button->Enable (s);
984 _show_audio->Enable (s);
985 _audio_delay->Enable (s);
986 _still_duration->Enable (s);
988 setup_subtitle_control_sensitivity ();
989 setup_audio_control_sensitivity ();
990 setup_show_audio_sensitivity ();
993 /** Called when the `Edit filters' button has been clicked */
995 FilmEditor::edit_filters_clicked (wxCommandEvent &)
997 FilterDialog* d = new FilterDialog (this, _film->filters());
998 d->ActiveChanged.connect (bind (&Film::set_filters, _film, _1));
1003 /** Called when the scaler widget has been changed */
1005 FilmEditor::scaler_changed (wxCommandEvent &)
1011 int const n = _scaler->GetSelection ();
1013 _film->set_scaler (Scaler::from_index (n));
1018 FilmEditor::audio_gain_changed (wxCommandEvent &)
1024 _film->set_audio_gain (_audio_gain->GetValue ());
1028 FilmEditor::audio_delay_changed (wxCommandEvent &)
1034 _film->set_audio_delay (_audio_delay->GetValue ());
1038 FilmEditor::video_control (wxControl* c)
1040 _video_controls.push_back (c);
1045 FilmEditor::still_control (wxControl* c)
1047 _still_controls.push_back (c);
1052 FilmEditor::setup_visibility ()
1054 ContentType c = VIDEO;
1057 c = _film->content_type ();
1060 for (list<wxControl*>::iterator i = _video_controls.begin(); i != _video_controls.end(); ++i) {
1061 (*i)->Show (c == VIDEO);
1064 for (list<wxControl*>::iterator i = _still_controls.begin(); i != _still_controls.end(); ++i) {
1065 (*i)->Show (c == STILL);
1068 setup_notebook_size ();
1072 FilmEditor::setup_notebook_size ()
1074 _notebook->InvalidateBestSize ();
1076 _film_sizer->Layout ();
1077 _film_sizer->SetSizeHints (_film_panel);
1078 _video_sizer->Layout ();
1079 _video_sizer->SetSizeHints (_video_panel);
1080 _audio_sizer->Layout ();
1081 _audio_sizer->SetSizeHints (_audio_panel);
1082 _subtitle_sizer->Layout ();
1083 _subtitle_sizer->SetSizeHints (_subtitle_panel);
1090 FilmEditor::still_duration_changed (wxCommandEvent &)
1096 _film->set_still_duration (_still_duration->GetValue ());
1100 FilmEditor::trim_start_changed (wxCommandEvent &)
1106 _film->set_trim_start (_trim_start->GetValue ());
1110 FilmEditor::trim_end_changed (wxCommandEvent &)
1116 _film->set_trim_end (_trim_end->GetValue ());
1120 FilmEditor::audio_gain_calculate_button_clicked (wxCommandEvent &)
1122 GainCalculatorDialog* d = new GainCalculatorDialog (this);
1125 if (d->wanted_fader() == 0 || d->actual_fader() == 0) {
1130 _audio_gain->SetValue (
1131 Config::instance()->sound_processor()->db_for_fader_change (
1137 /* This appears to be necessary, as the change is not signalled,
1140 wxCommandEvent dummy;
1141 audio_gain_changed (dummy);
1147 FilmEditor::setup_formats ()
1149 ContentType c = VIDEO;
1152 c = _film->content_type ();
1157 vector<Format const *> fmt = Format::all ();
1158 for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
1159 if (c == VIDEO || (c == STILL && dynamic_cast<VariableFormat const *> (*i))) {
1160 _formats.push_back (*i);
1165 for (vector<Format const *>::iterator i = _formats.begin(); i != _formats.end(); ++i) {
1166 _format->Append (std_to_wx ((*i)->name ()));
1169 _film_sizer->Layout ();
1173 FilmEditor::with_subtitles_toggled (wxCommandEvent &)
1179 _film->set_with_subtitles (_with_subtitles->GetValue ());
1183 FilmEditor::setup_subtitle_control_sensitivity ()
1186 if (_generally_sensitive && _film) {
1187 h = !_film->subtitle_streams().empty();
1190 _with_subtitles->Enable (h);
1194 j = _film->with_subtitles ();
1197 _subtitle_stream->Enable (j);
1198 _subtitle_offset->Enable (j);
1199 _subtitle_scale->Enable (j);
1203 FilmEditor::setup_audio_control_sensitivity ()
1205 _use_content_audio->Enable (_generally_sensitive && _film && !_film->content_audio_streams().empty());
1206 _use_external_audio->Enable (_generally_sensitive);
1208 bool const source = _generally_sensitive && _use_content_audio->GetValue();
1209 bool const external = _generally_sensitive && _use_external_audio->GetValue();
1211 _audio_stream->Enable (source);
1212 for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
1213 _external_audio[i]->Enable (external);
1216 _pad_with_silence->Enable (_generally_sensitive && _film && _film->audio_stream() && _film->audio_stream()->channels() < MAX_AUDIO_CHANNELS);
1217 _minimum_audio_channels->Enable (_generally_sensitive && _pad_with_silence->GetValue ());
1221 FilmEditor::use_dci_name_toggled (wxCommandEvent &)
1227 _film->set_use_dci_name (_use_dci_name->GetValue ());
1231 FilmEditor::edit_dci_button_clicked (wxCommandEvent &)
1237 DCIMetadataDialog* d = new DCIMetadataDialog (this, _film->dci_metadata ());
1239 _film->set_dci_metadata (d->dci_metadata ());
1244 FilmEditor::setup_streams ()
1246 _audio_stream->Clear ();
1247 vector<shared_ptr<AudioStream> > a = _film->content_audio_streams ();
1248 for (vector<shared_ptr<AudioStream> >::iterator i = a.begin(); i != a.end(); ++i) {
1249 shared_ptr<FFmpegAudioStream> ffa = dynamic_pointer_cast<FFmpegAudioStream> (*i);
1251 _audio_stream->Append (std_to_wx (ffa->name()), new wxStringClientData (std_to_wx (ffa->to_string ())));
1254 if (_film->use_content_audio() && _film->audio_stream()) {
1255 checked_set (_audio_stream, _film->audio_stream()->to_string());
1258 _subtitle_stream->Clear ();
1259 vector<shared_ptr<SubtitleStream> > s = _film->subtitle_streams ();
1260 for (vector<shared_ptr<SubtitleStream> >::iterator i = s.begin(); i != s.end(); ++i) {
1261 _subtitle_stream->Append (std_to_wx ((*i)->name()), new wxStringClientData (std_to_wx ((*i)->to_string ())));
1263 if (_film->subtitle_stream()) {
1264 checked_set (_subtitle_stream, _film->subtitle_stream()->to_string());
1266 _subtitle_stream->SetSelection (wxNOT_FOUND);
1271 FilmEditor::audio_stream_changed (wxCommandEvent &)
1277 _film->set_content_audio_stream (
1278 audio_stream_factory (
1279 string_client_data (_audio_stream->GetClientObject (_audio_stream->GetSelection ())),
1286 FilmEditor::subtitle_stream_changed (wxCommandEvent &)
1292 _film->set_subtitle_stream (
1293 subtitle_stream_factory (
1294 string_client_data (_subtitle_stream->GetClientObject (_subtitle_stream->GetSelection ())),
1301 FilmEditor::setup_audio_details ()
1303 if (!_film->content_audio_stream()) {
1304 _audio->SetLabel (wxT (""));
1307 if (_film->audio_stream()->channels() == 1) {
1308 s << _("1 channel");
1310 s << _film->audio_stream()->channels () << wxT (" ") << _("channels");
1312 s << wxT (", ") << _film->audio_stream()->sample_rate() << _("Hz");
1313 _audio->SetLabel (s);
1316 setup_notebook_size ();
1320 FilmEditor::active_jobs_changed (bool a)
1322 set_things_sensitive (!a);
1326 FilmEditor::use_audio_changed (wxCommandEvent &)
1328 _film->set_use_content_audio (_use_content_audio->GetValue());
1332 FilmEditor::external_audio_changed (wxCommandEvent &)
1335 for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
1336 a.push_back (wx_to_std (_external_audio[i]->GetPath()));
1339 _film->set_external_audio (a);
1343 FilmEditor::setup_dcp_name ()
1345 string s = _film->dcp_name (true);
1346 if (s.length() > 28) {
1347 _dcp_name->SetLabel (std_to_wx (s.substr (0, 28)) + N_("..."));
1348 _dcp_name->SetToolTip (std_to_wx (s));
1350 _dcp_name->SetLabel (std_to_wx (s));
1355 FilmEditor::show_audio_clicked (wxCommandEvent &)
1357 if (_audio_dialog) {
1358 _audio_dialog->Destroy ();
1362 _audio_dialog = new AudioDialog (this);
1363 _audio_dialog->Show ();
1364 _audio_dialog->set_film (_film);
1368 FilmEditor::best_dcp_frame_rate_clicked (wxCommandEvent &)
1374 _film->set_dcp_frame_rate (best_dcp_frame_rate (_film->source_frame_rate ()));
1378 FilmEditor::setup_show_audio_sensitivity ()
1380 _show_audio->Enable (_film && _film->has_audio ());
1384 FilmEditor::setup_scaling_description ()
1390 if (_film->size().width && _film->size().height) {
1391 d << wxString::Format (
1392 _("Original video is %dx%d (%.2f:1)\n"),
1393 _film->size().width, _film->size().height,
1394 float (_film->size().width) / _film->size().height
1399 Crop const crop = _film->crop ();
1400 if ((crop.left || crop.right || crop.top || crop.bottom) && _film->size() != libdcp::Size (0, 0)) {
1401 libdcp::Size const cropped = _film->cropped_size (_film->size ());
1402 d << wxString::Format (
1403 _("Cropped to %dx%d (%.2f:1)\n"),
1404 cropped.width, cropped.height,
1405 float (cropped.width) / cropped.height
1410 Format const * format = _film->format ();
1412 int const padding = format->dcp_padding (_film);
1413 libdcp::Size scaled = format->dcp_size ();
1414 scaled.width -= padding * 2;
1415 d << wxString::Format (
1416 _("Scaled to %dx%d (%.2f:1)\n"),
1417 scaled.width, scaled.height,
1418 float (scaled.width) / scaled.height
1423 d << wxString::Format (
1424 _("Padded with black to %dx%d (%.2f:1)\n"),
1425 format->dcp_size().width, format->dcp_size().height,
1426 float (format->dcp_size().width) / format->dcp_size().height
1432 for (int i = lines; i < 4; ++i) {
1436 _scaling_description->SetLabel (d);
1440 FilmEditor::trim_type_changed (wxCommandEvent &)
1442 _film->set_trim_type (_trim_type->GetSelection () == 0 ? Film::CPL : Film::ENCODE);
1446 FilmEditor::setup_minimum_audio_channels ()
1448 if (!_film || !_film->audio_stream ()) {
1449 _pad_with_silence->SetValue (false);
1453 _pad_with_silence->SetValue (_film->audio_stream()->channels() < _film->minimum_audio_channels());
1455 AudioMapping m (_film);
1456 _minimum_audio_channels->SetRange (m.minimum_dcp_channels() + 1, MAX_AUDIO_CHANNELS);
1460 FilmEditor::pad_with_silence_toggled (wxCommandEvent &)
1462 setup_audio_control_sensitivity ();
1466 FilmEditor::minimum_audio_channels_changed (wxCommandEvent &)
1472 _film->set_minimum_audio_channels (_minimum_audio_channels->GetValue ());