[babl] extensions/CIE: do cbrt computation in single precision float
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] extensions/CIE: do cbrt computation in single precision float
- Date: Fri, 13 Jan 2017 03:01:50 +0000 (UTC)
commit b0e7abf2a6bc95b999d4377afead775f5080d135
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Jan 13 03:45:35 2017 +0100
extensions/CIE: do cbrt computation in single precision float
This is sufficient for our purposes, and gives a ~40% boost for
the affecte CIE Lab float conversions.
extensions/CIE.c | 16 +++-------------
1 files changed, 3 insertions(+), 13 deletions(-)
---
diff --git a/extensions/CIE.c b/extensions/CIE.c
index fa9df11..e1e2fa7 100644
--- a/extensions/CIE.c
+++ b/extensions/CIE.c
@@ -472,7 +472,7 @@ B2 = 642849266; /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */
static inline float _cbrtf(float x)
{
- double_t r,T;
+ float r,T;
union {float f; uint32_t i;} u = {x};
uint32_t hx = u.i & 0x7fffffff;
@@ -491,23 +491,13 @@ static inline float _cbrtf(float x)
u.i &= 0x80000000;
u.i |= hx;
- /*
- * First step Newton iteration (solving t*t-x/t == 0) to 16 bits. In
- * double precision so that its terms can be arranged for efficiency
- * without causing overflow or underflow.
- */
T = u.f;
r = T*T*T;
- T = T*((double_t)x+x+r)/(x+r+r);
+ T = T*((float)x+x+r)/(x+r+r);
- /*
- * Second step Newton iteration to 47 bits. In double precision for
- * efficiency and accuracy.
- */
r = T*T*T;
- T = T*((double_t)x+x+r)/(x+r+r);
+ T = T*((float)x+x+r)/(x+r+r);
- /* rounding to 24 bits is perfect in round-to-nearest mode */
return T;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]