[gnome-photos] operation-shadows-highlights-correction: Optimize - avoid NOP overlays
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] operation-shadows-highlights-correction: Optimize - avoid NOP overlays
- Date: Tue, 2 Jan 2018 07:43:18 +0000 (UTC)
commit 27742634b6bdf01122f7ff08ece14885d9859b6a
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Jan 2 08:33:52 2018 +0100
operation-shadows-highlights-correction: Optimize - avoid NOP overlays
This keeps the code in sync with gegl.
...hotos-operation-shadows-highlights-correction.c | 180 +++++++++++----------
1 file changed, 94 insertions(+), 86 deletions(-)
---
diff --git a/src/photos-operation-shadows-highlights-correction.c
b/src/photos-operation-shadows-highlights-correction.c
index 77d9c263..f1a344dd 100644
--- a/src/photos-operation-shadows-highlights-correction.c
+++ b/src/photos-operation-shadows-highlights-correction.c
@@ -155,10 +155,6 @@ photos_operation_shadows_highlights_correction_process (GeglOperation *operation
{
gfloat ta[3];
gfloat tb0;
- gfloat highlights_xform;
- gfloat highlights2 = highlights * highlights;
- gfloat shadows_xform;
- gfloat shadows2 = shadows * shadows;
ta[0] = in[0] / 100.0f;
ta[1] = in[1] / 128.0f;
@@ -169,92 +165,104 @@ photos_operation_shadows_highlights_correction_process (GeglOperation *operation
ta[0] = ta[0] > 0.0f ? ta[0] / whitepoint : ta[0];
tb0 = tb0 > 0.0f ? tb0 / whitepoint : tb0;
- highlights_xform = CLAMP (1.0f - tb0 / compress_inverted, 0.0f, 1.0f);
-
- while (highlights2 > 0.0f)
+ if (tb0 < compress_inverted)
{
- gfloat chunk;
- gfloat href;
- gfloat la = ta[0];
- gfloat la_abs;
- gfloat la_inverted = 1.0f - la;
- gfloat la_inverted_abs;
- gfloat la_inverted_sign;
- gfloat lb;
- gfloat lref;
- gfloat optrans;
- gfloat optrans_inverted;
-
- la_inverted_sign = la_inverted < 0.0f ? -1.0f : 1.0f;
- lb = (tb0 - 0.5f) * highlights_sign_negated * la_inverted_sign + 0.5f;
-
- la_abs = fabsf (la);
- lref = copysignf (la_abs > low_approximation ? 1.0f / la_abs : 1.0f / low_approximation, la);
-
- la_inverted_abs = fabsf (la_inverted);
- href = copysignf (la_inverted_abs > low_approximation ? 1.0f / la_inverted_abs : 1.0f /
low_approximation,
- la_inverted);
-
- chunk = fminf (highlights2, 1.0f);
- optrans = chunk * highlights_xform;
- optrans_inverted = 1.0f - optrans;
-
- highlights2 -= 1.0f;
-
- ta[0] = la * optrans_inverted
- + (la > 0.5f ? 1.0f - (1.0f - 2.0f * (la - 0.5f)) * (1.0f - lb) : 2.0f * la * lb) * optrans;
-
- ta[1] = ta[1] * optrans_inverted
- + ta[1] * (ta[0] * lref * highlights_color_correct_inverted
- + (1.0f - ta[0]) * href * highlights_color_correct) * optrans;
-
- ta[2] = ta[2] * optrans_inverted
- + ta[2] * (ta[0] * lref * highlights_color_correct_inverted
- + (1.0f - ta[0]) * href * highlights_color_correct) * optrans;
+ gfloat highlights_xform;
+ gfloat highlights2 = highlights * highlights;
+
+ highlights_xform = fminf (1.0f - tb0 / compress_inverted, 1.0f);
+
+ while (highlights2 > 0.0f)
+ {
+ gfloat chunk;
+ gfloat href;
+ gfloat la = ta[0];
+ gfloat la_abs;
+ gfloat la_inverted = 1.0f - la;
+ gfloat la_inverted_abs;
+ gfloat la_inverted_sign;
+ gfloat lb;
+ gfloat lref;
+ gfloat optrans;
+ gfloat optrans_inverted;
+
+ la_inverted_sign = la_inverted < 0.0f ? -1.0f : 1.0f;
+ lb = (tb0 - 0.5f) * highlights_sign_negated * la_inverted_sign + 0.5f;
+
+ la_abs = fabsf (la);
+ lref = copysignf (la_abs > low_approximation ? 1.0f / la_abs : 1.0f / low_approximation, la);
+
+ la_inverted_abs = fabsf (la_inverted);
+ href = copysignf (la_inverted_abs > low_approximation ? 1.0f / la_inverted_abs : 1.0f /
low_approximation,
+ la_inverted);
+
+ chunk = fminf (highlights2, 1.0f);
+ optrans = chunk * highlights_xform;
+ optrans_inverted = 1.0f - optrans;
+
+ highlights2 -= 1.0f;
+
+ ta[0] = la * optrans_inverted
+ + (la > 0.5f ? 1.0f - (1.0f - 2.0f * (la - 0.5f)) * (1.0f - lb) : 2.0f * la * lb) * optrans;
+
+ ta[1] = ta[1] * optrans_inverted
+ + ta[1] * (ta[0] * lref * highlights_color_correct_inverted
+ + (1.0f - ta[0]) * href * highlights_color_correct) * optrans;
+
+ ta[2] = ta[2] * optrans_inverted
+ + ta[2] * (ta[0] * lref * highlights_color_correct_inverted
+ + (1.0f - ta[0]) * href * highlights_color_correct) * optrans;
+ }
}
- shadows_xform = CLAMP (tb0 / compress_inverted - compress / compress_inverted, 0.0f, 1.0f);
-
- while (shadows2 > 0.0f)
+ if (tb0 > compress)
{
- gfloat chunk;
- gfloat href;
- gfloat la = ta[0];
- gfloat la_abs;
- gfloat la_inverted = 1.0f - la;
- gfloat la_inverted_abs;
- gfloat la_inverted_sign;
- gfloat lb;
- gfloat lref;
- gfloat optrans;
- gfloat optrans_inverted;
-
- la_inverted_sign = la_inverted < 0.0f ? -1.0f : 1.0f;
- lb = (tb0 - 0.5f) * shadows_sign * la_inverted_sign + 0.5f;
-
- la_abs = fabsf (la);
- lref = copysignf (la_abs > low_approximation ? 1.0f / la_abs : 1.0f / low_approximation, la);
-
- la_inverted_abs = fabsf (la_inverted);
- href = copysignf (la_inverted_abs > low_approximation ? 1.0f / la_inverted_abs : 1.0f /
low_approximation,
- la_inverted);
-
- chunk = fminf (shadows2, 1.0f);
- optrans = chunk * shadows_xform;
- optrans_inverted = 1.0f - optrans;
-
- shadows2 -= 1.0f;
-
- ta[0] = la * optrans_inverted
- + (la > 0.5f ? 1.0f - (1.0f - 2.0f * (la - 0.5f)) * (1.0f - lb) : 2.0f * la * lb) * optrans;
-
- ta[1] = ta[1] * optrans_inverted
- + ta[1] * (ta[0] * lref * shadows_color_correct
- + (1.0f - ta[0]) * href * shadows_color_correct_inverted) * optrans;
-
- ta[2] = ta[2] * optrans_inverted
- + ta[2] * (ta[0] * lref * shadows_color_correct
- + (1.0f - ta[0]) * href * shadows_color_correct_inverted) * optrans;
+ gfloat shadows_xform;
+ gfloat shadows2 = shadows * shadows;
+
+ shadows_xform = fminf (tb0 / compress_inverted - compress / compress_inverted, 1.0f);
+
+ while (shadows2 > 0.0f)
+ {
+ gfloat chunk;
+ gfloat href;
+ gfloat la = ta[0];
+ gfloat la_abs;
+ gfloat la_inverted = 1.0f - la;
+ gfloat la_inverted_abs;
+ gfloat la_inverted_sign;
+ gfloat lb;
+ gfloat lref;
+ gfloat optrans;
+ gfloat optrans_inverted;
+
+ la_inverted_sign = la_inverted < 0.0f ? -1.0f : 1.0f;
+ lb = (tb0 - 0.5f) * shadows_sign * la_inverted_sign + 0.5f;
+
+ la_abs = fabsf (la);
+ lref = copysignf (la_abs > low_approximation ? 1.0f / la_abs : 1.0f / low_approximation, la);
+
+ la_inverted_abs = fabsf (la_inverted);
+ href = copysignf (la_inverted_abs > low_approximation ? 1.0f / la_inverted_abs : 1.0f /
low_approximation,
+ la_inverted);
+
+ chunk = fminf (shadows2, 1.0f);
+ optrans = chunk * shadows_xform;
+ optrans_inverted = 1.0f - optrans;
+
+ shadows2 -= 1.0f;
+
+ ta[0] = la * optrans_inverted
+ + (la > 0.5f ? 1.0f - (1.0f - 2.0f * (la - 0.5f)) * (1.0f - lb) : 2.0f * la * lb) * optrans;
+
+ ta[1] = ta[1] * optrans_inverted
+ + ta[1] * (ta[0] * lref * shadows_color_correct
+ + (1.0f - ta[0]) * href * shadows_color_correct_inverted) * optrans;
+
+ ta[2] = ta[2] * optrans_inverted
+ + ta[2] * (ta[0] * lref * shadows_color_correct
+ + (1.0f - ta[0]) * href * shadows_color_correct_inverted) * optrans;
+ }
}
out[0] = ta[0] * 100.0f;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]