From 0d7fe66361a40702cb97357955cf35256f1d2c26 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 2 Feb 2015 19:25:43 +0000 Subject: Rename XYZFrame -> XYZImage and ARGBFrame -> ARGBImage. --- src/argb_frame.cc | 49 ------------------------ src/argb_frame.h | 71 ----------------------------------- src/argb_image.cc | 49 ++++++++++++++++++++++++ src/argb_image.h | 71 +++++++++++++++++++++++++++++++++++ src/mono_picture_frame.cc | 6 +-- src/mono_picture_frame.h | 4 +- src/picture_mxf.cc | 6 +-- src/rgb_xyz.cc | 50 ++++++++++++------------- src/rgb_xyz.h | 14 +++---- src/stereo_picture_frame.cc | 22 +++++------ src/stereo_picture_frame.h | 4 +- src/util.cc | 8 ++-- src/util.h | 6 +-- src/wscript | 8 ++-- src/xyz_frame.cc | 90 --------------------------------------------- src/xyz_frame.h | 55 --------------------------- src/xyz_image.cc | 90 +++++++++++++++++++++++++++++++++++++++++++++ src/xyz_image.h | 55 +++++++++++++++++++++++++++ 18 files changed, 329 insertions(+), 329 deletions(-) delete mode 100644 src/argb_frame.cc delete mode 100644 src/argb_frame.h create mode 100644 src/argb_image.cc create mode 100644 src/argb_image.h delete mode 100644 src/xyz_frame.cc delete mode 100644 src/xyz_frame.h create mode 100644 src/xyz_image.cc create mode 100644 src/xyz_image.h (limited to 'src') diff --git a/src/argb_frame.cc b/src/argb_frame.cc deleted file mode 100644 index 99d6c814..00000000 --- a/src/argb_frame.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - 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 - 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; -} diff --git a/src/argb_frame.h b/src/argb_frame.h deleted file mode 100644 index db0d07a9..00000000 --- a/src/argb_frame.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - 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 - 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 - -namespace dcp -{ - -/** @class ARGBFrame - * @brief A single frame of picture data held in an ARGB buffer. - * - * The format of the data is: - * - *
- *  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| ...
- *  
- * - * 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 -}; - -} diff --git a/src/argb_image.cc b/src/argb_image.cc new file mode 100644 index 00000000..79dcd85a --- /dev/null +++ b/src/argb_image.cc @@ -0,0 +1,49 @@ +/* + Copyright (C) 2012-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 + 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; +} diff --git a/src/argb_image.h b/src/argb_image.h new file mode 100644 index 00000000..805d0a22 --- /dev/null +++ b/src/argb_image.h @@ -0,0 +1,71 @@ +/* + 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 + 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 + +namespace dcp +{ + +/** @class ARGBImage + * @brief A single frame of picture data held in an ARGB buffer. + * + * The format of the data is: + * + *
+ *  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| ...
+ *  
+ * + * 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 +}; + +} diff --git a/src/mono_picture_frame.cc b/src/mono_picture_frame.cc index 563853ba..1edfd411 100644 --- a/src/mono_picture_frame.cc +++ b/src/mono_picture_frame.cc @@ -23,7 +23,7 @@ #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" @@ -119,8 +119,8 @@ MonoPictureFrame::j2k_size () const * 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 -MonoPictureFrame::argb_frame (int reduce) const +shared_ptr +MonoPictureFrame::argb_image (int reduce) const { return xyz_to_rgba ( decompress_j2k (const_cast (_buffer->RoData()), _buffer->Size(), reduce), diff --git a/src/mono_picture_frame.h b/src/mono_picture_frame.h index fde918fb..c9183a12 100644 --- a/src/mono_picture_frame.h +++ b/src/mono_picture_frame.h @@ -38,7 +38,7 @@ namespace ASDCP { namespace dcp { -class ARGBFrame; +class ARGBImage; class Image; /** @class MonoPictureFrame @@ -52,7 +52,7 @@ public: MonoPictureFrame (); ~MonoPictureFrame (); - boost::shared_ptr argb_frame (int reduce = 0) const; + boost::shared_ptr argb_image (int reduce = 0) const; void rgb_frame (boost::shared_ptr rgb, boost::optional note = boost::optional ()) const; uint8_t const * j2k_data () const; uint8_t* j2k_data (); diff --git a/src/picture_mxf.cc b/src/picture_mxf.cc index 0991cd50..46aa7752 100644 --- a/src/picture_mxf.cc +++ b/src/picture_mxf.cc @@ -20,7 +20,7 @@ #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" @@ -124,8 +124,8 @@ PictureMXF::frame_buffer_equals ( } /* Decompress the images to bitmaps */ - shared_ptr image_A = decompress_j2k (const_cast (data_A), size_A, 0); - shared_ptr image_B = decompress_j2k (const_cast (data_B), size_B, 0); + shared_ptr image_A = decompress_j2k (const_cast (data_A), size_A, 0); + shared_ptr image_B = decompress_j2k (const_cast (data_B), size_B, 0); /* Compare them */ diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc index c5dbcb8f..f44b1a30 100644 --- a/src/rgb_xyz.cc +++ b/src/rgb_xyz.cc @@ -18,8 +18,8 @@ */ #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" @@ -37,12 +37,12 @@ using namespace dcp; #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 +shared_ptr dcp::xyz_to_rgba ( - boost::shared_ptr xyz_frame, + boost::shared_ptr xyz_image, ColourConversion const & conversion ) { @@ -56,20 +56,20 @@ dcp::xyz_to_rgba ( 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 argb_frame (new ARGBFrame (xyz_frame->size ())); - uint8_t* argb = argb_frame->data (); + shared_ptr 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 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); @@ -104,14 +104,14 @@ dcp::xyz_to_rgba ( *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, @@ -120,7 +120,7 @@ dcp::xyz_to_rgba ( */ void dcp::xyz_to_rgb ( - shared_ptr xyz_frame, + shared_ptr xyz_image, ColourConversion const & conversion, shared_ptr rgb, optional note @@ -135,17 +135,17 @@ dcp::xyz_to_rgb ( } 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 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 (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++; @@ -206,13 +206,13 @@ dcp::xyz_to_rgb ( /** 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 +shared_ptr dcp::rgb_to_xyz ( boost::shared_ptr rgb, ColourConversion const & conversion ) { - shared_ptr xyz (new XYZFrame (rgb->size ())); + shared_ptr xyz (new XYZImage (rgb->size ())); struct { double r, g, b; @@ -266,10 +266,10 @@ dcp::rgb_to_xyz ( /** 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 +shared_ptr dcp::xyz_to_xyz (shared_ptr xyz_16) { - shared_ptr xyz_12 (new XYZFrame (xyz_16->size ())); + shared_ptr xyz_12 (new XYZImage (xyz_16->size ())); int jn = 0; for (int y = 0; y < xyz_16->size().height; ++y) { diff --git a/src/rgb_xyz.h b/src/rgb_xyz.h index 0c998e41..cd0125cb 100644 --- a/src/rgb_xyz.h +++ b/src/rgb_xyz.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-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 @@ -24,19 +24,19 @@ namespace dcp { -class ARGBFrame; -class XYZFrame; +class ARGBImage; +class XYZImage; class Image; class ColourConversion; -extern boost::shared_ptr xyz_to_rgba (boost::shared_ptr, ColourConversion const & conversion); +extern boost::shared_ptr xyz_to_rgba (boost::shared_ptr, ColourConversion const & conversion); extern void xyz_to_rgb ( - boost::shared_ptr, + boost::shared_ptr, ColourConversion const & conversion, boost::shared_ptr rgb, boost::optional note = boost::optional () ); -extern boost::shared_ptr rgb_to_xyz (boost::shared_ptr, ColourConversion const & conversion); -extern boost::shared_ptr xyz_to_xyz (boost::shared_ptr); +extern boost::shared_ptr rgb_to_xyz (boost::shared_ptr, ColourConversion const & conversion); +extern boost::shared_ptr xyz_to_xyz (boost::shared_ptr); } diff --git a/src/stereo_picture_frame.cc b/src/stereo_picture_frame.cc index 060e86cc..0eae7583 100644 --- a/src/stereo_picture_frame.cc +++ b/src/stereo_picture_frame.cc @@ -19,7 +19,7 @@ #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" @@ -74,36 +74,36 @@ StereoPictureFrame::~StereoPictureFrame () * third red and fourth alpha (always 255). * */ -shared_ptr -StereoPictureFrame::argb_frame (Eye eye, int reduce) const +shared_ptr +StereoPictureFrame::argb_image (Eye eye, int reduce) const { - shared_ptr xyz_frame; + shared_ptr xyz_image; switch (eye) { case LEFT: - xyz_frame = decompress_j2k (const_cast (_buffer->Left.RoData()), _buffer->Left.Size(), reduce); + xyz_image = decompress_j2k (const_cast (_buffer->Left.RoData()), _buffer->Left.Size(), reduce); break; case RIGHT: - xyz_frame = decompress_j2k (const_cast (_buffer->Right.RoData()), _buffer->Right.Size(), reduce); + xyz_image = decompress_j2k (const_cast (_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) const { - shared_ptr xyz_frame; + shared_ptr xyz_image; switch (eye) { case LEFT: - xyz_frame = decompress_j2k (const_cast (_buffer->Left.RoData()), _buffer->Left.Size(), 0); + xyz_image = decompress_j2k (const_cast (_buffer->Left.RoData()), _buffer->Left.Size(), 0); break; case RIGHT: - xyz_frame = decompress_j2k (const_cast (_buffer->Right.RoData()), _buffer->Right.Size(), 0); + xyz_image = decompress_j2k (const_cast (_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 * diff --git a/src/stereo_picture_frame.h b/src/stereo_picture_frame.h index d1aa6137..ba78d922 100644 --- a/src/stereo_picture_frame.h +++ b/src/stereo_picture_frame.h @@ -33,7 +33,7 @@ namespace ASDCP { namespace dcp { -class ARGBFrame; +class ARGBImage; class Image; /** A single frame of a 3D (stereoscopic) picture asset */ @@ -44,7 +44,7 @@ public: StereoPictureFrame (); ~StereoPictureFrame (); - boost::shared_ptr argb_frame (Eye eye, int reduce = 0) const; + boost::shared_ptr argb_image (Eye eye, int reduce = 0) const; void rgb_frame (Eye eye, boost::shared_ptr) const; uint8_t const * left_j2k_data () const; uint8_t* left_j2k_data (); diff --git a/src/util.cc b/src/util.cc index ac067a76..89b563ae 100644 --- a/src/util.cc +++ b/src/util.cc @@ -24,9 +24,9 @@ #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" @@ -202,7 +202,7 @@ dcp::content_kind_from_string (string kind) * This is useful for scaling 4K DCP images down to 2K. * @return XYZ image. */ -shared_ptr +shared_ptr dcp::decompress_j2k (uint8_t* data, int64_t size, int reduce) { opj_dinfo_t* decoder = opj_create_decompress (CODEC_J2K); @@ -223,7 +223,7 @@ dcp::decompress_j2k (uint8_t* data, int64_t size, int reduce) image->x1 = rint (float(image->x1) / pow (2, reduce)); image->y1 = rint (float(image->y1) / pow (2, reduce)); - return shared_ptr (new XYZFrame (image)); + return shared_ptr (new XYZImage (image)); } /** @param s A string. diff --git a/src/util.h b/src/util.h index 857f872f..5bc3a78d 100644 --- a/src/util.h +++ b/src/util.h @@ -39,10 +39,10 @@ namespace xmlpp { namespace dcp { -class ARGBFrame; +class ARGBImage; class CertificateChain; class GammaLUT; -class XYZFrame; +class XYZImage; /** @struct Size * @brief The integer, two-dimensional size of something. @@ -76,7 +76,7 @@ extern std::string make_digest (boost::filesystem::path filename, boost::functio 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 decompress_j2k (uint8_t* data, int64_t size, int reduce); +extern boost::shared_ptr decompress_j2k (uint8_t* data, int64_t size, int reduce); extern bool ids_equal (std::string a, std::string b); extern void init (); diff --git a/src/wscript b/src/wscript index d6444aee..af7b823e 100644 --- a/src/wscript +++ b/src/wscript @@ -2,7 +2,7 @@ from waflib import TaskGen def build(bld): source = """ - argb_frame.cc + argb_image.cc asset.cc certificate_chain.cc certificates.cc @@ -60,7 +60,7 @@ def build(bld): types.cc util.cc version.cc - xyz_frame.cc + xyz_image.cc """ headers = """ @@ -104,7 +104,7 @@ def build(bld): 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 @@ -120,7 +120,7 @@ def build(bld): types.h util.h version.h - xyz_frame.h + xyz_image.h """ # Main library diff --git a/src/xyz_frame.cc b/src/xyz_frame.cc deleted file mode 100644 index f1c69491..00000000 --- a/src/xyz_frame.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* - 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 - 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 - -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); -} diff --git a/src/xyz_frame.h b/src/xyz_frame.h deleted file mode 100644 index 8ba829b2..00000000 --- a/src/xyz_frame.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - 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 - 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 - -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 -}; - -} diff --git a/src/xyz_image.cc b/src/xyz_image.cc new file mode 100644 index 00000000..48ee6ad6 --- /dev/null +++ b/src/xyz_image.cc @@ -0,0 +1,90 @@ +/* + Copyright (C) 2012-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 + 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 + +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); +} diff --git a/src/xyz_image.h b/src/xyz_image.h new file mode 100644 index 00000000..6be065e0 --- /dev/null +++ b/src/xyz_image.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2012-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 + 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 + +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 +}; + +} -- cgit v1.2.3