X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fimage_decoder.cc;h=3d543eaf28562572a8ee3f0ce29d50cd3b921ec6;hb=e60bb3e51bd1508b149e6b8f6608f09b5196ae26;hp=d3cdbd6f1ee753b994919cd677828662c1b96a8e;hpb=4616b19fb5241a54c9d57f7a91bb975f41aed14b;p=dcpomatic.git diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index d3cdbd6f1..3d543eaf2 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -23,7 +23,8 @@ #include "image_content.h" #include "image_decoder.h" #include "image.h" -#include "image_proxy.h" +#include "magick_image_proxy.h" +#include "j2k_image_proxy.h" #include "film.h" #include "exceptions.h" @@ -36,6 +37,7 @@ using dcp::Size; ImageDecoder::ImageDecoder (shared_ptr c) : VideoDecoder (c) , _image_content (c) + , _video_position (0) { } @@ -43,15 +45,23 @@ ImageDecoder::ImageDecoder (shared_ptr c) bool ImageDecoder::pass () { - 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;