< prev index next >
src/java.desktop/share/native/liblcms/cmsxform.c
Print this page
*** 28,38 ****
// file:
//
//---------------------------------------------------------------------------------
//
// Little Color Management System
! // Copyright (c) 1998-2017 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,
--- 28,38 ----
// file:
//
//---------------------------------------------------------------------------------
//
// Little Color Management System
! // 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,207 ****
--- 198,224 ----
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,221 ****
_cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
cmsStride stride;
stride.BytesPerLineIn = 0; // Not used
stride.BytesPerLineOut = 0;
! stride.BytesPerPlaneIn = Size;
! stride.BytesPerPlaneOut = Size;
p -> xform(p, InputBuffer, OutputBuffer, Size, 1, &stride);
}
--- 227,238 ----
_cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
cmsStride stride;
stride.BytesPerLineIn = 0; // Not used
stride.BytesPerLineOut = 0;
! stride.BytesPerPlaneIn = Size * PixelSize(p->InputFormat);
! stride.BytesPerPlaneOut = Size * PixelSize(p->OutputFormat);
p -> xform(p, InputBuffer, OutputBuffer, Size, 1, &stride);
}
*** 368,378 ****
}
}
// 16 bit precision -----------------------------------------------------------------------------------------------------------
! // Null transformation, only applies formatters. No caché
static
void NullXFORM(_cmsTRANSFORM* p,
const void* in,
void* out,
cmsUInt32Number PixelsPerLine,
--- 385,395 ----
}
}
// 16 bit precision -----------------------------------------------------------------------------------------------------------
! // Null transformation, only applies formatters. No cache
static
void NullXFORM(_cmsTRANSFORM* p,
const void* in,
void* out,
cmsUInt32Number PixelsPerLine,
*** 415,426 ****
void* out,
cmsUInt32Number PixelsPerLine,
cmsUInt32Number LineCount,
const cmsStride* Stride)
{
! register cmsUInt8Number* accum;
! register cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
cmsUInt32Number i, j, strideIn, strideOut;
_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
--- 432,443 ----
void* out,
cmsUInt32Number PixelsPerLine,
cmsUInt32Number LineCount,
const cmsStride* Stride)
{
! CMSREGISTER cmsUInt8Number* accum;
! CMSREGISTER cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
cmsUInt32Number i, j, strideIn, strideOut;
_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
*** 469,479 ****
}
else
p ->Lut ->Eval16Fn(wIn, wOut, p -> Lut->Data);
}
! // Gamut check, No caché, 16 bits.
static
void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
const void* in,
void* out,
cmsUInt32Number PixelsPerLine,
--- 486,496 ----
}
else
p ->Lut ->Eval16Fn(wIn, wOut, p -> Lut->Data);
}
! // Gamut check, No cache, 16 bits.
static
void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
const void* in,
void* out,
cmsUInt32Number PixelsPerLine,
*** 508,518 ****
strideOut += Stride->BytesPerLineOut;
}
}
! // No gamut check, Caché, 16 bits,
static
void CachedXFORM(_cmsTRANSFORM* p,
const void* in,
void* out,
cmsUInt32Number PixelsPerLine,
--- 525,535 ----
strideOut += Stride->BytesPerLineOut;
}
}
! // No gamut check, Cache, 16 bits,
static
void CachedXFORM(_cmsTRANSFORM* p,
const void* in,
void* out,
cmsUInt32Number PixelsPerLine,
*** 807,816 ****
--- 824,835 ----
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,850 ****
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->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);
}
--- 853,870 ----
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->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,876 ****
if (*dwFlags & cmsFLAGS_NULLTRANSFORM) {
p ->xform = NullFloatXFORM;
}
else {
! // Float transforms don't use caché, always are non-NULL
p ->xform = FloatXFORM;
}
}
else {
--- 886,896 ----
if (*dwFlags & cmsFLAGS_NULLTRANSFORM) {
p ->xform = NullFloatXFORM;
}
else {
! // Float transforms don't use cache, always are non-NULL
p ->xform = FloatXFORM;
}
}
else {
*** 905,924 ****
}
else {
if (*dwFlags & cmsFLAGS_NOCACHE) {
if (*dwFlags & cmsFLAGS_GAMUTCHECK)
! p ->xform = PrecalculatedXFORMGamutCheck; // Gamut check, no caché
else
! p ->xform = PrecalculatedXFORM; // No caché, no gamut check
}
else {
if (*dwFlags & cmsFLAGS_GAMUTCHECK)
! p ->xform = CachedXFORMGamutCheck; // Gamut check, caché
else
! p ->xform = CachedXFORM; // No gamut check, caché
}
}
}
--- 925,944 ----
}
else {
if (*dwFlags & cmsFLAGS_NOCACHE) {
if (*dwFlags & cmsFLAGS_GAMUTCHECK)
! p ->xform = PrecalculatedXFORMGamutCheck; // Gamut check, no cache
else
! p ->xform = PrecalculatedXFORM; // No cache, no gamut check
}
else {
if (*dwFlags & cmsFLAGS_GAMUTCHECK)
! p ->xform = CachedXFORMGamutCheck; // Gamut check, cache
else
! p ->xform = CachedXFORM; // No gamut check, cache
}
}
}
< prev index next >