+
+bool
+J2KImageProxy::same (shared_ptr<const ImageProxy> other) const
+{
+ shared_ptr<const J2KImageProxy> jp = dynamic_pointer_cast<const J2KImageProxy> (other);
+ if (!jp) {
+ return false;
+ }
+
+ if (_data.size() != jp->_data.size()) {
+ return false;
+ }
+
+ return memcmp (_data.data().get(), jp->_data.data().get(), _data.size()) == 0;
+}
+
+J2KImageProxy::J2KImageProxy (Data data, dcp::Size size, AVPixelFormat pixel_format)
+ : _data (data)
+ , _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
+J2KImageProxy::memory_used () const
+{
+ size_t m = _data.size();
+ if (_image) {
+ /* 3 components, 16-bits per pixel */
+ m += 3 * 2 * _image->size().width * _image->size().height;
+ }
+ return m;
+}