[Rawstudio-commit] r3199 - in trunk/plugins: colorspace-transform dcp

Anders Brander anders at brander.dk
Sat Feb 13 02:14:38 CET 2010


Author: abrander
Date: 2010-02-13 02:14:38 +0100 (Sat, 13 Feb 2010)
New Revision: 3199

Modified:
   trunk/plugins/colorspace-transform/colorspace_transform.c
   trunk/plugins/dcp/dcp-sse2.c
   trunk/plugins/dcp/dcp.c
   trunk/plugins/dcp/dcp.h
Log:
Enabled RSDcp and RSColorspaceTransform to premultiply in beautiful harmony.

Modified: trunk/plugins/colorspace-transform/colorspace_transform.c
===================================================================
--- trunk/plugins/colorspace-transform/colorspace_transform.c	2010-02-13 00:45:34 UTC (rev 3198)
+++ trunk/plugins/colorspace-transform/colorspace_transform.c	2010-02-13 01:14:38 UTC (rev 3199)
@@ -110,6 +110,7 @@
 		{
 			/* Image was converted */
 			response = rs_filter_response_clone(previous_response);
+			rs_filter_param_set_boolean(RS_FILTER_PARAM(response), "is-premultiplied", TRUE);
 			g_object_unref(previous_response);
 			rs_filter_response_set_image(response, output);
 			g_object_unref(output);

Modified: trunk/plugins/dcp/dcp-sse2.c
===================================================================
--- trunk/plugins/dcp/dcp-sse2.c	2010-02-13 00:45:34 UTC (rev 3198)
+++ trunk/plugins/dcp/dcp-sse2.c	2010-02-13 01:14:38 UTC (rev 3199)
@@ -593,7 +593,7 @@
 	gboolean do_contrast = (ABS(1.0f - dcp->contrast) > 0.001f);
 
 	int xfer[4] __attribute__ ((aligned (16)));
-	SETFLOAT4(_min_cam, 0.0f, dcp->camera_white.z, dcp->camera_white.y, dcp->camera_white.x);
+	SETFLOAT4_SAME(_min_cam, 1.0);
 	SETFLOAT4_SAME(_black_minus_radius, dcp->exposure_black - dcp->exposure_radius);
 	SETFLOAT4_SAME(_black_plus_radius, dcp->exposure_black + dcp->exposure_radius);
 	SETFLOAT4_SAME(_exposure_black, dcp->exposure_black);
@@ -604,6 +604,25 @@
 	SETFLOAT4_SAME(_cm_g, dcp->channelmixer_green);
 	SETFLOAT4_SAME(_cm_b, dcp->channelmixer_blue);
 	
+	if (dcp->use_profile)
+	{
+		_min_cam[0] = dcp->camera_white.x;
+		_min_cam[1] = dcp->camera_white.y;
+		_min_cam[2] = dcp->camera_white.z;
+		_min_cam[3] = 0.0;
+	}
+	else if (!t->dcp->is_premultiplied)
+	{
+		_min_cam[0] = 1.0 / MAX(dcp->pre_mul.R, 0.1);
+		_min_cam[1] = 1.0 / MAX(dcp->pre_mul.G, 0.1);
+		_min_cam[2] = 1.0 / MAX(dcp->pre_mul.B, 0.1);
+		_min_cam[3] = 0.0;
+
+		_cm_r[0] = _cm_r[1] = _cm_r[2] = _cm_r[3] *= dcp->pre_mul.R;
+		_cm_g[0] = _cm_g[1] = _cm_g[2] = _cm_g[3] *= dcp->pre_mul.G;
+		_cm_b[0] = _cm_b[1] = _cm_b[2] = _cm_b[3] *= dcp->pre_mul.B;
+	}
+
 	float cam_prof[4*4*3] __attribute__ ((aligned (16)));
 	for (x = 0; x < 4; x++ ) {
 		cam_prof[x] = dcp->camera_to_prophoto.coeff[0][0] * dcp->channelmixer_red;

Modified: trunk/plugins/dcp/dcp.c
===================================================================
--- trunk/plugins/dcp/dcp.c	2010-02-13 00:45:34 UTC (rev 3198)
+++ trunk/plugins/dcp/dcp.c	2010-02-13 01:14:38 UTC (rev 3199)
@@ -431,6 +431,9 @@
 	rs_filter_param_set_object(RS_FILTER_PARAM(response), "colorspace", klass->prophoto);
 	g_object_unref(previous_response);
 
+	dcp->is_premultiplied = FALSE;
+	rs_filter_param_get_boolean(RS_FILTER_PARAM(response), "is-premultiplied", &dcp->is_premultiplied);
+
 	output = rs_image16_copy(input, TRUE);
 	g_object_unref(input);
 
@@ -859,7 +862,21 @@
 	gfloat r, g, b;
 	RS_VECTOR3 pix;
 	gboolean do_contrast = (ABS(1.0f - dcp->contrast) > 0.001f);
-	
+	RS_VECTOR3 clip;
+
+	if (dcp->use_profile)
+	{
+		clip.R = dcp->camera_white.R;
+		clip.G = dcp->camera_white.G;
+		clip.B = dcp->camera_white.B;
+	}
+	else if (!t->dcp->is_premultiplied)
+	{
+		clip.R = 1.0 / MAX(dcp->pre_mul.R, 0.1);
+		clip.G = 1.0 / MAX(dcp->pre_mul.G, 0.1);
+		clip.B = 1.0 / MAX(dcp->pre_mul.B, 0.1);
+	}
+
 	for(y = t->start_y ; y < t->end_y; y++)
 	{
 		for(x=t->start_x; x < image->w; x++)
@@ -873,9 +890,9 @@
 
 			if (dcp->use_profile)
 			{
-				r = MIN(dcp->camera_white.x, r);
-				g = MIN(dcp->camera_white.y, g);
-				b = MIN(dcp->camera_white.z, b);
+				r = MIN(clip.R, r);
+				g = MIN(clip.G, g);
+				b = MIN(clip.B, b);
 
 				pix.R = r;
 				pix.G = g;
@@ -886,7 +903,17 @@
 				g = pix.G;
 				b = pix.B;
 			}
+			else if (!t->dcp->is_premultiplied)
+			{
+				r = MIN(clip.R, r);
+				g = MIN(clip.G, g);
+				b = MIN(clip.B, b);
 
+				r *= dcp->pre_mul.R;
+				g *= dcp->pre_mul.G;
+				b *= dcp->pre_mul.B;
+			}
+
 			r = CLAMP(r * dcp->channelmixer_red, 0.0, 1.0);
 			g = CLAMP(g * dcp->channelmixer_green, 0.0, 1.0);
 			b = CLAMP(b * dcp->channelmixer_blue, 0.0, 1.0);

Modified: trunk/plugins/dcp/dcp.h
===================================================================
--- trunk/plugins/dcp/dcp.h	2010-02-13 00:45:34 UTC (rev 3198)
+++ trunk/plugins/dcp/dcp.h	2010-02-13 01:14:38 UTC (rev 3199)
@@ -56,6 +56,7 @@
 	gfloat channelmixer_blue;
 
 	RS_VECTOR3 pre_mul;
+	gboolean is_premultiplied;
 	RS_xy_COORD white_xy;
 
 	gint nknots;




More information about the Rawstudio-commit mailing list