+
+
+void
+VideoContent::take_settings_from (shared_ptr<const VideoContent> c)
+{
+ if (c->_colour_conversion) {
+ set_colour_conversion (c->_colour_conversion.get());
+ } else {
+ unset_colour_conversion ();
+ }
+ set_use (c->_use);
+ set_frame_type (c->_frame_type);
+ set_left_crop (c->_crop.left);
+ set_right_crop (c->_crop.right);
+ set_top_crop (c->_crop.top);
+ set_bottom_crop (c->_crop.bottom);
+ set_custom_ratio (c->_custom_ratio);
+ set_custom_size (c->_custom_size);
+ set_fade_in (c->_fade_in);
+ set_fade_out (c->_fade_out);
+ set_burnt_subtitle_language (c->_burnt_subtitle_language);
+}
+
+
+void
+VideoContent::modify_position (shared_ptr<const Film> film, DCPTime& pos) const
+{
+ pos = pos.round (film->video_frame_rate());
+}
+
+void
+VideoContent::modify_trim_start (ContentTime& trim) const
+{
+ if (_parent->video_frame_rate()) {
+ trim = trim.round (_parent->video_frame_rate().get());
+ }
+}
+
+
+/** @param film_container The size of the container for the DCP that we are working on */
+dcp::Size
+VideoContent::scaled_size (dcp::Size film_container)
+{
+ if (_custom_ratio) {
+ return fit_ratio_within(*_custom_ratio, film_container);
+ }
+
+ if (_custom_size) {
+ return *_custom_size;
+ }
+
+ auto size = size_after_crop ();
+ size.width *= _sample_aspect_ratio.get_value_or(1);
+
+ /* This is what we will return unless there is any legacy stuff to take into account */
+ auto auto_size = fit_ratio_within (size.ratio(), film_container);
+
+ if (_legacy_ratio) {
+ if (fit_ratio_within(*_legacy_ratio, film_container) != auto_size) {
+ _custom_ratio = *_legacy_ratio;
+ _legacy_ratio = optional<float>();
+ return fit_ratio_within(*_custom_ratio, film_container);
+ }
+ _legacy_ratio = boost::optional<float>();
+ }
+
+ return _pixel_quanta.round (auto_size);
+}
+
+
+void
+VideoContent::set_custom_ratio (optional<float> ratio)
+{
+ maybe_set (_custom_ratio, ratio, VideoContentProperty::CUSTOM_RATIO);
+}
+
+
+void
+VideoContent::set_custom_size (optional<dcp::Size> size)
+{
+ maybe_set (_custom_size, size, VideoContentProperty::CUSTOM_SIZE);
+}
+
+
+Crop
+VideoContent::actual_crop () const
+{
+ return Crop(
+ _pixel_quanta.round_x(_crop.left),
+ _pixel_quanta.round_x(_crop.right),
+ _pixel_quanta.round_y(_crop.top),
+ _pixel_quanta.round_y(_crop.bottom)
+ );
+}
+