From 621926b6bfc15b6bb0d87c03b00bf831b46e7b14 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 18 Oct 2023 10:39:26 +0200 Subject: [PATCH] Split rgb_to_xyz() into two parts. --- src/rgb_xyz.cc | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc index 988f9bac..49f9e905 100644 --- a/src/rgb_xyz.cc +++ b/src/rgb_xyz.cc @@ -266,17 +266,20 @@ dcp::make_inverse_gamma_lut(shared_ptr fn) } -shared_ptr -dcp::rgb_to_xyz ( - uint8_t const * rgb, + +static +void +rgb_to_xyz_internal( + uint8_t const* rgb, + int*& xyz_x, + int*& xyz_y, + int*& xyz_z, dcp::Size size, int stride, - ColourConversion const & conversion, + ColourConversion const& conversion, optional note ) { - auto xyz = make_shared(size); - struct { double r, g, b; } s; @@ -293,9 +296,6 @@ dcp::rgb_to_xyz ( combined_rgb_to_xyz (conversion, fast_matrix); int clamped = 0; - int* xyz_x = xyz->data (0); - int* xyz_y = xyz->data (1); - int* xyz_z = xyz->data (2); for (int y = 0; y < size.height; ++y) { auto p = reinterpret_cast (rgb + y * stride); for (int x = 0; x < size.width; ++x) { @@ -333,6 +333,27 @@ dcp::rgb_to_xyz ( if (clamped && note) { note.get()(NoteType::NOTE, String::compose("%1 XYZ value(s) clamped", clamped)); } +} + + +shared_ptr +dcp::rgb_to_xyz ( + uint8_t const * rgb, + dcp::Size size, + int stride, + ColourConversion const & conversion, + optional note + ) +{ + auto xyz = make_shared(size); + + int* xyz_x = xyz->data (0); + int* xyz_y = xyz->data (1); + int* xyz_z = xyz->data (2); + + rgb_to_xyz_internal(rgb, xyz_x, xyz_y, xyz_z, size, stride, conversion, note); return xyz; } + + -- 2.30.2