[Rawstudio-commit] r3160 - trunk/plugins/dcp

Klaus Post klauspost at gmail.com
Thu Feb 4 20:31:48 CET 2010


Author: post
Date: 2010-02-04 20:31:47 +0100 (Thu, 04 Feb 2010)
New Revision: 3160

Modified:
   trunk/plugins/dcp/dcp.c
Log:
Interpolate curve values to avoid unneeded posterization accumulation.

Modified: trunk/plugins/dcp/dcp.c
===================================================================
--- trunk/plugins/dcp/dcp.c	2010-02-03 23:00:39 UTC (rev 3159)
+++ trunk/plugins/dcp/dcp.c	2010-02-04 19:31:47 UTC (rev 3160)
@@ -191,10 +191,12 @@
 
 				if (!dcp->curve_is_flat)
 				{
-					gfloat sampled[65536];
+					gfloat sampled[65537];
 					RSSpline *spline = rs_spline_new(knots, dcp->nknots, NATURAL);
 					rs_spline_sample(spline, sampled, sizeof(sampled) / sizeof(gfloat));
 					g_object_unref(spline);
+					/* Create extra entry */
+					sampled[65536] = sampled[65535];
 					for (i = 0; i < 65536; i++)
 					{
 						gfloat value = (gfloat)i * (1.0 / 65535.0f);
@@ -202,7 +204,11 @@
 						value = powf(value, 1.0f / 2.2f);
 						
 						/*Lookup curve corrected value */
-						value = sampled[(int)(value * 65535.0f + 0.49999f)];
+						gfloat lookup = (int)(value * 65535.0f);
+						gfloat v0 = sampled[(int)lookup];
+						gfloat v1 = sampled[(int)lookup+1];
+						lookup -= (gfloat)(gint)lookup;
+						value = v0 * (1.0f-lookup) + v1 * lookup;
 
 						/* Convert from gamma 2.2 back to linear */
 						value = powf(value, 2.2f);




More information about the Rawstudio-commit mailing list