[babl] fast-float: use higher accuracy LUTs and rework some alpha handling
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] fast-float: use higher accuracy LUTs and rework some alpha handling
- Date: Thu, 17 Nov 2016 00:31:55 +0000 (UTC)
commit 054c9e4aaafff5a79b64cd036d960c712f27adce
Author: Øyvind Kolås <pippin gimp org>
Date: Wed Nov 16 22:39:17 2016 +0100
fast-float: use higher accuracy LUTs and rework some alpha handling
extensions/fast-float.c | 37 ++++++++++++++++++++++++++++---------
extensions/float.c | 42 +++++++++++++++++++++---------------------
2 files changed, 49 insertions(+), 30 deletions(-)
---
diff --git a/extensions/fast-float.c b/extensions/fast-float.c
index 9103bc9..7393645 100644
--- a/extensions/fast-float.c
+++ b/extensions/fast-float.c
@@ -222,7 +222,7 @@ static BablLookup *fast_pow = NULL;
static inline float core_lookup (float val, void *userdata)
{
- return linear_to_gamma_2_2 (val);
+ return babl_linear_to_gamma_2_2f (val);
}
static float
@@ -236,7 +236,7 @@ static BablLookup *fast_rpow = NULL;
static inline float core_rlookup (float val, void *userdata)
{
- return gamma_2_2_to_linear (val);
+ return babl_gamma_2_2_to_linearf (val);
}
static float
@@ -265,10 +265,29 @@ conv_rgbaF_linear_rgbAF_gamma (unsigned char *src,
while (n--)
{
float alpha = fsrc[3];
- *fdst++ = linear_to_gamma_2_2_lut (*fsrc++) * alpha;
- *fdst++ = linear_to_gamma_2_2_lut (*fsrc++) * alpha;
- *fdst++ = linear_to_gamma_2_2_lut (*fsrc++) * alpha;
- *fdst++ = *fsrc++;
+ if (alpha == 1.0)
+ {
+ *fdst++ = linear_to_gamma_2_2_lut (*fsrc++);
+ *fdst++ = linear_to_gamma_2_2_lut (*fsrc++);
+ *fdst++ = linear_to_gamma_2_2_lut (*fsrc++);
+ *fdst++ = *fsrc++;
+ }
+ else if (alpha == 0.0)
+ {
+ *fdst++ = 0.0;
+ *fdst++ = 0.0;
+ *fdst++ = 0.0;
+ *fdst++ = 0.0;
+ fsrc+=4;
+ }
+ else
+ {
+ *fdst++ = linear_to_gamma_2_2_lut (*fsrc++) * alpha;
+ *fdst++ = linear_to_gamma_2_2_lut (*fsrc++) * alpha;
+ *fdst++ = linear_to_gamma_2_2_lut (*fsrc++) * alpha;
+ *fdst++ = alpha;
+ fsrc++;
+ }
}
return samples;
}
@@ -446,10 +465,10 @@ init (void)
float f;
float a;
- fast_pow = babl_lookup_new (core_lookup, NULL, 0.0, 1.0, 0.0001);
- fast_rpow = babl_lookup_new (core_rlookup, NULL, 0.0, 1.0, 0.0001);
+ fast_pow = babl_lookup_new (core_lookup, NULL, 0.0, 1.0, 0.00005);
+ fast_rpow = babl_lookup_new (core_rlookup, NULL, 0.0, 1.0, 0.00005);
- for (f = 0.0; f < 1.0; f+= 0.000012)
+ for (f = 0.0; f < 1.0; f+= 0.0000001)
{
a = linear_to_gamma_2_2_lut (f);
a = gamma_2_2_to_linear_lut (f);
diff --git a/extensions/float.c b/extensions/float.c
index 5cbbeb6..9460804 100644
--- a/extensions/float.c
+++ b/extensions/float.c
@@ -41,9 +41,9 @@ conv_rgbaF_linear_rgbAF_gamma (unsigned char *src,
while (n--)
{
float alpha = fsrc[3];
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++) * alpha;
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++) * alpha;
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++) * alpha;
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++) * alpha;
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++) * alpha;
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++) * alpha;
*fdst++ = *fsrc++;
}
return samples;
@@ -71,17 +71,17 @@ conv_rgbAF_linear_rgbAF_gamma (unsigned char *src,
}
else if (alpha >= 1.0)
{
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++);
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
*fdst++ = *fsrc++;
}
else
{
float alpha_recip = 1.0 / alpha;
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++ * alpha_recip) * alpha;
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++ * alpha_recip) * alpha;
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++ * alpha_recip) * alpha;
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++ * alpha_recip) * alpha;
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++ * alpha_recip) * alpha;
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++ * alpha_recip) * alpha;
*fdst++ = *fsrc++;
}
}
@@ -99,9 +99,9 @@ conv_rgbaF_linear_rgbaF_gamma (unsigned char *src,
while (n--)
{
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++);
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
*fdst++ = *fsrc++;
}
return samples;
@@ -118,9 +118,9 @@ conv_rgbF_linear_rgbF_gamma (unsigned char *src,
while (n--)
{
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2 (*fsrc++);
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
+ *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
}
return samples;
}
@@ -137,9 +137,9 @@ conv_rgbaF_gamma_rgbaF_linear (unsigned char *src,
while (n--)
{
- *fdst++ = babl_gamma_2_2_to_linear (*fsrc++);
- *fdst++ = babl_gamma_2_2_to_linear (*fsrc++);
- *fdst++ = babl_gamma_2_2_to_linear (*fsrc++);
+ *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
+ *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
+ *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
*fdst++ = *fsrc++;
}
return samples;
@@ -156,9 +156,9 @@ conv_rgbF_gamma_rgbF_linear (unsigned char *src,
while (n--)
{
- *fdst++ = babl_gamma_2_2_to_linear (*fsrc++);
- *fdst++ = babl_gamma_2_2_to_linear (*fsrc++);
- *fdst++ = babl_gamma_2_2_to_linear (*fsrc++);
+ *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
+ *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
+ *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
}
return samples;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]