< prev index next >
src/java.desktop/share/native/liblcms/cmsxform.c
Print this page
@@ -28,11 +28,11 @@
// file:
//
//---------------------------------------------------------------------------------
//
// Little Color Management System
-// Copyright (c) 1998-2017 Marti Maria Saguer
+// Copyright (c) 1998-2020 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"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -198,10 +198,27 @@
p ->FreeUserData(p ->ContextID, p ->UserData);
_cmsFree(p ->ContextID, (void *) p);
}
+
+static
+cmsUInt32Number PixelSize(cmsUInt32Number Format)
+{
+ cmsUInt32Number fmt_bytes = T_BYTES(Format);
+
+ // For double, the T_BYTES field is zero
+ if (fmt_bytes == 0)
+ return sizeof(cmsUInt64Number);
+
+ // Otherwise, it is already correct for all formats
+ return fmt_bytes;
+}
+
+
+
+
// Apply transform.
void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
const void* InputBuffer,
void* OutputBuffer,
cmsUInt32Number Size)
@@ -210,12 +227,12 @@
_cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
cmsStride stride;
stride.BytesPerLineIn = 0; // Not used
stride.BytesPerLineOut = 0;
- stride.BytesPerPlaneIn = Size;
- stride.BytesPerPlaneOut = Size;
+ stride.BytesPerPlaneIn = Size * PixelSize(p->InputFormat);
+ stride.BytesPerPlaneOut = Size * PixelSize(p->OutputFormat);
p -> xform(p, InputBuffer, OutputBuffer, Size, 1, &stride);
}
@@ -368,11 +385,11 @@
}
}
// 16 bit precision -----------------------------------------------------------------------------------------------------------
-// Null transformation, only applies formatters. No caché
+// Null transformation, only applies formatters. No cache
static
void NullXFORM(_cmsTRANSFORM* p,
const void* in,
void* out,
cmsUInt32Number PixelsPerLine,
@@ -415,12 +432,12 @@
void* out,
cmsUInt32Number PixelsPerLine,
cmsUInt32Number LineCount,
const cmsStride* Stride)
{
- register cmsUInt8Number* accum;
- register cmsUInt8Number* output;
+ CMSREGISTER cmsUInt8Number* accum;
+ CMSREGISTER cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
cmsUInt32Number i, j, strideIn, strideOut;
_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
@@ -469,11 +486,11 @@
}
else
p ->Lut ->Eval16Fn(wIn, wOut, p -> Lut->Data);
}
-// Gamut check, No caché, 16 bits.
+// Gamut check, No cache, 16 bits.
static
void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
const void* in,
void* out,
cmsUInt32Number PixelsPerLine,
@@ -508,11 +525,11 @@
strideOut += Stride->BytesPerLineOut;
}
}
-// No gamut check, Caché, 16 bits,
+// No gamut check, Cache, 16 bits,
static
void CachedXFORM(_cmsTRANSFORM* p,
const void* in,
void* out,
cmsUInt32Number PixelsPerLine,
@@ -807,10 +824,12 @@
p->Lut = lut;
// Let's see if any plug-in want to do the transform by itself
if (p->Lut != NULL) {
+ if (!(*dwFlags & cmsFLAGS_NOOPTIMIZE))
+ {
for (Plugin = ctx->TransformCollection;
Plugin != NULL;
Plugin = Plugin->Next) {
if (Plugin->Factory(&p->xform, &p->UserData, &p->FreeUserData, &p->Lut, InputFormat, OutputFormat, dwFlags)) {
@@ -834,17 +853,18 @@
p->FromInputFloat = _cmsGetFormatter(ContextID, *InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
p->ToOutputFloat = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
// Save the day? (Ignore the warning)
if (Plugin->OldXform) {
- p->OldXform = (_cmsTransformFn)(void*) p->xform;
+ p->OldXform = (_cmsTransformFn)(void*)p->xform;
p->xform = _cmsTransform2toTransformAdaptor;
}
return p;
}
}
+ }
// Not suitable for the transform plug-in, let's check the pipeline plug-in
_cmsOptimizePipeline(ContextID, &p->Lut, Intent, InputFormat, OutputFormat, dwFlags);
}
@@ -866,11 +886,11 @@
if (*dwFlags & cmsFLAGS_NULLTRANSFORM) {
p ->xform = NullFloatXFORM;
}
else {
- // Float transforms don't use caché, always are non-NULL
+ // Float transforms don't use cache, always are non-NULL
p ->xform = FloatXFORM;
}
}
else {
@@ -905,20 +925,20 @@
}
else {
if (*dwFlags & cmsFLAGS_NOCACHE) {
if (*dwFlags & cmsFLAGS_GAMUTCHECK)
- p ->xform = PrecalculatedXFORMGamutCheck; // Gamut check, no caché
+ p ->xform = PrecalculatedXFORMGamutCheck; // Gamut check, no cache
else
- p ->xform = PrecalculatedXFORM; // No caché, no gamut check
+ p ->xform = PrecalculatedXFORM; // No cache, no gamut check
}
else {
if (*dwFlags & cmsFLAGS_GAMUTCHECK)
- p ->xform = CachedXFORMGamutCheck; // Gamut check, caché
+ p ->xform = CachedXFORMGamutCheck; // Gamut check, cache
else
- p ->xform = CachedXFORM; // No gamut check, caché
+ p ->xform = CachedXFORM; // No gamut check, cache
}
}
}
< prev index next >