Merge 1.0
[dcpomatic.git] / src / lib / image_decoder.cc
index a7999c02a86b5270b09dd50fd118c00280ef5761..a5ca67e0d95856c4de867b4f5ea70a17a5dd7a6a 100644 (file)
@@ -36,20 +36,22 @@ ImageDecoder::ImageDecoder (shared_ptr<const Film> f, shared_ptr<const ImageCont
        : Decoder (f)
        , VideoDecoder (f, c)
        , _image_content (c)
+       , _video_position (0)
 {
 
 }
 
-void
+bool
 ImageDecoder::pass ()
 {
        if (_video_position >= _image_content->video_length ()) {
-               return;
+               return true;
        }
 
        if (_image && _image_content->still ()) {
-               video (_image, true, _video_position);
-               return;
+               video (_image, true, _video_position * TIME_HZ / _video_content->video_frame_rate ());
+               ++_video_position;
+               return false;
        }
 
        Magick::Image* magick_image = 0;
@@ -80,17 +82,16 @@ ImageDecoder::pass ()
 
        delete magick_image;
 
-       video (_image, false, _video_position);
-}
+       video (_image, false, _video_position * TIME_HZ / _video_content->video_frame_rate ());
+       ++_video_position;
 
-void
-ImageDecoder::seek (VideoContent::Frame frame, bool)
-{
-       _video_position = frame;
+       return false;
 }
 
-bool
-ImageDecoder::done () const
+void
+ImageDecoder::seek (ContentTime time, bool accurate)
 {
-       return _video_position >= _image_content->video_length ();
+       Decoder::seek (time, accurate);
+       
+       _video_position = rint (time * _video_content->video_frame_rate() / TIME_HZ);
 }