[babl] extensions/simple: add u16 fast paths
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] extensions/simple: add u16 fast paths
- Date: Fri, 9 Dec 2016 21:36:50 +0000 (UTC)
commit 0ea14b7e3d7dbc9456b1435ca643a5fe1cdcda82
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Dec 9 22:21:48 2016 +0100
extensions/simple: add u16 fast paths
extensions/simple.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 108 insertions(+), 9 deletions(-)
---
diff --git a/extensions/simple.c b/extensions/simple.c
index d03981d..31ec455 100644
--- a/extensions/simple.c
+++ b/extensions/simple.c
@@ -89,17 +89,17 @@ float_to_u16_x1 (unsigned char *src_char, unsigned char *dst_char, long samples)
static inline long
float_to_u16_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u16_x2 (src_char, dst_char, samples * 2);
+ return float_to_u16_x1 (src_char, dst_char, samples * 2);
}
static inline long
float_to_u16_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u16_x3 (src_char, dst_char, samples * 3);
+ return float_to_u16_x1 (src_char, dst_char, samples * 3);
}
static inline long
float_to_u16_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u16_x4 (src_char, dst_char, samples * 4);
+ return float_to_u16_x1 (src_char, dst_char, samples * 4);
}
static inline long
@@ -185,17 +185,17 @@ float_to_u32_x1 (unsigned char *src_char, unsigned char *dst_char, long samples)
static inline long
float_to_u32_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u32_x2 (src_char, dst_char, samples * 2);
+ return float_to_u32_x1 (src_char, dst_char, samples * 2);
}
static inline long
float_to_u32_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u32_x3 (src_char, dst_char, samples * 3);
+ return float_to_u32_x1 (src_char, dst_char, samples * 3);
}
static inline long
float_to_u32_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u32_x4 (src_char, dst_char, samples * 4);
+ return float_to_u32_x1 (src_char, dst_char, samples * 4);
}
@@ -207,7 +207,7 @@ u32_to_float (unsigned char *src_char, unsigned char *dst_char, long samples)
long n = samples;
while (n--)
{
- dst[0] = src[0] / 4294967296.0f;
+ dst[0] = src[0] / 4294967295.0f;
dst ++;
src ++;
}
@@ -222,12 +222,59 @@ u32_to_float_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
}
static inline long
+u32_to_float_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ u32_to_float (src_char, dst_char, samples * 3);
+ return samples;
+}
+
+
+static inline long
u32_to_float_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
{
u32_to_float (src_char, dst_char, samples * 2);
return samples;
}
+
+static inline long
+u16_to_float (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ uint32_t *src = (uint32_t *)src_char;
+ float *dst = (float *)dst_char;
+ long n = samples;
+ while (n--)
+ {
+ dst[0] = src[0] / 65535.0f;
+ dst ++;
+ src ++;
+ }
+ return samples;
+}
+
+static inline long
+u16_to_float_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ u16_to_float (src_char, dst_char, samples * 4);
+ return samples;
+}
+
+static inline long
+u16_to_float_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ u16_to_float (src_char, dst_char, samples * 3);
+ return samples;
+}
+
+
+static inline long
+u16_to_float_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ u16_to_float (src_char, dst_char, samples * 2);
+ return samples;
+}
+
+
int
init (void)
{
@@ -388,8 +435,6 @@ init (void)
"linear",
float_pre_to_u32_pre,
NULL);
-
-
babl_conversion_new (babl_format ("YA u32"),
babl_format ("YA float"),
"linear",
@@ -421,6 +466,60 @@ init (void)
u32_to_float_x4,
NULL);
+ babl_conversion_new (babl_format ("RGB u32"),
+ babl_format ("RGB float"),
+ "linear",
+ u32_to_float_x3,
+ NULL);
+ babl_conversion_new (babl_format ("R'G'B' u32"),
+ babl_format ("R'G'B' float"),
+ "linear",
+ u32_to_float_x3,
+ NULL);
+
+
+
+ babl_conversion_new (babl_format ("YA u16"),
+ babl_format ("YA float"),
+ "linear",
+ u16_to_float_x2,
+ NULL);
+ babl_conversion_new (babl_format ("Y'A u16"),
+ babl_format ("Y'A float"),
+ "linear",
+ u16_to_float_x2,
+ NULL);
+ babl_conversion_new (babl_format ("Y u16"),
+ babl_format ("Y float"),
+ "linear",
+ u16_to_float,
+ NULL);
+ babl_conversion_new (babl_format ("Y' u16"),
+ babl_format ("Y' float"),
+ "linear",
+ u16_to_float,
+ NULL);
+ babl_conversion_new (babl_format ("RGBA u16"),
+ babl_format ("RGBA float"),
+ "linear",
+ u16_to_float_x4,
+ NULL);
+ babl_conversion_new (babl_format ("R'G'B'A u16"),
+ babl_format ("R'G'B'A float"),
+ "linear",
+ u16_to_float_x4,
+ NULL);
+
+ babl_conversion_new (babl_format ("RGB u16"),
+ babl_format ("RGB float"),
+ "linear",
+ u16_to_float_x3,
+ NULL);
+ babl_conversion_new (babl_format ("R'G'B' u16"),
+ babl_format ("R'G'B' float"),
+ "linear",
+ u16_to_float_x3,
+ NULL);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]