summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-07-07 13:42:12 +0100
committerCarl Hetherington <cth@carlh.net>2014-07-07 13:42:12 +0100
commited18fc59be461a8f08ffa8d52897f2710e0359bf (patch)
tree95fa4a7169742152b97019ed229535c8e8c0cd3f /src
parent7103135fcf2e02458a2cfb53ba98d10cd450af8d (diff)
12-bit hacks.
Diffstat (limited to 'src')
-rw-r--r--src/rgb_xyz.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc
index dea2106c..ebe263cb 100644
--- a/src/rgb_xyz.cc
+++ b/src/rgb_xyz.cc
@@ -99,6 +99,9 @@ libdcp::xyz_to_rgb (shared_ptr<const XYZFrame> xyz_frame, shared_ptr<const LUT>
return argb_frame;
}
+/** Image must be packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian;
+ * i.e. AV_PIX_FMT_RGB48BE.
+ */
shared_ptr<libdcp::XYZFrame>
libdcp::rgb_to_xyz (shared_ptr<const Image> rgb, shared_ptr<const LUT> lut_in, shared_ptr<const LUT> lut_out, double const colour_matrix[3][3])
{
@@ -117,13 +120,13 @@ libdcp::rgb_to_xyz (shared_ptr<const Image> rgb, shared_ptr<const LUT> lut_in, s
int jn = 0;
for (int y = 0; y < rgb->size().height; ++y) {
- uint8_t* p = rgb->data()[0] + y * rgb->stride()[0];
+ uint16_t* p = reinterpret_cast<uint16_t *> (rgb->data()[0] + y * rgb->stride()[0]);
for (int x = 0; x < rgb->size().width; ++x) {
- /* In gamma LUT (converting 8-bit input to 12-bit) */
- s.r = lut_in->lut()[*p++ << 4];
- s.g = lut_in->lut()[*p++ << 4];
- s.b = lut_in->lut()[*p++ << 4];
+ /* In gamma LUT (truncating 16-bit to 12-bit) */
+ s.r = lut_in->lut()[*p++ >> 4];
+ s.g = lut_in->lut()[*p++ >> 4];
+ s.b = lut_in->lut()[*p++ >> 4];
/* RGB to XYZ Matrix */
d.x = ((s.r * colour_matrix[0][0]) +