X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fstereo_picture_frame.cc;h=5a90e0a13a898952e2751da141c72fef05bc8615;hb=1caefd8541e12e7d205c3d5bb46f3ec84719baa0;hp=8f3183714055b902a0bdf87a536d90ccd5a5afad;hpb=41fc6e366ad3de85704c35961beaf539ab9ceb8b;p=libdcp.git diff --git a/src/stereo_picture_frame.cc b/src/stereo_picture_frame.cc index 8f318371..5a90e0a1 100644 --- a/src/stereo_picture_frame.cc +++ b/src/stereo_picture_frame.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 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,18 +17,16 @@ */ -#include -#include "AS_DCP.h" -#include "KM_fileio.h" #include "stereo_picture_frame.h" #include "exceptions.h" -#include "argb_frame.h" -#include "lut.h" #include "util.h" -#include "gamma_lut.h" #include "rgb_xyz.h" - -#define DCI_GAMMA 2.6 +#include "colour_conversion.h" +#include "AS_DCP.h" +#include "KM_fileio.h" +#include "compose.hpp" +#include "j2k.h" +#include using std::string; using boost::shared_ptr; @@ -38,53 +36,48 @@ using namespace dcp; * @param mxf_path Path to the asset's MXF file. * @param n Frame within the asset, not taking EntryPoint into account. */ -StereoPictureFrame::StereoPictureFrame (boost::filesystem::path mxf_path, int n) +StereoPictureFrame::StereoPictureFrame (boost::filesystem::path path, int n) { ASDCP::JP2K::MXFSReader reader; - Kumu::Result_t r = reader.OpenRead (mxf_path.string().c_str()); + Kumu::Result_t r = reader.OpenRead (path.string().c_str()); if (ASDCP_FAILURE (r)) { - boost::throw_exception (FileError ("could not open MXF file for reading", mxf_path, r)); + boost::throw_exception (FileError ("could not open MXF file for reading", path, r)); } /* XXX: unfortunate guesswork on this buffer size */ _buffer = new ASDCP::JP2K::SFrameBuffer (4 * Kumu::Megabyte); if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer))) { - boost::throw_exception (DCPReadError ("could not read video frame")); + boost::throw_exception (DCPReadError (String::compose ("could not read video frame %1 of %2", n, path.string()))); } } +StereoPictureFrame::StereoPictureFrame () +{ + _buffer = new ASDCP::JP2K::SFrameBuffer (4 * Kumu::Megabyte); +} + StereoPictureFrame::~StereoPictureFrame () { delete _buffer; } -/** @param reduce a factor by which to reduce the resolution +/** @param eye Eye to return (EYE_LEFT or EYE_RIGHT). + * @param reduce a factor by which to reduce the resolution * of the image, expressed as a power of two (pass 0 for no * reduction). - * - * @param eye Eye to return (EYE_LEFT or EYE_RIGHT). - * - * @return An ARGB representation of one of the eyes (left or right) - * of this frame. This is ARGB in the Cairo sense, so that each - * pixel takes up 4 bytes; the first byte is blue, second green, - * third red and fourth alpha (always 255). - * */ -shared_ptr -StereoPictureFrame::argb_frame (Eye eye, int reduce, float srgb_gamma) const +shared_ptr +StereoPictureFrame::xyz_image (Eye eye, int reduce) const { - shared_ptr xyz_frame; switch (eye) { case LEFT: - xyz_frame = decompress_j2k (const_cast (_buffer->Left.RoData()), _buffer->Left.Size(), reduce); - break; + return decompress_j2k (const_cast (_buffer->Left.RoData()), _buffer->Left.Size(), reduce); case RIGHT: - xyz_frame = decompress_j2k (const_cast (_buffer->Right.RoData()), _buffer->Right.Size(), reduce); - break; + return decompress_j2k (const_cast (_buffer->Right.RoData()), _buffer->Right.Size(), reduce); } - - return xyz_to_rgb (xyz_frame, GammaLUT::cache.get (12, DCI_GAMMA), GammaLUT::cache.get (12, 1 / srgb_gamma)); + + return shared_ptr (); } uint8_t const * @@ -93,6 +86,12 @@ StereoPictureFrame::left_j2k_data () const return _buffer->Left.RoData (); } +uint8_t* +StereoPictureFrame::left_j2k_data () +{ + return _buffer->Left.Data (); +} + int StereoPictureFrame::left_j2k_size () const { @@ -105,6 +104,12 @@ StereoPictureFrame::right_j2k_data () const return _buffer->Right.RoData (); } +uint8_t* +StereoPictureFrame::right_j2k_data () +{ + return _buffer->Right.Data (); +} + int StereoPictureFrame::right_j2k_size () const {