+ set_scale (VideoContentScale(film->container()));
+
+ int const crop = max (0, int (size().height - double (film->frame_size().height) * size().width / film->frame_size().width));
+ set_left_crop (0);
+ set_right_crop (0);
+ set_top_crop (crop / 2);
+ set_bottom_crop (crop / 2);
+}
+
+void
+VideoContent::scale_and_crop_to_fit_height (shared_ptr<const Film> film)
+{
+ set_scale (VideoContentScale(film->container()));
+
+ int const crop = max (0, int (size().width - double (film->frame_size().width) * size().height / film->frame_size().height));
+ set_left_crop (crop / 2);
+ set_right_crop (crop / 2);
+ set_top_crop (0);
+ set_bottom_crop (0);
+}
+
+/** @param f Frame index within the whole (untrimmed) content.
+ * @return Fade factor (between 0 and 1) or unset if there is no fade.
+ */
+optional<double>
+VideoContent::fade (shared_ptr<const Film> film, Frame f) const
+{
+ DCPOMATIC_ASSERT (f >= 0);
+
+ double const vfr = _parent->active_video_frame_rate(film);
+
+ Frame const ts = _parent->trim_start().frames_round(vfr);
+ if ((f - ts) < fade_in()) {
+ return double (f - ts) / fade_in();
+ }
+
+ Frame fade_out_start = length() - _parent->trim_end().frames_round(vfr) - fade_out();
+ if (f >= fade_out_start) {
+ return 1 - double (f - fade_out_start) / fade_out();
+ }
+
+ return optional<double> ();
+}
+
+string
+VideoContent::processing_description (shared_ptr<const Film> film) const
+{
+ string d;
+ char buffer[256];
+
+ if (size().width && size().height) {
+ d += String::compose (
+ _("Content video is %1x%2"),
+ size_after_3d_split().width,
+ size_after_3d_split().height
+ );
+
+
+ double ratio = size_after_3d_split().ratio ();
+
+ if (sample_aspect_ratio ()) {
+ snprintf (buffer, sizeof(buffer), _(", pixel aspect ratio %.2f:1"), sample_aspect_ratio().get());
+ d += buffer;
+ ratio *= sample_aspect_ratio().get ();