X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fj2k_image_proxy.cc;h=a46cda13c4fc841e55f0da7a6b4ca835e4455c46;hb=a8f7f04a68b3bdf3df1975541323166bf472a6cd;hp=2489a949925f12ffd535779c0efc2507257d0135;hpb=a5ea5c0d2637dd41e3d356cb62cac75b8cadf8ce;p=dcpomatic.git diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index 2489a9499..a46cda13c 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -21,6 +21,7 @@ #include "j2k_image_proxy.h" #include "dcpomatic_socket.h" #include "image.h" +#include "dcpomatic_assert.h" #include #include #include @@ -38,6 +39,8 @@ using std::string; using std::cout; using std::max; +using std::pair; +using std::make_pair; using boost::shared_ptr; using boost::optional; using boost::dynamic_pointer_cast; @@ -50,7 +53,8 @@ J2KImageProxy::J2KImageProxy (boost::filesystem::path path, dcp::Size size, AVPi , _size (size) , _pixel_format (pixel_format) { - + /* ::image assumes 16bpp */ + DCPOMATIC_ASSERT (_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); } J2KImageProxy::J2KImageProxy ( @@ -64,6 +68,8 @@ J2KImageProxy::J2KImageProxy ( , _pixel_format (pixel_format) , _forced_reduction (forced_reduction) { + /* ::image assumes 16bpp */ + DCPOMATIC_ASSERT (_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); memcpy (_data.data().get(), frame->j2k_data(), _data.size ()); } @@ -79,6 +85,8 @@ J2KImageProxy::J2KImageProxy ( , _pixel_format (pixel_format) , _forced_reduction (forced_reduction) { + /* ::image assumes 16bpp */ + DCPOMATIC_ASSERT (_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); switch (eye) { case dcp::EYE_LEFT: _data = Data (frame->left_j2k_size ()); @@ -106,13 +114,14 @@ J2KImageProxy::J2KImageProxy (shared_ptr xml, shared_ptr soc socket->read (_data.data().get (), _data.size ()); } -void +int J2KImageProxy::prepare (optional target_size) const { boost::mutex::scoped_lock lm (_mutex); if (_decompressed && target_size == _target_size) { - return; + DCPOMATIC_ASSERT (_reduce); + return *_reduce; } int reduce = 0; @@ -143,12 +152,15 @@ J2KImageProxy::prepare (optional target_size) const } _target_size = target_size; + _reduce = reduce; + + return reduce; } -shared_ptr +pair, int> J2KImageProxy::image (optional, optional target_size) const { - prepare (target_size); + int const reduce = prepare (target_size); shared_ptr image (new Image (_pixel_format, _decompressed->size(), true)); @@ -169,7 +181,7 @@ J2KImageProxy::image (optional, optional target_siz } } - return image; + return make_pair (image, reduce); } void @@ -210,7 +222,8 @@ J2KImageProxy::J2KImageProxy (Data data, dcp::Size size, AVPixelFormat pixel_for , _size (size) , _pixel_format (pixel_format) { - + /* ::image assumes 16bpp */ + DCPOMATIC_ASSERT (_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); } size_t