#include "stereo_picture_mxf.h"
#include "sound_mxf.h"
#include "subtitle_content.h"
-#include "argb_frame.h"
+#include "argb_image.h"
#include <Magick++.h>
/** @file examples/read_dcp.cc
boost::shared_ptr<const dcp::MonoPictureFrame> picture_frame_j2k = picture_mxf->get_frame(999);
/* Get a ARGB copy of it */
- boost::shared_ptr<dcp::ARGBFrame> picture_frame_rgb = picture_frame_j2k->argb_frame ();
+ boost::shared_ptr<dcp::ARGBImage> picture_image_rgb = picture_frame_j2k->argb_image ();
- Magick::Image image (picture_frame_rgb->size().width, picture_frame_rgb->size().height, "BGRA", Magick::CharPixel, picture_frame_rgb->data ());
+ Magick::Image image (picture_image_rgb->size().width, picture_image_rgb->size().height, "BGRA", Magick::CharPixel, picture_image_rgb->data ());
image.write ("frame.png");
return 0;
+++ /dev/null
-/*
- Copyright (C) 2012-2014 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/** @file src/argb_frame.cc
- * @brief ARGBFrame class.
- */
-
-#include "argb_frame.h"
-
-using namespace dcp;
-
-/** Construct an empty ARGBFrame of a given size and with
- * undefined contents.
- * @param size Size in pixels.
- */
-ARGBFrame::ARGBFrame (Size size)
- : _size (size)
-{
- _data = new uint8_t[_size.width * _size.height * 4];
-}
-
-
-ARGBFrame::~ARGBFrame ()
-{
- delete[] _data;
-}
-
-/** @return The stride, in bytes; that is, the number of bytes per row of the image */
-int
-ARGBFrame::stride () const
-{
- return _size.width * 4;
-}
+++ /dev/null
-/*
- Copyright (C) 2012-2014 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/** @file src/argb_frame.h
- * @brief ARGBFrame class.
- */
-
-#include "util.h"
-#include <stdint.h>
-
-namespace dcp
-{
-
-/** @class ARGBFrame
- * @brief A single frame of picture data held in an ARGB buffer.
- *
- * The format of the data is:
- *
- * <pre>
- * Byte /- 0 -------|- 1 --------|- 2 --------|- 3 --------|- 4 --------|- 5 --------| ...
- * |(0, 0) Blue|(0, 0)Green |(0, 0) Red |(0, 0) Alpha|(0, 1) Blue |(0, 1) Green| ...
- * </pre>
- *
- * So that the first byte is the blue component of the pixel at x=0, y=0, the second
- * is the green component, and so on.
- *
- * Lines are packed so that the second row directly follows the first.
- *
- * XXX: this should probably be an Image...?
- */
-class ARGBFrame : boost::noncopyable
-{
-public:
- ARGBFrame (Size size);
- ~ARGBFrame ();
-
- /** @return pointer to the image data */
- uint8_t* data () const {
- return _data;
- }
-
- /** @return length of one picture row in bytes */
- int stride () const;
-
- /** @return size of the picture in pixels */
- Size size () const {
- return _size;
- }
-
-private:
- Size _size; ///< frame size in pixels
- uint8_t* _data; ///< pointer to image data
-};
-
-}
--- /dev/null
+/*
+ Copyright (C) 2012-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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file src/argb_image.cc
+ * @brief ARGBImage class.
+ */
+
+#include "argb_image.h"
+
+using namespace dcp;
+
+/** Construct an empty ARGBImage of a given size and with
+ * undefined contents.
+ * @param size Size in pixels.
+ */
+ARGBImage::ARGBImage (Size size)
+ : _size (size)
+{
+ _data = new uint8_t[_size.width * _size.height * 4];
+}
+
+
+ARGBImage::~ARGBImage ()
+{
+ delete[] _data;
+}
+
+/** @return The stride, in bytes; that is, the number of bytes per row of the image */
+int
+ARGBImage::stride () const
+{
+ return _size.width * 4;
+}
--- /dev/null
+/*
+ Copyright (C) 2012-2014 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file src/argb_image.h
+ * @brief ARGBImage class.
+ */
+
+#include "util.h"
+#include <stdint.h>
+
+namespace dcp
+{
+
+/** @class ARGBImage
+ * @brief A single frame of picture data held in an ARGB buffer.
+ *
+ * The format of the data is:
+ *
+ * <pre>
+ * Byte /- 0 -------|- 1 --------|- 2 --------|- 3 --------|- 4 --------|- 5 --------| ...
+ * |(0, 0) Blue|(0, 0)Green |(0, 0) Red |(0, 0) Alpha|(0, 1) Blue |(0, 1) Green| ...
+ * </pre>
+ *
+ * So that the first byte is the blue component of the pixel at x=0, y=0, the second
+ * is the green component, and so on.
+ *
+ * Lines are packed so that the second row directly follows the first.
+ *
+ * XXX: this should probably be an Image...?
+ */
+class ARGBImage : boost::noncopyable
+{
+public:
+ ARGBImage (Size size);
+ ~ARGBImage ();
+
+ /** @return pointer to the image data */
+ uint8_t* data () const {
+ return _data;
+ }
+
+ /** @return length of one picture row in bytes */
+ int stride () const;
+
+ /** @return size of the picture in pixels */
+ Size size () const {
+ return _size;
+ }
+
+private:
+ Size _size; ///< frame size in pixels
+ uint8_t* _data; ///< pointer to image data
+};
+
+}
#include "mono_picture_frame.h"
#include "exceptions.h"
-#include "argb_frame.h"
+#include "argb_image.h"
#include "util.h"
#include "rgb_xyz.h"
#include "colour_conversion.h"
* 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<ARGBFrame>
-MonoPictureFrame::argb_frame (int reduce) const
+shared_ptr<ARGBImage>
+MonoPictureFrame::argb_image (int reduce) const
{
return xyz_to_rgba (
decompress_j2k (const_cast<uint8_t*> (_buffer->RoData()), _buffer->Size(), reduce),
namespace dcp {
-class ARGBFrame;
+class ARGBImage;
class Image;
/** @class MonoPictureFrame
MonoPictureFrame ();
~MonoPictureFrame ();
- boost::shared_ptr<ARGBFrame> argb_frame (int reduce = 0) const;
+ boost::shared_ptr<ARGBImage> argb_image (int reduce = 0) const;
void rgb_frame (boost::shared_ptr<Image> rgb, boost::optional<NoteHandler> note = boost::optional<NoteHandler> ()) const;
uint8_t const * j2k_data () const;
uint8_t* j2k_data ();
#include "picture_mxf.h"
#include "util.h"
#include "exceptions.h"
-#include "xyz_frame.h"
+#include "xyz_image.h"
#include "picture_mxf_writer.h"
#include "compose.hpp"
#include "AS_DCP.h"
}
/* Decompress the images to bitmaps */
- shared_ptr<XYZFrame> image_A = decompress_j2k (const_cast<uint8_t*> (data_A), size_A, 0);
- shared_ptr<XYZFrame> image_B = decompress_j2k (const_cast<uint8_t*> (data_B), size_B, 0);
+ shared_ptr<XYZImage> image_A = decompress_j2k (const_cast<uint8_t*> (data_A), size_A, 0);
+ shared_ptr<XYZImage> image_B = decompress_j2k (const_cast<uint8_t*> (data_B), size_B, 0);
/* Compare them */
*/
#include "rgb_xyz.h"
-#include "argb_frame.h"
-#include "xyz_frame.h"
+#include "argb_image.h"
+#include "xyz_image.h"
#include "image.h"
#include "colour_matrix.h"
#include "colour_conversion.h"
#define DCI_COEFFICIENT (48.0 / 52.37)
/** Convert an openjpeg XYZ image to RGBA.
- * @param xyz_frame Frame in XYZ.
+ * @param xyz_image Image in XYZ.
* @return RGB image.
*/
-shared_ptr<ARGBFrame>
+shared_ptr<ARGBImage>
dcp::xyz_to_rgba (
- boost::shared_ptr<const XYZFrame> xyz_frame,
+ boost::shared_ptr<const XYZImage> xyz_image,
ColourConversion const & conversion
)
{
double r, g, b;
} d;
- int* xyz_x = xyz_frame->data (0);
- int* xyz_y = xyz_frame->data (1);
- int* xyz_z = xyz_frame->data (2);
+ int* xyz_x = xyz_image->data (0);
+ int* xyz_y = xyz_image->data (1);
+ int* xyz_z = xyz_image->data (2);
- shared_ptr<ARGBFrame> argb_frame (new ARGBFrame (xyz_frame->size ()));
- uint8_t* argb = argb_frame->data ();
+ shared_ptr<ARGBImage> argb_image (new ARGBImage (xyz_image->size ()));
+ uint8_t* argb = argb_image->data ();
double const * lut_in = conversion.in()->lut (16);
double const * lut_out = conversion.out()->lut (12);
boost::numeric::ublas::matrix<double> matrix = conversion.matrix ();
- for (int y = 0; y < xyz_frame->size().height; ++y) {
+ for (int y = 0; y < xyz_image->size().height; ++y) {
uint8_t* argb_line = argb;
- for (int x = 0; x < xyz_frame->size().width; ++x) {
+ for (int x = 0; x < xyz_image->size().width; ++x) {
DCP_ASSERT (*xyz_x >= 0 && *xyz_y >= 0 && *xyz_z >= 0 && *xyz_x < 4096 && *xyz_y < 4096 && *xyz_z < 4096);
*argb_line++ = 0xff;
}
- argb += argb_frame->stride ();
+ argb += argb_image->stride ();
}
- return argb_frame;
+ return argb_image;
}
/** Convert an openjpeg XYZ image to RGB.
- * @param xyz_frame Frame in XYZ.
+ * @param xyz_image Frame in XYZ.
* @param conversion Colour conversion to use.
* @param rgb Image to write RGB data to; must have space to be
* filled with packed RGB 16:16:16, 48bpp, 16R, 16G, 16B,
*/
void
dcp::xyz_to_rgb (
- shared_ptr<const XYZFrame> xyz_frame,
+ shared_ptr<const XYZImage> xyz_image,
ColourConversion const & conversion,
shared_ptr<Image> rgb,
optional<NoteHandler> note
} d;
/* These should be 12-bit values from 0-4095 */
- int* xyz_x = xyz_frame->data (0);
- int* xyz_y = xyz_frame->data (1);
- int* xyz_z = xyz_frame->data (2);
+ int* xyz_x = xyz_image->data (0);
+ int* xyz_y = xyz_image->data (1);
+ int* xyz_z = xyz_image->data (2);
double const * lut_in = conversion.in()->lut (12);
double const * lut_out = conversion.out()->lut (16);
boost::numeric::ublas::matrix<double> matrix = conversion.matrix ();
- for (int y = 0; y < xyz_frame->size().height; ++y) {
+ for (int y = 0; y < xyz_image->size().height; ++y) {
uint16_t* rgb_line = reinterpret_cast<uint16_t*> (rgb->data()[0] + y * rgb->stride()[0]);
- for (int x = 0; x < xyz_frame->size().width; ++x) {
+ for (int x = 0; x < xyz_image->size().width; ++x) {
int cx = *xyz_x++;
int cy = *xyz_y++;
/** rgb must be packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, with the 2-byte value for each R/G/B component stored as little-endian;
* i.e. AV_PIX_FMT_RGB48LE.
*/
-shared_ptr<dcp::XYZFrame>
+shared_ptr<dcp::XYZImage>
dcp::rgb_to_xyz (
boost::shared_ptr<const Image> rgb,
ColourConversion const & conversion
)
{
- shared_ptr<XYZFrame> xyz (new XYZFrame (rgb->size ()));
+ shared_ptr<XYZImage> xyz (new XYZImage (rgb->size ()));
struct {
double r, g, b;
/** Image must be packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, with the 2-byte value for each R/G/B component stored as little-endian;
* i.e. AV_PIX_FMT_RGB48LE.
*/
-shared_ptr<dcp::XYZFrame>
+shared_ptr<dcp::XYZImage>
dcp::xyz_to_xyz (shared_ptr<const Image> xyz_16)
{
- shared_ptr<XYZFrame> xyz_12 (new XYZFrame (xyz_16->size ()));
+ shared_ptr<XYZImage> xyz_12 (new XYZImage (xyz_16->size ()));
int jn = 0;
for (int y = 0; y < xyz_16->size().height; ++y) {
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-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
namespace dcp {
-class ARGBFrame;
-class XYZFrame;
+class ARGBImage;
+class XYZImage;
class Image;
class ColourConversion;
-extern boost::shared_ptr<ARGBFrame> xyz_to_rgba (boost::shared_ptr<const XYZFrame>, ColourConversion const & conversion);
+extern boost::shared_ptr<ARGBImage> xyz_to_rgba (boost::shared_ptr<const XYZImage>, ColourConversion const & conversion);
extern void xyz_to_rgb (
- boost::shared_ptr<const XYZFrame>,
+ boost::shared_ptr<const XYZImage>,
ColourConversion const & conversion,
boost::shared_ptr<Image> rgb,
boost::optional<NoteHandler> note = boost::optional<NoteHandler> ()
);
-extern boost::shared_ptr<XYZFrame> rgb_to_xyz (boost::shared_ptr<const Image>, ColourConversion const & conversion);
-extern boost::shared_ptr<XYZFrame> xyz_to_xyz (boost::shared_ptr<const Image>);
+extern boost::shared_ptr<XYZImage> rgb_to_xyz (boost::shared_ptr<const Image>, ColourConversion const & conversion);
+extern boost::shared_ptr<XYZImage> xyz_to_xyz (boost::shared_ptr<const Image>);
}
#include "stereo_picture_frame.h"
#include "exceptions.h"
-#include "argb_frame.h"
+#include "argb_image.h"
#include "util.h"
#include "rgb_xyz.h"
#include "colour_conversion.h"
* third red and fourth alpha (always 255).
*
*/
-shared_ptr<ARGBFrame>
-StereoPictureFrame::argb_frame (Eye eye, int reduce) const
+shared_ptr<ARGBImage>
+StereoPictureFrame::argb_image (Eye eye, int reduce) const
{
- shared_ptr<XYZFrame> xyz_frame;
+ shared_ptr<XYZImage> xyz_image;
switch (eye) {
case LEFT:
- xyz_frame = decompress_j2k (const_cast<uint8_t*> (_buffer->Left.RoData()), _buffer->Left.Size(), reduce);
+ xyz_image = decompress_j2k (const_cast<uint8_t*> (_buffer->Left.RoData()), _buffer->Left.Size(), reduce);
break;
case RIGHT:
- xyz_frame = decompress_j2k (const_cast<uint8_t*> (_buffer->Right.RoData()), _buffer->Right.Size(), reduce);
+ xyz_image = decompress_j2k (const_cast<uint8_t*> (_buffer->Right.RoData()), _buffer->Right.Size(), reduce);
break;
}
- return xyz_to_rgba (xyz_frame, ColourConversion::xyz_to_srgb ());
+ return xyz_to_rgba (xyz_image, ColourConversion::xyz_to_srgb ());
}
void
StereoPictureFrame::rgb_frame (Eye eye, shared_ptr<Image> image) const
{
- shared_ptr<XYZFrame> xyz_frame;
+ shared_ptr<XYZImage> xyz_image;
switch (eye) {
case LEFT:
- xyz_frame = decompress_j2k (const_cast<uint8_t*> (_buffer->Left.RoData()), _buffer->Left.Size(), 0);
+ xyz_image = decompress_j2k (const_cast<uint8_t*> (_buffer->Left.RoData()), _buffer->Left.Size(), 0);
break;
case RIGHT:
- xyz_frame = decompress_j2k (const_cast<uint8_t*> (_buffer->Right.RoData()), _buffer->Right.Size(), 0);
+ xyz_image = decompress_j2k (const_cast<uint8_t*> (_buffer->Right.RoData()), _buffer->Right.Size(), 0);
break;
}
- return xyz_to_rgb (xyz_frame, ColourConversion::xyz_to_srgb (), image);
+ return xyz_to_rgb (xyz_image, ColourConversion::xyz_to_srgb (), image);
}
uint8_t const *
namespace dcp {
-class ARGBFrame;
+class ARGBImage;
class Image;
/** A single frame of a 3D (stereoscopic) picture asset */
StereoPictureFrame ();
~StereoPictureFrame ();
- boost::shared_ptr<ARGBFrame> argb_frame (Eye eye, int reduce = 0) const;
+ boost::shared_ptr<ARGBImage> argb_image (Eye eye, int reduce = 0) const;
void rgb_frame (Eye eye, boost::shared_ptr<Image>) const;
uint8_t const * left_j2k_data () const;
uint8_t* left_j2k_data ();
#include "util.h"
#include "exceptions.h"
#include "types.h"
-#include "argb_frame.h"
+#include "argb_image.h"
#include "certificates.h"
-#include "xyz_frame.h"
+#include "xyz_image.h"
#include "dcp_assert.h"
#include "compose.hpp"
#include "KM_util.h"
* This is useful for scaling 4K DCP images down to 2K.
* @return XYZ image.
*/
-shared_ptr<dcp::XYZFrame>
+shared_ptr<dcp::XYZImage>
dcp::decompress_j2k (uint8_t* data, int64_t size, int reduce)
{
opj_dinfo_t* decoder = opj_create_decompress (CODEC_J2K);
image->x1 = rint (float(image->x1) / pow (2, reduce));
image->y1 = rint (float(image->y1) / pow (2, reduce));
- return shared_ptr<XYZFrame> (new XYZFrame (image));
+ return shared_ptr<XYZImage> (new XYZImage (image));
}
/** @param s A string.
namespace dcp {
-class ARGBFrame;
+class ARGBImage;
class CertificateChain;
class GammaLUT;
-class XYZFrame;
+class XYZImage;
/** @struct Size
* @brief The integer, two-dimensional size of something.
extern std::string content_kind_to_string (ContentKind kind);
extern ContentKind content_kind_from_string (std::string kind);
extern bool empty_or_white_space (std::string s);
-extern boost::shared_ptr<XYZFrame> decompress_j2k (uint8_t* data, int64_t size, int reduce);
+extern boost::shared_ptr<XYZImage> decompress_j2k (uint8_t* data, int64_t size, int reduce);
extern bool ids_equal (std::string a, std::string b);
extern void init ();
def build(bld):
source = """
- argb_frame.cc
+ argb_image.cc
asset.cc
certificate_chain.cc
certificates.cc
types.cc
util.cc
version.cc
- xyz_frame.cc
+ xyz_image.cc
"""
headers = """
reel_stereo_picture_asset.h
reel_subtitle_asset.h
ref.h
- argb_frame.h
+ argb_image.h
signer.h
smpte_load_font.h
smpte_subtitle_content.h
types.h
util.h
version.h
- xyz_frame.h
+ xyz_image.h
"""
# Main library
+++ /dev/null
-/*
- Copyright (C) 2012-2014 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/** @file src/xyz_frame.cc
- * @brief XZYFrame class.
- */
-
-#include "xyz_frame.h"
-#include "dcp_assert.h"
-#include <stdexcept>
-
-using namespace dcp;
-
-/** Construct an XYZFrame, taking ownership of the opj_image_t */
-XYZFrame::XYZFrame (opj_image_t* image)
- : _opj_image (image)
-{
- DCP_ASSERT (_opj_image->numcomps == 3);
-}
-
-/** Construct a new XYZFrame with undefined contents.
- * @param size Size for the frame in pixels.
- */
-XYZFrame::XYZFrame (Size size)
-{
- opj_image_cmptparm_t cmptparm[3];
-
- for (int i = 0; i < 3; ++i) {
- cmptparm[i].dx = 1;
- cmptparm[i].dy = 1;
- cmptparm[i].w = size.width;
- cmptparm[i].h = size.height;
- cmptparm[i].x0 = 0;
- cmptparm[i].y0 = 0;
- cmptparm[i].prec = 12;
- cmptparm[i].bpp = 12;
- cmptparm[i].sgnd = 0;
- }
-
- /* XXX: is this _SRGB right? */
- _opj_image = opj_image_create (3, &cmptparm[0], CLRSPC_SRGB);
- if (_opj_image == 0) {
- throw std::runtime_error ("could not create libopenjpeg image");
- }
-
- _opj_image->x0 = 0;
- _opj_image->y0 = 0;
- _opj_image->x1 = size.width;
- _opj_image->y1 = size.height;
-}
-
-/** XYZFrame destructor */
-XYZFrame::~XYZFrame ()
-{
- opj_image_destroy (_opj_image);
-}
-
-/** @param c Component index (0, 1 or 2)
- * @return Pointer to the data for component c; 12-bit values from 0-4095.
- */
-int *
-XYZFrame::data (int c) const
-{
- DCP_ASSERT (c >= 0 && c < 3);
- return _opj_image->comps[c].data;
-}
-
-/** @return Size of the image in pixels */
-dcp::Size
-XYZFrame::size () const
-{
- /* XXX: this may not be right; x0 and y0 can presumably be non-zero */
- return dcp::Size (_opj_image->x1, _opj_image->y1);
-}
+++ /dev/null
-/*
- Copyright (C) 2012-2014 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/** @file src/xyz_frame.h
- * @brief XZYFrame class.
- */
-
-#include "util.h"
-#include <openjpeg.h>
-
-namespace dcp {
-
-/** @class XYZFrame
- * @brief An image in XYZ colour.
- *
- * This class is a thin wrapper of libopenjpeg's opj_image_t.
- */
-class XYZFrame : public boost::noncopyable
-{
-public:
- XYZFrame (opj_image_t *);
- XYZFrame (Size);
- ~XYZFrame ();
-
- int* data (int) const;
- dcp::Size size () const;
-
- /** @return Pointer to opj_image_t struct. The caller
- * must not delete this.
- */
- opj_image_t* opj_image () const {
- return _opj_image;
- }
-
-private:
- opj_image_t* _opj_image; ///< opj_image_t that we are managing
-};
-
-}
--- /dev/null
+/*
+ Copyright (C) 2012-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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file src/xyz_image.cc
+ * @brief XYZImage class.
+ */
+
+#include "xyz_image.h"
+#include "dcp_assert.h"
+#include <stdexcept>
+
+using namespace dcp;
+
+/** Construct an XYZImage, taking ownership of the opj_image_t */
+XYZImage::XYZImage (opj_image_t* image)
+ : _opj_image (image)
+{
+ DCP_ASSERT (_opj_image->numcomps == 3);
+}
+
+/** Construct a new XYZImage with undefined contents.
+ * @param size Size for the frame in pixels.
+ */
+XYZImage::XYZImage (Size size)
+{
+ opj_image_cmptparm_t cmptparm[3];
+
+ for (int i = 0; i < 3; ++i) {
+ cmptparm[i].dx = 1;
+ cmptparm[i].dy = 1;
+ cmptparm[i].w = size.width;
+ cmptparm[i].h = size.height;
+ cmptparm[i].x0 = 0;
+ cmptparm[i].y0 = 0;
+ cmptparm[i].prec = 12;
+ cmptparm[i].bpp = 12;
+ cmptparm[i].sgnd = 0;
+ }
+
+ /* XXX: is this _SRGB right? */
+ _opj_image = opj_image_create (3, &cmptparm[0], CLRSPC_SRGB);
+ if (_opj_image == 0) {
+ throw std::runtime_error ("could not create libopenjpeg image");
+ }
+
+ _opj_image->x0 = 0;
+ _opj_image->y0 = 0;
+ _opj_image->x1 = size.width;
+ _opj_image->y1 = size.height;
+}
+
+/** XYZImage destructor */
+XYZImage::~XYZImage ()
+{
+ opj_image_destroy (_opj_image);
+}
+
+/** @param c Component index (0, 1 or 2)
+ * @return Pointer to the data for component c; 12-bit values from 0-4095.
+ */
+int *
+XYZImage::data (int c) const
+{
+ DCP_ASSERT (c >= 0 && c < 3);
+ return _opj_image->comps[c].data;
+}
+
+/** @return Size of the image in pixels */
+dcp::Size
+XYZImage::size () const
+{
+ /* XXX: this may not be right; x0 and y0 can presumably be non-zero */
+ return dcp::Size (_opj_image->x1, _opj_image->y1);
+}
--- /dev/null
+/*
+ Copyright (C) 2012-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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file src/xyz_image.h
+ * @brief XYZImage class.
+ */
+
+#include "util.h"
+#include <openjpeg.h>
+
+namespace dcp {
+
+/** @class XYZImage
+ * @brief An image in XYZ colour.
+ *
+ * This class is a thin wrapper of libopenjpeg's opj_image_t.
+ */
+class XYZImage : public boost::noncopyable
+{
+public:
+ XYZImage (opj_image_t *);
+ XYZImage (Size);
+ ~XYZImage ();
+
+ int* data (int) const;
+ dcp::Size size () const;
+
+ /** @return Pointer to opj_image_t struct. The caller
+ * must not delete this.
+ */
+ opj_image_t* opj_image () const {
+ return _opj_image;
+ }
+
+private:
+ opj_image_t* _opj_image; ///< opj_image_t that we are managing
+};
+
+}
+++ /dev/null
-/*
- Copyright (C) 2014 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "argb_frame.h"
-#include <boost/test/unit_test.hpp>
-
-/** Very simple tests of ARGBFrame */
-BOOST_AUTO_TEST_CASE (argb_frame_test)
-{
- dcp::ARGBFrame f (dcp::Size (100, 200));
-
- BOOST_CHECK (f.data() != 0);
- BOOST_CHECK_EQUAL (f.stride(), 100 * 4);
- BOOST_CHECK_EQUAL (f.size(), dcp::Size (100, 200));
-}
--- /dev/null
+/*
+ Copyright (C) 2014 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "argb_image.h"
+#include <boost/test/unit_test.hpp>
+
+/** Very simple tests of ARGBImage */
+BOOST_AUTO_TEST_CASE (argb_image_test)
+{
+ dcp::ARGBImage f (dcp::Size (100, 200));
+
+ BOOST_CHECK (f.data() != 0);
+ BOOST_CHECK_EQUAL (f.stride(), 100 * 4);
+ BOOST_CHECK_EQUAL (f.size(), dcp::Size (100, 200));
+}
#include "cpl.h"
#include "decrypted_kdm.h"
#include "encrypted_kdm.h"
-#include "argb_frame.h"
+#include "argb_image.h"
#include "mono_picture_mxf.h"
#include "reel_picture_asset.h"
#include "reel.h"
using boost::dynamic_pointer_cast;
using boost::shared_ptr;
-static shared_ptr<const dcp::ARGBFrame>
+static shared_ptr<const dcp::ARGBImage>
get_frame (dcp::DCP const & dcp)
{
shared_ptr<const dcp::Reel> reel = dcp.cpls().front()->reels().front ();
shared_ptr<const dcp::MonoPictureMXF> mono_picture = dynamic_pointer_cast<const dcp::MonoPictureMXF> (picture);
shared_ptr<const dcp::MonoPictureFrame> j2k_frame = mono_picture->get_frame (0);
- return j2k_frame->argb_frame ();
+ return j2k_frame->argb_image ();
}
/** Decrypt an encrypted test DCP and check that its first frame is the same as the unencrypted version */
encrypted.add (kdm);
- shared_ptr<const dcp::ARGBFrame> plaintext_frame = get_frame (plaintext);
- shared_ptr<const dcp::ARGBFrame> encrypted_frame = get_frame (encrypted);
+ shared_ptr<const dcp::ARGBImage> plaintext_frame = get_frame (plaintext);
+ shared_ptr<const dcp::ARGBImage> encrypted_frame = get_frame (encrypted);
/* Check that plaintext and encrypted are the same */
BOOST_CHECK_EQUAL (plaintext_frame->stride(), encrypted_frame->stride());
/*
- 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 "image.h"
#include "rgb_xyz.h"
-#include "xyz_frame.h"
+#include "xyz_image.h"
#include "colour_conversion.h"
#include <boost/test/unit_test.hpp>
#include <boost/bind.hpp>
}
}
- shared_ptr<dcp::XYZFrame> xyz = dcp::rgb_to_xyz (rgb, dcp::ColourConversion::srgb_to_xyz ());
+ shared_ptr<dcp::XYZImage> xyz = dcp::rgb_to_xyz (rgb, dcp::ColourConversion::srgb_to_xyz ());
for (int y = 0; y < size.height; ++y) {
uint16_t* p = reinterpret_cast<uint16_t*> (rgb->data()[0] + y * rgb->stride()[0]);
/** Check that xyz_to_rgb clamps XYZ values correctly */
BOOST_AUTO_TEST_CASE (xyz_rgb_range_test)
{
- shared_ptr<dcp::XYZFrame> xyz (new dcp::XYZFrame (dcp::Size (2, 2)));
+ shared_ptr<dcp::XYZImage> xyz (new dcp::XYZImage (dcp::Size (2, 2)));
xyz->data(0)[0] = -4;
xyz->data(0)[1] = 6901;
/*
- Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-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 "test.h"
#include "cpl.h"
#include "mono_picture_frame.h"
-#include "argb_frame.h"
+#include "argb_image.h"
#include "certificate_chain.h"
#include "mono_picture_mxf_writer.h"
#include "reel_picture_asset.h"
BOOST_CHECK (!kdm_B.keys().empty ());
mxf_B->set_key (kdm_B.keys().front().key());
- shared_ptr<dcp::ARGBFrame> frame_A = mxf_A->get_frame(0)->argb_frame ();
- shared_ptr<dcp::ARGBFrame> frame_B = mxf_B->get_frame(0)->argb_frame ();
+ shared_ptr<dcp::ARGBImage> frame_A = mxf_A->get_frame(0)->argb_image ();
+ shared_ptr<dcp::ARGBImage> frame_B = mxf_B->get_frame(0)->argb_image ();
BOOST_CHECK_EQUAL (frame_A->size().width, frame_B->size().width);
BOOST_CHECK_EQUAL (frame_A->size().height, frame_B->size().height);
BOOST_CHECK_EQUAL (memcmp (frame_A->data(), frame_B->data(), frame_A->size().width * frame_A->size().height), 0);
else:
obj.use = 'libdcp%s' % bld.env.API_VERSION
obj.source = """
- argb_frame_test.cc
+ argb_image_test.cc
certificates_test.cc
colour_test.cc
colour_conversion_test.cc