From 0e474b763f65f2b446db55ffc50f37a936393dee Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 19 Jun 2025 13:35:50 +0300 Subject: [PATCH] color-lcms: recognize single bounded curve segment I don't have a specific use case in my mind for this, but it is something we can easily handle. Signed-off-by: Pekka Paalanen --- libweston/color-lcms/color-curve-segments.c | 27 ++++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/libweston/color-lcms/color-curve-segments.c b/libweston/color-lcms/color-curve-segments.c index c879eebbf..51aae583e 100644 --- a/libweston/color-lcms/color-curve-segments.c +++ b/libweston/color-lcms/color-curve-segments.c @@ -583,15 +583,24 @@ get_defining_curve_segment(cmsToneCurve *from, bool *clamped_input) seg1 = cmsGetToneCurveSegment(1, from); seg2 = cmsGetToneCurveSegment(2, from); if (seg0 && !seg1) { - /* Case 1: we have a single segment (seg0). - * - * Ensure that the domain is (-inf, inf). - */ - if (!are_segment_breaks_equal(seg0->x0, -INFINITY) || - !are_segment_breaks_equal(seg0->x1, INFINITY)) - return NULL; - *clamped_input = false; - return seg0; + /* Case 1: we have a single segment (seg0). */ + + /* If the domain is (-inf, inf), the curve is unbounded. */ + if (are_segment_breaks_equal(seg0->x0, -INFINITY) && + are_segment_breaks_equal(seg0->x1, INFINITY)) { + *clamped_input = false; + return seg0; + } + + /* If the domain is [0.0, 1.0], the curve is bounded. */ + if (are_segment_breaks_equal(seg0->x0, 0.0) && + are_segment_breaks_equal(seg0->x1, 1.0)) { + *clamped_input = true; + return seg0; + } + + /* We don't handle anything else. */ + return NULL; } else if (seg0 && seg1 && seg2) { /* Case 2: we have three segments. Clamped input. *