babl: make model_is_symmetric test adapt tolerance for high values
authorØyvind Kolås <pippin@gimp.org>
Thu, 4 Jul 2019 10:32:07 +0000 (12:32 +0200)
committerØyvind Kolås <pippin@gimp.org>
Thu, 4 Jul 2019 10:33:32 +0000 (12:33 +0200)
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

index 90b1ad025c68f68c1268e91ad9888d9fd802a9e9..142734c125dfa929fb5dadf4daa19a38fb856544 100644 (file)
@@ -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);