summaryrefslogtreecommitdiff
path: root/src/lib/j2k_image_proxy.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-04-13 23:23:00 +0100
committerCarl Hetherington <cth@carlh.net>2018-04-13 23:23:00 +0100
commit0ff4fa6058b305476e7bc60c590acb6135c49b1c (patch)
tree1ea7e181846964bd1bab52bbfafc118f49b584f8 /src/lib/j2k_image_proxy.cc
parent9106e6ed551b13e1b7c7ee2088d54ce0ae430bcf (diff)
Account for J2K decoding at lower-than-maximum resolution when croppingv2.13.14
the resulting images; fixes #1274.
Diffstat (limited to 'src/lib/j2k_image_proxy.cc')
-rw-r--r--src/lib/j2k_image_proxy.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc
index 2489a9499..9100414e4 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 <dcp/raw_convert.h>
#include <dcp/openjpeg_image.h>
#include <dcp/mono_picture_frame.h>
@@ -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;
@@ -106,13 +109,14 @@ J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc
socket->read (_data.data().get (), _data.size ());
}
-void
+int
J2KImageProxy::prepare (optional<dcp::Size> 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 +147,15 @@ J2KImageProxy::prepare (optional<dcp::Size> target_size) const
}
_target_size = target_size;
+ _reduce = reduce;
+
+ return reduce;
}
-shared_ptr<Image>
+pair<shared_ptr<Image>, int>
J2KImageProxy::image (optional<dcp::NoteHandler>, optional<dcp::Size> target_size) const
{
- prepare (target_size);
+ int const reduce = prepare (target_size);
shared_ptr<Image> image (new Image (_pixel_format, _decompressed->size(), true));
@@ -169,7 +176,7 @@ J2KImageProxy::image (optional<dcp::NoteHandler>, optional<dcp::Size> target_siz
}
}
- return image;
+ return make_pair (image, reduce);
}
void