Allow + in DCP names for ISDCF RU rating strings.
[dcpomatic.git] / src / lib / video_content.cc
index 13e7ba893789b11ec682a9d56494cc1cf0d1a97c..d3ba6c1ab1f3d50d89806290b8eb8ed12b2b54aa 100644 (file)
@@ -32,7 +32,6 @@
 #include "log.h"
 #include <dcp/raw_convert.h>
 #include <libcxml/cxml.h>
-#include <dcp/colour_matrix.h>
 #include <libxml++/libxml++.h>
 #include <iomanip>
 #include <iostream>
@@ -141,7 +140,6 @@ VideoContent::VideoContent (Content* parent, cxml::ConstNodePtr node, int versio
                _scale = VideoContentScale (node->node_child ("Scale"));
        }
 
-
        if (node->optional_node_child ("ColourConversion")) {
                _colour_conversion = ColourConversion (node->node_child ("ColourConversion"), version);
        }
@@ -243,10 +241,14 @@ VideoContent::take_from_examiner (shared_ptr<VideoExaminer> d)
                _sample_aspect_ratio = ar;
                _yuv = yuv;
 
-               /* Guess correct scale from size and sample aspect ratio */
-               _scale = VideoContentScale (
-                       Ratio::nearest_from_ratio (double (_size.width) * ar.get_value_or (1) / _size.height)
-                       );
+               if (Config::instance()->default_scale_to ()) {
+                       _scale = VideoContentScale (Config::instance()->default_scale_to ());
+               } else {
+                       /* Guess correct scale from size and sample aspect ratio */
+                       _scale = VideoContentScale (
+                               Ratio::nearest_from_ratio (double (_size.width) * ar.get_value_or (1) / _size.height)
+                               );
+               }
        }
 
        LOG_GENERAL ("Video length obtained from header as %1 frames", _length);
@@ -400,18 +402,18 @@ VideoContent::processing_description () const
                        ratio *= sample_aspect_ratio().get ();
                }
 
-               snprintf (buffer, sizeof(buffer), _("\nDisplay aspect ratio %.2f:1\n"), ratio);
+               snprintf (buffer, sizeof(buffer), _("\nDisplay aspect ratio %.2f:1"), ratio);
                d += buffer;
        }
 
        if ((crop().left || crop().right || crop().top || crop().bottom) && size() != dcp::Size (0, 0)) {
                dcp::Size cropped = size_after_crop ();
                d += String::compose (
-                       _("Cropped to %1x%2"),
+                       _("\nCropped to %1x%2"),
                        cropped.width, cropped.height
                        );
 
-               snprintf (buffer, sizeof(buffer), " (%.2f:1)\n", cropped.ratio());
+               snprintf (buffer, sizeof(buffer), " (%.2f:1)", cropped.ratio());
                d += buffer;
        }
 
@@ -421,33 +423,33 @@ VideoContent::processing_description () const
 
        if (scaled != size_after_crop ()) {
                d += String::compose (
-                       _("Scaled to %1x%2"),
+                       _("\nScaled to %1x%2"),
                        scaled.width, scaled.height
                        );
 
-               snprintf (buffer, sizeof(buffer), _(" (%.2f:1)\n"), scaled.ratio());
+               snprintf (buffer, sizeof(buffer), _(" (%.2f:1)"), scaled.ratio());
                d += buffer;
        }
 
        if (scaled != container_size) {
                d += String::compose (
-                       _("Padded with black to fit container %1 (%2x%3)"),
-                       film->container()->nickname (),
+                       _("\nPadded with black to fit container %1 (%2x%3)"),
+                       film->container()->container_nickname (),
                        container_size.width, container_size.height
                        );
 
-               snprintf (buffer, sizeof(buffer), _(" (%.2f:1)\n"), container_size.ratio());
+               snprintf (buffer, sizeof(buffer), _(" (%.2f:1)"), container_size.ratio());
                d += buffer;
        }
 
        if (_parent->video_frame_rate()) {
                double const vfr = _parent->video_frame_rate().get ();
 
-               snprintf (buffer, sizeof(buffer), _("Content frame rate %.4f\n"), vfr);
+               snprintf (buffer, sizeof(buffer), _("\nContent frame rate %.4f\n"), vfr);
                d += buffer;
 
                FrameRateChange frc (vfr, film->video_frame_rate ());
-               d += frc.description () + "\n";
+               d += frc.description ();
        }
 
        return d;
@@ -457,7 +459,7 @@ void
 VideoContent::add_properties (list<UserProperty>& p) const
 {
        p.push_back (UserProperty (UserProperty::VIDEO, _("Length"), length (), _("video frames")));
-       p.push_back (UserProperty (UserProperty::VIDEO, _("Size"), size().width + "x" + size().height));
+       p.push_back (UserProperty (UserProperty::VIDEO, _("Size"), String::compose ("%1x%2", size().width, size().height)));
 }
 
 void
@@ -525,3 +527,35 @@ VideoContent::set_fade_out (Frame t)
 {
        maybe_set (_fade_out, t, VideoContentProperty::FADE_OUT);
 }
+
+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_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_scale (c->_scale);
+       set_fade_in (c->_fade_in);
+       set_fade_out (c->_fade_out);
+}
+
+void
+VideoContent::modify_position (DCPTime& pos) const
+{
+       pos = pos.round (_parent->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());
+       }
+}