Fix nonfunctional send-problem-report.
[dcpomatic.git] / src / lib / video_content.cc
index 498d5b9db7f3215dd870bb40db3fc2c4ff29e646..7321fc7c584bbf8c9dfa42b39f81dfce76b1d752 100644 (file)
@@ -55,7 +55,6 @@ using std::cout;
 using std::vector;
 using std::min;
 using std::max;
-using std::stringstream;
 using std::fixed;
 using std::setprecision;
 using std::list;
@@ -69,6 +68,7 @@ VideoContent::VideoContent (shared_ptr<const Film> film)
        , _video_length (0)
        , _video_frame_type (VIDEO_FRAME_TYPE_2D)
        , _scale (VideoContentScale (Ratio::from_id ("178")))
+       , _yuv (true)
        , _fade_in (0)
        , _fade_out (0)
 {
@@ -80,6 +80,7 @@ VideoContent::VideoContent (shared_ptr<const Film> film, DCPTime s, Frame len)
        , _video_length (len)
        , _video_frame_type (VIDEO_FRAME_TYPE_2D)
        , _scale (VideoContentScale (Ratio::from_id ("178")))
+       , _yuv (true)
        , _fade_in (0)
        , _fade_out (0)
 {
@@ -91,6 +92,7 @@ VideoContent::VideoContent (shared_ptr<const Film> film, boost::filesystem::path
        , _video_length (0)
        , _video_frame_type (VIDEO_FRAME_TYPE_2D)
        , _scale (VideoContentScale (Ratio::from_id ("178")))
+       , _yuv (true)
        , _fade_in (0)
        , _fade_out (0)
 {
@@ -124,6 +126,9 @@ VideoContent::VideoContent (shared_ptr<const Film> film, cxml::ConstNodePtr node
        if (node->optional_node_child ("ColourConversion")) {
                _colour_conversion = ColourConversion (node->node_child ("ColourConversion"), version);
        }
+
+       _yuv = node->optional_bool_child("YUV").get_value_or (true);
+
        if (version >= 32) {
                _fade_in = node->number_child<Frame> ("FadeIn");
                _fade_out = node->number_child<Frame> ("FadeOut");
@@ -135,6 +140,7 @@ VideoContent::VideoContent (shared_ptr<const Film> film, cxml::ConstNodePtr node
 VideoContent::VideoContent (shared_ptr<const Film> film, vector<shared_ptr<Content> > c)
        : Content (film, c)
        , _video_length (0)
+       , _yuv (false)
 {
        shared_ptr<VideoContent> ref = dynamic_pointer_cast<VideoContent> (c[0]);
        DCPOMATIC_ASSERT (ref);
@@ -171,6 +177,10 @@ VideoContent::VideoContent (shared_ptr<const Film> film, vector<shared_ptr<Conte
                }
 
                _video_length += vc->video_length ();
+
+               if (vc->yuv ()) {
+                       _yuv = true;
+               }
        }
 
        _video_size = ref->video_size ();
@@ -202,6 +212,7 @@ VideoContent::as_xml (xmlpp::Node* node) const
        if (_colour_conversion) {
                _colour_conversion.get().as_xml (node->add_child("ColourConversion"));
        }
+       node->add_child("YUV")->add_child_text (_yuv ? "1" : "0");
        node->add_child("FadeIn")->add_child_text (raw_convert<string> (_fade_in));
        node->add_child("FadeOut")->add_child_text (raw_convert<string> (_fade_out));
 }
@@ -222,6 +233,7 @@ VideoContent::take_from_video_examiner (shared_ptr<VideoExaminer> d)
        optional<double> const vfr = d->video_frame_rate ();
        Frame vl = d->video_length ();
        optional<double> const ar = d->sample_aspect_ratio ();
+       bool const yuv = d->yuv ();
 
        {
                boost::mutex::scoped_lock lm (_mutex);
@@ -229,6 +241,7 @@ VideoContent::take_from_video_examiner (shared_ptr<VideoExaminer> d)
                _video_frame_rate = vfr;
                _video_length = vl;
                _sample_aspect_ratio = ar;
+               _yuv = yuv;
 
                /* Guess correct scale from size and sample aspect ratio */
                _scale = VideoContentScale (
@@ -498,7 +511,7 @@ string
 VideoContent::processing_description () const
 {
        /* stringstream is OK here as this string is just for presentation to the user */
-       stringstream d;
+       SafeStringStream d;
 
        if (video_size().width && video_size().height) {
                d << String::compose (