X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fimage_decoder.cc;h=c3a11ce971f3895aa3b6ccc8407105dff9757151;hb=2d5beb0d6794df13ad1df47e84fd7a57d1d1c64d;hp=8702c1a33b18692dbc43b89c9e60ab416ef9e50e;hpb=8d58a7c5f4320ad5c111e336c45e44d6b51ab509;p=dcpomatic.git diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index 8702c1a33..c3a11ce97 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -24,6 +24,7 @@ #include "image_decoder.h" #include "image.h" #include "magick_image_proxy.h" +#include "j2k_image_proxy.h" #include "film.h" #include "exceptions.h" @@ -33,25 +34,34 @@ using std::cout; using boost::shared_ptr; using dcp::Size; -ImageDecoder::ImageDecoder (shared_ptr c) - : VideoDecoder (c) +ImageDecoder::ImageDecoder (shared_ptr c, shared_ptr log) + : VideoDecoder (c->video, log) , _image_content (c) + , _video_position (0) { } bool -ImageDecoder::pass () +ImageDecoder::pass (PassReason, bool) { - if (_video_position >= _image_content->video_length().frames (_image_content->video_frame_rate ())) { + if (_video_position >= _image_content->video->length()) { return true; } if (!_image_content->still() || !_image) { /* Either we need an image or we are using moving images, so load one */ - _image.reset (new MagickImageProxy (_image_content->path (_image_content->still() ? 0 : _video_position), _image_content->film()->log ())); + boost::filesystem::path path = _image_content->path (_image_content->still() ? 0 : _video_position); + if (valid_j2k_file (path)) { + /* We can't extract image size from a JPEG2000 codestream without decoding it, + so pass in the image content's size here. + */ + _image.reset (new J2KImageProxy (path, _image_content->video->size ())); + } else { + _image.reset (new MagickImageProxy (path)); + } } - + video (_image, _video_position); ++_video_position; return false; @@ -61,5 +71,5 @@ void ImageDecoder::seek (ContentTime time, bool accurate) { VideoDecoder::seek (time, accurate); - _video_position = time.frames (_image_content->video_frame_rate ()); + _video_position = time.frames_round (_image_content->video->frame_rate ()); }