From 3f605424056ffd77df62b51e06411ce651934fb6 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Mon, 20 Jun 2022 13:14:13 +0300 Subject: [PATCH] tests/color_util: make rgb_diff_stat pos explicit The recently introduced rgb_diff_stat value dumping feature logs the "position" where the value or error was measured. The reference value was used as the position, but the problem with the reference value is that it is an output value and not an input value. Therefore mapping that back to which input values promoted the error is not easy. Fix that problem by passing the position explicitly into rgb_diff_stat_update(), just like it is already passed in to scalar_stat_update(). Currently the only user simply passes the reference value as position, because there the input value is also the reference value. This is not true for future uses of rgb_diff_stat. Signed-off-by: Pekka Paalanen --- tests/color-icc-output-test.c | 2 +- tests/color_util.c | 7 ++++--- tests/color_util.h | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/color-icc-output-test.c b/tests/color-icc-output-test.c index 2f2de05e..682e10c7 100644 --- a/tests/color-icc-output-test.c +++ b/tests/color-icc-output-test.c @@ -175,7 +175,7 @@ test_roundtrip(uint8_t r, uint8_t g, uint8_t b, cmsPipeline *pip, struct color_float out = {}; cmsPipelineEvalFloat(in.rgb, out.rgb, pip); - rgb_diff_stat_update(stat, &in, &out); + rgb_diff_stat_update(stat, &in, &out, &in); } /* diff --git a/tests/color_util.c b/tests/color_util.c index da2f5c6b..9267aefe 100644 --- a/tests/color_util.c +++ b/tests/color_util.c @@ -449,7 +449,8 @@ rgb_diff_stat_print(const struct rgb_diff_stat *stat, void rgb_diff_stat_update(struct rgb_diff_stat *stat, const struct color_float *ref, - const struct color_float *val) + const struct color_float *val, + const struct color_float *pos) { unsigned i; double ssd = 0.0; @@ -457,9 +458,9 @@ rgb_diff_stat_update(struct rgb_diff_stat *stat, for (i = 0; i < COLOR_CHAN_NUM; i++) { double diff = val->rgb[i] - ref->rgb[i]; - scalar_stat_update(&stat->rgb[i], diff, ref); + scalar_stat_update(&stat->rgb[i], diff, pos); ssd += diff * diff; } - scalar_stat_update(&stat->two_norm, sqrt(ssd), ref); + scalar_stat_update(&stat->two_norm, sqrt(ssd), pos); } diff --git a/tests/color_util.h b/tests/color_util.h index 1bb7297a..9ad09588 100644 --- a/tests/color_util.h +++ b/tests/color_util.h @@ -164,7 +164,8 @@ scalar_stat_print_float(const struct scalar_stat *stat); void rgb_diff_stat_update(struct rgb_diff_stat *stat, const struct color_float *ref, - const struct color_float *val); + const struct color_float *val, + const struct color_float *pos); void rgb_diff_stat_print(const struct rgb_diff_stat *stat,