From: Øyvind Kolås Date: Thu, 4 Jul 2019 10:32:07 +0000 (+0200) Subject: babl: make model_is_symmetric test adapt tolerance for high values X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~11^2~93 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e8b753ff9dadfb4819e4f3876aa792e4a719cbfc;p=babl.git 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. --- 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);