[Rawstudio-commit] r4148 - in trunk: . plugins/colorspace-transform plugins/load-dcraw plugins/load-gdk

Klaus Post klauspost at gmail.com
Sat Feb 18 17:17:41 CET 2012


Author: post
Date: 2012-02-18 17:17:41 +0100 (Sat, 18 Feb 2012)
New Revision: 4148

Modified:
   trunk/configure.in
   trunk/plugins/colorspace-transform/Makefile.am
   trunk/plugins/colorspace-transform/rs-cmm.c
   trunk/plugins/load-dcraw/Makefile.am
   trunk/plugins/load-dcraw/dcraw.cc
   trunk/plugins/load-gdk/load-gdk.c
Log:
Support both lcms v1 and v2 - automatically determined at configure.

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2012-02-18 11:22:50 UTC (rev 4147)
+++ trunk/configure.in	2012-02-18 16:17:41 UTC (rev 4148)
@@ -100,9 +100,14 @@
 AC_SUBST(LENSFUN_CFLAGS)
 AC_SUBST(LENSFUN_LIBS)
 
-PKG_CHECK_MODULES(LCMS2, [lcms2])
-AC_SUBST(LCMS2_CFLAGS)
-AC_SUBST(LCMS2_LIBS)
+PKG_CHECK_MODULES([LCMS], [lcms2],
+   [AC_DEFINE([HAVE_LCMS2], [1], [Use LCMS2])],
+   [PKG_CHECK_MODULES([LCMS], [lcms],
+       [AC_DEFINE([HAVE_LCMS], [1], [Use LCMS])
+    ], AC_MSG_ERROR([*** liblcms or liblcms2 not found!]))
+])
+AC_SUBST(LCMS_CFLAGS)
+AC_SUBST(LCMS_LIBS)
 
 PKG_CHECK_MODULES(LIBGPHOTO2, [libgphoto2])
 AC_SUBST(LIBGPHOTO2_CFLAGS)

Modified: trunk/plugins/colorspace-transform/Makefile.am
===================================================================
--- trunk/plugins/colorspace-transform/Makefile.am	2012-02-18 11:22:50 UTC (rev 4147)
+++ trunk/plugins/colorspace-transform/Makefile.am	2012-02-18 16:17:41 UTC (rev 4148)
@@ -9,7 +9,7 @@
 INCLUDES = \
 	-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-	@PACKAGE_CFLAGS@ @LCMS2_CFLAGS@ \
+	@PACKAGE_CFLAGS@ @LCMS_CFLAGS@ \
 	-I$(top_srcdir)/librawstudio/ \
 	-I$(top_srcdir)/
 
@@ -17,7 +17,7 @@
 
 libdir = $(datadir)/rawstudio/plugins/
 
-colorspace_transform_la_LIBADD = @PACKAGE_LIBS@ @LCMS2_LIBS@ colorspace_transform_avx.lo colorspace_transform_sse2.lo rs-cmm.lo colorspace_transform-c.lo
+colorspace_transform_la_LIBADD = @PACKAGE_LIBS@ @LCMS_LIBS@ colorspace_transform_avx.lo colorspace_transform_sse2.lo rs-cmm.lo colorspace_transform-c.lo
 colorspace_transform_la_LDFLAGS = -module -avoid-version
 colorspace_transform_la_SOURCES = 
 

Modified: trunk/plugins/colorspace-transform/rs-cmm.c
===================================================================
--- trunk/plugins/colorspace-transform/rs-cmm.c	2012-02-18 11:22:50 UTC (rev 4147)
+++ trunk/plugins/colorspace-transform/rs-cmm.c	2012-02-18 16:17:41 UTC (rev 4148)
@@ -17,7 +17,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
+#include <config.h>
+
+#if defined(HAVE_LCMS2)
 #include <lcms2.h>
+#elif defined(HAVE_LCMS)
+#include <lcms.h>
+#else
+#error "LCMS v1 or LCMS v2 required"
+#endif
+
 #include <math.h>
 #include <stdlib.h>
 #include "rs-cmm.h"
@@ -403,11 +412,18 @@
 			{0.115, 0.826, 0.724938},
 			{0.157, 0.018, 0.016875}};
 		cmsCIExyY D65;
+
+#if defined(HAVE_LCMS2)
+		gint context = 1337;
 		cmsToneCurve* gamma[3];
-		gint context = 1337;
-
 		cmsWhitePointFromTemp(&D65, 6504);
 		gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma(&context,1.0);
+#else
+		LPGAMMATABLE gamma[3];
+		cmsWhitePointFromTemp(6504, &D65);
+		gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma(2,1.0);
+#endif
+
 		linear = cmsCreateRGBProfile(&D65, &srgb_primaries, gamma);
 	}
 	g_mutex_unlock(is_profile_gamma_22_corrected_linear_lock);
@@ -443,8 +459,11 @@
 	cmm->lcms_transform16 = cmsCreateTransform(
 		cmm->lcms_input_profile, TYPE_RGBA_16,
 		cmm->lcms_output_profile, TYPE_RGBA_16,
+#if defined(HAVE_LCMS2)
 		INTENT_PERCEPTUAL, cmsFLAGS_NOCACHE);
-
+#else
+		INTENT_PERCEPTUAL, 0);
+#endif
 	g_warn_if_fail(cmm->lcms_transform16 != NULL);
 
 	/* Enable packing/unpacking for pixelsize==4 */

Modified: trunk/plugins/load-dcraw/Makefile.am
===================================================================
--- trunk/plugins/load-dcraw/Makefile.am	2012-02-18 11:22:50 UTC (rev 4147)
+++ trunk/plugins/load-dcraw/Makefile.am	2012-02-18 16:17:41 UTC (rev 4148)
@@ -12,7 +12,7 @@
 INCLUDES = \
 	-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-	@PACKAGE_CFLAGS@ @LCMS2_CFLAGS@\
+	@PACKAGE_CFLAGS@ @LCMS_CFLAGS@\
 	-I$(top_srcdir)/librawstudio/ \
 	-I$(top_srcdir)/
 
@@ -20,6 +20,6 @@
 
 libdir = $(datadir)/rawstudio/plugins/
 
-load_dcraw_la_LIBADD = @PACKAGE_LIBS@ @LCMS2_LIBS@
+load_dcraw_la_LIBADD = @PACKAGE_LIBS@ @LCMS_LIBS@
 load_dcraw_la_LDFLAGS = -module -avoid-version
 load_dcraw_la_SOURCES =  dcrawloader.c dcraw.cc dcraw.h dcraw_api.cc dcraw_api.h mmap-hack.c mmap-hack.h

Modified: trunk/plugins/load-dcraw/dcraw.cc
===================================================================
--- trunk/plugins/load-dcraw/dcraw.cc	2012-02-18 11:22:50 UTC (rev 4147)
+++ trunk/plugins/load-dcraw/dcraw.cc	2012-02-18 16:17:41 UTC (rev 4148)
@@ -62,8 +62,16 @@
    NO_LCMS disables the "-p" option.
  */
 #ifndef NO_LCMS
+#include <config.h>
+#if defined(HAVE_LCMS2)
 #include <lcms2.h>
+#elif defined(HAVE_LCMS)
+#include <lcms.h>
+#else
+#error "LCMS v1 or LCMS v2 required"
 #endif
+#endif
+
 #ifdef HAVE_LIBJPEG
 extern "C" {
 #include <jpeglib.h>		/* Decode compressed Kodak DC120 photos */

Modified: trunk/plugins/load-gdk/load-gdk.c
===================================================================
--- trunk/plugins/load-gdk/load-gdk.c	2012-02-18 11:22:50 UTC (rev 4147)
+++ trunk/plugins/load-gdk/load-gdk.c	2012-02-18 16:17:41 UTC (rev 4148)
@@ -20,7 +20,14 @@
 #include <rawstudio.h>
 #include <math.h> /* pow() */
 #include "exiv2-colorspace.h"
+#include <config.h>
+#if defined(HAVE_LCMS2)
 #include <lcms2.h>
+#elif defined(HAVE_LCMS)
+#include <lcms.h>
+#else
+#error "LCMS v1 or LCMS v2 required"
+#endif
 
 
 /**
@@ -56,6 +63,7 @@
 			cmsHPROFILE *lcms_target = cmsOpenProfileFromMem(data, length);
 			if (lcms_target)
 			{
+#if defined(HAVE_LCMS2)
 				cmsToneCurve *curve = NULL;
 				if (cmsIsTag(lcms_target, cmsSigGrayTRCTag))
 					curve = cmsReadTag(lcms_target, cmsSigGrayTRCTag);
@@ -68,6 +76,21 @@
 					if (gamma>0.0)
 						gamma_guess = gamma;
 				}
+#else
+				LPGAMMATABLE curve = NULL;
+				if (cmsIsTag(lcms_target, icSigGrayTRCTag))
+					curve = cmsReadICCGamma(lcms_target, icSigGrayTRCTag);
+
+				if (NULL== curve && cmsIsTag(lcms_target, icSigRedTRCTag))
+					curve = cmsReadICCGamma(lcms_target, icSigRedTRCTag);
+
+				if (curve)
+				{
+					double gamma = cmsEstimateGamma(curve);
+					if (gamma>0.0)
+						gamma_guess = gamma;
+				}
+#endif
 			}
 		}
 




More information about the Rawstudio-commit mailing list