From 130b5dc1d918194ceec756d2388c33665efcc169 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 25 Jun 2015 16:22:34 +0100 Subject: [PATCH] Clamp out-of-range XYZ values rather than assert()ing. --- src/rgb_xyz.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc index 509e320a..c27e18c7 100644 --- a/src/rgb_xyz.cc +++ b/src/rgb_xyz.cc @@ -166,9 +166,12 @@ libdcp::rgb_to_xyz ( e.y = e.y * DCI_COEFFICIENT * 65535; e.z = e.z * DCI_COEFFICIENT * 65535; - assert (e.x >= 0 && e.x < 65536); - assert (e.y >= 0 && e.y < 65536); - assert (e.z >= 0 && e.z < 65536); + e.x = max (0.0, e.x); + e.y = max (0.0, e.y); + e.z = max (0.0, e.z); + e.x = min (65535.0, e.x); + e.y = min (65535.0, e.y); + e.z = min (65535.0, e.z); /* Out gamma LUT */ xyz->data(0)[jn] = lut_out->lut()[(int) e.x] * 4096; -- 2.30.2