[babl] extensions/gggl{, -lies}.c: use 'lrint' where it is not yet used
- From: Massimo Valentini <mvalentini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] extensions/gggl{, -lies}.c: use 'lrint' where it is not yet used
- Date: Sat, 14 Jul 2012 15:21:30 +0000 (UTC)
commit f8195231a7400e27754ade29a96b3d278bdb1658
Author: Massimo Valentini <mvalentini src gnome org>
Date: Sat Jul 14 17:07:38 2012 +0200
extensions/gggl{,-lies}.c: use 'lrint' where it is not yet used
and instead of 'rint'.
'lrint' returning a long does not require a conversion double->int
that in theory requires changing the rounding direction from
toward the nearest to toward zero.
extensions/gggl-lies.c | 16 ++++++++--------
extensions/gggl.c | 18 +++++++++---------
2 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/extensions/gggl-lies.c b/extensions/gggl-lies.c
index 7f99b00..849e3f4 100644
--- a/extensions/gggl-lies.c
+++ b/extensions/gggl-lies.c
@@ -113,8 +113,8 @@ table_init (void)
}
else
{
- c = rint (u.f * 255.0);
- s = rint (u.f * 65535.0);
+ c = lrint (u.f * 255.0);
+ s = lrint (u.f * 65535.0);
}
/*fprintf (stderr, "%2.3f=%03i %05i ", f, c, (*hi));
@@ -240,7 +240,7 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
}
else
{
- *(unsigned char *) dst = rint (f * 255.0);
+ *(unsigned char *) dst = lrint (f * 255.0);
}
dst += 1;
src += 4;
@@ -266,7 +266,7 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
}
else
{
- *(unsigned short *) dst = rint (f * 65535.0);
+ *(unsigned short *) dst = lrint (f * 65535.0);
}
dst += 2;
src += 4;
@@ -846,11 +846,11 @@ conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
for (c = 0; c < 3; c++)
{
- *(unsigned char *) dst = ((*(float *) src) * alpha) * 255.0;
+ *(unsigned char *) dst = lrint (((*(float *) src) * alpha) * 255.0);
dst += 1;
src += 4;
}
- *(unsigned char *) dst = alpha * 255.0;
+ *(unsigned char *) dst = lrint (alpha * 255.0);
dst++;
src += 4;
}
@@ -868,7 +868,7 @@ conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
for (c = 0; c < 3; c++)
{
- *(unsigned char *) dst = (*(float *) src) * 255.0;
+ *(unsigned char *) dst = lrint ((*(float *) src) * 255.0);
dst += 1;
src += 4;
}
@@ -910,7 +910,7 @@ conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
for (c = 0; c < 3; c++)
{
- *(unsigned short *) dst = (*(float *) src) * 65535.0;
+ *(unsigned short *) dst = lrint ((*(float *) src) * 65535.0);
dst += 2;
src += 4;
}
diff --git a/extensions/gggl.c b/extensions/gggl.c
index 307c574..10094ac 100644
--- a/extensions/gggl.c
+++ b/extensions/gggl.c
@@ -107,8 +107,8 @@ table_init (void)
}
else
{
- c = rint (u.f * 255.0);
- s = rint (u.f * 65535.0);
+ c = lrint (u.f * 255.0);
+ s = lrint (u.f * 65535.0);
}
/*fprintf (stderr, "%2.3f=%03i %05i ", f, c, (*hi));
@@ -250,7 +250,7 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
while (n--)
{
float f = ((*(float *) src));
- int uval = rint (f * 255.0);
+ int uval = lrint (f * 255.0);
if (uval < 0) uval = 0;
if (uval > 255) uval = 255;
@@ -280,7 +280,7 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
}
else
{
- *(unsigned short *) dst = rint (f * 65535.0);
+ *(unsigned short *) dst = lrint (f * 65535.0);
}
dst += 2;
src += 4;
@@ -836,11 +836,11 @@ conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
for (c = 0; c < 3; c++)
{
- *(unsigned char *) dst = ((*(float *) src) * alpha) * 255.0;
+ *(unsigned char *) dst = lrint (((*(float *) src) * alpha) * 255.0);
dst += 1;
src += 4;
}
- *(unsigned char *) dst = alpha * 255.0;
+ *(unsigned char *) dst = lrint (alpha * 255.0);
dst++;
src += 4;
}
@@ -859,11 +859,11 @@ conv_rgbaF_rgbA16 (unsigned char *src, unsigned char *dst, long samples)
for (c = 0; c < 3; c++)
{
- *(unsigned short *) dst = ((*(float *) src) * alpha) * 65535.0;
+ *(unsigned short *) dst = lrint (((*(float *) src) * alpha) * 65535.0);
dst += 2;
src += 4;
}
- *(unsigned short *) dst = alpha * 65535.0;
+ *(unsigned short *) dst = lrint (alpha * 65535.0);
dst += 2;
src += 4;
}
@@ -881,7 +881,7 @@ conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
for (c = 0; c < 3; c++)
{
- *(unsigned short *) dst = (*(float *) src) * 65535.0;
+ *(unsigned short *) dst = lrint ((*(float *) src) * 65535.0);
dst += 2;
src += 4;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]