Add rgb_to_xyz for packed int16_t. v1.8.87
authorCarl Hetherington <cth@carlh.net>
Sun, 3 Sep 2023 22:48:10 +0000 (00:48 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 18 Oct 2023 10:53:58 +0000 (12:53 +0200)
Adapted from a patch from Aaron Boxer for grok support.

src/rgb_xyz.cc
src/rgb_xyz.h

index 49f9e905575da164046f217aff3c421013ea1082..e6c5105d6fc9f5877b5a0569bd21c653e3eda2ae 100644 (file)
@@ -266,14 +266,13 @@ dcp::make_inverse_gamma_lut(shared_ptr<const TransferFunction> fn)
 }
 
 
-
-static
+template <class T>
 void
 rgb_to_xyz_internal(
        uint8_t const* rgb,
-       int*& xyz_x,
-       int*& xyz_y,
-       int*& xyz_z,
+       T*& xyz_x,
+       T*& xyz_y,
+       T*& xyz_z,
        dcp::Size size,
        int stride,
        ColourConversion const& conversion,
@@ -357,3 +356,15 @@ dcp::rgb_to_xyz (
 }
 
 
+void
+dcp::rgb_to_xyz (
+       uint8_t const * rgb,
+       uint16_t* dst,
+       dcp::Size size,
+       int stride,
+       ColourConversion const & conversion,
+       optional<NoteHandler> note
+       )
+{
+       rgb_to_xyz_internal(rgb, dst, dst, dst, size, stride, conversion, note);
+}
index d6fb4d35df559e2de60ac3d598e75621b7df5006..22e1396d688064d693bba7cd1a7f160a71456cb2 100644 (file)
@@ -94,6 +94,22 @@ extern void xyz_to_rgb (
 
 extern PiecewiseLUT2 make_inverse_gamma_lut(std::shared_ptr<const TransferFunction> fn);
 
+/** @param rgb RGB data; 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.
+ *  @param dst Buffer to fill with packed 16-bit XYZ data, i.e. first
+ *  16-bit word is X, second is Y etc.
+ *  @param size size of RGB image in pixels.
+ *  @param size stride of RGB data in pixels.
+ */
+extern void rgb_to_xyz (
+       uint8_t const * rgb,
+       uint16_t* dst,
+       dcp::Size size,
+       int stride,
+       ColourConversion const & conversion,
+       boost::optional<NoteHandler> note = boost::optional<NoteHandler>()
+       );
 
 /** @param rgb RGB data; packed RGB 16:16:16, 48bpp, 16R, 16G, 16B,
  *  with the 2-byte value for each R/G/B component stored as