Use a new ImageProxy to hold J2K data from DCP content.
[dcpomatic.git] / src / lib / dcp_decoder.cc
index 1939fc1c9d21ef731467fb2d2d5075361855835c..e23efba3e11898fcd89db85f089b9fde9d4462d9 100644 (file)
@@ -62,23 +62,20 @@ DCPDecoder::pass ()
                shared_ptr<dcp::PictureMXF> mxf = (*_reel)->main_picture()->mxf ();
                shared_ptr<dcp::MonoPictureMXF> mono = dynamic_pointer_cast<dcp::MonoPictureMXF> (mxf);
                shared_ptr<dcp::StereoPictureMXF> stereo = dynamic_pointer_cast<dcp::StereoPictureMXF> (mxf);
-               int64_t const ep = (*_reel)->main_picture()->entry_point ();
+               int64_t const entry_point = (*_reel)->main_picture()->entry_point ();
+               int64_t const frame = _next.frames (vfr);
                if (mono) {
-                       shared_ptr<Image> image (new Image (PIX_FMT_RGB24, mxf->size(), false));
-                       mono->get_frame (ep + _next.frames (vfr))->rgb_frame (image->data()[0]);
-                       shared_ptr<Image> aligned (new Image (image, true));
-                       video (shared_ptr<ImageProxy> (new RawImageProxy (aligned, _log)), _next.frames (vfr));
+                       video (shared_ptr<ImageProxy> (new J2KImageProxy (mono->get_frame (entry_point + frame), mxf->size(), _log)), frame);
                } else {
-
-                       shared_ptr<Image> left (new Image (PIX_FMT_RGB24, mxf->size(), false));
-                       stereo->get_frame (ep + _next.frames (vfr))->rgb_frame (dcp::EYE_LEFT, left->data()[0]);
-                       shared_ptr<Image> aligned_left (new Image (left, true));
-                       video (shared_ptr<ImageProxy> (new RawImageProxy (aligned_left, _log)), _next.frames (vfr));
-
-                       shared_ptr<Image> right (new Image (PIX_FMT_RGB24, mxf->size(), false));
-                       stereo->get_frame (ep + _next.frames (vfr))->rgb_frame (dcp::EYE_RIGHT, right->data()[0]);
-                       shared_ptr<Image> aligned_right (new Image (right, true));
-                       video (shared_ptr<ImageProxy> (new RawImageProxy (aligned_right, _log)), _next.frames (vfr));
+                       video (
+                               shared_ptr<ImageProxy> (new J2KImageProxy (stereo->get_frame (entry_point + frame), mxf->size(), dcp::EYE_LEFT, _log)),
+                               frame
+                               );
+                       
+                       video (
+                               shared_ptr<ImageProxy> (new J2KImageProxy (stereo->get_frame (entry_point + frame), mxf->size(), dcp::EYE_RIGHT, _log)),
+                               frame
+                               );
                }
        }