+ signal_changed (VideoContentProperty::VIDEO_FRAME_TYPE);
+}
+
+string
+VideoContent::technical_summary () const
+{
+ return String::compose (
+ "video: length %1, size %2x%3, rate %4",
+ video_length_after_3d_combine().seconds(),
+ video_size().width,
+ video_size().height,
+ video_frame_rate()
+ );
+}
+
+dcp::Size
+VideoContent::video_size_after_3d_split () const
+{
+ dcp::Size const s = video_size ();
+ switch (video_frame_type ()) {
+ case VIDEO_FRAME_TYPE_2D:
+ case VIDEO_FRAME_TYPE_3D_ALTERNATE:
+ case VIDEO_FRAME_TYPE_3D_LEFT:
+ case VIDEO_FRAME_TYPE_3D_RIGHT:
+ return s;
+ case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
+ return dcp::Size (s.width / 2, s.height);
+ case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
+ return dcp::Size (s.width, s.height / 2);
+ }
+
+ assert (false);
+}
+
+void
+VideoContent::set_colour_conversion (ColourConversion c)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _colour_conversion = c;
+ }
+
+ signal_changed (VideoContentProperty::COLOUR_CONVERSION);
+}
+
+/** @return Video size after 3D split and crop */
+dcp::Size
+VideoContent::video_size_after_crop () const
+{
+ return crop().apply (video_size_after_3d_split ());
+}
+
+/** @param t A time offset from the start of this piece of content.
+ * @return Corresponding time with respect to the content.
+ */
+ContentTime
+VideoContent::dcp_time_to_content_time (DCPTime t) const
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+ return ContentTime (t, FrameRateChange (video_frame_rate(), film->video_frame_rate()));
+}
+
+void
+VideoContent::scale_and_crop_to_fit_width ()
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ set_scale (VideoContentScale (film->container ()));
+
+ int const crop = max (0, int (video_size().height - double (film->frame_size().height) * video_size().width / film->frame_size().width));
+ set_top_crop (crop / 2);
+ set_bottom_crop (crop / 2);
+}
+
+void
+VideoContent::scale_and_crop_to_fit_height ()
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ set_scale (VideoContentScale (film->container ()));
+
+ int const crop = max (0, int (video_size().width - double (film->frame_size().width) * video_size().height / film->frame_size().height));
+ set_left_crop (crop / 2);
+ set_right_crop (crop / 2);
+}
+
+VideoContentScale::VideoContentScale (Ratio const * r)
+ : _ratio (r)
+ , _scale (true)
+{
+
+}
+
+VideoContentScale::VideoContentScale ()
+ : _ratio (0)
+ , _scale (false)
+{
+
+}
+
+VideoContentScale::VideoContentScale (bool scale)
+ : _ratio (0)
+ , _scale (scale)
+{
+
+}
+
+VideoContentScale::VideoContentScale (cxml::NodePtr node)
+ : _ratio (0)
+ , _scale (true)
+{
+ optional<string> r = node->optional_string_child ("Ratio");
+ if (r) {
+ _ratio = Ratio::from_id (r.get ());
+ } else {
+ _scale = node->bool_child ("Scale");
+ }
+}
+
+void
+VideoContentScale::as_xml (xmlpp::Node* node) const
+{
+ if (_ratio) {
+ node->add_child("Ratio")->add_child_text (_ratio->id ());
+ } else {
+ node->add_child("Scale")->add_child_text (_scale ? "1" : "0");
+ }
+}
+
+string
+VideoContentScale::id () const
+{
+ stringstream s;
+
+ if (_ratio) {
+ s << _ratio->id () << "_";
+ } else {
+ s << (_scale ? "S1" : "S0");
+ }
+