From c8195289a73ca54309bcc030a07873364c56df47 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 10 May 2022 11:12:38 +0300 Subject: [PATCH] tests/color_util: refactor into color_float_apply_curve() Make process_pixel_using_pipeline() slightly easier to read by extracting a meaningful function. Pure refactoring, no changes. Signed-off-by: Pekka Paalanen --- tests/color_util.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/color_util.c b/tests/color_util.c index aa24372d..66a23f3b 100644 --- a/tests/color_util.c +++ b/tests/color_util.c @@ -221,6 +221,17 @@ a8r8g8b8_to_float(uint32_t v) return cf; } +static struct color_float +color_float_apply_curve(enum transfer_fn fn, struct color_float c) +{ + unsigned i; + + for (i = 0; i < COLOR_CHAN_NUM; i++) + c.rgb[i] = apply_tone_curve(fn, c.rgb[i]); + + return c; +} + void process_pixel_using_pipeline(enum transfer_fn pre_curve, const struct lcmsMAT3 *mat, @@ -232,8 +243,7 @@ process_pixel_using_pipeline(enum transfer_fn pre_curve, struct color_float cf; float tmp; - for (i = 0; i < COLOR_CHAN_NUM; i++) - cf.rgb[i] = apply_tone_curve(pre_curve, in->rgb[i]); + cf = color_float_apply_curve(pre_curve, *in); for (i = 0; i < 3; i++) { tmp = 0.0f; @@ -242,6 +252,5 @@ process_pixel_using_pipeline(enum transfer_fn pre_curve, out->rgb[i] = tmp; } - for (i = 0; i < COLOR_CHAN_NUM; i++) - out->rgb[i] = apply_tone_curve(post_curve, out->rgb[i]); + *out = color_float_apply_curve(post_curve, *out); }