From 141cd3021e250057fdd8d5d558af3a2418f5850b Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 10 May 2022 15:55:36 +0300 Subject: [PATCH] tests/color_util: add transfer_fn_invert() When defining a color space with a transfer function, this looks up the inverse transfer function without needing to store that separately. Signed-off-by: Pekka Paalanen --- tests/color_util.c | 23 +++++++++++++++++++++++ tests/color_util.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/tests/color_util.c b/tests/color_util.c index b8c66997..cc4d3fab 100644 --- a/tests/color_util.c +++ b/tests/color_util.c @@ -93,6 +93,29 @@ find_tone_curve_type(enum transfer_fn fn, int *type, double params[5]) return false; } +enum transfer_fn +transfer_fn_invert(enum transfer_fn fn) +{ + switch (fn) { + case TRANSFER_FN_ADOBE_RGB_EOTF: + return TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE; + case TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE: + return TRANSFER_FN_ADOBE_RGB_EOTF; + case TRANSFER_FN_IDENTITY: + return TRANSFER_FN_IDENTITY; + case TRANSFER_FN_POWER2_4_EOTF: + return TRANSFER_FN_POWER2_4_EOTF_INVERSE; + case TRANSFER_FN_POWER2_4_EOTF_INVERSE: + return TRANSFER_FN_POWER2_4_EOTF; + case TRANSFER_FN_SRGB_EOTF: + return TRANSFER_FN_SRGB_EOTF_INVERSE; + case TRANSFER_FN_SRGB_EOTF_INVERSE: + return TRANSFER_FN_SRGB_EOTF; + } + assert(0 && "bad transfer_fn"); + return 0; +} + /** * NaN comes out as is *This function is not intended for hiding NaN. diff --git a/tests/color_util.h b/tests/color_util.h index b4cd1f55..14fd6095 100644 --- a/tests/color_util.h +++ b/tests/color_util.h @@ -106,3 +106,6 @@ process_pixel_using_pipeline(enum transfer_fn pre_curve, struct color_float color_float_apply_matrix(const struct lcmsMAT3 *mat, struct color_float c); + +enum transfer_fn +transfer_fn_invert(enum transfer_fn fn);