c6046cb372b5a90241e0fce027c183db677eca7f
[dcpomatic.git] / src / lib / video_content.cc
1 /*
2     Copyright (C) 2013-2022 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
22 #include "colour_conversion.h"
23 #include "compose.hpp"
24 #include "config.h"
25 #include "content.h"
26 #include "dcpomatic_log.h"
27 #include "exceptions.h"
28 #include "film.h"
29 #include "frame_rate_change.h"
30 #include "log.h"
31 #include "ratio.h"
32 #include "util.h"
33 #include "video_content.h"
34 #include "video_examiner.h"
35 #include <dcp/raw_convert.h>
36 #include <libcxml/cxml.h>
37 #include <libxml++/libxml++.h>
38 #include <iomanip>
39 #include <iostream>
40
41 #include "i18n.h"
42
43
44 int const VideoContentProperty::USE               = 0;
45 int const VideoContentProperty::SIZE              = 1;
46 int const VideoContentProperty::FRAME_TYPE        = 2;
47 int const VideoContentProperty::CROP              = 3;
48 int const VideoContentProperty::COLOUR_CONVERSION = 4;
49 int const VideoContentProperty::FADE_IN           = 5;
50 int const VideoContentProperty::FADE_OUT          = 6;
51 int const VideoContentProperty::RANGE             = 7;
52 int const VideoContentProperty::CUSTOM_RATIO      = 8;
53 int const VideoContentProperty::CUSTOM_SIZE       = 9;
54 int const VideoContentProperty::BURNT_SUBTITLE_LANGUAGE = 10;
55
56
57 using std::cout;
58 using std::dynamic_pointer_cast;
59 using std::fixed;
60 using std::list;
61 using std::make_shared;
62 using std::max;
63 using std::min;
64 using std::pair;
65 using std::setprecision;
66 using std::setprecision;
67 using std::shared_ptr;
68 using std::string;
69 using std::vector;
70 using boost::optional;
71 using dcp::raw_convert;
72 using namespace dcpomatic;
73
74
75 VideoContent::VideoContent (Content* parent)
76         : ContentPart (parent)
77         , _use (true)
78         , _length (0)
79         , _frame_type (VideoFrameType::TWO_D)
80         , _yuv (true)
81         , _fade_in (0)
82         , _fade_out (0)
83         , _range (VideoRange::FULL)
84 {
85
86 }
87
88
89 /** @param video_range_hint Video range to use if none is given in the XML */
90 shared_ptr<VideoContent>
91 VideoContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version, VideoRange video_range_hint)
92 {
93         if (!node->optional_number_child<int> ("VideoWidth")) {
94                 return {};
95         }
96
97         return make_shared<VideoContent>(parent, node, version, video_range_hint);
98 }
99
100
101 /** @param video_range_hint Video range to use if none is given in the XML */
102 VideoContent::VideoContent (Content* parent, cxml::ConstNodePtr node, int version, VideoRange video_range_hint)
103         : ContentPart (parent)
104 {
105         _size = dcp::Size(node->number_child<int>("VideoWidth"), node->number_child<int>("VideoHeight"));
106
107         _use = node->optional_bool_child("Use").get_value_or(true);
108         _length = node->number_child<Frame> ("VideoLength");
109
110         if (version <= 34) {
111                 /* Snapshot of the VideoFrameType enum at version 34 */
112                 switch (node->number_child<int> ("VideoFrameType")) {
113                 case 0:
114                         _frame_type = VideoFrameType::TWO_D;
115                         break;
116                 case 1:
117                         _frame_type = VideoFrameType::THREE_D_LEFT_RIGHT;
118                         break;
119                 case 2:
120                         _frame_type = VideoFrameType::THREE_D_TOP_BOTTOM;
121                         break;
122                 case 3:
123                         _frame_type = VideoFrameType::THREE_D_ALTERNATE;
124                         break;
125                 case 4:
126                         _frame_type = VideoFrameType::THREE_D_LEFT;
127                         break;
128                 case 5:
129                         _frame_type = VideoFrameType::THREE_D_RIGHT;
130                         break;
131                 }
132         } else {
133                 _frame_type = string_to_video_frame_type (node->string_child ("VideoFrameType"));
134         }
135
136         _sample_aspect_ratio = node->optional_number_child<double> ("SampleAspectRatio");
137         _crop.left = node->number_child<int> ("LeftCrop");
138         _crop.right = node->number_child<int> ("RightCrop");
139         _crop.top = node->number_child<int> ("TopCrop");
140         _crop.bottom = node->number_child<int> ("BottomCrop");
141
142         if (version <= 7) {
143                 auto r = node->optional_string_child ("Ratio");
144                 if (r) {
145                         _legacy_ratio = Ratio::from_id(r.get())->ratio();
146                 }
147         } else if (version <= 37) {
148                 auto ratio = node->node_child("Scale")->optional_string_child("Ratio");
149                 if (ratio) {
150                         _legacy_ratio = Ratio::from_id(ratio.get())->ratio();
151                 }
152                 auto scale = node->node_child("Scale")->optional_bool_child("Scale");
153                 if (scale) {
154                         if (*scale) {
155                                 /* This is what we used to call "no stretch" */
156                                 DCPOMATIC_ASSERT(_size);
157                                 _legacy_ratio = _size->ratio();
158                         } else {
159                                 /* This is what we used to call "no scale" */
160                                 DCPOMATIC_ASSERT(_size);
161                                 _custom_size = *_size;
162                         }
163                 }
164
165         } else {
166                 _custom_ratio = node->optional_number_child<float>("CustomRatio");
167                 if (node->optional_number_child<int>("CustomWidth")) {
168                         _custom_size = dcp::Size (node->number_child<int>("CustomWidth"), node->number_child<int>("CustomHeight"));
169                 }
170         }
171
172         if (node->optional_node_child ("ColourConversion")) {
173                 _colour_conversion = ColourConversion (node->node_child ("ColourConversion"), version);
174         }
175
176         _yuv = node->optional_bool_child("YUV").get_value_or (true);
177
178         if (version >= 32) {
179                 /* These should be VideoFadeIn and VideoFadeOut but we'll leave them like this until 2.18.x */
180                 _fade_in = node->number_child<Frame> ("FadeIn");
181                 _fade_out = node->number_child<Frame> ("FadeOut");
182         } else {
183                 _fade_in = _fade_out = 0;
184         }
185
186         auto video_range = node->optional_string_child("Range");
187         if (!video_range) {
188                 _range = video_range_hint;
189         } else if (*video_range == "full") {
190                 _range = VideoRange::FULL;
191         } else {
192                 _range = VideoRange::VIDEO;
193         }
194
195         if (auto pixel_quanta = node->optional_node_child("PixelQuanta")) {
196                 _pixel_quanta = PixelQuanta(pixel_quanta);
197         }
198
199         auto burnt = node->optional_string_child("BurntSubtitleLanguage");
200         if (burnt) {
201                 _burnt_subtitle_language = dcp::LanguageTag (*burnt);
202         }
203
204 }
205
206
207 VideoContent::VideoContent (Content* parent, vector<shared_ptr<Content> > c)
208         : ContentPart (parent)
209         , _length (0)
210         , _yuv (false)
211 {
212         auto ref = c[0]->video;
213         DCPOMATIC_ASSERT (ref);
214
215         for (size_t i = 1; i < c.size(); ++i) {
216
217                 if (c[i]->video->use() != ref->use()) {
218                         throw JoinError (_("Content to be joined must have all its video used or not used."));
219                 }
220
221                 if (c[i]->video->size() != ref->size()) {
222                         throw JoinError (_("Content to be joined must have the same picture size."));
223                 }
224
225                 if (c[i]->video->frame_type() != ref->frame_type()) {
226                         throw JoinError (_("Content to be joined must have the same video frame type."));
227                 }
228
229                 if (c[i]->video->requested_crop() != ref->requested_crop()) {
230                         throw JoinError (_("Content to be joined must have the same crop."));
231                 }
232
233                 if (c[i]->video->custom_ratio() != ref->custom_ratio()) {
234                         throw JoinError (_("Content to be joined must have the same custom ratio setting."));
235                 }
236
237                 if (c[i]->video->custom_size() != ref->custom_size()) {
238                         throw JoinError (_("Content to be joined must have the same custom size setting."));
239                 }
240
241                 if (c[i]->video->colour_conversion() != ref->colour_conversion()) {
242                         throw JoinError (_("Content to be joined must have the same colour conversion."));
243                 }
244
245                 if (c[i]->video->fade_in() != ref->fade_in() || c[i]->video->fade_out() != ref->fade_out()) {
246                         throw JoinError (_("Content to be joined must have the same fades."));
247                 }
248
249                 if (c[i]->video->burnt_subtitle_language() != ref->burnt_subtitle_language()) {
250                         throw JoinError (_("Content to be joined must have the same burnt subtitle language."));
251                 }
252
253                 _length += c[i]->video->length ();
254
255                 if (c[i]->video->yuv ()) {
256                         _yuv = true;
257                 }
258
259                 _pixel_quanta = max(_pixel_quanta, c[i]->video->_pixel_quanta);
260         }
261
262         _use = ref->use ();
263         _size = ref->size ();
264         _frame_type = ref->frame_type ();
265         _crop = ref->requested_crop ();
266         _custom_ratio = ref->custom_ratio ();
267         _colour_conversion = ref->colour_conversion ();
268         _fade_in = ref->fade_in ();
269         _fade_out = ref->fade_out ();
270         _range = ref->range ();
271         _burnt_subtitle_language = ref->burnt_subtitle_language ();
272 }
273
274
275 void
276 VideoContent::as_xml (xmlpp::Node* node) const
277 {
278         boost::mutex::scoped_lock lm (_mutex);
279         node->add_child("Use")->add_child_text (_use ? "1" : "0");
280         node->add_child("VideoLength")->add_child_text (raw_convert<string> (_length));
281         if (_size) {
282                 node->add_child("VideoWidth")->add_child_text(raw_convert<string>(_size->width));
283                 node->add_child("VideoHeight")->add_child_text(raw_convert<string>(_size->height));
284         }
285         node->add_child("VideoFrameType")->add_child_text (video_frame_type_to_string (_frame_type));
286         if (_sample_aspect_ratio) {
287                 node->add_child("SampleAspectRatio")->add_child_text (raw_convert<string> (_sample_aspect_ratio.get ()));
288         }
289         _crop.as_xml (node);
290         if (_custom_ratio) {
291                 node->add_child("CustomRatio")->add_child_text(raw_convert<string>(*_custom_ratio));
292         }
293         if (_custom_size) {
294                 node->add_child("CustomWidth")->add_child_text(raw_convert<string>(_custom_size->width));
295                 node->add_child("CustomHeight")->add_child_text(raw_convert<string>(_custom_size->height));
296         }
297         if (_colour_conversion) {
298                 _colour_conversion.get().as_xml (node->add_child("ColourConversion"));
299         }
300         node->add_child("YUV")->add_child_text (_yuv ? "1" : "0");
301         node->add_child("FadeIn")->add_child_text (raw_convert<string> (_fade_in));
302         node->add_child("FadeOut")->add_child_text (raw_convert<string> (_fade_out));
303         node->add_child("Range")->add_child_text(_range == VideoRange::FULL ? "full" : "video");
304         _pixel_quanta.as_xml(node->add_child("PixelQuanta"));
305         if (_burnt_subtitle_language) {
306                 node->add_child("BurntSubtitleLanguage")->add_child_text(_burnt_subtitle_language->to_string());
307         }
308 }
309
310 void
311 VideoContent::take_from_examiner(shared_ptr<const Film> film, shared_ptr<VideoExaminer> d)
312 {
313         /* These examiner calls could call other content methods which take a lock on the mutex */
314         auto const vs = d->video_size ();
315         auto vl = d->video_length ();
316         auto const ar = d->sample_aspect_ratio ();
317         auto const yuv = d->yuv ();
318         auto const range = d->range ();
319         auto const pixel_quanta = d->pixel_quanta ();
320
321         ContentChangeSignaller cc1 (_parent, VideoContentProperty::SIZE);
322         ContentChangeSignaller cc2 (_parent, ContentProperty::LENGTH);
323         ContentChangeSignaller cc3 (_parent, VideoContentProperty::RANGE);
324
325         {
326                 boost::mutex::scoped_lock lm (_mutex);
327                 _size = vs;
328                 _length = vl;
329                 _sample_aspect_ratio = ar;
330                 _yuv = yuv;
331                 _range = range;
332                 _pixel_quanta = pixel_quanta;
333         }
334
335         LOG_GENERAL ("Video length obtained from header as %1 frames", _length);
336
337         if (d->video_frame_rate()) {
338                 _parent->set_video_frame_rate(film, d->video_frame_rate().get());
339         }
340 }
341
342 /** @return string which includes everything about how this content looks */
343 string
344 VideoContent::identifier () const
345 {
346         char buffer[256];
347         auto const crop = actual_crop();
348         snprintf (
349                 buffer, sizeof(buffer), "%d_%d_%d_%d_%d_%f_%d_%d%" PRId64 "_%" PRId64 "_%d",
350                 (_use ? 1 : 0),
351                 crop.left,
352                 crop.right,
353                 crop.top,
354                 crop.bottom,
355                 _custom_ratio.get_value_or(0),
356                 _custom_size ? _custom_size->width : 0,
357                 _custom_size ? _custom_size->height : 0,
358                 _fade_in,
359                 _fade_out,
360                 _range == VideoRange::FULL ? 0 : 1
361                 );
362
363         string s (buffer);
364
365         if (colour_conversion()) {
366                 s += "_" + colour_conversion().get().identifier ();
367         }
368
369         return s;
370 }
371
372 string
373 VideoContent::technical_summary () const
374 {
375         string const size_string = size() ? String::compose("%1x%2", size()->width, size()->height) : _("unknown");
376
377         string s = String::compose (
378                 N_("video: length %1 frames, size %2"),
379                 length_after_3d_combine(),
380                 size_string
381                 );
382
383         if (sample_aspect_ratio ()) {
384                 s += String::compose (N_(", sample aspect ratio %1"), (sample_aspect_ratio().get ()));
385         }
386
387         return s;
388 }
389
390 optional<dcp::Size>
391 VideoContent::size_after_3d_split () const
392 {
393         auto const s = size ();
394         if (!s) {
395                 return {};
396         }
397
398         switch (frame_type ()) {
399         case VideoFrameType::TWO_D:
400         case VideoFrameType::THREE_D:
401         case VideoFrameType::THREE_D_ALTERNATE:
402         case VideoFrameType::THREE_D_LEFT:
403         case VideoFrameType::THREE_D_RIGHT:
404                 return *s;
405         case VideoFrameType::THREE_D_LEFT_RIGHT:
406                 return dcp::Size(s->width / 2, s->height);
407         case VideoFrameType::THREE_D_TOP_BOTTOM:
408                 return dcp::Size(s->width, s->height / 2);
409         }
410
411         DCPOMATIC_ASSERT (false);
412 }
413
414 /** @return Video size after 3D split and crop */
415 optional<dcp::Size>
416 VideoContent::size_after_crop () const
417 {
418         auto const after_3d = size_after_3d_split();
419         if (!after_3d) {
420                 return {};
421         }
422
423         return actual_crop().apply(*after_3d);
424 }
425
426
427 /** @param time Time within the whole (untrimmed) content.
428  *  @return Fade factor (between 0 and 1) or unset if there is no fade.
429  */
430 optional<double>
431 VideoContent::fade(shared_ptr<const Film> film, ContentTime time) const
432 {
433         DCPOMATIC_ASSERT(time.get() >= 0);
434
435         double const vfr = _parent->active_video_frame_rate(film);
436
437         auto const ts = _parent->trim_start();
438         auto const fade_in_time = ContentTime::from_frames(fade_in(), vfr);
439         if ((time - ts) < fade_in_time) {
440                 return double(ContentTime(time - ts).get()) / fade_in_time.get();
441         }
442
443         auto const fade_out_time = ContentTime::from_frames(fade_out(), vfr);
444         auto fade_out_start = ContentTime::from_frames(length(), vfr) - _parent->trim_end() - fade_out_time;
445         if (time >= fade_out_start) {
446                 return 1 - double(ContentTime(time - fade_out_start).get()) / fade_out_time.get();
447         }
448
449         return {};
450 }
451
452 string
453 VideoContent::processing_description (shared_ptr<const Film> film)
454 {
455         string d;
456         char buffer[256];
457
458         if (size() && size()->width && size()->height) {
459                 d += String::compose (
460                         _("Content video is %1x%2"),
461                         size_after_3d_split()->width,
462                         size_after_3d_split()->height
463                         );
464
465
466                 auto ratio = size_after_3d_split()->ratio();
467
468                 if (sample_aspect_ratio ()) {
469                         snprintf (buffer, sizeof(buffer), _(", pixel aspect ratio %.2f:1"), sample_aspect_ratio().get());
470                         d += buffer;
471                         ratio *= sample_aspect_ratio().get ();
472                 }
473
474                 snprintf (buffer, sizeof(buffer), _("\nDisplay aspect ratio %.2f:1"), ratio);
475                 d += buffer;
476         }
477
478         auto const crop = actual_crop();
479
480         if ((crop.left || crop.right || crop.top || crop.bottom) && size() != dcp::Size(0, 0)) {
481                 auto const cropped = size_after_crop ();
482                 if (cropped) {
483                         d += String::compose (
484                                 _("\nCropped to %1x%2"),
485                                 cropped->width, cropped->height
486                                 );
487
488                         snprintf(buffer, sizeof(buffer), " (%.2f:1)", cropped->ratio());
489                         d += buffer;
490                 }
491         }
492
493         auto const container_size = film->frame_size ();
494         auto const scaled = scaled_size (container_size);
495
496         if (scaled && *scaled != size_after_crop()) {
497                 d += String::compose (
498                         _("\nScaled to %1x%2"),
499                         scaled->width, scaled->height
500                         );
501
502                 snprintf (buffer, sizeof(buffer), _(" (%.2f:1)"), scaled->ratio());
503                 d += buffer;
504         }
505
506         if (scaled && *scaled != container_size) {
507                 d += String::compose (
508                         _("\nPadded with black to fit container %1 (%2x%3)"),
509                         film->container()->container_nickname (),
510                         container_size.width, container_size.height
511                         );
512
513                 snprintf (buffer, sizeof(buffer), _(" (%.2f:1)"), container_size.ratio());
514                 d += buffer;
515         }
516
517         if (_parent->video_frame_rate()) {
518                 double const vfr = _parent->video_frame_rate().get ();
519
520                 snprintf (buffer, sizeof(buffer), _("\nContent frame rate %.4f\n"), vfr);
521                 d += buffer;
522
523                 FrameRateChange frc (vfr, film->video_frame_rate ());
524                 d += frc.description ();
525         }
526
527         return d;
528 }
529
530 void
531 VideoContent::add_properties (list<UserProperty>& p) const
532 {
533         p.push_back (UserProperty (UserProperty::VIDEO, _("Length"), length (), _("video frames")));
534         if (auto s = size()) {
535                 p.push_back(UserProperty(UserProperty::VIDEO, _("Size"), String::compose("%1x%2", s->width, s->height)));
536         }
537 }
538
539 void
540 VideoContent::set_length (Frame len)
541 {
542         maybe_set (_length, len, ContentProperty::LENGTH);
543 }
544
545 void
546 VideoContent::set_crop (Crop c)
547 {
548         maybe_set (_crop, c, VideoContentProperty::CROP);
549 }
550
551 void
552 VideoContent::set_left_crop (int c)
553 {
554         maybe_set (_crop.left, c, VideoContentProperty::CROP);
555 }
556
557 void
558 VideoContent::set_right_crop (int c)
559 {
560         maybe_set (_crop.right, c, VideoContentProperty::CROP);
561 }
562
563 void
564 VideoContent::set_top_crop (int c)
565 {
566         maybe_set (_crop.top, c, VideoContentProperty::CROP);
567 }
568
569 void
570 VideoContent::set_bottom_crop (int c)
571 {
572         maybe_set (_crop.bottom, c, VideoContentProperty::CROP);
573 }
574
575
576 void
577 VideoContent::set_frame_type (VideoFrameType t)
578 {
579         maybe_set (_frame_type, t, VideoContentProperty::FRAME_TYPE);
580 }
581
582 void
583 VideoContent::unset_colour_conversion ()
584 {
585         maybe_set (_colour_conversion, boost::optional<ColourConversion> (), VideoContentProperty::COLOUR_CONVERSION);
586 }
587
588 void
589 VideoContent::set_colour_conversion (ColourConversion c)
590 {
591         maybe_set (_colour_conversion, c, VideoContentProperty::COLOUR_CONVERSION);
592 }
593
594 void
595 VideoContent::set_fade_in (Frame t)
596 {
597         maybe_set (_fade_in, t, VideoContentProperty::FADE_IN);
598 }
599
600 void
601 VideoContent::set_fade_out (Frame t)
602 {
603         maybe_set (_fade_out, t, VideoContentProperty::FADE_OUT);
604 }
605
606 void
607 VideoContent::set_range (VideoRange r)
608 {
609         maybe_set (_range, r, VideoContentProperty::RANGE);
610 }
611
612 void
613 VideoContent::set_use (bool u)
614 {
615         maybe_set (_use, u, VideoContentProperty::USE);
616 }
617
618
619 void
620 VideoContent::set_burnt_subtitle_language (boost::optional<dcp::LanguageTag> language)
621 {
622         maybe_set (_burnt_subtitle_language, language, VideoContentProperty::BURNT_SUBTITLE_LANGUAGE);
623 }
624
625
626 void
627 VideoContent::take_settings_from (shared_ptr<const VideoContent> c)
628 {
629         if (c->_colour_conversion) {
630                 set_colour_conversion (c->_colour_conversion.get());
631         } else {
632                 unset_colour_conversion ();
633         }
634         set_use (c->_use);
635         set_frame_type (c->_frame_type);
636         set_left_crop (c->_crop.left);
637         set_right_crop (c->_crop.right);
638         set_top_crop (c->_crop.top);
639         set_bottom_crop (c->_crop.bottom);
640         set_custom_ratio (c->_custom_ratio);
641         set_custom_size (c->_custom_size);
642         set_fade_in (c->_fade_in);
643         set_fade_out (c->_fade_out);
644         set_burnt_subtitle_language (c->_burnt_subtitle_language);
645         set_range(c->_range);
646 }
647
648
649 void
650 VideoContent::modify_position (shared_ptr<const Film> film, DCPTime& pos) const
651 {
652         pos = pos.round (film->video_frame_rate());
653 }
654
655 void
656 VideoContent::modify_trim_start (ContentTime& trim) const
657 {
658         if (_parent->video_frame_rate()) {
659                 trim = trim.round (_parent->video_frame_rate().get());
660         }
661 }
662
663
664 /** @param film_container The size of the container for the DCP that we are working on */
665 optional<dcp::Size>
666 VideoContent::scaled_size (dcp::Size film_container)
667 {
668         if (_custom_ratio) {
669                 return fit_ratio_within(*_custom_ratio, film_container);
670         }
671
672         if (_custom_size) {
673                 if (_custom_size->width <= film_container.width && _custom_size->height <= film_container.height) {
674                         return *_custom_size;
675                 }
676                 return fit_ratio_within(_custom_size->ratio(), film_container);
677         }
678
679         auto size = size_after_crop ();
680         if (!size) {
681                 return {};
682         }
683
684         size->width = std::lrint(size->width * _sample_aspect_ratio.get_value_or(1));
685
686         /* This is what we will return unless there is any legacy stuff to take into account */
687         auto auto_size = fit_ratio_within(size->ratio(), film_container);
688
689         if (_legacy_ratio) {
690                 if (fit_ratio_within(*_legacy_ratio, film_container) != auto_size) {
691                         _custom_ratio = *_legacy_ratio;
692                         _legacy_ratio = {};
693                         return fit_ratio_within(*_custom_ratio, film_container);
694                 }
695                 _legacy_ratio = {};
696         }
697
698         return _pixel_quanta.round (auto_size);
699 }
700
701
702 void
703 VideoContent::set_custom_ratio (optional<float> ratio)
704 {
705         maybe_set (_custom_ratio, ratio, VideoContentProperty::CUSTOM_RATIO);
706 }
707
708
709 void
710 VideoContent::set_custom_size (optional<dcp::Size> size)
711 {
712         maybe_set (_custom_size, size, VideoContentProperty::CUSTOM_SIZE);
713 }
714
715
716 Crop
717 VideoContent::actual_crop () const
718 {
719         return Crop(
720                 _pixel_quanta.round_x(_crop.left),
721                 _pixel_quanta.round_x(_crop.right),
722                 _pixel_quanta.round_y(_crop.top),
723                 _pixel_quanta.round_y(_crop.bottom)
724         );
725 }
726