From 0073935231a225fe488105eec416bc9350fd9496 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 24 Oct 2014 22:26:50 +0100 Subject: Add xyz_to_xyz to do what rgb_to_xyz does without the colourspace conversion. --- src/rgb_xyz.cc | 23 +++++++++++++++++++++++ src/rgb_xyz.h | 2 ++ 2 files changed, 25 insertions(+) (limited to 'src') 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 rgb, shared_ptr 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::xyz_to_xyz (shared_ptr xyz_16) +{ + shared_ptr 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 (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 xyz_to_rgb ( extern boost::shared_ptr rgb_to_xyz ( boost::shared_ptr, boost::shared_ptr, boost::shared_ptr, double const colour_matrix[3][3] ); + +extern boost::shared_ptr xyz_to_xyz (boost::shared_ptr); } -- cgit v1.2.3