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 <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 3 years ago committed by Pekka Paalanen
parent 912ea2cb20
commit 3f60542405
  1. 2
      tests/color-icc-output-test.c
  2. 7
      tests/color_util.c
  3. 3
      tests/color_util.h

@ -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);
}
/*

@ -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);
}

@ -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,

Loading…
Cancel
Save