tests: add rgb_diff_stat dumps

This is a special case of scalar_stat dumps to record all of two-norm
and RGB differences on the same line in the dump file.

This makes the dump file easier to handle when you want full RGB errors
recorded.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 2 years ago committed by Pekka Paalanen
parent 3f60542405
commit e103ef4d0d
  1. 18
      tests/color_util.c
  2. 12
      tests/color_util.h

@ -454,13 +454,23 @@ rgb_diff_stat_update(struct rgb_diff_stat *stat,
{ {
unsigned i; unsigned i;
double ssd = 0.0; double ssd = 0.0;
double diff[COLOR_CHAN_NUM];
double two_norm;
for (i = 0; i < COLOR_CHAN_NUM; i++) { for (i = 0; i < COLOR_CHAN_NUM; i++) {
double diff = val->rgb[i] - ref->rgb[i]; diff[i] = val->rgb[i] - ref->rgb[i];
scalar_stat_update(&stat->rgb[i], diff, pos); scalar_stat_update(&stat->rgb[i], diff[i], pos);
ssd += diff * diff; ssd += diff[i] * diff[i];
} }
two_norm = sqrt(ssd);
scalar_stat_update(&stat->two_norm, sqrt(ssd), pos); scalar_stat_update(&stat->two_norm, two_norm, pos);
if (stat->dump) {
fprintf(stat->dump, "%.8g %.8g %.8g %.8g %.5g %.5g %.5g %.5g\n",
two_norm,
diff[COLOR_CHAN_R], diff[COLOR_CHAN_G], diff[COLOR_CHAN_B],
pos->r, pos->g, pos->b, pos->a);
}
} }

@ -148,6 +148,18 @@ struct scalar_stat {
struct rgb_diff_stat { struct rgb_diff_stat {
struct scalar_stat rgb[COLOR_CHAN_NUM]; struct scalar_stat rgb[COLOR_CHAN_NUM];
struct scalar_stat two_norm; struct scalar_stat two_norm;
/** Debug dump into file
*
* Initialize this to a writable file to get a record of all values
* ever fed through this statistics accumulator. The file shall be
* text with the two-norm error, the rgb difference, and their position
* per line:
* norm diff.r diff.g diff.b pos.r pos.g pos.b pos.a
*
* Set to NULL to not record.
*/
FILE *dump;
}; };
void void

Loading…
Cancel
Save