Fix crash on emitting a signal during a constructor.
[dcpomatic.git] / src / lib / image_examiner.cc
index cea5dfea7d1ea5addb5540a9cf0999ec735ccea0..8e15a9d4836b8aee38c2eb0c3893587c8eb1be02 100644 (file)
 #include "exceptions.h"
 #include "config.h"
 #include "cross.h"
+#include "compose.hpp"
 #include <dcp/openjpeg_image.h>
 #include <dcp/exceptions.h>
+#include <dcp/j2k.h>
 #include <Magick++.h>
 #include <iostream>
 
@@ -41,7 +43,7 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
        : _film (film)
        , _image_content (content)
 {
-#ifdef DCPOMATIC_IMAGE_MAGICK  
+#ifdef DCPOMATIC_IMAGE_MAGICK
        using namespace MagickCore;
 #endif
        boost::filesystem::path path = content->path(0).string ();
@@ -68,7 +70,7 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
        }
 
        if (content->still ()) {
-               _video_length = Config::instance()->default_still_length() * video_frame_rate().get_value_or (24);
+               _video_length = Config::instance()->default_still_length() * video_frame_rate().get_value_or (film->video_frame_rate ());
        } else {
                _video_length = _image_content->number_of_paths ();
        }
@@ -80,9 +82,24 @@ ImageExaminer::video_size () const
        return _video_size.get ();
 }
 
-optional<float>
+optional<double>
 ImageExaminer::video_frame_rate () const
 {
+       if (_image_content->video->has_own_frame_rate()) {
+               /* The content already knows what frame rate it should be */
+               return _image_content->video->frame_rate();
+       }
+
        /* Don't know */
-       return optional<float> ();
+       return optional<double> ();
+}
+
+bool
+ImageExaminer::yuv () const
+{
+       /* We never convert ImageSource from YUV to RGB (though maybe sometimes we should)
+          so it makes sense to just say they are never YUV so the option of a conversion
+          to RGB is not offered.
+       */
+       return false;
 }