Improve efficiency of DCP -> image decoding.
[dcpomatic.git] / src / lib / j2k_image_proxy.cc
index 9312a7763ba8e5c959cf48e39cd227de5c686a9f..2c4a2db5b1763e89611d1c6d3bcc9242bb6b1711 100644 (file)
@@ -22,7 +22,7 @@
 #include <dcp/mono_picture_frame.h>
 #include <dcp/stereo_picture_frame.h>
 #include "j2k_image_proxy.h"
-#include "util.h"
+#include "dcpomatic_socket.h"
 #include "image.h"
 #include "encoded_data.h"
 
@@ -30,6 +30,7 @@
 
 using std::string;
 using boost::shared_ptr;
+using boost::optional;
 
 /** Construct a J2KImageProxy from a JPEG2000 file */
 J2KImageProxy::J2KImageProxy (boost::filesystem::path path, dcp::Size size)
@@ -74,17 +75,17 @@ J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc
 }
 
 shared_ptr<Image>
-J2KImageProxy::image () const
+J2KImageProxy::image (optional<dcp::NoteHandler> note) const
 {
-       shared_ptr<Image> image (new Image (PIX_FMT_RGB24, _size, false));
+       shared_ptr<Image> image (new Image (PIX_FMT_RGB48LE, _size, true));
 
        if (_mono) {
-               _mono->rgb_frame (image->data()[0]);
+               _mono->rgb_frame (image, note);
        } else {
-               _stereo->rgb_frame (_eye, image->data()[0]);
+               _stereo->rgb_frame (_eye, image);
        }
 
-       return shared_ptr<Image> (new Image (image, true));
+       return image;
 }
 
 void