Basic ability to set video range (JPEG/MPEG) at least for YUV content. May not work...
[dcpomatic.git] / src / wx / video_panel.cc
1 /*
2     Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 #include "filter_dialog.h"
22 #include "video_panel.h"
23 #include "wx_util.h"
24 #include "content_colour_conversion_dialog.h"
25 #include "content_widget.h"
26 #include "content_panel.h"
27 #include "static_text.h"
28 #include "check_box.h"
29 #include "dcpomatic_button.h"
30 #include "lib/filter.h"
31 #include "lib/ffmpeg_content.h"
32 #include "lib/colour_conversion.h"
33 #include "lib/config.h"
34 #include "lib/util.h"
35 #include "lib/ratio.h"
36 #include "lib/frame_rate_change.h"
37 #include "lib/dcp_content.h"
38 #include "lib/video_content.h"
39 #include <wx/spinctrl.h>
40 #include <boost/foreach.hpp>
41 #include <set>
42 #include <iostream>
43
44 using std::vector;
45 using std::string;
46 using std::pair;
47 using std::cout;
48 using std::list;
49 using std::set;
50 using boost::shared_ptr;
51 using boost::dynamic_pointer_cast;
52 using boost::bind;
53 using boost::optional;
54 using namespace dcpomatic;
55
56 static VideoContentScale
57 index_to_scale (int n)
58 {
59         vector<VideoContentScale> scales = VideoContentScale::all ();
60         DCPOMATIC_ASSERT (n >= 0);
61         DCPOMATIC_ASSERT (n < int (scales.size ()));
62         return scales[n];
63 }
64
65 static int
66 scale_to_index (VideoContentScale scale)
67 {
68         vector<VideoContentScale> scales = VideoContentScale::all ();
69         for (size_t i = 0; i < scales.size(); ++i) {
70                 if (scales[i] == scale) {
71                         return i;
72                 }
73         }
74
75         DCPOMATIC_ASSERT (false);
76 }
77
78 VideoPanel::VideoPanel (ContentPanel* p)
79         : ContentSubPanel (p, _("Video"))
80 {
81         _reference = new CheckBox (this, _("Use this DCP's video as OV and make VF"));
82         _reference_note = new StaticText (this, wxT(""));
83         _reference_note->Wrap (200);
84         wxFont font = _reference_note->GetFont();
85         font.SetStyle(wxFONTSTYLE_ITALIC);
86         font.SetPointSize(font.GetPointSize() - 1);
87         _reference_note->SetFont(font);
88
89         _type_label = create_label (this, _("Type"), true);
90         _frame_type = new ContentChoice<VideoContent, VideoFrameType> (
91                 this,
92                 new wxChoice (this, wxID_ANY),
93                 VideoContentProperty::FRAME_TYPE,
94                 &Content::video,
95                 boost::mem_fn (&VideoContent::frame_type),
96                 boost::mem_fn (&VideoContent::set_frame_type),
97                 &caster<int, VideoFrameType>,
98                 &caster<VideoFrameType, int>
99                 );
100
101         _left_crop_label = create_label (this, _("Left crop"), true);
102         _left_crop = new ContentSpinCtrl<VideoContent> (
103                 this,
104                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
105                 VideoContentProperty::CROP,
106                 &Content::video,
107                 boost::mem_fn (&VideoContent::left_crop),
108                 boost::mem_fn (&VideoContent::set_left_crop)
109                 );
110
111         _right_crop_label = create_label (this, _("Right crop"), true);
112         _right_crop = new ContentSpinCtrl<VideoContent> (
113                 this,
114                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
115                 VideoContentProperty::CROP,
116                 &Content::video,
117                 boost::mem_fn (&VideoContent::right_crop),
118                 boost::mem_fn (&VideoContent::set_right_crop)
119                 );
120
121         _top_crop_label = create_label (this, _("Top crop"), true);
122         _top_crop = new ContentSpinCtrl<VideoContent> (
123                 this,
124                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
125                 VideoContentProperty::CROP,
126                 &Content::video,
127                 boost::mem_fn (&VideoContent::top_crop),
128                 boost::mem_fn (&VideoContent::set_top_crop)
129                 );
130
131         _bottom_crop_label = create_label (this, _("Bottom crop"), true);
132         _bottom_crop = new ContentSpinCtrl<VideoContent> (
133                 this,
134                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
135                 VideoContentProperty::CROP,
136                 &Content::video,
137                 boost::mem_fn (&VideoContent::bottom_crop),
138                 boost::mem_fn (&VideoContent::set_bottom_crop)
139                 );
140
141         _fade_in_label = create_label (this, _("Fade in"), true);
142         _fade_in = new Timecode<ContentTime> (this);
143
144         _fade_out_label = create_label (this, _("Fade out"), true);
145         _fade_out = new Timecode<ContentTime> (this);
146
147         _scale_to_label = create_label (this, _("Scale to"), true);
148         _scale = new ContentChoice<VideoContent, VideoContentScale> (
149                 this,
150                 new wxChoice (this, wxID_ANY),
151                 VideoContentProperty::SCALE,
152                 &Content::video,
153                 boost::mem_fn (&VideoContent::scale),
154                 boost::mem_fn (&VideoContent::set_scale),
155                 &index_to_scale,
156                 &scale_to_index
157                 );
158
159         wxClientDC dc (this);
160         wxSize size = dc.GetTextExtent (wxT ("A quite long name"));
161         size.SetHeight (-1);
162
163         _filters_label = create_label (this, _("Filters"), true);
164         _filters = new StaticText (this, _("None"), wxDefaultPosition, size);
165         _filters_button = new Button (this, _("Edit..."));
166
167         _colour_conversion_label = create_label (this, _("Colour conversion"), true);
168         _colour_conversion = new wxChoice (this, wxID_ANY, wxDefaultPosition, size);
169         _colour_conversion->Append (_("None"));
170         BOOST_FOREACH (PresetColourConversion const & i, PresetColourConversion::all()) {
171                 _colour_conversion->Append (std_to_wx (i.name));
172         }
173
174         /// TRANSLATORS: translate the word "Custom" here; do not include the "Colour|" prefix
175         _colour_conversion->Append (S_("Colour|Custom"));
176         _edit_colour_conversion_button = new Button (this, _("Edit..."));
177
178         _range_label = create_label (this, _("Range"), true);
179         _range = new wxChoice (this, wxID_ANY);
180         _range->Append (_("Full (JPEG, 0-255)"));
181         _range->Append (_("Video (MPEG, 16-235)"));
182
183         _description = new StaticText (this, wxT ("\n \n \n \n \n"), wxDefaultPosition, wxDefaultSize);
184         _description->SetFont(font);
185
186         _left_crop->wrapped()->SetRange (0, 4096);
187         _top_crop->wrapped()->SetRange (0, 4096);
188         _right_crop->wrapped()->SetRange (0, 4096);
189         _bottom_crop->wrapped()->SetRange (0, 4096);
190
191         _scale->wrapped()->Clear ();
192         BOOST_FOREACH (VideoContentScale const & i, VideoContentScale::all ()) {
193                 _scale->wrapped()->Append (std_to_wx (i.name ()));
194         }
195
196         _frame_type->wrapped()->Append (_("2D"));
197         _frame_type->wrapped()->Append (_("3D"));
198         _frame_type->wrapped()->Append (_("3D left/right"));
199         _frame_type->wrapped()->Append (_("3D top/bottom"));
200         _frame_type->wrapped()->Append (_("3D alternate"));
201         _frame_type->wrapped()->Append (_("3D left only"));
202         _frame_type->wrapped()->Append (_("3D right only"));
203
204         content_selection_changed ();
205
206         _fade_in->Changed.connect (boost::bind (&VideoPanel::fade_in_changed, this));
207         _fade_out->Changed.connect (boost::bind (&VideoPanel::fade_out_changed, this));
208
209         _reference->Bind                     (wxEVT_CHECKBOX, boost::bind (&VideoPanel::reference_clicked, this));
210         _filters_button->Bind                (wxEVT_BUTTON,   boost::bind (&VideoPanel::edit_filters_clicked, this));
211         _colour_conversion->Bind             (wxEVT_CHOICE,   boost::bind (&VideoPanel::colour_conversion_changed, this));
212         _range->Bind                         (wxEVT_CHOICE,   boost::bind (&VideoPanel::range_changed, this));
213         _edit_colour_conversion_button->Bind (wxEVT_BUTTON,   boost::bind (&VideoPanel::edit_colour_conversion_clicked, this));
214
215         add_to_grid ();
216 }
217
218 void
219 VideoPanel::add_to_grid ()
220 {
221         bool const full = Config::instance()->interface_complexity() == Config::INTERFACE_FULL;
222
223         int r = 0;
224
225         _reference->Show (full);
226         _reference_note->Show (full);
227
228         if (full) {
229                 wxBoxSizer* reference_sizer = new wxBoxSizer (wxVERTICAL);
230                 reference_sizer->Add (_reference, 0);
231                 reference_sizer->Add (_reference_note, 0);
232                 _grid->Add (reference_sizer, wxGBPosition(r, 0), wxGBSpan(1, 3));
233                 ++r;
234         }
235
236         add_label_to_sizer (_grid, _type_label, true, wxGBPosition(r, 0));
237         _frame_type->add (_grid, wxGBPosition(r, 1), wxGBSpan(1, 2));
238         ++r;
239
240         int cr = 0;
241         wxGridBagSizer* crop = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
242         add_label_to_sizer (crop, _left_crop_label, true, wxGBPosition (cr, 0));
243         _left_crop->add (crop, wxGBPosition (cr, 1));
244         add_label_to_sizer (crop, _right_crop_label, true, wxGBPosition (cr, 2));
245         _right_crop->add (crop, wxGBPosition (cr, 3));
246         ++cr;
247         add_label_to_sizer (crop, _top_crop_label, true, wxGBPosition (cr, 0));
248         _top_crop->add (crop, wxGBPosition (cr, 1));
249         add_label_to_sizer (crop, _bottom_crop_label, true, wxGBPosition (cr, 2));
250         _bottom_crop->add (crop, wxGBPosition (cr, 3));
251         _grid->Add (crop, wxGBPosition (r, 0), wxGBSpan (2, 4));
252         r += 2;
253
254         _scale_to_label->Show (full);
255         _scale->show (full);
256         _filters_label->Show (full);
257         _filters->Show (full);
258         _filters_button->Show (full);
259         _colour_conversion_label->Show (full);
260         _colour_conversion->Show (full);
261         _edit_colour_conversion_button->Show (full);
262         _range_label->Show (full);
263         _range->Show (full);
264
265         add_label_to_sizer (_grid, _fade_in_label, true, wxGBPosition (r, 0));
266         _grid->Add (_fade_in, wxGBPosition (r, 1), wxGBSpan (1, 3));
267         ++r;
268
269         add_label_to_sizer (_grid, _fade_out_label, true, wxGBPosition (r, 0));
270         _grid->Add (_fade_out, wxGBPosition (r, 1), wxGBSpan (1, 3));
271         ++r;
272
273         if (full) {
274                 add_label_to_sizer (_grid, _scale_to_label, true, wxGBPosition (r, 0));
275                 _scale->add (_grid, wxGBPosition (r, 1), wxGBSpan (1, 2));
276                 ++r;
277
278                 add_label_to_sizer (_grid, _filters_label, true, wxGBPosition (r, 0));
279                 {
280                         wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
281                         s->Add (_filters, 1, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
282                         s->Add (_filters_button, 0, wxALIGN_CENTER_VERTICAL);
283                         _grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
284                 }
285                 ++r;
286
287                 add_label_to_sizer (_grid, _colour_conversion_label, true, wxGBPosition(r, 0));
288                 {
289                         wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
290                         s->Add (_colour_conversion, 1, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
291                         s->Add (_edit_colour_conversion_button, 0, wxALIGN_CENTER_VERTICAL);
292                         _grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
293                 }
294                 ++r;
295
296                 add_label_to_sizer (_grid, _range_label, true, wxGBPosition(r, 0));
297                 _grid->Add (_range, wxGBPosition(r, 1), wxGBSpan(1, 2), wxALIGN_CENTER_VERTICAL);
298                 ++r;
299         }
300
301         _grid->Add (_description, wxGBPosition (r, 0), wxGBSpan (1, 4), wxEXPAND | wxALIGN_CENTER_VERTICAL, 6);
302         ++r;
303 }
304
305 void
306 VideoPanel::range_changed ()
307 {
308         ContentList vc = _parent->selected_video ();
309         if (vc.size() != 1) {
310                 return;
311         }
312
313         switch (_range->GetSelection()) {
314         case 0:
315                 vc.front()->video->set_range (VIDEO_RANGE_FULL);
316                 break;
317         case 1:
318                 vc.front()->video->set_range (VIDEO_RANGE_VIDEO);
319                 break;
320         default:
321                 DCPOMATIC_ASSERT (false);
322         }
323 }
324
325
326 void
327 VideoPanel::film_changed (Film::Property property)
328 {
329         switch (property) {
330         case Film::VIDEO_FRAME_RATE:
331         case Film::CONTAINER:
332         case Film::RESOLUTION:
333                 setup_description ();
334                 setup_sensitivity ();
335                 break;
336         case Film::REEL_TYPE:
337         case Film::INTEROP:
338                 setup_sensitivity ();
339                 break;
340         default:
341                 break;
342         }
343 }
344
345 void
346 VideoPanel::film_content_changed (int property)
347 {
348         ContentList vc = _parent->selected_video ();
349         shared_ptr<Content> vcs;
350         shared_ptr<FFmpegContent> fcs;
351         if (!vc.empty ()) {
352                 vcs = vc.front ();
353                 fcs = dynamic_pointer_cast<FFmpegContent> (vcs);
354         }
355
356         if (property == ContentProperty::VIDEO_FRAME_RATE ||
357             property == VideoContentProperty::FRAME_TYPE ||
358             property == VideoContentProperty::CROP ||
359             property == VideoContentProperty::SCALE) {
360                 setup_description ();
361         } else if (property == VideoContentProperty::COLOUR_CONVERSION) {
362                 if (vcs && vcs->video->colour_conversion ()) {
363                         optional<size_t> preset = vcs->video->colour_conversion().get().preset ();
364                         vector<PresetColourConversion> cc = PresetColourConversion::all ();
365                         if (preset) {
366                                 checked_set (_colour_conversion, preset.get() + 1);
367                         } else {
368                                 checked_set (_colour_conversion, cc.size() + 1);
369                         }
370                 } else {
371                         checked_set (_colour_conversion, 0);
372                 }
373
374                 setup_sensitivity ();
375
376         } else if (property == FFmpegContentProperty::FILTERS) {
377                 if (fcs) {
378                         string p = Filter::ffmpeg_string (fcs->filters ());
379                         if (p.empty ()) {
380                                 checked_set (_filters, _("None"));
381                         } else {
382                                 if (p.length() > 25) {
383                                         p = p.substr (0, 25) + "...";
384                                 }
385                                 checked_set (_filters, p);
386                         }
387                 }
388         } else if (property == VideoContentProperty::FADE_IN) {
389                 set<Frame> check;
390                 BOOST_FOREACH (shared_ptr<const Content> i, vc) {
391                         check.insert (i->video->fade_in ());
392                 }
393
394                 if (check.size() == 1) {
395                         _fade_in->set (
396                                 ContentTime::from_frames (vc.front()->video->fade_in(), vc.front()->active_video_frame_rate(_parent->film())),
397                                 vc.front()->active_video_frame_rate(_parent->film())
398                                 );
399                 } else {
400                         _fade_in->clear ();
401                 }
402         } else if (property == VideoContentProperty::FADE_OUT) {
403                 set<Frame> check;
404                 BOOST_FOREACH (shared_ptr<const Content> i, vc) {
405                         check.insert (i->video->fade_out ());
406                 }
407
408                 if (check.size() == 1) {
409                         _fade_out->set (
410                                 ContentTime::from_frames (vc.front()->video->fade_out(), vc.front()->active_video_frame_rate(_parent->film())),
411                                 vc.front()->active_video_frame_rate(_parent->film())
412                                 );
413                 } else {
414                         _fade_out->clear ();
415                 }
416         } else if (property == DCPContentProperty::REFERENCE_VIDEO) {
417                 if (vc.size() == 1) {
418                         shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (vc.front ());
419                         checked_set (_reference, dcp ? dcp->reference_video () : false);
420                 } else {
421                         checked_set (_reference, false);
422                 }
423
424                 setup_sensitivity ();
425         } else if (property == VideoContentProperty::RANGE) {
426                 if (vcs) {
427                         checked_set (_range, vcs->video->range() == VIDEO_RANGE_FULL ? 0 : 1);
428                 } else {
429                         checked_set (_range, 0);
430                 }
431
432                 setup_sensitivity ();
433         }
434 }
435
436 /** Called when the `Edit filters' button has been clicked */
437 void
438 VideoPanel::edit_filters_clicked ()
439 {
440         FFmpegContentList c = _parent->selected_ffmpeg ();
441         if (c.size() != 1) {
442                 return;
443         }
444
445         FilterDialog* d = new FilterDialog (this, c.front()->filters());
446         d->ActiveChanged.connect (bind (&FFmpegContent::set_filters, c.front(), _1));
447         d->ShowModal ();
448         d->Destroy ();
449 }
450
451 void
452 VideoPanel::setup_description ()
453 {
454         ContentList vc = _parent->selected_video ();
455         if (vc.empty ()) {
456                 checked_set (_description, wxT (""));
457                 return;
458         } else if (vc.size() > 1) {
459                 checked_set (_description, _("Multiple content selected"));
460                 return;
461         }
462
463         string d = vc.front()->video->processing_description (_parent->film());
464         size_t lines = count (d.begin(), d.end(), '\n');
465
466         for (int i = lines; i < 6; ++i) {
467                 d += "\n ";
468         }
469
470         checked_set (_description, d);
471         _sizer->Layout ();
472 }
473
474 void
475 VideoPanel::colour_conversion_changed ()
476 {
477         ContentList vc = _parent->selected_video ();
478         if (vc.size() != 1) {
479                 return;
480         }
481
482         int const s = _colour_conversion->GetSelection ();
483         vector<PresetColourConversion> all = PresetColourConversion::all ();
484
485         if (s == 0) {
486                 vc.front()->video->unset_colour_conversion ();
487         } else if (s == int (all.size() + 1)) {
488                 edit_colour_conversion_clicked ();
489         } else {
490                 vc.front()->video->set_colour_conversion (all[s - 1].conversion);
491         }
492 }
493
494 void
495 VideoPanel::edit_colour_conversion_clicked ()
496 {
497         ContentList vc = _parent->selected_video ();
498         if (vc.size() != 1) {
499                 return;
500         }
501
502         ContentColourConversionDialog* d = new ContentColourConversionDialog (this, vc.front()->video->yuv ());
503         d->set (vc.front()->video->colour_conversion().get_value_or (PresetColourConversion::all().front().conversion));
504         if (d->ShowModal() == wxID_OK) {
505                 vc.front()->video->set_colour_conversion (d->get ());
506         } else {
507                 /* Reset the colour conversion choice */
508                 film_content_changed (VideoContentProperty::COLOUR_CONVERSION);
509         }
510         d->Destroy ();
511 }
512
513 void
514 VideoPanel::content_selection_changed ()
515 {
516         ContentList video_sel = _parent->selected_video ();
517
518         _frame_type->set_content (video_sel);
519         _left_crop->set_content (video_sel);
520         _right_crop->set_content (video_sel);
521         _top_crop->set_content (video_sel);
522         _bottom_crop->set_content (video_sel);
523         _scale->set_content (video_sel);
524
525         film_content_changed (ContentProperty::VIDEO_FRAME_RATE);
526         film_content_changed (VideoContentProperty::CROP);
527         film_content_changed (VideoContentProperty::COLOUR_CONVERSION);
528         film_content_changed (VideoContentProperty::FADE_IN);
529         film_content_changed (VideoContentProperty::FADE_OUT);
530         film_content_changed (VideoContentProperty::RANGE);
531         film_content_changed (FFmpegContentProperty::FILTERS);
532         film_content_changed (DCPContentProperty::REFERENCE_VIDEO);
533
534         setup_sensitivity ();
535 }
536
537 void
538 VideoPanel::setup_sensitivity ()
539 {
540         ContentList sel = _parent->selected ();
541
542         shared_ptr<DCPContent> dcp;
543         if (sel.size() == 1) {
544                 dcp = dynamic_pointer_cast<DCPContent> (sel.front ());
545         }
546
547         string why_not;
548         bool const can_reference = dcp && dcp->can_reference_video (_parent->film(), why_not);
549         setup_refer_button (_reference, _reference_note, dcp, can_reference, why_not);
550
551         if (_reference->GetValue ()) {
552                 _frame_type->wrapped()->Enable (false);
553                 _left_crop->wrapped()->Enable (false);
554                 _right_crop->wrapped()->Enable (false);
555                 _top_crop->wrapped()->Enable (false);
556                 _bottom_crop->wrapped()->Enable (false);
557                 _fade_in->Enable (false);
558                 _fade_out->Enable (false);
559                 _scale->wrapped()->Enable (false);
560                 _description->Enable (false);
561                 _filters->Enable (false);
562                 _filters_button->Enable (false);
563                 _colour_conversion->Enable (false);
564                 _range->Enable (false);
565         } else {
566                 ContentList video_sel = _parent->selected_video ();
567                 FFmpegContentList ffmpeg_sel = _parent->selected_ffmpeg ();
568                 bool const single = video_sel.size() == 1;
569
570                 _frame_type->wrapped()->Enable (true);
571                 _left_crop->wrapped()->Enable (true);
572                 _right_crop->wrapped()->Enable (true);
573                 _top_crop->wrapped()->Enable (true);
574                 _bottom_crop->wrapped()->Enable (true);
575                 _fade_in->Enable (!video_sel.empty ());
576                 _fade_out->Enable (!video_sel.empty ());
577                 _scale->wrapped()->Enable (true);
578                 _description->Enable (true);
579                 _filters->Enable (true);
580                 _filters_button->Enable (single && !ffmpeg_sel.empty ());
581                 _colour_conversion->Enable (single && !video_sel.empty ());
582                 _range->Enable (single && !video_sel.empty());
583         }
584
585         ContentList vc = _parent->selected_video ();
586         shared_ptr<Content> vcs;
587         if (!vc.empty ()) {
588                 vcs = vc.front ();
589         }
590
591         if (vcs && vcs->video->colour_conversion ()) {
592                 _edit_colour_conversion_button->Enable (!vcs->video->colour_conversion().get().preset());
593         } else {
594                 _edit_colour_conversion_button->Enable (false);
595         }
596 }
597
598 void
599 VideoPanel::fade_in_changed ()
600 {
601         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_video ()) {
602                 int const vfr = _parent->film()->video_frame_rate ();
603                 i->video->set_fade_in (_fade_in->get (vfr).frames_round (vfr));
604         }
605 }
606
607 void
608 VideoPanel::fade_out_changed ()
609 {
610         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_video ()) {
611                 int const vfr = _parent->film()->video_frame_rate ();
612                 i->video->set_fade_out (_fade_out->get (vfr).frames_round (vfr));
613         }
614 }
615
616 void
617 VideoPanel::reference_clicked ()
618 {
619         ContentList c = _parent->selected ();
620         if (c.size() != 1) {
621                 return;
622         }
623
624         shared_ptr<DCPContent> d = dynamic_pointer_cast<DCPContent> (c.front ());
625         if (!d) {
626                 return;
627         }
628
629         d->set_reference_video (_reference->GetValue ());
630 }