summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-10-18 10:39:26 +0200
committerCarl Hetherington <cth@carlh.net>2023-10-18 12:53:58 +0200
commit621926b6bfc15b6bb0d87c03b00bf831b46e7b14 (patch)
tree812b97df811d84a2282691c4229cd61c16b10c79 /src
parent06c02f781597a5679c9a2fcdc7a7c9f79f58f6f4 (diff)
Split rgb_to_xyz() into two parts.
Diffstat (limited to 'src')
-rw-r--r--src/rgb_xyz.cc39
1 files 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<const TransferFunction> fn)
}
-shared_ptr<dcp::OpenJPEGImage>
-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<NoteHandler> note
)
{
- auto xyz = make_shared<OpenJPEGImage>(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<uint16_t const *> (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::OpenJPEGImage>
+dcp::rgb_to_xyz (
+ uint8_t const * rgb,
+ dcp::Size size,
+ int stride,
+ ColourConversion const & conversion,
+ optional<NoteHandler> note
+ )
+{
+ auto xyz = make_shared<OpenJPEGImage>(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;
}
+
+