gimp r25636 - in trunk: . app/gegl



Author: neo
Date: Sun May 11 09:51:15 2008
New Revision: 25636
URL: http://svn.gnome.org/viewvc/gimp?rev=25636&view=rev

Log:
2008-05-11  Sven Neumann  <sven gimp org>

	* app/gegl/gimpoperationlevels.c (gimp_operation_levels_map):
	optimized for the case where gamma is 1.0.



Modified:
   trunk/ChangeLog
   trunk/app/gegl/gimpoperationlevels.c

Modified: trunk/app/gegl/gimpoperationlevels.c
==============================================================================
--- trunk/app/gegl/gimpoperationlevels.c	(original)
+++ trunk/app/gegl/gimpoperationlevels.c	Sun May 11 09:51:15 2008
@@ -77,7 +77,7 @@
 
 static inline gdouble
 gimp_operation_levels_map (gdouble value,
-                           gdouble gamma,
+                           gdouble inv_gamma,
                            gdouble low_input,
                            gdouble high_input,
                            gdouble low_output,
@@ -89,12 +89,12 @@
   else
     value = (value - low_input);
 
-  if (gamma != 0.0)
+  if (inv_gamma != 1.0)
     {
       if (value >= 0.0)
-        value =  pow ( value, 1.0 / gamma);
+        value =  pow ( value, inv_gamma);
       else
-        value = -pow (-value, 1.0 / gamma);
+        value = -pow (-value, inv_gamma);
     }
 
   /*  determine the output intensity  */
@@ -116,20 +116,27 @@
   GimpLevelsConfig         *config = GIMP_LEVELS_CONFIG (point->config);
   gfloat                   *src    = in_buf;
   gfloat                   *dest   = out_buf;
+  gfloat                    inv_gamma[5];
+  gint                      channel;
 
   if (! config)
     return FALSE;
 
-  while (samples--)
+  for (channel = 0; channel < 5; channel++)
     {
-      gint channel;
+      g_return_val_if_fail (config->gamma[channel] != 0.0, FALSE);
+
+      inv_gamma[channel] = 1.0 / config->gamma[channel];
+    }
 
+  while (samples--)
+    {
       for (channel = 0; channel < 4; channel++)
         {
           gdouble value;
 
           value = gimp_operation_levels_map (src[channel],
-                                             config->gamma[channel + 1],
+                                             inv_gamma[channel + 1],
                                              config->low_input[channel + 1],
                                              config->high_input[channel + 1],
                                              config->low_output[channel + 1],
@@ -138,7 +145,7 @@
           /* don't apply the overall curve to the alpha channel */
           if (channel != ALPHA_PIX)
             value = gimp_operation_levels_map (value,
-                                               config->gamma[0],
+                                               inv_gamma[0],
                                                config->low_input[0],
                                                config->high_input[0],
                                                config->low_output[0],



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]