From 718f7f56df309582af1a183831a3123f79fa8d70 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 25 Apr 2025 16:44:33 +0300 Subject: [PATCH] tests/color_util: add power-2.2 transfer function This is needed by the next commit. Signed-off-by: Pekka Paalanen --- tests/color_util.c | 28 ++++++++++++++++++++++++++++ tests/color_util.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/tests/color_util.c b/tests/color_util.c index 86b59a596..27a2627d3 100644 --- a/tests/color_util.c +++ b/tests/color_util.c @@ -114,6 +114,20 @@ AdobeRGB_EOTF_inv(float o) return pow(o, 256./563.); } +static float +Power2_2_EOTF(float e) +{ + e = ensure_unit_range(e); + return pow(e, 2.2); +} + +static float +Power2_2_EOTF_inv(float o) +{ + o = ensure_unit_range(o); + return pow(o, 1./2.2); +} + static float Power2_4_EOTF(float e) { @@ -169,6 +183,20 @@ static const struct tone_curve_info tone_curves[] = { .apply = AdobeRGB_EOTF_inv, .lcms2 = { -1, { 563./256., 0.0, 0.0, 0.0 , 0.0 }}, }, + [TRANSFER_FN_POWER2_2_EOTF] = { + .fn = TRANSFER_FN_POWER2_2_EOTF, + .name = "power 2.2", + .inv_fn = TRANSFER_FN_POWER2_2_EOTF_INVERSE, + .apply = Power2_2_EOTF, + .lcms2 = { 1, { 2.2, 0.0, 0.0, 0.0 , 0.0 }}, + }, + [TRANSFER_FN_POWER2_2_EOTF_INVERSE] = { + .fn = TRANSFER_FN_POWER2_2_EOTF_INVERSE, + .name = "inverse power 2.2", + .inv_fn = TRANSFER_FN_POWER2_2_EOTF, + .apply = Power2_2_EOTF_inv, + .lcms2 = { -1, { 2.2, 0.0, 0.0, 0.0 , 0.0 }}, + }, [TRANSFER_FN_POWER2_4_EOTF] = { .fn = TRANSFER_FN_POWER2_4_EOTF, .name = "power 2.4", diff --git a/tests/color_util.h b/tests/color_util.h index fabb09b47..1abb890d7 100644 --- a/tests/color_util.h +++ b/tests/color_util.h @@ -56,6 +56,8 @@ enum transfer_fn { TRANSFER_FN_SRGB_INVERSE, TRANSFER_FN_ADOBE_RGB_EOTF, TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE, + TRANSFER_FN_POWER2_2_EOTF, + TRANSFER_FN_POWER2_2_EOTF_INVERSE, TRANSFER_FN_POWER2_4_EOTF, TRANSFER_FN_POWER2_4_EOTF_INVERSE, };