* 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
{
}
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
);
}
namespace dcp {
class ARGBFrame;
+class Image;
/** @class MonoPictureFrame
* @brief A single frame of a 2D (monoscopic) picture asset.
~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;
/** 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
)
{
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++;
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;
}
}
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);
}
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) {
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 *
namespace dcp {
class ARGBFrame;
+class Image;
/** A single frame of a 3D (stereoscopic) picture asset */
class StereoPictureFrame : public boost::noncopyable
~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;
xyz->data(2)[2] = 0;
xyz->data(2)[3] = 4095;
- uint16_t buffer[12];
+ shared_ptr<SimpleImage> image (new SimpleImage (dcp::Size (2, 2)));
notes.clear ();
- dcp::xyz_to_rgb (xyz, dcp::ColourConversion::xyz_to_srgb (), buffer, boost::optional<dcp::NoteHandler> (boost::bind (¬e_handler, _1, _2)));
+ dcp::xyz_to_rgb (xyz, dcp::ColourConversion::xyz_to_srgb (), image, boost::optional<dcp::NoteHandler> (boost::bind (¬e_handler, _1, _2)));
/* The 6 out-of-range samples should have been noted */
BOOST_REQUIRE_EQUAL (notes.size(), 6);
as inputs at the extremes (0 and 4095).
*/
+ uint16_t* buffer = reinterpret_cast<uint16_t*> (image->data()[0]);
BOOST_REQUIRE_EQUAL (buffer[0 * 3 + 0], buffer[2 * 3 + 1]);
BOOST_REQUIRE_EQUAL (buffer[0 * 3 + 1], buffer[2 * 3 + 1]);
BOOST_REQUIRE_EQUAL (buffer[0 * 3 + 2], buffer[2 * 3 + 2]);