summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-10-24 22:26:50 +0100
committerCarl Hetherington <cth@carlh.net>2014-10-24 22:26:50 +0100
commit0073935231a225fe488105eec416bc9350fd9496 (patch)
treeaa2dfba7978cf8493e0e9e79886cfced4adf600a /src
parent00125c40d40e124abfca89aa678cd260815adae9 (diff)
Add xyz_to_xyz to do what rgb_to_xyz does without the colourspace conversion.
Diffstat (limited to 'src')
-rw-r--r--src/rgb_xyz.cc23
-rw-r--r--src/rgb_xyz.h2
2 files changed, 25 insertions, 0 deletions
diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc
index 0400ad88..40949f07 100644
--- a/src/rgb_xyz.cc
+++ b/src/rgb_xyz.cc
@@ -161,3 +161,26 @@ libdcp::rgb_to_xyz (shared_ptr<const Image> rgb, shared_ptr<const LUT> lut_in, s
return 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<libdcp::XYZFrame>
+libdcp::xyz_to_xyz (shared_ptr<const Image> xyz_16)
+{
+ shared_ptr<XYZFrame> xyz_12 (new XYZFrame (xyz_16->size ()));
+
+ int jn = 0;
+ for (int y = 0; y < xyz_16->size().height; ++y) {
+ uint16_t* p = reinterpret_cast<uint16_t *> (xyz_16->data()[0] + y * xyz_16->stride()[0]);
+ for (int x = 0; x < xyz_16->size().width; ++x) {
+ /* Truncate 16-bit to 12-bit */
+ xyz_12->data(0)[jn] = *p++ >> 4;
+ xyz_12->data(1)[jn] = *p++ >> 4;
+ xyz_12->data(2)[jn] = *p++ >> 4;
+ ++jn;
+ }
+ }
+
+ return xyz_12;
+}
diff --git a/src/rgb_xyz.h b/src/rgb_xyz.h
index 87959cb3..734401dc 100644
--- a/src/rgb_xyz.h
+++ b/src/rgb_xyz.h
@@ -33,5 +33,7 @@ extern boost::shared_ptr<ARGBFrame> xyz_to_rgb (
extern boost::shared_ptr<XYZFrame> rgb_to_xyz (
boost::shared_ptr<const Image>, boost::shared_ptr<const LUT>, boost::shared_ptr<const LUT>, double const colour_matrix[3][3]
);
+
+extern boost::shared_ptr<XYZFrame> xyz_to_xyz (boost::shared_ptr<const Image>);
}