summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2011-02-07 14:37:01 +0100
committerMarti Maria <info@littlecms.com>2011-02-07 14:37:01 +0100
commit85b4930a0d9c4bc885c90e2b880c0db907fe7915 (patch)
tree566b6ca54727776b871fc0958dbe945fd70d3861
parenteb714c2c114c25be43891a43f12be8f718f5718b (diff)
downloadlcms2-85b4930a0d9c4bc885c90e2b880c0db907fe7915.tar.gz
Get rid of pthread library requeriments
-rw-r--r--include/lcms2.h9
-rw-r--r--src/cmsxform.c57
-rw-r--r--src/lcms2_internal.h47
3 files changed, 39 insertions, 74 deletions
diff --git a/include/lcms2.h b/include/lcms2.h
index ea5ac41..e1c5341 100644
--- a/include/lcms2.h
+++ b/include/lcms2.h
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------------
//
// Little Color Management System
-// Copyright (c) 1998-2010 Marti Maria Saguer
+// Copyright (c) 1998-2011 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
@@ -23,7 +23,7 @@
//
//---------------------------------------------------------------------------------
//
-// Version 2.1
+// Version 2.2a
//
#ifndef _lcms2_H
@@ -40,9 +40,6 @@
// Uncomment this if your compiler doesn't work with fast floor function
// #define CMS_DONT_USE_FAST_FLOOR 1
-// Uncomment this line if your system does not support multithreading
-#define CMS_DONT_USE_PTHREADS 1
-
// Uncomment this line if you want lcms to use the black point tag in profile,
// if commented, lcms will compute the black point by its own.
// It is safer to leave it commented out
@@ -72,7 +69,7 @@ extern "C" {
#endif
// Version/release
-#define LCMS_VERSION 2010
+#define LCMS_VERSION 2020
// I will give the chance of redefining basic types for compilers that are not fully C99 compliant
#ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
diff --git a/src/cmsxform.c b/src/cmsxform.c
index 7f5cc94..1782456 100644
--- a/src/cmsxform.c
+++ b/src/cmsxform.c
@@ -89,7 +89,6 @@ void CMSEXPORT cmsDeleteTransform(cmsHTRANSFORM hTransform)
if (p ->Sequence)
cmsFreeProfileSequenceDescription(p ->Sequence);
- LCMS_FREE_LOCK(&p->rwlock);
_cmsFree(p ->ContextID, (void *) p);
}
@@ -101,8 +100,9 @@ void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
{
_cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
+ _cmsCACHE Cache;
- p -> xform(p, InputBuffer, OutputBuffer, Size);
+ p -> xform(p, &Cache, InputBuffer, OutputBuffer, Size);
}
@@ -112,6 +112,7 @@ void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
// Note that because extended range, we can use a -1.0 value for out of gamut in this case.
static
void FloatXFORM(_cmsTRANSFORM* p,
+ _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -156,6 +157,8 @@ void FloatXFORM(_cmsTRANSFORM* p,
// Back to asked representation
output = p -> ToOutputFloat(p, fOut, output, Size);
}
+
+ cmsUNUSED_PARAMETER(Cache);
}
// 16 bit precision -----------------------------------------------------------------------------------------------------------
@@ -163,6 +166,7 @@ void FloatXFORM(_cmsTRANSFORM* p,
// Null transformation, only applies formatters. No caché
static
void NullXFORM(_cmsTRANSFORM* p,
+ _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -180,12 +184,15 @@ void NullXFORM(_cmsTRANSFORM* p,
accum = p -> FromInput(p, wIn, accum, Size);
output = p -> ToOutput(p, wIn, output, Size);
}
+
+ cmsUNUSED_PARAMETER(Cache);
}
// No gamut check, no cache, 16 bits
static
void PrecalculatedXFORM(_cmsTRANSFORM* p,
+ _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -204,6 +211,8 @@ void PrecalculatedXFORM(_cmsTRANSFORM* p,
p ->Lut ->Eval16Fn(wIn, wOut, p -> Lut->Data);
output = p -> ToOutput(p, wOut, output, Size);
}
+
+ cmsUNUSED_PARAMETER(Cache);
}
@@ -230,6 +239,7 @@ void TransformOnePixelWithGamutCheck(_cmsTRANSFORM* p,
// Gamut check, No caché, 16 bits.
static
void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
+ _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -248,12 +258,15 @@ void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
TransformOnePixelWithGamutCheck(p, wIn, wOut);
output = p -> ToOutput(p, wOut, output, Size);
}
+
+ cmsUNUSED_PARAMETER(Cache);
}
// No gamut check, Caché, 16 bits,
static
void CachedXFORM(_cmsTRANSFORM* p,
+ _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -261,7 +274,6 @@ void CachedXFORM(_cmsTRANSFORM* p,
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
cmsUInt32Number i, n;
- cmsUInt16Number CacheIn[cmsMAXCHANNELS], CacheOut[cmsMAXCHANNELS];
accum = (cmsUInt8Number*) in;
output = (cmsUInt8Number*) out;
@@ -272,41 +284,33 @@ void CachedXFORM(_cmsTRANSFORM* p,
memset(wOut, 0, sizeof(wOut));
- LCMS_READ_LOCK(&p ->rwlock);
- memmove(CacheIn, p ->CacheIn, sizeof(CacheIn));
- memmove(CacheOut, p ->CacheOut, sizeof(CacheOut));
- LCMS_UNLOCK(&p ->rwlock);
for (i=0; i < n; i++) {
accum = p -> FromInput(p, wIn, accum, Size);
- if (memcmp(wIn, CacheIn, sizeof(CacheIn)) == 0) {
+ if (memcmp(wIn, Cache ->CacheIn, sizeof(Cache -> CacheIn)) == 0) {
- memmove(wOut, CacheOut, sizeof(CacheOut));
+ memmove(wOut, Cache -> CacheOut, sizeof(Cache -> CacheOut));
}
else {
p ->Lut ->Eval16Fn(wIn, wOut, p -> Lut->Data);
- memmove(CacheIn, wIn, sizeof(CacheIn));
- memmove(CacheOut, wOut, sizeof(CacheOut));
+ memmove(Cache -> CacheIn, wIn, sizeof(Cache -> CacheIn));
+ memmove(Cache -> CacheOut, wOut, sizeof(Cache -> CacheOut));
}
output = p -> ToOutput(p, wOut, output, Size);
}
-
- LCMS_WRITE_LOCK(&p ->rwlock);
- memmove(p->CacheIn, CacheIn, sizeof(CacheIn));
- memmove(p->CacheOut, CacheOut, sizeof(CacheOut));
- LCMS_UNLOCK(&p ->rwlock);
}
// All those nice features together
static
void CachedXFORMGamutCheck(_cmsTRANSFORM* p,
+ _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -314,7 +318,6 @@ void CachedXFORMGamutCheck(_cmsTRANSFORM* p,
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
cmsUInt32Number i, n;
- cmsUInt16Number CacheIn[cmsMAXCHANNELS], CacheOut[cmsMAXCHANNELS];
accum = (cmsUInt8Number*) in;
output = (cmsUInt8Number*) out;
@@ -324,32 +327,23 @@ void CachedXFORMGamutCheck(_cmsTRANSFORM* p,
memset(wIn, 0, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
memset(wOut, 0, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
- LCMS_READ_LOCK(&p ->rwlock);
- memmove(CacheIn, p ->CacheIn, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
- memmove(CacheOut, p ->CacheOut, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
- LCMS_UNLOCK(&p ->rwlock);
-
for (i=0; i < n; i++) {
accum = p -> FromInput(p, wIn, accum, Size);
- if (memcmp(wIn, CacheIn, sizeof(cmsUInt16Number) * cmsMAXCHANNELS) == 0) {
- memmove(wOut, CacheOut, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
+ if (memcmp(wIn, Cache -> CacheIn, sizeof(cmsUInt16Number) * cmsMAXCHANNELS) == 0) {
+ memmove(wOut, Cache -> CacheOut, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
}
else {
TransformOnePixelWithGamutCheck(p, wIn, wOut);
- memmove(CacheIn, wIn, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
- memmove(CacheOut, wOut, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
+ memmove(Cache -> CacheIn, wIn, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
+ memmove(Cache -> CacheOut, wOut, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
}
output = p -> ToOutput(p, wOut, output, Size);
}
- LCMS_WRITE_LOCK(&p ->rwlock);
- memmove(p->CacheIn, CacheIn, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
- memmove(p->CacheOut, CacheOut, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
- LCMS_UNLOCK(&p ->rwlock);
}
@@ -431,9 +425,6 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsUInt32Number InputFo
}
- // Create a mutex for shared memory
- LCMS_CREATE_LOCK(&p->rwlock);
-
p ->InputFormat = InputFormat;
p ->OutputFormat = OutputFormat;
p ->dwOriginalFlags = dwFlags;
diff --git a/src/lcms2_internal.h b/src/lcms2_internal.h
index 84e5a80..a0f8117 100644
--- a/src/lcms2_internal.h
+++ b/src/lcms2_internal.h
@@ -1,7 +1,7 @@
//
// Little Color Management System
-// Copyright (c) 1998-2010 Marti Maria Saguer
+// Copyright (c) 1998-2011 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
@@ -88,36 +88,6 @@
# endif
#endif
-// Pthreads. In windows we use the native WIN32 API instead
-#ifdef CMS_DONT_USE_PTHREADS
-typedef int LCMS_RWLOCK_T;
-# define LCMS_CREATE_LOCK(x)
-# define LCMS_FREE_LOCK(x)
-# define LCMS_READ_LOCK(x)
-# define LCMS_WRITE_LOCK(x)
-# define LCMS_UNLOCK(x)
-#else
-#ifdef CMS_IS_WINDOWS_
-# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-# endif
-# include <windows.h>
- typedef CRITICAL_SECTION LCMS_RWLOCK_T;
-# define LCMS_CREATE_LOCK(x) InitializeCriticalSection((x))
-# define LCMS_FREE_LOCK(x) DeleteCriticalSection((x))
-# define LCMS_READ_LOCK(x) EnterCriticalSection((x))
-# define LCMS_WRITE_LOCK(x) EnterCriticalSection((x))
-# define LCMS_UNLOCK(x) LeaveCriticalSection((x))
-#else
-# include <pthread.h>
- typedef pthread_rwlock_t LCMS_RWLOCK_T;
-# define LCMS_CREATE_LOCK(x) pthread_rwlock_init((x), NULL)
-# define LCMS_FREE_LOCK(x) pthread_rwlock_destroy((x))
-# define LCMS_READ_LOCK(x) pthread_rwlock_rdlock((x))
-# define LCMS_WRITE_LOCK(x) pthread_rwlock_wrlock((x))
-# define LCMS_UNLOCK(x) pthread_rwlock_unlock((x))
-#endif
-#endif
// A fast way to convert from/to 16 <-> 8 bits
#define FROM_8_TO_16(rgb) (cmsUInt16Number) ((((cmsUInt16Number) (rgb)) << 8)|(rgb))
@@ -559,10 +529,20 @@ cmsFormatter _cmsGetFormatter(cmsUInt32Number Type, // Specific type
struct _cmstransform_struct;
+typedef struct {
+ // 1-pixel cache (16 bits only)
+ cmsUInt16Number CacheIn[cmsMAXCHANNELS];
+ cmsUInt16Number CacheOut[cmsMAXCHANNELS];
+} _cmsCACHE;
+
+
+
// Full xform
typedef void (* _cmsTransformFn)(struct _cmstransform_struct *Transform,
+ _cmsCACHE* Cache,
const void* InputBuffer,
- void* OutputBuffer, cmsUInt32Number Size);
+ void* OutputBuffer,
+ cmsUInt32Number Size);
typedef struct {
@@ -589,9 +569,6 @@ typedef struct _cmstransform_struct {
// 1-pixel cache (16 bits only)
cmsUInt16Number CacheIn[cmsMAXCHANNELS];
cmsUInt16Number CacheOut[cmsMAXCHANNELS];
-
- // Semaphor for cache
- LCMS_RWLOCK_T rwlock;
// A MPE LUT holding the full (optimized) transform
cmsPipeline* Lut;