gray: add graya to rgba expanders
authorØyvind Kolås <pippin@gimp.org>
Mon, 19 Aug 2019 22:19:32 +0000 (00:19 +0200)
committerØyvind Kolås <pippin@gimp.org>
Mon, 19 Aug 2019 22:19:32 +0000 (00:19 +0200)
babl/babl-fish-path.c
extensions/grey.c
tools/babl-benchmark.c

index 82b728ed4171b864a86b2efe8947e1c32b47f32b..c8911d192b64563814cc15d79de1d31dda155d10 100644 (file)
@@ -601,6 +601,7 @@ babl_fish_path2 (const Babl *source,
 
     get_conversion_path (&pc, (Babl *) source, 0, max_path_length (), tolerance);
 
+#if 0
     /* second attempt,. at path length + 1*/
     if (babl->fish_path.conversion_list->count == 0 &&
         max_path_length () + 1 <= BABL_HARD_MAX_PATH_LENGTH)
@@ -615,6 +616,7 @@ babl_fish_path2 (const Babl *source,
       }
 #endif
     }
+#endif
 
     /* third attempt,. at path length + 2 */
     if (babl->fish_path.conversion_list->count == 0 &&
@@ -624,12 +626,22 @@ babl_fish_path2 (const Babl *source,
 #if 1
       if (babl->fish_path.conversion_list->count)
       {
-        fprintf (stderr, "babl is using very long chain, should be optimized\n");
-        babl_list_each (babl->fish_path.conversion_list, show_item, NULL);
+        //fprintf (stderr, "babl is a long chain, should be optimized\n");
+        //babl_list_each (babl->fish_path.conversion_list, show_item, NULL);
       }
       else
       {
-         fprintf (stderr, "babl is lacking conversion for %s to %s\n",
+         static int show_missing = -1;
+         if (show_missing < 0)
+         {
+            const char *val = getenv ("BABL_DEBUG_MISSING");
+            if (val && strcmp (val, "0"))
+              show_missing = 1;
+            else
+              show_missing = 0;
+         }
+         if (show_missing)
+           fprintf (stderr, "babl is lacking conversion for %s to %s\n",
                babl_get_name (source), babl_get_name (destination));
       }
 #endif
index 11ad58793080d15b3e9bc67da9027b2d37e6fe6e..3f208426cb918e14d4204dde208a20ebeb7a2809 100644 (file)
@@ -107,6 +107,28 @@ conv_rgbaF_linear_yaF_linear (const Babl    *conversion,
     }
 }
 
+static void
+conv_yaF_linear_rgbaF_linear (const Babl    *conversion,
+                              unsigned char *src,
+                              unsigned char *dst,
+                              long           samples)
+{
+  float *s = (float *) src;
+  float *d = (float *) dst;
+  long   n = samples;
+
+  while (n--)
+    {
+      float value;
+      value  = *s++;
+      *d++ = value;
+      *d++ = value;
+      *d++ = value;
+      *d++ = *s++;  /* alpha */
+    }
+}
+
+
 int init (void);
 
 int
@@ -130,5 +152,24 @@ init (void)
                        conv_rgbaF_linear_yaF_linear,
                        NULL);
 
+
+  babl_conversion_new (babl_format ("YA float"),
+                       babl_format ("RGBA float"),
+                       "linear",
+                       conv_yaF_linear_rgbaF_linear,
+                       NULL);
+
+  babl_conversion_new (babl_format ("YaA float"),
+                       babl_format ("RaGaBaA float"),
+                       "linear",
+                       conv_yaF_linear_rgbaF_linear,
+                       NULL);
+
+  babl_conversion_new (babl_format ("Y'A float"),
+                       babl_format ("R'G'B'A float"),
+                       "linear",
+                       conv_yaF_linear_rgbaF_linear,
+                       NULL);
+
   return 0;
 }
index d3d95b0f9ff4dc08a705fef1eb140967dc763f62..1fd9e78bded001c11e8ea257614b2522ddaab642 100644 (file)
@@ -25,7 +25,7 @@
 #define random  rand
 #endif
 
-int ITERATIONS = 2;
+int ITERATIONS = 1;
 #define  N_PIXELS (512*1024)  // a too small batch makes the test set live
                                // in l2 cache skewing results
 
@@ -80,12 +80,20 @@ test (void)
      babl_format_with_space("RGBA float",     babl_space("ProPhoto")),
      babl_format_with_space("R'G'B' u16",     babl_space("ProPhoto")),
 #endif
-     //babl_format("R'G'B'A u8"),
-     //babl_format("R'G'B'A u16"),
-       babl_format_with_space("R'G'B'A u8", babl_space("ProPhoto")),
-       babl_format_with_space("R'G'B'A half", babl_space("ProPhoto")),
+       //babl_format("R'G'B'A u8"),
+       babl_format("R'G'B'A u16"),
+       //babl_format_with_space("R'G'B'A u8", babl_space("ProPhoto")),
+       //babl_format_with_space("Y'A u8", babl_space("ProPhoto")),
+       babl_format_with_space("Y'A u16", babl_space("ProPhoto")),
+       babl_format_with_space("Y' u16", babl_space("ProPhoto")),
+       //babl_format_with_space("Y' u8", babl_space("ProPhoto")),
+       babl_format_with_space("Y float", babl_space("ProPhoto")),
+       babl_format_with_space("YaA float", babl_space("ProPhoto")),
+       babl_format_with_space("YA float", babl_space("ProPhoto")),
+       //babl_format_with_space("YA u16", babl_space("ProPhoto")),
+       //babl_format_with_space("R'G'B'A half", babl_space("ProPhoto")),
        babl_format_with_space("R'G'B'A float", babl_space("ProPhoto")),
-       babl_format_with_space("R'G'B'A double", babl_space("ProPhoto")),
+       babl_format_with_space("RaGaBaA float", babl_space("ProPhoto")),
        babl_format_with_space("cairo-RGB24", babl_space("Adobe")),
        babl_format_with_space("cairo-ARGB32", babl_space("Adobe")),
 
@@ -93,7 +101,7 @@ test (void)
   int n_formats = sizeof (formats) / sizeof (formats[0]);
   const Babl *fishes[50 * 50];
   double mbps[50 * 50] = {0,};
-  int n;
+  long n;
   double max = 0.0;
 
   assert (n_formats < 50);