Author: post
Date: 2009-12-29 19:29:13 +0100 (Tue, 29 Dec 2009)
New Revision: 2880
Modified:
branches/rawstudio-ng-color/plugins/dcp/dcp-sse.c
branches/rawstudio-ng-color/plugins/dcp/dcp.c
branches/rawstudio-ng-color/plugins/dcp/dcp.h
Log:
DCP: Make channel mixer work. Made SSE code able to render without DCP. Made
slight change to how "use_profile" is used, when dcp is disabled, the dcp-parts
that are disabled are set to NULL to avoid double check.
Modified: branches/rawstudio-ng-color/plugins/dcp/dcp-sse.c
===================================================================
--- branches/rawstudio-ng-color/plugins/dcp/dcp-sse.c 2009-12-29 17:09:17 UTC
(rev 2879)
+++ branches/rawstudio-ng-color/plugins/dcp/dcp-sse.c 2009-12-29 18:29:13 UTC
(rev 2880)
@@ -577,18 +577,21 @@
SETFLOAT4_SAME(_exposure_slope, dcp->exposure_slope);
SETFLOAT4_SAME(_exposure_qscale, dcp->exposure_qscale);
SETFLOAT4_SAME(_contrast, dcp->contrast);
+ SETFLOAT4_SAME(_cm_r, dcp->channelmixer_red);
+ SETFLOAT4_SAME(_cm_g, dcp->channelmixer_green);
+ SETFLOAT4_SAME(_cm_b, dcp->channelmixer_blue);
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];
- cam_prof[x+4] = dcp->camera_to_prophoto.coeff[0][1];
- cam_prof[x+8] = dcp->camera_to_prophoto.coeff[0][2];
- cam_prof[12+x] = dcp->camera_to_prophoto.coeff[1][0];
- cam_prof[12+x+4] = dcp->camera_to_prophoto.coeff[1][1];
- cam_prof[12+x+8] = dcp->camera_to_prophoto.coeff[1][2];
- cam_prof[24+x] = dcp->camera_to_prophoto.coeff[2][0];
- cam_prof[24+x+4] = dcp->camera_to_prophoto.coeff[2][1];
- cam_prof[24+x+8] = dcp->camera_to_prophoto.coeff[2][2];
+ cam_prof[x] = dcp->camera_to_prophoto.coeff[0][0] *
dcp->channelmixer_red;
+ cam_prof[x+4] = dcp->camera_to_prophoto.coeff[0][1] *
dcp->channelmixer_red;
+ cam_prof[x+8] = dcp->camera_to_prophoto.coeff[0][2] *
dcp->channelmixer_red;
+ cam_prof[12+x] = dcp->camera_to_prophoto.coeff[1][0] *
dcp->channelmixer_green;
+ cam_prof[12+x+4] = dcp->camera_to_prophoto.coeff[1][1] *
dcp->channelmixer_green;
+ cam_prof[12+x+8] = dcp->camera_to_prophoto.coeff[1][2] *
dcp->channelmixer_green;
+ cam_prof[24+x] = dcp->camera_to_prophoto.coeff[2][0] *
dcp->channelmixer_blue;
+ cam_prof[24+x+4] = dcp->camera_to_prophoto.coeff[2][1] *
dcp->channelmixer_blue;
+ cam_prof[24+x+8] = dcp->camera_to_prophoto.coeff[2][2]*
dcp->channelmixer_blue;
}
gint end_x = image->w - (image->w & 3);
@@ -618,27 +621,45 @@
p3f = _mm_mul_ps(p3f, rgb_div);
p4f = _mm_mul_ps(p4f, rgb_div);
- /* Restric to camera white */
- __m128 min_cam = _mm_load_ps(_min_cam);
- p1f = _mm_min_ps(p1f, min_cam);
- p2f = _mm_min_ps(p2f, min_cam);
- p3f = _mm_min_ps(p3f, min_cam);
- p4f = _mm_min_ps(p4f, min_cam);
+ if (dcp->use_profile)
+ {
+ /* Restric to camera white */
+ __m128 min_cam = _mm_load_ps(_min_cam);
+ p1f = _mm_min_ps(p1f, min_cam);
+ p2f = _mm_min_ps(p2f, min_cam);
+ p3f = _mm_min_ps(p3f, min_cam);
+ p4f = _mm_min_ps(p4f, min_cam);
- /* Convert to planar */
- __m128 g1g0r1r0 = _mm_unpacklo_ps(p1f, p2f);
- __m128 b1b0 = _mm_unpackhi_ps(p1f, p2f);
- __m128 g3g2r3r2 = _mm_unpacklo_ps(p3f, p4f);
- __m128 b3b2 = _mm_unpackhi_ps(p3f, p4f);
- r = _mm_movelh_ps(g1g0r1r0, g3g2r3r2);
- g = _mm_movehl_ps(g3g2r3r2, g1g0r1r0);
- b = _mm_movelh_ps(b1b0, b3b2);
+ /* Convert to planar */
+ __m128 g1g0r1r0 = _mm_unpacklo_ps(p1f, p2f);
+ __m128 b1b0 = _mm_unpackhi_ps(p1f, p2f);
+ __m128 g3g2r3r2 = _mm_unpacklo_ps(p3f, p4f);
+ __m128 b3b2 = _mm_unpackhi_ps(p3f, p4f);
+ r = _mm_movelh_ps(g1g0r1r0, g3g2r3r2);
+ g = _mm_movehl_ps(g3g2r3r2, g1g0r1r0);
+ b = _mm_movelh_ps(b1b0, b3b2);
- /* Convert to Prophoto */
- r2 = sse_matrix3_mul(cam_prof, r, g, b);
- g2 = sse_matrix3_mul(&cam_prof[12], r, g, b);
- b2 = sse_matrix3_mul(&cam_prof[24], r, g, b);
+ /* Convert to Prophoto */
+ r2 = sse_matrix3_mul(cam_prof, r, g, b);
+ g2 = sse_matrix3_mul(&cam_prof[12], r, g, b);
+ b2 = sse_matrix3_mul(&cam_prof[24], r, g, b);
+ } else
+ {
+ /* Convert to planar */
+ __m128 g1g0r1r0 = _mm_unpacklo_ps(p1f, p2f);
+ __m128 b1b0 = _mm_unpackhi_ps(p1f, p2f);
+ __m128 g3g2r3r2 = _mm_unpacklo_ps(p3f, p4f);
+ __m128 b3b2 = _mm_unpackhi_ps(p3f, p4f);
+ r = _mm_movelh_ps(g1g0r1r0, g3g2r3r2);
+ g = _mm_movehl_ps(g3g2r3r2, g1g0r1r0);
+ b = _mm_movelh_ps(b1b0, b3b2);
+ /* Multiply channel mixer */
+ r2 = _mm_mul_ps(_mm_load_ps(_cm_r), r);
+ g2 = _mm_mul_ps(_mm_load_ps(_cm_g), g);
+ b2 = _mm_mul_ps(_mm_load_ps(_cm_b), b);
+ }
+
RGBtoHSV_SSE(&r2, &g2, &b2);
h = r2; s = g2; v = b2;
@@ -1029,13 +1050,6 @@
#define LOOK_SINGLE(A,B,C,D) A = _mm_insert_epi32( A, *(gint32*)&C[D]->B, D)
-/*
-//#define LOOKUP_FOUR(A, B, C) A = _mm_cvtsi32_si128(*(gint32*)&C[0]->B);\
- LOOK_SINGLE(A, B, C, 1);\
- LOOK_SINGLE(A, B, C, 2);\
- LOOK_SINGLE(A, B, C, 3);
-*/
-
#define LOOKUP_FOUR(A, B, C) LOOK_SINGLE(A, B, C, 0);\
LOOK_SINGLE(A, B, C, 1);\
LOOK_SINGLE(A, B, C, 2);\
@@ -1257,18 +1271,21 @@
SETFLOAT4_SAME(_exposure_slope, dcp->exposure_slope);
SETFLOAT4_SAME(_exposure_qscale, dcp->exposure_qscale);
SETFLOAT4_SAME(_contrast, dcp->contrast);
+ SETFLOAT4_SAME(_cm_r, dcp->channelmixer_red);
+ SETFLOAT4_SAME(_cm_g, dcp->channelmixer_green);
+ SETFLOAT4_SAME(_cm_b, dcp->channelmixer_blue);
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];
- cam_prof[x+4] = dcp->camera_to_prophoto.coeff[0][1];
- cam_prof[x+8] = dcp->camera_to_prophoto.coeff[0][2];
- cam_prof[12+x] = dcp->camera_to_prophoto.coeff[1][0];
- cam_prof[12+x+4] = dcp->camera_to_prophoto.coeff[1][1];
- cam_prof[12+x+8] = dcp->camera_to_prophoto.coeff[1][2];
- cam_prof[24+x] = dcp->camera_to_prophoto.coeff[2][0];
- cam_prof[24+x+4] = dcp->camera_to_prophoto.coeff[2][1];
- cam_prof[24+x+8] = dcp->camera_to_prophoto.coeff[2][2];
+ cam_prof[x] = dcp->camera_to_prophoto.coeff[0][0] *
dcp->channelmixer_red;
+ cam_prof[x+4] = dcp->camera_to_prophoto.coeff[0][1] *
dcp->channelmixer_red;
+ cam_prof[x+8] = dcp->camera_to_prophoto.coeff[0][2] *
dcp->channelmixer_red;
+ cam_prof[12+x] = dcp->camera_to_prophoto.coeff[1][0] *
dcp->channelmixer_green;
+ cam_prof[12+x+4] = dcp->camera_to_prophoto.coeff[1][1] *
dcp->channelmixer_green;
+ cam_prof[12+x+8] = dcp->camera_to_prophoto.coeff[1][2] *
dcp->channelmixer_green;
+ cam_prof[24+x] = dcp->camera_to_prophoto.coeff[2][0] *
dcp->channelmixer_blue;
+ cam_prof[24+x+4] = dcp->camera_to_prophoto.coeff[2][1] *
dcp->channelmixer_blue;
+ cam_prof[24+x+8] = dcp->camera_to_prophoto.coeff[2][2]*
dcp->channelmixer_blue;
}
@@ -1299,27 +1316,45 @@
p3f = _mm_mul_ps(p3f, rgb_div);
p4f = _mm_mul_ps(p4f, rgb_div);
- /* Restric to camera white */
- __m128 min_cam = _mm_load_ps(_min_cam);
- p1f = _mm_min_ps(p1f, min_cam);
- p2f = _mm_min_ps(p2f, min_cam);
- p3f = _mm_min_ps(p3f, min_cam);
- p4f = _mm_min_ps(p4f, min_cam);
+ if (dcp->use_profile)
+ {
+ /* Restric to camera white */
+ __m128 min_cam = _mm_load_ps(_min_cam);
+ p1f = _mm_min_ps(p1f, min_cam);
+ p2f = _mm_min_ps(p2f, min_cam);
+ p3f = _mm_min_ps(p3f, min_cam);
+ p4f = _mm_min_ps(p4f, min_cam);
- /* Convert to planar */
- __m128 g1g0r1r0 = _mm_unpacklo_ps(p1f, p2f);
- __m128 b1b0 = _mm_unpackhi_ps(p1f, p2f);
- __m128 g3g2r3r2 = _mm_unpacklo_ps(p3f, p4f);
- __m128 b3b2 = _mm_unpackhi_ps(p3f, p4f);
- r = _mm_movelh_ps(g1g0r1r0, g3g2r3r2);
- g = _mm_movehl_ps(g3g2r3r2, g1g0r1r0);
- b = _mm_movelh_ps(b1b0, b3b2);
+ /* Convert to planar */
+ __m128 g1g0r1r0 = _mm_unpacklo_ps(p1f, p2f);
+ __m128 b1b0 = _mm_unpackhi_ps(p1f, p2f);
+ __m128 g3g2r3r2 = _mm_unpacklo_ps(p3f, p4f);
+ __m128 b3b2 = _mm_unpackhi_ps(p3f, p4f);
+ r = _mm_movelh_ps(g1g0r1r0, g3g2r3r2);
+ g = _mm_movehl_ps(g3g2r3r2, g1g0r1r0);
+ b = _mm_movelh_ps(b1b0, b3b2);
- /* Convert to Prophoto */
- r2 = sse_matrix3_mul(cam_prof, r, g, b);
- g2 = sse_matrix3_mul(&cam_prof[12], r, g, b);
- b2 = sse_matrix3_mul(&cam_prof[24], r, g, b);
+ /* Convert to Prophoto */
+ r2 = sse_matrix3_mul(cam_prof, r, g, b);
+ g2 = sse_matrix3_mul(&cam_prof[12], r, g, b);
+ b2 = sse_matrix3_mul(&cam_prof[24], r, g, b);
+ } else
+ {
+ /* Convert to planar */
+ __m128 g1g0r1r0 = _mm_unpacklo_ps(p1f, p2f);
+ __m128 b1b0 = _mm_unpackhi_ps(p1f, p2f);
+ __m128 g3g2r3r2 = _mm_unpacklo_ps(p3f, p4f);
+ __m128 b3b2 = _mm_unpackhi_ps(p3f, p4f);
+ r = _mm_movelh_ps(g1g0r1r0, g3g2r3r2);
+ g = _mm_movehl_ps(g3g2r3r2, g1g0r1r0);
+ b = _mm_movelh_ps(b1b0, b3b2);
+ /* Multiply channel mixer */
+ r2 = _mm_mul_ps(_mm_load_ps(_cm_r), r);
+ g2 = _mm_mul_ps(_mm_load_ps(_cm_g), g);
+ b2 = _mm_mul_ps(_mm_load_ps(_cm_b), b);
+ }
+
RGBtoHSV_SSE4(&r, &g, &b);
h = r; s = g; v = b;
Modified: branches/rawstudio-ng-color/plugins/dcp/dcp.c
===================================================================
--- branches/rawstudio-ng-color/plugins/dcp/dcp.c 2009-12-29 17:09:17 UTC
(rev 2879)
+++ branches/rawstudio-ng-color/plugins/dcp/dcp.c 2009-12-29 18:29:13 UTC
(rev 2880)
@@ -23,7 +23,6 @@
#include <math.h> /* pow() */
#include "dcp.h"
-
RS_DEFINE_FILTER(rs_dcp, RSDcp)
enum {
@@ -124,28 +123,38 @@
changed = TRUE;
}
- if ((mask & MASK_WB) || (mask & MASK_CHANNELMIXER))
+ if (mask & MASK_CHANNELMIXER)
{
- const gfloat warmth;
- gfloat tint;
const gfloat channelmixer_red;
const gfloat channelmixer_green;
const gfloat channelmixer_blue;
-
g_object_get(settings,
- "warmth", &warmth,
- "tint", &tint,
"channelmixer_red", &channelmixer_red,
"channelmixer_green", &channelmixer_green,
"channelmixer_blue", &channelmixer_blue,
NULL);
+ dcp->channelmixer_red = channelmixer_red / 100.0f;
+ dcp->channelmixer_green = channelmixer_green / 100.0f;
+ dcp->channelmixer_blue = channelmixer_blue / 100.0f;
+ changed = TRUE;
+ }
+ if (mask & MASK_WB)
+ {
+ const gfloat warmth;
+ gfloat tint;
+
+ g_object_get(settings,
+ "warmth", &warmth,
+ "tint", &tint,
+ NULL);
+
RS_xy_COORD whitepoint;
RS_VECTOR3 pre_mul;
/* This is messy, but we're essentially converting from
warmth/tint to cameraneutral */
- pre_mul.x = (1.0+warmth)*(2.0-tint)*(channelmixer_red/100.0);
- pre_mul.y = 1.0*(channelmixer_green/100.0);
- pre_mul.z = (1.0-warmth)*(2.0-tint)*(channelmixer_blue/100.0);
+ pre_mul.x = (1.0+warmth)*(2.0-tint);
+ pre_mul.y = 1.0;
+ pre_mul.z = (1.0-warmth)*(2.0-tint);
RS_VECTOR3 neutral;
neutral.x = 1.0 / CLAMP(pre_mul.x, 0.001, 100.00);
neutral.y = 1.0 / CLAMP(pre_mul.y, 0.001, 100.00);
@@ -198,6 +207,7 @@
dcp->curve_samples = g_new(gfloat, 65536);
dcp->huesatmap_interpolated = NULL;
+ dcp->use_profile = FALSE;
for(i=0;i<65536;i++)
dcp->curve_samples[i] = ((gfloat)i)/65536.0;
@@ -266,6 +276,12 @@
break;
case PROP_USE_PROFILE:
dcp->use_profile = g_value_get_boolean(value);
+ if (!dcp->use_profile)
+ {
+ dcp->huesatmap = NULL;
+ dcp->tone_curve = NULL;
+ dcp->looktable = NULL;
+ }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id,
pspec);
@@ -767,16 +783,20 @@
pix.G = g;
pix.B = b;
pix = vector3_multiply_matrix(&pix,
&dcp->camera_to_prophoto);
-
- r = CLAMP(pix.R, 0.0, 1.0);
- g = CLAMP(pix.G, 0.0, 1.0);
- b = CLAMP(pix.B, 0.0, 1.0);
+
+ r = pix.R;
+ g = pix.G;
+ b = pix.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);
+
/* To HSV */
RGBtoHSV(r, g, b, &h, &s, &v);
- if (dcp->use_profile && dcp->huesatmap)
+ if (dcp->huesatmap)
huesat_map(dcp->huesatmap, &h, &s, &v);
/* Saturation */
@@ -808,14 +828,14 @@
/* Curve */
v = dcp->curve_samples[_S(v)];
- if (dcp->use_profile && dcp->looktable)
+ if (dcp->looktable)
huesat_map(dcp->looktable, &h, &s, &v);
/* Back to RGB */
HSVtoRGB(h, s, v, &r, &g, &b);
/* Apply tone curve */
- if (dcp->use_profile && dcp->tone_curve_lut)
+ if (dcp->tone_curve_lut)
rgb_tone(&r, &g, &b, dcp->tone_curve_lut);
/* Save as gushort */
@@ -1025,6 +1045,7 @@
dcp->huesatmap1 = rs_dcp_file_get_huesatmap1(dcp_file);
dcp->huesatmap2 = rs_dcp_file_get_huesatmap2(dcp_file);
dcp->huesatmap = 0;
+ dcp->use_profile = TRUE;
}
/*
Modified: branches/rawstudio-ng-color/plugins/dcp/dcp.h
===================================================================
--- branches/rawstudio-ng-color/plugins/dcp/dcp.h 2009-12-29 17:09:17 UTC
(rev 2879)
+++ branches/rawstudio-ng-color/plugins/dcp/dcp.h 2009-12-29 18:29:13 UTC
(rev 2880)
@@ -51,6 +51,9 @@
gfloat saturation;
gfloat contrast;
gfloat hue;
+ gfloat channelmixer_red;
+ gfloat channelmixer_green;
+ gfloat channelmixer_blue;
RS_xy_COORD white_xy;
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit