Author: post
Date: 2009-12-31 16:17:52 +0100 (Thu, 31 Dec 2009)
New Revision: 2956

Modified:
   branches/rawstudio-ng-color/plugins/dcp/dcp-sse2.c
   branches/rawstudio-ng-color/plugins/dcp/dcp-sse4.c
   branches/rawstudio-ng-color/plugins/dcp/dcp.c
   branches/rawstudio-ng-color/plugins/dcp/dcp.h
Log:
DCP: Skip curve, if it is flat. Don't include tone table multiple times.

Modified: branches/rawstudio-ng-color/plugins/dcp/dcp-sse2.c
===================================================================
--- branches/rawstudio-ng-color/plugins/dcp/dcp-sse2.c  2009-12-31 14:35:59 UTC 
(rev 2955)
+++ branches/rawstudio-ng-color/plugins/dcp/dcp-sse2.c  2009-12-31 15:17:52 UTC 
(rev 2956)
@@ -742,20 +742,23 @@
                        RGBtoHSV_SSE(&r, &g, &b);
                        h = r; s = g; v = b;
 
-                       /* Convert v to lookup values */
-                       /* TODO: Use 8 bit fraction as interpolation, for 
interpolating
-                       * a more precise lookup using linear interpolation. 
Maybe use less than
-                       * 16 bits for lookup for speed, 10 bits with 
interpolation should be enough */
-                       __m128 v_mul = _mm_load_ps(_16_bit_ps);
-                       v = _mm_mul_ps(v, v_mul);
-                       __m128i lookup = _mm_cvtps_epi32(v);
-                       gfloat* v_p = (gfloat*)&v;
-                       _mm_store_si128((__m128i*)&xfer[0], lookup);
+                       if (!dcp->curve_is_flat)                        
+                       {
+                               /* Convert v to lookup values */
+                               /* TODO: Use 8 bit fraction as interpolation, 
for interpolating
+                               * a more precise lookup using linear 
interpolation. Maybe use less than
+                               * 16 bits for lookup for speed, 10 bits with 
interpolation should be enough */
+                               __m128 v_mul = _mm_load_ps(_16_bit_ps);
+                               v = _mm_mul_ps(v, v_mul);
+                               __m128i lookup = _mm_cvtps_epi32(v);
+                               gfloat* v_p = (gfloat*)&v;
+                               _mm_store_si128((__m128i*)&xfer[0], lookup);
 
-                       v_p[0] = dcp->curve_samples[xfer[0]];
-                       v_p[1] = dcp->curve_samples[xfer[1]];
-                       v_p[2] = dcp->curve_samples[xfer[2]];
-                       v_p[3] = dcp->curve_samples[xfer[3]];
+                               v_p[0] = dcp->curve_samples[xfer[0]];
+                               v_p[1] = dcp->curve_samples[xfer[1]];
+                               v_p[2] = dcp->curve_samples[xfer[2]];
+                               v_p[3] = dcp->curve_samples[xfer[3]];
+                       }
 
                        /* Apply looktable */
                        if (dcp->looktable) {

Modified: branches/rawstudio-ng-color/plugins/dcp/dcp-sse4.c
===================================================================
--- branches/rawstudio-ng-color/plugins/dcp/dcp-sse4.c  2009-12-31 14:35:59 UTC 
(rev 2955)
+++ branches/rawstudio-ng-color/plugins/dcp/dcp-sse4.c  2009-12-31 15:17:52 UTC 
(rev 2956)
@@ -663,21 +663,24 @@
                        RGBtoHSV_SSE4(&r, &g, &b);
                        h = r; s = g; v = b;
 
-                       /* Convert v to lookup values */
-                       /* TODO: Use 8 bit fraction as interpolation, for 
interpolating
-                       * a more precise lookup using linear interpolation. 
Maybe use less than
-                       * 16 bits for lookup for speed, 10 bits with 
interpolation should be enough */
-                       __m128 v_mul = _mm_load_ps(_16_bit_ps);
-                       v = _mm_mul_ps(v, v_mul);
-                       __m128i lookup = _mm_cvtps_epi32(v);
+                       if (!dcp->curve_is_flat)                        
+                       {
+                               /* Convert v to lookup values */
+                               /* TODO: Use 8 bit fraction as interpolation, 
for interpolating
+                               * a more precise lookup using linear 
interpolation. Maybe use less than
+                               * 16 bits for lookup for speed, 10 bits with 
interpolation should be enough */
+                               __m128 v_mul = _mm_load_ps(_16_bit_ps);
+                               v = _mm_mul_ps(v, v_mul);
+                               __m128i lookup = _mm_cvtps_epi32(v);
 
-                       __m128i v_curved = lookup;
-                       v_curved = _mm_insert_epi32(v_curved, 
((gint32*)dcp->curve_samples)[_mm_extract_epi32(lookup,0)], 0);
-                       v_curved = _mm_insert_epi32(v_curved, 
((gint32*)dcp->curve_samples)[_mm_extract_epi32(lookup,1)], 1);
-                       v_curved = _mm_insert_epi32(v_curved, 
((gint32*)dcp->curve_samples)[_mm_extract_epi32(lookup,2)], 2);
-                       v_curved = _mm_insert_epi32(v_curved, 
((gint32*)dcp->curve_samples)[_mm_extract_epi32(lookup,3)], 3);
+                               __m128i v_curved = lookup;
+                               v_curved = _mm_insert_epi32(v_curved, 
((gint32*)dcp->curve_samples)[_mm_extract_epi32(lookup,0)], 0);
+                               v_curved = _mm_insert_epi32(v_curved, 
((gint32*)dcp->curve_samples)[_mm_extract_epi32(lookup,1)], 1);
+                               v_curved = _mm_insert_epi32(v_curved, 
((gint32*)dcp->curve_samples)[_mm_extract_epi32(lookup,2)], 2);
+                               v_curved = _mm_insert_epi32(v_curved, 
((gint32*)dcp->curve_samples)[_mm_extract_epi32(lookup,3)], 3);
 
-                       v = PS(v_curved);
+                               v = PS(v_curved);
+                       }
 
                        /* Apply looktable */
                        if (dcp->looktable) {

Modified: branches/rawstudio-ng-color/plugins/dcp/dcp.c
===================================================================
--- branches/rawstudio-ng-color/plugins/dcp/dcp.c       2009-12-31 14:35:59 UTC 
(rev 2955)
+++ branches/rawstudio-ng-color/plugins/dcp/dcp.c       2009-12-31 15:17:52 UTC 
(rev 2956)
@@ -21,7 +21,9 @@
 
 #include "config.h"
 #include <math.h> /* pow() */
+#define INCLUDE_TONE_CURVE
 #include "dcp.h"
+#undef INCLUDE_TONE_CURVE
 
 RS_DEFINE_FILTER(rs_dcp, RSDcp)
 
@@ -172,6 +174,7 @@
        if (mask & MASK_CURVE)
        {
                const gint nknots = rs_settings_get_curve_nknots(settings);
+               gint i;
 
                if (nknots > 1)
                {
@@ -184,13 +187,14 @@
                                g_object_unref(spline);
                                g_free(knots);
                        }
+                       dcp->curve_is_flat = FALSE;
                }
                else
-               {
-                       gint i;
-                       for(i=0;i<65536;i++)
-                               dcp->curve_samples[i] = ((gfloat)i)/65536.0;
-               }
+                       dcp->curve_is_flat = TRUE;
+
+               for(i=0;i<65536;i++)
+                       dcp->curve_samples[i] = MIN(1.0f, MAX(0.0f, 
dcp->curve_samples[i]));
+
                changed = TRUE;
        }
 
@@ -227,15 +231,12 @@
 rs_dcp_init(RSDcp *dcp)
 {
        RSDcpClass *klass = RS_DCP_GET_CLASS(dcp);
-       gint i;
 
        dcp->curve_samples = g_new(gfloat, 65536);
        dcp->huesatmap_interpolated = NULL;
        dcp->use_profile = FALSE;
+       dcp->curve_is_flat = TRUE;
 
-       for(i=0;i<65536;i++)
-               dcp->curve_samples[i] = ((gfloat)i)/65536.0;
-
        /* We cannot initialize this in class init, the RSProphoto plugin may 
not
         * be loaded yet at that time :( */
        if (!klass->prophoto)
@@ -316,7 +317,7 @@
        ThreadInfo* t = _thread_info;
        RS_IMAGE16 *tmp = t->tmp;
 
-       if (tmp->pixelsize == 4  && (rs_detect_cpu_features() & 
RS_CPU_FLAG_SSE2))
+       if (t->start_y && tmp->pixelsize == 4  && (rs_detect_cpu_features() & 
RS_CPU_FLAG_SSE2))
        {
                if (render_SSE2(t))
                {
@@ -859,7 +860,8 @@
                        RGBtoHSV(r, g, b, &h, &s, &v);
 
                        /* Curve */
-                       v = dcp->curve_samples[_S(v)];
+                       if (!dcp->curve_is_flat)
+                               v = dcp->curve_samples[_S(v)];
 
                        if (dcp->looktable)
                                huesat_map(dcp->looktable, &h, &s, &v);

Modified: branches/rawstudio-ng-color/plugins/dcp/dcp.h
===================================================================
--- branches/rawstudio-ng-color/plugins/dcp/dcp.h       2009-12-31 14:35:59 UTC 
(rev 2955)
+++ branches/rawstudio-ng-color/plugins/dcp/dcp.h       2009-12-31 15:17:52 UTC 
(rev 2956)
@@ -59,6 +59,7 @@
 
        gint nknots;
        gfloat *curve_samples;
+       gboolean curve_is_flat;
 
        gfloat temp1;
        gfloat temp2;
@@ -116,6 +117,51 @@
 
 } ThreadInfo;
 
+gboolean render_SSE2(ThreadInfo* t);
+gboolean render_SSE4(ThreadInfo* t);
+void calc_hsm_constants(const RSHuesatMap *map, PrecalcHSM* table); 
+
+#ifdef INCLUDE_TONE_CURVE
+
+/* Default tone curve from Adobe DNG SDK: */
+
+/*****************************************************************************/
+// Copyright 2006-2007 Adobe Systems Incorporated
+// All Rights Reserved.
+//
+// NOTICE:  Adobe permits you to use, modify, and distribute this file in
+// accordance with the terms of the Adobe license agreement accompanying it.
+/*****************************************************************************/
+
+/* $Id: //mondo/dng_sdk_1_3/dng_sdk/source/dng_render.cpp#1 $ */ 
+/* $DateTime: 2009/06/22 05:04:49 $ */
+/* $Change: 578634 $ */
+/* $Author: tknoll $ */
+/*****************************************************************************/
+/*
+The MIT License specifies the terms and conditions of use for those Adobe Open 
Source libraries that it covers:
+
+Copyright (c) 2005 Adobe Systems Incorporated
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\endverbatim
+*/
+
 static const float adobe_default_table [] =
 {
   0.00000f, 0.00078f, 0.00160f, 0.00242f,
@@ -379,7 +425,7 @@
 
 const int adobe_default_table_size = sizeof (adobe_default_table) / sizeof 
(adobe_default_table [0]);
 
-gboolean render_SSE2(ThreadInfo* t);
-void calc_hsm_constants(const RSHuesatMap *map, PrecalcHSM* table); 
+#endif// INCLUDE_TONE_CURVE
 
+
 #endif /* DCP_H */


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to