From 8bae33d8127e18d4a1312ec590bfa26a85ca8bd2 Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 17 Feb 2023 22:45:11 +0100 Subject: [PATCH] babl: make LUT from 2bpp to 4bpp totally generic. The deleting of the first byte when creating the LUT, then copying the first byte from source to destination, worked for cases such as "YA u8" to "RGBA u8" but it would not work for say: * "Y half" to anything: in such a case, deleting the first byte in LUT's content, when creating it, we are basically deleting source's color information! * "YA u8" to "Y float": in such a case, when copying the first byte, at conversion time, we are destroying the result color (which didn't need any copying of alpha channel as there is no alpha channel in the result). * And so on. In such cases, it's just better to include everything in the LUT, in a totally model-agnostic way. In some cases, the alpha channel will be stored in the LUT, in others, not. But it's not really a problem. It doesn't even make the LUT bigger; if anything, it makes the LUT creation and the conversion calculus simpler, hence faster. --- babl/babl-fish-path.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c index bda0c7b..15bf65f 100644 --- a/babl/babl-fish-path.c +++ b/babl/babl-fish-path.c @@ -199,8 +199,7 @@ static inline int _do_lut (uint32_t *lut, uint32_t *dst = (uint32_t*)destination; while (n--) { - uint16_t col = *src++; - *dst = lut[col & 0xff] | (((uint32_t) (col & 0xff00)) << 16); + *dst = lut[*src++]; dst++; } } @@ -455,8 +454,6 @@ static inline int babl_fish_lut_process_maybe (const Babl *babl, temp_lut, 2, lut, 4, 256*256); - for (int o = 0; o < 256 * 256; o++) - lut[o] = lut[o] & 0x00ffffff; free (temp_lut); } else if (source_bpp == 2 && dest_bpp == 16) -- 2.30.2