babl: limit LUT creation for 4→8 and 4→16 bpp further.
authorJehan <jehan@girinstud.io>
Fri, 17 Feb 2023 22:27:32 +0000 (23:27 +0100)
committerJehan <jehan@girinstud.io>
Fri, 17 Feb 2023 22:39:38 +0000 (23:39 +0100)
Looking at LUT conversion code, we are clearly only supporting
converting from "u8" (to "u16" or "float" respectively).

Conversions such as "YA half" to "R'G'B'A float" for instance would be
completely broken (it was trying to use only one byte of the "YA half",
assumed it was "u8" and transform it to "float"). This is why the sample
image in #85 was appearing on display as more transparent than it should
when converted to 16-bit floating point grayscale image.

babl/babl-fish-path.c

index 15bf65f31d9ba57fe9bbaa3558fbebc12a44d487..2cfb507e2e15b2fad14c37bea82aceb3f07b95a5 100644 (file)
@@ -969,9 +969,10 @@ _babl_fish_prepare_bpp (Babl *babl)
       && (  (   source_bpp == 2
              && dest_bpp   == 16)
 
-          ||(   source_bpp == 4
-             && dest_bpp   == 16
-             && dest_type  == babl_type_from_id (BABL_FLOAT)
+          ||(   source_bpp  == 4
+             && dest_bpp    == 16
+             && source_type == babl_type_from_id (BABL_U8)
+             && dest_type   == babl_type_from_id (BABL_FLOAT)
              && dest_not_associated)
 
           ||(   source_bpp == 4
@@ -979,9 +980,10 @@ _babl_fish_prepare_bpp (Babl *babl)
              && dest_type  == source_type
              && dest_not_associated)
 
-          ||(   source_bpp == 4
-             && dest_bpp   == 8
-             && dest_type  == babl_type_from_id (BABL_U16)
+          ||(   source_bpp  == 4
+             && dest_bpp    == 8
+             && source_type == babl_type_from_id (BABL_U8)
+             && dest_type   == babl_type_from_id (BABL_U16)
              && dest_not_associated)
 
           ||(   source_bpp == 3