[gnome-photos/gnome-3-24] operation-insta-curve: Use single precision floating point
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/gnome-3-24] operation-insta-curve: Use single precision floating point
- Date: Mon, 11 Dec 2017 17:34:10 +0000 (UTC)
commit bd97c27f6ae05f8f4d49ea2069eadcd902cd45a7
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Dec 11 12:46:44 2017 +0100
operation-insta-curve: Use single precision floating point
Single precision floating point is all that's needed. It is wasteful to
promote calculations to double precision through the use of such
literals. This can have significant performance impact on architectures
like ARM.
src/photos-operation-insta-curve.c | 108 ++++++++++++++++++------------------
1 files changed, 54 insertions(+), 54 deletions(-)
---
diff --git a/src/photos-operation-insta-curve.c b/src/photos-operation-insta-curve.c
index 608884b..16206ed 100644
--- a/src/photos-operation-insta-curve.c
+++ b/src/photos-operation-insta-curve.c
@@ -448,7 +448,7 @@ photos_operation_insta_curve_brannan_process_alpha_float (GeglOperation *operati
for (i = 0; i < n_pixels; i++)
{
- const gfloat saturation = 0.1;
+ const gfloat saturation = 0.1f;
guint max;
out[0] = photos_operation_insta_curve_interpolate (in[0], BRANNAN_R, BRANNAN_A);
@@ -459,13 +459,13 @@ photos_operation_insta_curve_brannan_process_alpha_float (GeglOperation *operati
max = (out[max] > out[2]) ? max : 2;
if (max != 0)
- out[0] += (guint8) ((out[max] - out[0]) * saturation + 0.5);
+ out[0] += (guint8) ((out[max] - out[0]) * saturation + 0.5f);
if (max != 1)
- out[1] += (guint8) ((out[max] - out[1]) * saturation + 0.5);
+ out[1] += (guint8) ((out[max] - out[1]) * saturation + 0.5f);
if (max != 2)
- out[2] += (guint8) ((out[max] - out[2]) * saturation + 0.5);
+ out[2] += (guint8) ((out[max] - out[2]) * saturation + 0.5f);
out[3] = in[3];
@@ -489,7 +489,7 @@ photos_operation_insta_curve_brannan_process_alpha_u8 (GeglOperation *operation,
for (i = 0; i < n_pixels; i++)
{
- const gfloat saturation = 0.1;
+ const gfloat saturation = 0.1f;
guint max;
out[0] = BRANNAN_R[in[0]];
@@ -504,13 +504,13 @@ photos_operation_insta_curve_brannan_process_alpha_u8 (GeglOperation *operation,
max = (out[max] > out[2]) ? max : 2;
if (max != 0)
- out[0] += (guint8) ((out[max] - out[0]) * saturation + 0.5);
+ out[0] += (guint8) ((out[max] - out[0]) * saturation + 0.5f);
if (max != 1)
- out[1] += (guint8) ((out[max] - out[1]) * saturation + 0.5);
+ out[1] += (guint8) ((out[max] - out[1]) * saturation + 0.5f);
if (max != 2)
- out[2] += (guint8) ((out[max] - out[2]) * saturation + 0.5);
+ out[2] += (guint8) ((out[max] - out[2]) * saturation + 0.5f);
out[3] = in[3];
@@ -534,7 +534,7 @@ photos_operation_insta_curve_brannan_process_float (GeglOperation *operation,
for (i = 0; i < n_pixels; i++)
{
- const gfloat saturation = 0.1;
+ const gfloat saturation = 0.1f;
guint max;
out[0] = photos_operation_insta_curve_interpolate (in[0], BRANNAN_R, BRANNAN_A);
@@ -545,13 +545,13 @@ photos_operation_insta_curve_brannan_process_float (GeglOperation *operation,
max = (out[max] > out[2]) ? max : 2;
if (max != 0)
- out[0] += (guint8) ((out[max] - out[0]) * saturation + 0.5);
+ out[0] += (guint8) ((out[max] - out[0]) * saturation + 0.5f);
if (max != 1)
- out[1] += (guint8) ((out[max] - out[1]) * saturation + 0.5);
+ out[1] += (guint8) ((out[max] - out[1]) * saturation + 0.5f);
if (max != 2)
- out[2] += (guint8) ((out[max] - out[2]) * saturation + 0.5);
+ out[2] += (guint8) ((out[max] - out[2]) * saturation + 0.5f);
in += 3;
out += 3;
@@ -573,7 +573,7 @@ photos_operation_insta_curve_brannan_process_u8 (GeglOperation *operation,
for (i = 0; i < n_pixels; i++)
{
- const gfloat saturation = 0.1;
+ const gfloat saturation = 0.1f;
guint max;
out[0] = BRANNAN_R[in[0]];
@@ -588,13 +588,13 @@ photos_operation_insta_curve_brannan_process_u8 (GeglOperation *operation,
max = (out[max] > out[2]) ? max : 2;
if (max != 0)
- out[0] += (guint8) ((out[max] - out[0]) * saturation + 0.5);
+ out[0] += (guint8) ((out[max] - out[0]) * saturation + 0.5f);
if (max != 1)
- out[1] += (guint8) ((out[max] - out[1]) * saturation + 0.5);
+ out[1] += (guint8) ((out[max] - out[1]) * saturation + 0.5f);
if (max != 2)
- out[2] += (guint8) ((out[max] - out[2]) * saturation + 0.5);
+ out[2] += (guint8) ((out[max] - out[2]) * saturation + 0.5f);
in += 3;
out += 3;
@@ -723,12 +723,12 @@ photos_operation_insta_curve_nashville_process_alpha_float (GeglOperation *opera
for (i = 0; i < n_pixels; i++)
{
- const gfloat brightness = -0.05;
- const gfloat contrast = 1.1;
+ const gfloat brightness = -0.05f;
+ const gfloat contrast = 1.1f;
- out[0] = (in[0] - 0.5f) * contrast + brightness + 0.5;
- out[1] = (in[1] - 0.5f) * contrast + brightness + 0.5;
- out[2] = (in[2] - 0.5f) * contrast + brightness + 0.5;
+ out[0] = (in[0] - 0.5f) * contrast + brightness + 0.5f;
+ out[1] = (in[1] - 0.5f) * contrast + brightness + 0.5f;
+ out[2] = (in[2] - 0.5f) * contrast + brightness + 0.5f;
out[0] = photos_operation_insta_curve_interpolate (out[0], NASHVILLE_R, NASHVILLE_A);
out[1] = photos_operation_insta_curve_interpolate (out[1], NASHVILLE_G, NASHVILLE_A);
@@ -756,24 +756,24 @@ photos_operation_insta_curve_nashville_process_alpha_u8 (GeglOperation *operatio
for (i = 0; i < n_pixels; i++)
{
- const gfloat brightness = -0.05;
- const gfloat contrast = 1.1;
+ const gfloat brightness = -0.05f;
+ const gfloat contrast = 1.1f;
gfloat channel;
- channel = in[0] / 255.0;
- channel = (channel - 0.5f) * contrast + brightness + 0.5;
- channel = CLAMP (channel, 0.0, 1.0);
- out[0] = (guint8) (channel * 255.0);
+ channel = in[0] / 255.0f;
+ channel = (channel - 0.5f) * contrast + brightness + 0.5f;
+ channel = CLAMP (channel, 0.0f, 1.0f);
+ out[0] = (guint8) (channel * 255.0f);
- channel = in[1] / 255.0;
- out[1] = (channel - 0.5f) * contrast + brightness + 0.5;
- channel = CLAMP (channel, 0.0, 1.0);
- out[1] = (guint8) (channel * 255.0);
+ channel = in[1] / 255.0f;
+ out[1] = (channel - 0.5f) * contrast + brightness + 0.5f;
+ channel = CLAMP (channel, 0.0f, 1.0f);
+ out[1] = (guint8) (channel * 255.0f);
- channel = in[2] / 255.0;
- out[2] = (channel - 0.5f) * contrast + brightness + 0.5;
- channel = CLAMP (channel, 0.0, 1.0);
- out[2] = (guint8) (channel * 255.0);
+ channel = in[2] / 255.0f;
+ out[2] = (channel - 0.5f) * contrast + brightness + 0.5f;
+ channel = CLAMP (channel, 0.0f, 1.0f);
+ out[2] = (guint8) (channel * 255.0f);
out[0] = NASHVILLE_R[out[0]];
out[1] = NASHVILLE_G[out[1]];
@@ -805,12 +805,12 @@ photos_operation_insta_curve_nashville_process_float (GeglOperation *operation,
for (i = 0; i < n_pixels; i++)
{
- const gfloat brightness = -0.05;
- const gfloat contrast = 1.1;
+ const gfloat brightness = -0.05f;
+ const gfloat contrast = 1.1f;
- out[0] = (in[0] - 0.5f) * contrast + brightness + 0.5;
- out[1] = (in[1] - 0.5f) * contrast + brightness + 0.5;
- out[2] = (in[2] - 0.5f) * contrast + brightness + 0.5;
+ out[0] = (in[0] - 0.5f) * contrast + brightness + 0.5f;
+ out[1] = (in[1] - 0.5f) * contrast + brightness + 0.5f;
+ out[2] = (in[2] - 0.5f) * contrast + brightness + 0.5f;
out[0] = photos_operation_insta_curve_interpolate (out[0], NASHVILLE_R, NASHVILLE_A);
out[1] = photos_operation_insta_curve_interpolate (out[1], NASHVILLE_G, NASHVILLE_A);
@@ -836,24 +836,24 @@ photos_operation_insta_curve_nashville_process_u8 (GeglOperation *operation,
for (i = 0; i < n_pixels; i++)
{
- const gfloat brightness = -0.05;
- const gfloat contrast = 1.1;
+ const gfloat brightness = -0.05f;
+ const gfloat contrast = 1.1f;
gfloat channel;
- channel = in[0] / 255.0;
- channel = (channel - 0.5f) * contrast + brightness + 0.5;
- channel = CLAMP (channel, 0.0, 1.0);
- out[0] = (guint8) (channel * 255.0);
+ channel = in[0] / 255.0f;
+ channel = (channel - 0.5f) * contrast + brightness + 0.5f;
+ channel = CLAMP (channel, 0.0f, 1.0f);
+ out[0] = (guint8) (channel * 255.0f);
- channel = in[1] / 255.0;
- out[1] = (channel - 0.5f) * contrast + brightness + 0.5;
- channel = CLAMP (channel, 0.0, 1.0);
- out[1] = (guint8) (channel * 255.0);
+ channel = in[1] / 255.0f;
+ out[1] = (channel - 0.5f) * contrast + brightness + 0.5f;
+ channel = CLAMP (channel, 0.0f, 1.0f);
+ out[1] = (guint8) (channel * 255.0f);
- channel = in[2] / 255.0;
- out[2] = (channel - 0.5f) * contrast + brightness + 0.5;
- channel = CLAMP (channel, 0.0, 1.0);
- out[2] = (guint8) (channel * 255.0);
+ channel = in[2] / 255.0f;
+ out[2] = (channel - 0.5f) * contrast + brightness + 0.5f;
+ channel = CLAMP (channel, 0.0f, 1.0f);
+ out[2] = (guint8) (channel * 255.0f);
out[0] = NASHVILLE_R[out[0]];
out[1] = NASHVILLE_G[out[1]];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]