Add xyz_to_xyz, forward ported from 0.x.
authorCarl Hetherington <cth@carlh.net>
Sat, 25 Oct 2014 13:07:10 +0000 (14:07 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 25 Oct 2014 13:07:10 +0000 (14:07 +0100)
src/rgb_xyz.cc
src/rgb_xyz.h

index 98044403e14b5c7b4699653e8be7839336246b8f..f53a51ea8188f83d46ec2098513d68ec251e7905 100644 (file)
@@ -243,3 +243,27 @@ dcp::rgb_to_xyz (
 
        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<dcp::XYZFrame>
+dcp::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;
+}
index ee354d5346712b6ff10aa9a4939bd92671084c56..871473c0162b53dd41a5aed7dec06e19a07cabf1 100644 (file)
@@ -38,5 +38,7 @@ extern void xyz_to_rgb (
 extern boost::shared_ptr<XYZFrame> rgb_to_xyz (
        boost::shared_ptr<const Image>, boost::shared_ptr<const GammaLUT>, boost::shared_ptr<const GammaLUT>, double const colour_matrix[3][3]
        );
+
+extern boost::shared_ptr<XYZFrame> xyz_to_xyz (boost::shared_ptr<const Image>);
        
 }