Merge branch '2.0' of ssh://main.carlh.net/home/carl/git/dcpomatic into 2.0
[dcpomatic.git] / src / lib / j2k_image_proxy.cc
index 2c4a2db5b1763e89611d1c6d3bcc9242bb6b1711..99e4dddab52dd6bbd59d3a10fca166e49d4f1cf7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
 */
 
-#include <libcxml/cxml.h>
-#include <dcp/raw_convert.h>
-#include <dcp/mono_picture_frame.h>
-#include <dcp/stereo_picture_frame.h>
 #include "j2k_image_proxy.h"
 #include "dcpomatic_socket.h"
 #include "image.h"
 #include "encoded_data.h"
+#include <dcp/raw_convert.h>
+#include <dcp/mono_picture_frame.h>
+#include <dcp/stereo_picture_frame.h>
+#include <dcp/colour_conversion.h>
+#include <dcp/rgb_xyz.h>
+#include <libcxml/cxml.h>
 
 #include "i18n.h"
 
@@ -80,9 +82,9 @@ J2KImageProxy::image (optional<dcp::NoteHandler> note) const
        shared_ptr<Image> image (new Image (PIX_FMT_RGB48LE, _size, true));
 
        if (_mono) {
-               _mono->rgb_frame (image, note);
+               dcp::xyz_to_rgb (_mono->xyz_image (), dcp::ColourConversion::xyz_to_srgb(), image->data()[0], image->stride()[0], note);
        } else {
-               _stereo->rgb_frame (_eye, image);
+               dcp::xyz_to_rgb (_stereo->xyz_image (_eye.get ()), dcp::ColourConversion::xyz_to_srgb(), image->data()[0], image->stride()[0], note);
        }
 
        return image;
@@ -95,7 +97,7 @@ J2KImageProxy::add_metadata (xmlpp::Node* node) const
        node->add_child("Width")->add_child_text (dcp::raw_convert<string> (_size.width));
        node->add_child("Height")->add_child_text (dcp::raw_convert<string> (_size.height));
        if (_stereo) {
-               node->add_child("Eye")->add_child_text (dcp::raw_convert<string> (_eye));
+               node->add_child("Eye")->add_child_text (dcp::raw_convert<string> (_eye.get ()));
                node->add_child("LeftSize")->add_child_text (dcp::raw_convert<string> (_stereo->left_j2k_size ()));
                node->add_child("RightSize")->add_child_text (dcp::raw_convert<string> (_stereo->right_j2k_size ()));
        } else {
@@ -120,7 +122,7 @@ J2KImageProxy::j2k () const
        if (_mono) {
                return shared_ptr<EncodedData> (new EncodedData (_mono->j2k_data(), _mono->j2k_size()));
        } else {
-               if (_eye == dcp::EYE_LEFT) {
+               if (_eye.get() == dcp::EYE_LEFT) {
                        return shared_ptr<EncodedData> (new EncodedData (_stereo->left_j2k_data(), _stereo->left_j2k_size()));
                } else {
                        return shared_ptr<EncodedData> (new EncodedData (_stereo->right_j2k_data(), _stereo->right_j2k_size()));