From e8b753ff9dadfb4819e4f3876aa792e4a719cbfc Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Thu, 4 Jul 2019 12:32:07 +0200 Subject: [PATCH] babl: make model_is_symmetric test adapt tolerance for high values When the values used are in the billions, the tolerance that originally was mostly intended for values in the range 0.0-1.0 and its neighborhood break apart - use 1% of component values as symmetry threshold for such values. --- babl/babl-model.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/babl/babl-model.c b/babl/babl-model.c index 90b1ad0..142734c 100644 --- a/babl/babl-model.c +++ b/babl/babl-model.c @@ -374,12 +374,17 @@ babl_model_is_symmetric (const Babl *cbabl) { int j; for (j = 0; j < 4; j++) - if (fabs (clipped[i *4 + j] - transformed[i * 4 + j]) > TOLERANCE) + { + float tolerance = TOLERANCE; + if (fabs(clipped[i*4+j]) > 1.0) + tolerance = fabs(clipped[i*4+j]) * 0.01; + if (fabs (clipped[i *4 + j] - transformed[i * 4 + j]) > tolerance) { if (!log) log = 1; symmetric = 0; } + } if (log && log < 5) { babl_log ("%s", babl->instance.name); -- 2.30.2