Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package babl for openSUSE:Factory checked in 
at 2023-05-29 22:47:30
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/babl (Old)
 and      /work/SRC/openSUSE:Factory/.babl.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "babl"

Mon May 29 22:47:30 2023 rev:64 rq:1089329 version:0.1.106

Changes:
--------
--- /work/SRC/openSUSE:Factory/babl/babl.changes        2023-03-11 
18:22:25.054373303 +0100
+++ /work/SRC/openSUSE:Factory/.babl.new.1533/babl.changes      2023-05-29 
22:47:32.650220709 +0200
@@ -1,0 +2,8 @@
+Thu May 18 13:29:32 UTC 2023 - Paolo Stivanin <i...@paolostivanin.com>
+
+- Update to 0.1.106:
+  * Disable LUTs on big-endian, fix to 1bpp->4bpp LUTs, faster startup by 
caching
+    balanced RGB to XYZ matrices.
+  * LUT code-paths re-enabled, some array overflow proofing.
+
+-------------------------------------------------------------------

Old:
----
  babl-0.1.102.tar.xz

New:
----
  babl-0.1.106.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ babl.spec ++++++
--- /var/tmp/diff_new_pack.SLzMSf/_old  2023-05-29 22:47:33.310224268 +0200
+++ /var/tmp/diff_new_pack.SLzMSf/_new  2023-05-29 22:47:33.318224310 +0200
@@ -19,7 +19,7 @@
 %define debug_package_requires libbabl-0_1-0 = %{version}-%{release}
 
 Name:           babl
-Version:        0.1.102
+Version:        0.1.106
 Release:        0
 Summary:        Dynamic Pixel Format Translation Library
 License:        GPL-3.0-or-later AND LGPL-3.0-or-later

++++++ babl-0.1.102.tar.xz -> babl-0.1.106.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/babl-0.1.102/NEWS new/babl-0.1.106/NEWS
--- old/babl-0.1.102/NEWS       2023-02-25 20:01:55.000000000 +0100
+++ new/babl-0.1.106/NEWS       2023-05-05 14:37:51.000000000 +0200
@@ -3,8 +3,16 @@
 the news section both in the README and the webpage.
                                                                           -->
 
+2023-05-05 babl-0.1.106                                             </dt><dd>
+Disable LUTs on big-endian, fix to 1bpp->4bpp LUTs, faster startup by caching
+balanced RGB to XYZ matrices.
+                                                                    </dd><dt>
+2023-04-21 babl-0.1.104                                             </dt><dd>
+LUT code-paths re-enabled, some array overflow proofing.
+                                                                    </dd><dt>
 2023-02-25 babl-0.1.102                                             </dt><dd>
 Brown paper bag release - LUT code-paths now disabled by default.
+                                                                    </dd><dt>
 2023-02-20 babl-0.1.100                                             </dt><dd>
 Stop double processing with LUT+normal fishes.
 Support for non-ASCII characters in file paths on windows. Improved wrap build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/babl-0.1.102/babl/babl-fish-path.c 
new/babl-0.1.106/babl/babl-fish-path.c
--- old/babl-0.1.102/babl/babl-fish-path.c      2023-02-25 20:01:55.000000000 
+0100
+++ new/babl-0.1.106/babl/babl-fish-path.c      2023-05-05 14:37:51.000000000 
+0200
@@ -129,6 +129,8 @@
 
 static float timings[256] = {0,};
 
+#define BPP_4ASSOCIATED   14
+
 static inline int _do_lut (uint32_t *lut,
                            int   source_bpp,
                            int   dest_bpp,
@@ -136,7 +138,34 @@
                            void *__restrict__ destination,
                            long n)
 {
-        if (source_bpp == 4 && dest_bpp == 16)
+        if (source_bpp == BPP_4ASSOCIATED  && dest_bpp == 4)
+        {
+          uint32_t *src = (uint32_t*)source;
+          uint32_t *dst = (uint32_t*)destination;
+          while (n--)
+          {
+             uint32_t col = *src++;
+             uint8_t *rgba=(uint8_t*)&col;
+             uint8_t oalpha = rgba[3];
+             if (oalpha==0)
+             {
+               *dst++ = 0;
+             }
+             else
+             {
+               uint32_t col_opaque = col;
+               uint8_t *rgbaB=(uint8_t*)&col_opaque;
+               uint32_t ralpha = 0;
+               ralpha = (256*255)/oalpha;
+               rgbaB[0] = (rgba[0]*ralpha)>>8;
+               rgbaB[1] = (rgba[1]*ralpha)>>8;
+               rgbaB[2] = (rgba[2]*ralpha)>>8;
+               rgbaB[3] = 0;
+               *dst++ = lut[col_opaque] | (oalpha<<24);
+             }
+          }
+        }
+        else if (source_bpp == 4 && dest_bpp == 16)
         {
           uint32_t *src = (uint32_t*)source;
           uint32_t *dst = (uint32_t*)destination;
@@ -247,8 +276,7 @@
           uint32_t *dst = (uint32_t*)destination;
           while (n--)
           {
-             uint32_t col = src[0]*256*256+src[1]*256+src[2];
-             *dst = lut[col] | 0xff000000;
+             *dst = lut[src[0]*256*256+src[1]*256+src[2]];
              dst++;
              src+=3;
           }
@@ -260,7 +288,6 @@
         return 1;
 }
 
-
 void babl_test_lut (uint32_t *lut,
              int   source_bpp,
              int   dest_bpp,
@@ -285,7 +312,7 @@
 static void measure_timings(void)
 {
    int num_pixels = babl_get_num_path_test_pixels () * 1000;
-   int pairs[][2]={{4,4},{4,8},{3,4},{3,3},{2,4},{2,2},{1,4},{2,16},{4,16}};
+   int 
pairs[][2]={{4,4},{BPP_4ASSOCIATED,4},{4,8},{3,4},{3,3},{2,4},{2,2},{1,4},{2,16},{4,16}};
    uint32_t *lut = malloc (256 * 256 * 256 * 16);
    uint32_t *src = malloc (num_pixels * 16);
    uint32_t *dst = malloc (num_pixels * 16);
@@ -341,7 +368,7 @@
      int source_bpp = babl->fish_path.source_bpp;
      int dest_bpp = babl->fish_path.dest_bpp;
      uint32_t *lut = (uint32_t*)babl->fish_path.u8_lut;
-
+ 
 
      if (BABL_UNLIKELY(!lut && babl->fish.pixels >= 128 * 256))
      {
@@ -352,20 +379,21 @@
        {
          lut = malloc (256 * 256 * 256 * 4);
          for (int o = 0; o < 256 * 256 * 256; o++)
-           lut[o] = o;
+           lut[o] = o | 0xff000000;
          process_conversion_path (babl->fish_path.conversion_list,
                                   lut, 4,
                                   lut, 4,
                                   256*256*256);
          for (int o = 0; o < 256 * 256 * 256; o++)
            lut[o] = lut[o] & 0x00ffffff;
+
        }
        else if (source_bpp == 4 && dest_bpp == 16)
        {
          uint32_t *temp_lut = malloc (256 * 256 * 256 * 4);
          lut = malloc (256 * 256 * 256 * 16);
          for (int o = 0; o < 256 * 256 * 256; o++)
-           temp_lut[o] = o;
+           temp_lut[o] = o | 0xff000000;
          process_conversion_path (babl->fish_path.conversion_list,
                                   temp_lut, 4,
                                   lut, 16,
@@ -377,7 +405,7 @@
          uint32_t *temp_lut = malloc (256 * 256 * 256 * 4);
          lut = malloc (256 * 256 * 256 * 8);
          for (int o = 0; o < 256 * 256 * 256; o++)
-           temp_lut[o] = o;
+           temp_lut[o] = o | 0xff000000;
          process_conversion_path (babl->fish_path.conversion_list,
                                   temp_lut, 4,
                                   lut, 8,
@@ -426,8 +454,6 @@
                                   temp_lut, 3,
                                   lut, 4,
                                   256*256*256);
-         for (int o = 0; o < 256 * 256 * 256; o++)
-           lut[o] = lut[o] & 0x00ffffff;
          free (temp_lut);
        }
        else if (source_bpp == 2 && dest_bpp == 2)
@@ -484,8 +510,6 @@
                                   temp_lut, 1,
                                   lut, 4,
                                   256);
-         for (int o = 0; o < 256; o++)
-           lut[o] = lut[o] & 0x00ffffff;
          free (temp_lut);
        }
 
@@ -505,8 +529,14 @@
          lut = babl->fish_path.u8_lut;
        }
      }
+
      if (lut)
      {
+       if (source_bpp == 4 && 
+           ((babl->conversion.source->format.model->flags &
+           BABL_MODEL_FLAG_ASSOCIATED)!=0))
+         source_bpp = BPP_4ASSOCIATED;
+
        if (_do_lut (lut, source_bpp, dest_bpp, source, destination, n))
        {
          BABL(babl)->fish_path.last_lut_use = babl_ticks ();
@@ -609,9 +639,17 @@
 
   env = getenv ("BABL_LUT");
   if (env && env[0] != '\0')
-    enable_lut = 1;
+    enable_lut = atoi(getenv("BABL_LUT"));
   else
-    enable_lut = 0;
+    enable_lut = 1;
+
+  { 
+    const uint32_t u32 = 1;
+    if ( *((char*)&u32) == 0)
+    {  /* disable use of LUTs if we are running on big endian */
+       enable_lut = 0;
+    }
+  }
 
   return error;
 }
@@ -969,9 +1007,10 @@
   const Babl *dest_type   = babl_format_get_type (babl_dest,
                                                   babl_format_get_n_components 
(babl_dest) - 1);
 
+  int src_not_associated = ((babl->conversion.source->format.model->flags &
+          BABL_MODEL_FLAG_ASSOCIATED)==0);
   int dest_not_associated = 
((babl->conversion.destination->format.model->flags &
           BABL_MODEL_FLAG_ASSOCIATED)==0);
-
   if (
       (babl->conversion.source->format.type[0]->bits < 32)       
 
@@ -982,6 +1021,7 @@
              && dest_bpp    == 16
              && source_type == babl_type_from_id (BABL_U8)
              && dest_type   == babl_type_from_id (BABL_FLOAT)
+             && src_not_associated
              && dest_not_associated)
 
           ||(   source_bpp == 4
@@ -993,6 +1033,7 @@
              && dest_bpp    == 8
              && source_type == babl_type_from_id (BABL_U8)
              && dest_type   == babl_type_from_id (BABL_U16)
+             && src_not_associated
              && dest_not_associated)
 
           ||(   source_bpp == 3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/babl-0.1.102/babl/babl-format.c 
new/babl-0.1.106/babl/babl-format.c
--- old/babl-0.1.102/babl/babl-format.c 2023-02-25 20:01:55.000000000 +0100
+++ new/babl-0.1.106/babl/babl-format.c 2023-05-05 14:37:51.000000000 +0200
@@ -140,8 +140,9 @@
 {
   Babl *ret;
   char new_name[256];
-  snprintf (new_name, sizeof (new_name), "%s-%s", babl_get_name 
((void*)format),
+  snprintf (new_name, sizeof (new_name)-1, "%s-%s", babl_get_name 
((void*)format),
                                                   babl_get_name 
((void*)space));
+  new_name[255]=0;
   ret = babl_db_find (babl_format_db(), new_name);
   if (ret)
     return ret;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/babl-0.1.102/babl/babl-internal.c 
new/babl-0.1.106/babl/babl-internal.c
--- old/babl-0.1.102/babl/babl-internal.c       2023-02-25 20:01:55.000000000 
+0100
+++ new/babl-0.1.106/babl/babl-internal.c       2023-05-05 14:37:51.000000000 
+0200
@@ -85,6 +85,7 @@
 #endif
 BablMutex *babl_reference_mutex;
 BablMutex *babl_space_mutex;
+BablMutex *babl_remodel_mutex;
 
 void
 babl_internal_init (void)
@@ -95,6 +96,7 @@
   babl_format_mutex = babl_mutex_new ();
   babl_reference_mutex = babl_mutex_new ();
   babl_space_mutex = babl_mutex_new ();
+  babl_remodel_mutex = babl_mutex_new ();
 #if BABL_DEBUG_MEM
   babl_debug_mutex = babl_mutex_new ();
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/babl-0.1.102/babl/babl-internal.h 
new/babl-0.1.106/babl/babl-internal.h
--- old/babl-0.1.102/babl/babl-internal.h       2023-02-25 20:01:55.000000000 
+0100
+++ new/babl-0.1.106/babl/babl-internal.h       2023-05-05 14:37:51.000000000 
+0200
@@ -250,6 +250,7 @@
 extern BablMutex *babl_fish_mutex;
 extern BablMutex *babl_reference_mutex;
 extern BablMutex *babl_space_mutex;
+extern BablMutex *babl_remodel_mutex;
 
 #define BABL_DEBUG_MEM 0
 #if BABL_DEBUG_MEM
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/babl-0.1.102/babl/babl-model.c 
new/babl-0.1.106/babl/babl-model.c
--- old/babl-0.1.102/babl/babl-model.c  2023-02-25 20:01:55.000000000 +0100
+++ new/babl-0.1.106/babl/babl-model.c  2023-05-05 14:37:51.000000000 +0200
@@ -421,11 +421,9 @@
 
 BABL_CLASS_IMPLEMENT (model)
 
-/* XXX: probably better to do like with babl_format, add a -suffix and
- *      insert in normal database than to have this static cache list
- */
-static const Babl *babl_remodels[512]={NULL,};
-int          babl_n_remodels = 0;
+static Babl **babl_remodels = NULL;
+static int    babl_remodel_size = 0;
+static int    babl_n_remodels = 0;
 
 const Babl *
 babl_remodel_with_space (const Babl *model, 
@@ -454,24 +452,37 @@
 
   assert (BABL_IS_BABL (model));
 
+  babl_mutex_lock (babl_remodel_mutex);
   /* get back to the sRGB model if we are in a COW clone of it  */
   if (model->model.model)
     model = (void*)model->model.model;
 
   assert (BABL_IS_BABL (model));
+  if (babl_remodel_size < babl_n_remodels + 2)
+  {
+    int new_size = (babl_n_remodels + 2) * 2;
+    if (new_size < 256) new_size = 256;
+    babl_remodels = babl_realloc (babl_remodels, new_size * sizeof (Babl*));
+    babl_remodel_size = new_size;
+  }
 
   for (i = 0; i < babl_n_remodels; i++)
   {
     if (babl_remodels[i]->model.model == model &&
         babl_remodels[i]->model.space == space)
-          return babl_remodels[i];
+        {
+          ret = (Babl*)babl_remodels[i];
+          babl_mutex_unlock (babl_remodel_mutex);
+          return ret;
+       }
   }
 
   ret = babl_calloc (sizeof (BablModel), 1);
   memcpy (ret, model, sizeof (BablModel));
   ret->model.space = space;
   ret->model.model = (void*)model; /* use the data as a backpointer to 
original model */
-  return babl_remodels[babl_n_remodels++] = ret;
+  babl_remodels[babl_n_remodels++] = ret;
+  babl_mutex_unlock (babl_remodel_mutex);
   return (Babl*)ret;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/babl-0.1.102/babl/babl-space.c 
new/babl-0.1.106/babl/babl-space.c
--- old/babl-0.1.102/babl/babl-space.c  2023-02-25 20:01:55.000000000 +0100
+++ new/babl-0.1.106/babl/babl-space.c  2023-05-05 14:37:51.000000000 +0200
@@ -93,6 +93,36 @@
   *to_b = 200.0 * (f_y - f_z);
 }
 
+// cached equalized matrices generated for spaces used internally by babl
+//
+static double equalized_matrices[][9]=
+{
+ {0.673492431640625000, 0.165679931640625000, 0.125030517578125000,
+  0.279052734375000000, 0.675354003906250000, 0.045593261718750000,
+ -0.001907348632812500, 0.029968261718750000, 0.796844482421875000},
+
+ {0.609756469726562500, 0.205276489257812500, 0.149169921875000000,
+  0.311126708984375000, 0.625671386718750000, 0.063201904296875000,
+  0.019485473632812500, 0.060867309570312500, 0.744552612304687500},
+
+ {0.797714233398437500, 0.135208129882812500, 0.031280517578125000,
+  0.288070678710937500, 0.711868286132812500, 0.000061035156250000,
+  0.000015258789062500, 0.000015258789062500, 0.824874877929687500},
+
+ {0.475555419921875000, 0.339706420898437500, 0.148941040039062500,
+  0.255172729492187500, 0.672592163085937500, 0.072235107421875000,
+  0.018463134765625000, 0.113342285156250000, 0.693099975585937500},
+
+ {0.689895629882812500, 0.149765014648437500, 0.124542236328125000,
+  0.284530639648437500, 0.671691894531250000, 0.043777465820312500,
+ -0.006011962890625000, 0.009994506835937500, 0.820922851562500000},
+
+ {0.990905761718750000, 0.012222290039062500,-0.038925170898437500,
+  0.361907958984375000, 0.722503662109375000,-0.084411621093750000,
+ -0.002685546875000000, 0.008239746093750000, 0.819351196289062500},
+};
+
+
 /* round all values to s15f16 precision and brute-force
  * jitter +/- 1 all entries for best uniform gray axis - this
  * also optimizes the accuracy of the matrix for floating point
@@ -117,6 +147,26 @@
   double best_error = 1000000.0;
   int i;
 
+  for (int i = 0; i < sizeof (equalized_matrices)/
+                      sizeof (equalized_matrices[0]); i++)
+  {
+    double diff_sum = 0.0f;
+    for (int j = 0; j < 9; j++){ 
+    double diff = equalized_matrices[i][j] - in_mat[j];
+    diff *= diff;
+    diff_sum += diff; }
+
+    // the threshold is based on being ~double the biggest
+    // difference seen in the default space set.
+
+    if (diff_sum < 0.000000005) { 
+      for (int j = 0; j < 9; j++){ 
+        in_mat[j] = equalized_matrices[i][j];
+      }
+      return;
+    }
+  }
+
   for (i = 0; i < 9; i++)
     best_j[i] = 0;
 
@@ -162,11 +212,23 @@
       memcpy (&best_j[0], &j[0], sizeof (best_j));
     }
   }
+
   for (i = 0; i < 9; i++)
   {
     int32_t val = in_mat[i] * 65536.0 + 0.5f;
     in_mat[i] = val / 65536.0 + best_j[i] / 65536.0;
   }
+
+#if 0 // uncomment to generate code for pasting in cache
+  fprintf (stderr, "{");
+  for (i = 0; i < 9; i++)
+  {
+    if (i)
+      fprintf (stderr, ", ");
+    fprintf (stderr, "%.18f", in_mat[i]);
+  }
+  fprintf (stderr, "},\n");
+#endif
 }
 
 static void
@@ -354,11 +416,13 @@
   if (name)
     snprintf (space_db[i].name, sizeof (space_db[i].name), "%s", name);
   else
-          /* XXX: this can get longer than 256bytes ! */
-    snprintf (space_db[i].name, sizeof (space_db[i].name),
+  {
+    snprintf (space_db[i].name, sizeof (space_db[i].name)-1,
              "space-%.4f,%.4f_%.4f,%.4f_%.4f,%.4f_%.4f,%.4f_%s,%s,%s",
              wx,wy,rx,ry,bx,by,gx,gy,babl_get_name (space.trc[0]),
              babl_get_name(space.trc[1]), babl_get_name(space.trc[2]));
+    space_db[i].name[sizeof (space_db[i].name)-1]=0;
+  }
 
   babl_space_get_icc ((Babl*)&space_db[i], NULL);
   return (Babl*)&space_db[i];
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/babl-0.1.102/git-version.h 
new/babl-0.1.106/git-version.h
--- old/babl-0.1.102/git-version.h      2023-02-25 20:01:59.394290700 +0100
+++ new/babl-0.1.106/git-version.h      2023-05-05 14:38:00.483815700 +0200
@@ -1,6 +1,6 @@
 #ifndef __BABL_GIT_VERSION_H__
 #define __BABL_GIT_VERSION_H__
 
-#define BABL_GIT_VERSION "BABL_0_1_100-4-g47affe9"
+#define BABL_GIT_VERSION "BABL_0_1_104-6-g150294d"
 
 #endif /* __BABL_GIT_VERSION_H__ */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/babl-0.1.102/meson.build new/babl-0.1.106/meson.build
--- old/babl-0.1.102/meson.build        2023-02-25 20:01:55.000000000 +0100
+++ new/babl-0.1.106/meson.build        2023-05-05 14:37:51.000000000 +0200
@@ -1,7 +1,7 @@
 project('babl', 'c',
   license: 'LGPL3+',
-  version: '0.1.102',
-  meson_version: '>=0.54.0',
+  version: '0.1.106',
+  meson_version: '>=0.55.0',
   default_options: [
     'buildtype=debugoptimized'
   ],

Reply via email to