From 6a85f56af6dfd7796112b9d3fc5c69d56c76a316 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Tue, 20 Aug 2019 02:54:51 +0200 Subject: [PATCH] babl: register gray and gray alpha shortcuts between spaces The formats "Y float", "YA float" and "YaA float" between different RGB and gray spaces are all exactly the same. This registers memcpy shortcuts for these combinations for all spaces. This avoids temporarily expand into RGBA for many babl path fishes. --- babl/babl-space.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/babl/babl-space.c b/babl/babl-space.c index c05796c..90c0a50 100644 --- a/babl/babl-space.c +++ b/babl/babl-space.c @@ -883,6 +883,27 @@ universal_rgb_converter (const Babl *conversion, } +static inline void +universal_ya_converter (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) +{ + memcpy (dst_char, src_char, samples * 4 * 2); +} + +static inline void +universal_y_converter (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) +{ + memcpy (dst_char, src_char, samples * 4); +} + + static inline void universal_nonlinear_rgb_u8_converter (const Babl *conversion, unsigned char *src_char, @@ -1268,6 +1289,22 @@ add_rgb_adapter (Babl *babl, babl_format_with_space("RGB float", space), "linear", universal_rgb_converter, NULL)); + + prep_conversion(babl_conversion_new( + babl_format_with_space("Y float", space), + babl_format_with_space("Y float", babl), + "linear", universal_y_converter, + NULL)); + prep_conversion(babl_conversion_new( + babl_format_with_space("YaA float", babl), + babl_format_with_space("YaA float", space), + "linear", universal_ya_converter, + NULL)); + prep_conversion(babl_conversion_new( + babl_format_with_space("YA float", babl), + babl_format_with_space("YA float", space), + "linear", universal_ya_converter, + NULL)); } return 0; } -- 2.30.2