X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fj2k_image_proxy.cc;h=3fc6ce9b252e50cd7c951069bc04dbe967fca7db;hb=5c0a67869dbddb924c9f5ccb4126aa06d85b9b8b;hp=6924fad795bd1ddbdcab067036a96917110560ed;hpb=3b48d5494c3cae7743d283203f5c8021860ab81f;p=dcpomatic.git diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index 6924fad79..3fc6ce9b2 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington 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 @@ -17,39 +17,47 @@ */ -#include -#include -#include -#include #include "j2k_image_proxy.h" -#include "util.h" +#include "dcpomatic_socket.h" #include "image.h" -#include "encoded_data.h" +#include "data.h" +#include "raw_convert.h" +#include +#include +#include +#include +#include #include "i18n.h" 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) + : _mono (new dcp::MonoPictureFrame (path)) + , _size (size) +{ + +} -J2KImageProxy::J2KImageProxy (shared_ptr frame, dcp::Size size, shared_ptr log) - : ImageProxy (log) - , _mono (frame) +J2KImageProxy::J2KImageProxy (shared_ptr frame, dcp::Size size) + : _mono (frame) , _size (size) { } -J2KImageProxy::J2KImageProxy (shared_ptr frame, dcp::Size size, dcp::Eye eye, shared_ptr log) - : ImageProxy (log) - , _stereo (frame) +J2KImageProxy::J2KImageProxy (shared_ptr frame, dcp::Size size, dcp::Eye eye) + : _stereo (frame) , _size (size) , _eye (eye) { } -J2KImageProxy::J2KImageProxy (shared_ptr xml, shared_ptr socket, shared_ptr log) - : ImageProxy (log) +J2KImageProxy::J2KImageProxy (shared_ptr xml, shared_ptr socket) { _size = dcp::Size (xml->number_child ("Width"), xml->number_child ("Height")); if (xml->optional_number_child ("Eye")) { @@ -69,31 +77,31 @@ J2KImageProxy::J2KImageProxy (shared_ptr xml, shared_ptr soc } shared_ptr -J2KImageProxy::image () const +J2KImageProxy::image (optional note) const { - shared_ptr image (new Image (PIX_FMT_RGB24, _size, false)); + shared_ptr image (new Image (PIX_FMT_RGB48LE, _size, true)); if (_mono) { - _mono->rgb_frame (image->data()[0]); + dcp::xyz_to_rgb (_mono->xyz_image (), dcp::ColourConversion::srgb_to_xyz(), image->data()[0], image->stride()[0], note); } else { - _stereo->rgb_frame (_eye, image->data()[0]); + dcp::xyz_to_rgb (_stereo->xyz_image (_eye.get ()), dcp::ColourConversion::srgb_to_xyz(), image->data()[0], image->stride()[0], note); } - return shared_ptr (new Image (image, true)); + return image; } void J2KImageProxy::add_metadata (xmlpp::Node* node) const { node->add_child("Type")->add_child_text (N_("J2K")); - node->add_child("Width")->add_child_text (dcp::raw_convert (_size.width)); - node->add_child("Height")->add_child_text (dcp::raw_convert (_size.height)); + node->add_child("Width")->add_child_text (raw_convert (_size.width)); + node->add_child("Height")->add_child_text (raw_convert (_size.height)); if (_stereo) { - node->add_child("Eye")->add_child_text (dcp::raw_convert (_eye)); - node->add_child("LeftSize")->add_child_text (dcp::raw_convert (_stereo->left_j2k_size ())); - node->add_child("RightSize")->add_child_text (dcp::raw_convert (_stereo->right_j2k_size ())); + node->add_child("Eye")->add_child_text (raw_convert (_eye.get ())); + node->add_child("LeftSize")->add_child_text (raw_convert (_stereo->left_j2k_size ())); + node->add_child("RightSize")->add_child_text (raw_convert (_stereo->right_j2k_size ())); } else { - node->add_child("Size")->add_child_text (dcp::raw_convert (_mono->j2k_size ())); + node->add_child("Size")->add_child_text (raw_convert (_mono->j2k_size ())); } } @@ -108,16 +116,16 @@ J2KImageProxy::send_binary (shared_ptr socket) const } } -shared_ptr +shared_ptr J2KImageProxy::j2k () const { if (_mono) { - return shared_ptr (new EncodedData (_mono->j2k_data(), _mono->j2k_size())); + return shared_ptr (new Data (_mono->j2k_data(), _mono->j2k_size())); } else { - if (_eye == dcp::EYE_LEFT) { - return shared_ptr (new EncodedData (_stereo->left_j2k_data(), _stereo->left_j2k_size())); + if (_eye.get() == dcp::EYE_LEFT) { + return shared_ptr (new Data (_stereo->left_j2k_data(), _stereo->left_j2k_size())); } else { - return shared_ptr (new EncodedData (_stereo->right_j2k_data(), _stereo->right_j2k_size())); + return shared_ptr (new Data (_stereo->right_j2k_data(), _stereo->right_j2k_size())); } } }