diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-10-25 14:07:10 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-10-25 14:07:10 +0100 |
| commit | 134683a552de13cd27c981bb79f30019914ff9b3 (patch) | |
| tree | 0dc707736cbbcc578bd687d1043eff20100f9edf /src | |
| parent | 3909602e3fccfd8465862a6dbe768ec0025218f8 (diff) | |
Add xyz_to_xyz, forward ported from 0.x.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rgb_xyz.cc | 24 | ||||
| -rw-r--r-- | src/rgb_xyz.h | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc index 98044403..f53a51ea 100644 --- a/src/rgb_xyz.cc +++ b/src/rgb_xyz.cc @@ -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; +} diff --git a/src/rgb_xyz.h b/src/rgb_xyz.h index ee354d53..871473c0 100644 --- a/src/rgb_xyz.h +++ b/src/rgb_xyz.h @@ -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>); } |
