summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-02-02 18:42:54 +0000
committerCarl Hetherington <cth@carlh.net>2015-02-02 18:42:54 +0000
commit923d5a17cdbe4c4ae947bbb45493be0792cfd54e (patch)
treec30cc659bb94aaf8231bb5f8c790e3d60a3362b1 /src
parentb47a54b85aee24795008463681cb31f4307ffe84 (diff)
Unpack XYZ to RGB into an Image class rather than a raw buffer.
Diffstat (limited to 'src')
-rw-r--r--src/argb_frame.h2
-rw-r--r--src/mono_picture_frame.cc4
-rw-r--r--src/mono_picture_frame.h3
-rw-r--r--src/rgb_xyz.cc21
-rw-r--r--src/rgb_xyz.h2
-rw-r--r--src/stereo_picture_frame.cc4
-rw-r--r--src/stereo_picture_frame.h3
7 files changed, 21 insertions, 18 deletions
diff --git a/src/argb_frame.h b/src/argb_frame.h
index 419227bb..db0d07a9 100644
--- a/src/argb_frame.h
+++ b/src/argb_frame.h
@@ -41,6 +41,8 @@ namespace dcp
* 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
{
diff --git a/src/mono_picture_frame.cc b/src/mono_picture_frame.cc
index 9c0c3cae..563853ba 100644
--- a/src/mono_picture_frame.cc
+++ b/src/mono_picture_frame.cc
@@ -129,12 +129,12 @@ MonoPictureFrame::argb_frame (int reduce) const
}
void
-MonoPictureFrame::rgb_frame (uint16_t* buffer, optional<NoteHandler> note) const
+MonoPictureFrame::rgb_frame (shared_ptr<Image> rgb, optional<NoteHandler> note) const
{
xyz_to_rgb (
decompress_j2k (const_cast<uint8_t*> (_buffer->RoData()), _buffer->Size(), 0),
ColourConversion::xyz_to_srgb (),
- buffer,
+ rgb,
note
);
}
diff --git a/src/mono_picture_frame.h b/src/mono_picture_frame.h
index aaafe398..fde918fb 100644
--- a/src/mono_picture_frame.h
+++ b/src/mono_picture_frame.h
@@ -39,6 +39,7 @@ namespace ASDCP {
namespace dcp {
class ARGBFrame;
+class Image;
/** @class MonoPictureFrame
* @brief A single frame of a 2D (monoscopic) picture asset.
@@ -52,7 +53,7 @@ public:
~MonoPictureFrame ();
boost::shared_ptr<ARGBFrame> argb_frame (int reduce = 0) const;
- void rgb_frame (uint16_t* buffer, boost::optional<NoteHandler> note = boost::optional<NoteHandler> ()) 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 ();
int j2k_size () const;
diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc
index a839dfa0..c5dbcb8f 100644
--- a/src/rgb_xyz.cc
+++ b/src/rgb_xyz.cc
@@ -113,15 +113,16 @@ dcp::xyz_to_rgba (
/** Convert an openjpeg XYZ image to RGB.
* @param xyz_frame Frame in XYZ.
* @param conversion Colour conversion to use.
- * @param buffer Buffer to write RGB data to; rgb will 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.
+ * @param rgb Image to write RGB data to; must have space to be
+ * filled with 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.
*/
void
dcp::xyz_to_rgb (
- boost::shared_ptr<const XYZFrame> xyz_frame,
+ shared_ptr<const XYZFrame> xyz_frame,
ColourConversion const & conversion,
- uint16_t* buffer,
+ shared_ptr<Image> rgb,
optional<NoteHandler> note
)
{
@@ -143,7 +144,7 @@ dcp::xyz_to_rgb (
boost::numeric::ublas::matrix<double> matrix = conversion.matrix ();
for (int y = 0; y < xyz_frame->size().height; ++y) {
- uint16_t* buffer_line = buffer;
+ 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) {
int cx = *xyz_x++;
@@ -195,12 +196,10 @@ dcp::xyz_to_rgb (
d.b = min (d.b, 1.0);
d.b = max (d.b, 0.0);
- *buffer_line++ = rint(lut_out[int(rint(d.r * 65535))] * 65535);
- *buffer_line++ = rint(lut_out[int(rint(d.g * 65535))] * 65535);
- *buffer_line++ = rint(lut_out[int(rint(d.b * 65535))] * 65535);
+ *rgb_line++ = rint(lut_out[int(rint(d.r * 65535))] * 65535);
+ *rgb_line++ = rint(lut_out[int(rint(d.g * 65535))] * 65535);
+ *rgb_line++ = rint(lut_out[int(rint(d.b * 65535))] * 65535);
}
-
- buffer += xyz_frame->size().width * 3;
}
}
diff --git a/src/rgb_xyz.h b/src/rgb_xyz.h
index 53568350..0c998e41 100644
--- a/src/rgb_xyz.h
+++ b/src/rgb_xyz.h
@@ -33,7 +33,7 @@ extern boost::shared_ptr<ARGBFrame> xyz_to_rgba (boost::shared_ptr<const XYZFram
extern void xyz_to_rgb (
boost::shared_ptr<const XYZFrame>,
ColourConversion const & conversion,
- uint16_t* buffer,
+ 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);
diff --git a/src/stereo_picture_frame.cc b/src/stereo_picture_frame.cc
index e0ed6905..060e86cc 100644
--- a/src/stereo_picture_frame.cc
+++ b/src/stereo_picture_frame.cc
@@ -91,7 +91,7 @@ StereoPictureFrame::argb_frame (Eye eye, int reduce) const
}
void
-StereoPictureFrame::rgb_frame (Eye eye, uint16_t* buffer) const
+StereoPictureFrame::rgb_frame (Eye eye, shared_ptr<Image> image) const
{
shared_ptr<XYZFrame> xyz_frame;
switch (eye) {
@@ -103,7 +103,7 @@ StereoPictureFrame::rgb_frame (Eye eye, uint16_t* buffer) const
break;
}
- return xyz_to_rgb (xyz_frame, ColourConversion::xyz_to_srgb (), buffer);
+ return xyz_to_rgb (xyz_frame, ColourConversion::xyz_to_srgb (), image);
}
uint8_t const *
diff --git a/src/stereo_picture_frame.h b/src/stereo_picture_frame.h
index 7c4d6767..d1aa6137 100644
--- a/src/stereo_picture_frame.h
+++ b/src/stereo_picture_frame.h
@@ -34,6 +34,7 @@ namespace ASDCP {
namespace dcp {
class ARGBFrame;
+class Image;
/** A single frame of a 3D (stereoscopic) picture asset */
class StereoPictureFrame : public boost::noncopyable
@@ -44,7 +45,7 @@ public:
~StereoPictureFrame ();
boost::shared_ptr<ARGBFrame> argb_frame (Eye eye, int reduce = 0) const;
- void rgb_frame (Eye eye, uint16_t* buffer) const;
+ void rgb_frame (Eye eye, boost::shared_ptr<Image>) const;
uint8_t const * left_j2k_data () const;
uint8_t* left_j2k_data ();
int left_j2k_size () const;