< prev index next >
src/java.desktop/share/native/liblcms/cmsxform.c
Print this page
*** 28,38 ****
// file:
//
//---------------------------------------------------------------------------------
//
// Little Color Management System
! // Copyright (c) 1998-2014 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-2016 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,
*** 206,360 ****
void* OutputBuffer,
cmsUInt32Number Size)
{
_cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
! p -> xform(p, InputBuffer, OutputBuffer, Size, Size);
}
! // Apply transform.
void CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform,
const void* InputBuffer,
void* OutputBuffer,
cmsUInt32Number Size, cmsUInt32Number Stride)
{
_cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
! p -> xform(p, InputBuffer, OutputBuffer, Size, Stride);
}
// Transform routines ----------------------------------------------------------------------------------------------------------
// Float xform converts floats. Since there are no performance issues, one routine does all job, including gamut check.
// Note that because extended range, we can use a -1.0 value for out of gamut in this case.
static
void FloatXFORM(_cmsTRANSFORM* p,
const void* in,
! void* out, cmsUInt32Number Size, cmsUInt32Number Stride)
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsFloat32Number fIn[cmsMAXCHANNELS], fOut[cmsMAXCHANNELS];
cmsFloat32Number OutOfGamut;
! cmsUInt32Number i, j;
! accum = (cmsUInt8Number*) in;
! output = (cmsUInt8Number*) out;
! for (i=0; i < Size; i++) {
! accum = p -> FromInputFloat(p, fIn, accum, Stride);
// Any gamut chack to do?
! if (p ->GamutCheck != NULL) {
// Evaluate gamut marker.
! cmsPipelineEvalFloat( fIn, &OutOfGamut, p ->GamutCheck);
// Is current color out of gamut?
if (OutOfGamut > 0.0) {
// Certainly, out of gamut
! for (j=0; j < cmsMAXCHANNELS; j++)
! fOut[j] = -1.0;
}
else {
// No, proceed normally
! cmsPipelineEvalFloat(fIn, fOut, p -> Lut);
}
}
else {
// No gamut check at all
! cmsPipelineEvalFloat(fIn, fOut, p -> Lut);
}
! // Back to asked representation
! output = p -> ToOutputFloat(p, fOut, output, Stride);
}
}
static
void NullFloatXFORM(_cmsTRANSFORM* p,
const void* in,
void* out,
! cmsUInt32Number Size,
! cmsUInt32Number Stride)
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsFloat32Number fIn[cmsMAXCHANNELS];
! cmsUInt32Number i, n;
! accum = (cmsUInt8Number*) in;
! output = (cmsUInt8Number*) out;
! n = Size;
! for (i=0; i < n; i++) {
! accum = p -> FromInputFloat(p, fIn, accum, Stride);
! output = p -> ToOutputFloat(p, fIn, output, Stride);
}
}
// 16 bit precision -----------------------------------------------------------------------------------------------------------
// Null transformation, only applies formatters. No caché
static
void NullXFORM(_cmsTRANSFORM* p,
const void* in,
! void* out, cmsUInt32Number Size,
! cmsUInt32Number Stride)
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS];
! cmsUInt32Number i, n;
! accum = (cmsUInt8Number*) in;
! output = (cmsUInt8Number*) out;
! n = Size; // Buffer len
! for (i=0; i < n; i++) {
! accum = p -> FromInput(p, wIn, accum, Stride);
! output = p -> ToOutput(p, wIn, output, Stride);
}
}
// No gamut check, no cache, 16 bits
static
void PrecalculatedXFORM(_cmsTRANSFORM* p,
const void* in,
! void* out, cmsUInt32Number Size, cmsUInt32Number Stride)
{
register cmsUInt8Number* accum;
register cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
! cmsUInt32Number i, n;
! accum = (cmsUInt8Number*) in;
! output = (cmsUInt8Number*) out;
! n = Size;
! for (i=0; i < n; i++) {
! accum = p -> FromInput(p, wIn, accum, Stride);
! p ->Lut ->Eval16Fn(wIn, wOut, p -> Lut->Data);
! output = p -> ToOutput(p, wOut, output, Stride);
}
}
! // Auxiliar: Handle precalculated gamut check. The retrieval of context may be alittle bit slow, but this function is not critical.
static
void TransformOnePixelWithGamutCheck(_cmsTRANSFORM* p,
const cmsUInt16Number wIn[],
cmsUInt16Number wOut[])
{
--- 206,450 ----
void* OutputBuffer,
cmsUInt32Number Size)
{
_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);
}
! // This is a legacy stride for planar
void CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform,
const void* InputBuffer,
void* OutputBuffer,
cmsUInt32Number Size, cmsUInt32Number Stride)
{
_cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
+ cmsStride stride;
+
+ stride.BytesPerLineIn = 0;
+ stride.BytesPerLineOut = 0;
+ stride.BytesPerPlaneIn = Stride;
+ stride.BytesPerPlaneOut = Stride;
+
+ p -> xform(p, InputBuffer, OutputBuffer, Size, 1, &stride);
+ }
+
+ // This is the "fast" function for plugins
+ void CMSEXPORT cmsDoTransformLineStride(cmsHTRANSFORM Transform,
+ const void* InputBuffer,
+ void* OutputBuffer,
+ cmsUInt32Number PixelsPerLine,
+ cmsUInt32Number LineCount,
+ cmsUInt32Number BytesPerLineIn,
+ cmsUInt32Number BytesPerLineOut,
+ cmsUInt32Number BytesPerPlaneIn,
+ cmsUInt32Number BytesPerPlaneOut)
+
+ {
+ _cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
+ cmsStride stride;
+
+ stride.BytesPerLineIn = BytesPerLineIn;
+ stride.BytesPerLineOut = BytesPerLineOut;
+ stride.BytesPerPlaneIn = BytesPerPlaneIn;
+ stride.BytesPerPlaneOut = BytesPerPlaneOut;
! p->xform(p, InputBuffer, OutputBuffer, PixelsPerLine, LineCount, &stride);
}
+
// Transform routines ----------------------------------------------------------------------------------------------------------
// Float xform converts floats. Since there are no performance issues, one routine does all job, including gamut check.
// Note that because extended range, we can use a -1.0 value for out of gamut in this case.
static
void FloatXFORM(_cmsTRANSFORM* p,
const void* in,
! void* out,
! cmsUInt32Number PixelsPerLine,
! cmsUInt32Number LineCount,
! const cmsStride* Stride)
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsFloat32Number fIn[cmsMAXCHANNELS], fOut[cmsMAXCHANNELS];
cmsFloat32Number OutOfGamut;
! cmsUInt32Number i, j, c, strideIn, strideOut;
!
! _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
! strideIn = 0;
! strideOut = 0;
! for (i = 0; i < LineCount; i++) {
! accum = (cmsUInt8Number*)in + strideIn;
! output = (cmsUInt8Number*)out + strideOut;
!
! for (j = 0; j < PixelsPerLine; j++) {
!
! accum = p->FromInputFloat(p, fIn, accum, Stride->BytesPerPlaneIn);
// Any gamut chack to do?
! if (p->GamutCheck != NULL) {
// Evaluate gamut marker.
! cmsPipelineEvalFloat(fIn, &OutOfGamut, p->GamutCheck);
// Is current color out of gamut?
if (OutOfGamut > 0.0) {
// Certainly, out of gamut
! for (c = 0; c < cmsMAXCHANNELS; c++)
! fOut[c] = -1.0;
}
else {
// No, proceed normally
! cmsPipelineEvalFloat(fIn, fOut, p->Lut);
}
}
else {
// No gamut check at all
! cmsPipelineEvalFloat(fIn, fOut, p->Lut);
! }
!
!
! output = p->ToOutputFloat(p, fOut, output, Stride->BytesPerPlaneOut);
}
! strideIn += Stride->BytesPerLineIn;
! strideOut += Stride->BytesPerLineOut;
}
+
}
static
void NullFloatXFORM(_cmsTRANSFORM* p,
const void* in,
void* out,
! cmsUInt32Number PixelsPerLine,
! cmsUInt32Number LineCount,
! const cmsStride* Stride)
!
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsFloat32Number fIn[cmsMAXCHANNELS];
! cmsUInt32Number i, j, strideIn, strideOut;
!
! _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
!
! strideIn = 0;
! strideOut = 0;
! for (i = 0; i < LineCount; i++) {
! accum = (cmsUInt8Number*) in + strideIn;
! output = (cmsUInt8Number*) out + strideOut;
! for (j = 0; j < PixelsPerLine; j++) {
!
! accum = p->FromInputFloat(p, fIn, accum, Stride ->BytesPerPlaneIn);
! output = p->ToOutputFloat(p, fIn, output, Stride->BytesPerPlaneOut);
! }
!
! strideIn += Stride->BytesPerLineIn;
! strideOut += Stride->BytesPerLineOut;
}
}
// 16 bit precision -----------------------------------------------------------------------------------------------------------
// Null transformation, only applies formatters. No caché
static
void NullXFORM(_cmsTRANSFORM* p,
const void* in,
! void* out,
! cmsUInt32Number PixelsPerLine,
! cmsUInt32Number LineCount,
! const cmsStride* Stride)
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS];
! cmsUInt32Number i, j, strideIn, strideOut;
!
! _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
!
! strideIn = 0;
! strideOut = 0;
! for (i = 0; i < LineCount; i++) {
! accum = (cmsUInt8Number*)in + strideIn;
! output = (cmsUInt8Number*)out + strideOut;
! for (j = 0; j < PixelsPerLine; j++) {
!
! accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
! output = p->ToOutput(p, wIn, output, Stride->BytesPerPlaneOut);
! }
!
! strideIn += Stride->BytesPerLineIn;
! strideOut += Stride->BytesPerLineOut;
}
+
}
// No gamut check, no cache, 16 bits
static
void PrecalculatedXFORM(_cmsTRANSFORM* p,
const void* in,
! 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);
! strideIn = 0;
! strideOut = 0;
! for (i = 0; i < LineCount; i++) {
!
! accum = (cmsUInt8Number*)in + strideIn;
! output = (cmsUInt8Number*)out + strideOut;
!
! for (j = 0; j < PixelsPerLine; j++) {
!
! accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
! p->Lut->Eval16Fn(wIn, wOut, p->Lut->Data);
! output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
}
+
+ strideIn += Stride->BytesPerLineIn;
+ strideOut += Stride->BytesPerLineOut;
+ }
+
}
! // Auxiliary: Handle precalculated gamut check. The retrieval of context may be alittle bit slow, but this function is not critical.
static
void TransformOnePixelWithGamutCheck(_cmsTRANSFORM* p,
const cmsUInt16Number wIn[],
cmsUInt16Number wOut[])
{
*** 377,498 ****
// Gamut check, No caché, 16 bits.
static
void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
const void* in,
! void* out, cmsUInt32Number Size, cmsUInt32Number Stride)
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
! cmsUInt32Number i, n;
! accum = (cmsUInt8Number*) in;
! output = (cmsUInt8Number*) out;
! n = Size; // Buffer len
! for (i=0; i < n; i++) {
! accum = p -> FromInput(p, wIn, accum, Stride);
TransformOnePixelWithGamutCheck(p, wIn, wOut);
! output = p -> ToOutput(p, wOut, output, Stride);
}
}
// No gamut check, Caché, 16 bits,
static
void CachedXFORM(_cmsTRANSFORM* p,
const void* in,
! void* out, cmsUInt32Number Size, cmsUInt32Number Stride)
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
- cmsUInt32Number i, n;
_cmsCACHE Cache;
! accum = (cmsUInt8Number*) in;
! output = (cmsUInt8Number*) out;
! n = Size; // Buffer len
// Empty buffers for quick memcmp
memset(wIn, 0, sizeof(wIn));
memset(wOut, 0, sizeof(wOut));
// Get copy of zero cache
! memcpy(&Cache, &p ->Cache, sizeof(Cache));
! for (i=0; i < n; i++) {
! accum = p -> FromInput(p, wIn, accum, Stride);
if (memcmp(wIn, Cache.CacheIn, sizeof(Cache.CacheIn)) == 0) {
memcpy(wOut, Cache.CacheOut, sizeof(Cache.CacheOut));
}
else {
!
! p ->Lut ->Eval16Fn(wIn, wOut, p -> Lut->Data);
memcpy(Cache.CacheIn, wIn, sizeof(Cache.CacheIn));
memcpy(Cache.CacheOut, wOut, sizeof(Cache.CacheOut));
}
! output = p -> ToOutput(p, wOut, output, Stride);
}
}
-
// All those nice features together
static
void CachedXFORMGamutCheck(_cmsTRANSFORM* p,
const void* in,
! void* out, cmsUInt32Number Size, cmsUInt32Number Stride)
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
- cmsUInt32Number i, n;
_cmsCACHE Cache;
! accum = (cmsUInt8Number*) in;
! output = (cmsUInt8Number*) out;
! n = Size; // Buffer len
// Empty buffers for quick memcmp
! memset(wIn, 0, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
! memset(wOut, 0, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
// Get copy of zero cache
! memcpy(&Cache, &p ->Cache, sizeof(Cache));
! for (i=0; i < n; i++) {
! accum = p -> FromInput(p, wIn, accum, Stride);
if (memcmp(wIn, Cache.CacheIn, sizeof(Cache.CacheIn)) == 0) {
memcpy(wOut, Cache.CacheOut, sizeof(Cache.CacheOut));
}
else {
TransformOnePixelWithGamutCheck(p, wIn, wOut);
memcpy(Cache.CacheIn, wIn, sizeof(Cache.CacheIn));
memcpy(Cache.CacheOut, wOut, sizeof(Cache.CacheOut));
}
! output = p -> ToOutput(p, wOut, output, Stride);
}
}
! // -------------------------------------------------------------------------------------------------------------
// List of used-defined transform factories
typedef struct _cmsTransformCollection_st {
! _cmsTransformFactory Factory;
struct _cmsTransformCollection_st *Next;
} _cmsTransformCollection;
// The linked list head
--- 467,627 ----
// Gamut check, No caché, 16 bits.
static
void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
const void* in,
! void* out,
! cmsUInt32Number PixelsPerLine,
! cmsUInt32Number LineCount,
! const cmsStride* Stride)
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
! cmsUInt32Number i, j, strideIn, strideOut;
!
! _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
!
! strideIn = 0;
! strideOut = 0;
! for (i = 0; i < LineCount; i++) {
! accum = (cmsUInt8Number*)in + strideIn;
! output = (cmsUInt8Number*)out + strideOut;
! for (j = 0; j < PixelsPerLine; j++) {
!
! accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
TransformOnePixelWithGamutCheck(p, wIn, wOut);
! output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
! }
!
! strideIn += Stride->BytesPerLineIn;
! strideOut += Stride->BytesPerLineOut;
}
}
// No gamut check, Caché, 16 bits,
static
void CachedXFORM(_cmsTRANSFORM* p,
const void* in,
! void* out,
! cmsUInt32Number PixelsPerLine,
! cmsUInt32Number LineCount,
! const cmsStride* Stride)
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
_cmsCACHE Cache;
+ cmsUInt32Number i, j, strideIn, strideOut;
! _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
// Empty buffers for quick memcmp
memset(wIn, 0, sizeof(wIn));
memset(wOut, 0, sizeof(wOut));
// Get copy of zero cache
! memcpy(&Cache, &p->Cache, sizeof(Cache));
!
! strideIn = 0;
! strideOut = 0;
! for (i = 0; i < LineCount; i++) {
! accum = (cmsUInt8Number*)in + strideIn;
! output = (cmsUInt8Number*)out + strideOut;
!
! for (j = 0; j < PixelsPerLine; j++) {
!
! accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
if (memcmp(wIn, Cache.CacheIn, sizeof(Cache.CacheIn)) == 0) {
memcpy(wOut, Cache.CacheOut, sizeof(Cache.CacheOut));
}
else {
! p->Lut->Eval16Fn(wIn, wOut, p->Lut->Data);
memcpy(Cache.CacheIn, wIn, sizeof(Cache.CacheIn));
memcpy(Cache.CacheOut, wOut, sizeof(Cache.CacheOut));
}
! output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
}
+ strideIn += Stride->BytesPerLineIn;
+ strideOut += Stride->BytesPerLineOut;
+ }
}
// All those nice features together
static
void CachedXFORMGamutCheck(_cmsTRANSFORM* p,
const void* in,
! void* out,
! cmsUInt32Number PixelsPerLine,
! cmsUInt32Number LineCount,
! const cmsStride* Stride)
{
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
_cmsCACHE Cache;
+ cmsUInt32Number i, j, strideIn, strideOut;
! _cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
// Empty buffers for quick memcmp
! memset(wIn, 0, sizeof(wIn));
! memset(wOut, 0, sizeof(wOut));
// Get copy of zero cache
! memcpy(&Cache, &p->Cache, sizeof(Cache));
! strideIn = 0;
! strideOut = 0;
! for (i = 0; i < LineCount; i++) {
!
! accum = (cmsUInt8Number*)in + strideIn;
! output = (cmsUInt8Number*)out + strideOut;
!
! for (j = 0; j < PixelsPerLine; j++) {
!
! accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
if (memcmp(wIn, Cache.CacheIn, sizeof(Cache.CacheIn)) == 0) {
+
memcpy(wOut, Cache.CacheOut, sizeof(Cache.CacheOut));
}
else {
TransformOnePixelWithGamutCheck(p, wIn, wOut);
+
memcpy(Cache.CacheIn, wIn, sizeof(Cache.CacheIn));
memcpy(Cache.CacheOut, wOut, sizeof(Cache.CacheOut));
}
! output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
}
+ strideIn += Stride->BytesPerLineIn;
+ strideOut += Stride->BytesPerLineOut;
+ }
}
! // Transform plug-ins ----------------------------------------------------------------------------------------------------
// List of used-defined transform factories
typedef struct _cmsTransformCollection_st {
! _cmsTransform2Factory Factory;
! cmsBool OldXform; // Factory returns xform function in the old style
!
struct _cmsTransformCollection_st *Next;
} _cmsTransformCollection;
// The linked list head
*** 531,540 ****
--- 660,670 ----
}
ctx ->chunks[TransformPlugin] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsTransformPluginChunkType));
}
+ // Allocates memory for transform plugin factory
void _cmsAllocTransformPluginChunk(struct _cmsContext_struct* ctx,
const struct _cmsContext_struct* src)
{
if (src != NULL) {
*** 545,554 ****
--- 675,713 ----
static _cmsTransformPluginChunkType TransformPluginChunkType = { NULL };
ctx ->chunks[TransformPlugin] = _cmsSubAllocDup(ctx ->MemPool, &TransformPluginChunkType, sizeof(_cmsTransformPluginChunkType));
}
}
+ // Adaptor for old versions of plug-in
+ static
+ void _cmsTransform2toTransformAdaptor(struct _cmstransform_struct *CMMcargo,
+ const void* InputBuffer,
+ void* OutputBuffer,
+ cmsUInt32Number PixelsPerLine,
+ cmsUInt32Number LineCount,
+ const cmsStride* Stride)
+ {
+
+ cmsUInt32Number i, strideIn, strideOut;
+
+ _cmsHandleExtraChannels(CMMcargo, InputBuffer, OutputBuffer, PixelsPerLine, LineCount, Stride);
+
+ strideIn = 0;
+ strideOut = 0;
+
+ for (i = 0; i < LineCount; i++) {
+
+ void *accum = (cmsUInt8Number*)InputBuffer + strideIn;
+ void *output = (cmsUInt8Number*)OutputBuffer + strideOut;
+
+ CMMcargo->OldXform(CMMcargo, accum, output, PixelsPerLine, Stride->BytesPerPlaneIn);
+
+ strideIn += Stride->BytesPerLineIn;
+ strideOut += Stride->BytesPerLineOut;
+ }
+ }
+
// Register new ways to transform
cmsBool _cmsRegisterTransformPlugin(cmsContext ContextID, cmsPluginBase* Data)
{
*** 562,579 ****
ctx->TransformCollection = NULL;
return TRUE;
}
// Factory callback is required
! if (Plugin ->Factory == NULL) return FALSE;
fl = (_cmsTransformCollection*) _cmsPluginMalloc(ContextID, sizeof(_cmsTransformCollection));
if (fl == NULL) return FALSE;
// Copy the parameters
! fl ->Factory = Plugin ->Factory;
// Keep linked list
fl ->Next = ctx->TransformCollection;
ctx->TransformCollection = fl;
--- 721,746 ----
ctx->TransformCollection = NULL;
return TRUE;
}
// Factory callback is required
! if (Plugin->factories.xform == NULL) return FALSE;
fl = (_cmsTransformCollection*) _cmsPluginMalloc(ContextID, sizeof(_cmsTransformCollection));
if (fl == NULL) return FALSE;
+ // Check for full xform plug-ins previous to 2.8, we would need an adapter in that case
+ if (Plugin->base.ExpectedVersion < 2080) {
+
+ fl->OldXform = TRUE;
+ }
+ else
+ fl->OldXform = FALSE;
+
// Copy the parameters
! fl->Factory = Plugin->factories.xform;
// Keep linked list
fl ->Next = ctx->TransformCollection;
ctx->TransformCollection = fl;
*** 654,663 ****
--- 821,836 ----
p->FromInput = _cmsGetFormatter(ContextID, *InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_16BITS).Fmt16;
p->ToOutput = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_16BITS).Fmt16;
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?
+ if (Plugin->OldXform) {
+ p->OldXform = (_cmsTransformFn) p->xform;
+ p->xform = _cmsTransform2toTransformAdaptor;
+ }
+
return p;
}
}
// Not suitable for the transform plug-in, let's check the pipeline plug-in
*** 814,823 ****
--- 987,1012 ----
return FALSE;
}
// ----------------------------------------------------------------------------------------------------------------
+ // Jun-21-2000: Some profiles (those that comes with W2K) comes
+ // with the media white (media black?) x 100. Add a sanity check
+
+ static
+ void NormalizeXYZ(cmsCIEXYZ* Dest)
+ {
+ while (Dest -> X > 2. &&
+ Dest -> Y > 2. &&
+ Dest -> Z > 2.) {
+
+ Dest -> X /= 10.;
+ Dest -> Y /= 10.;
+ Dest -> Z /= 10.;
+ }
+ }
+
static
void SetWhitePoint(cmsCIEXYZ* wtPt, const cmsCIEXYZ* src)
{
if (src == NULL) {
wtPt ->X = cmsD50X;
*** 826,835 ****
--- 1015,1026 ----
}
else {
wtPt ->X = src->X;
wtPt ->Y = src->Y;
wtPt ->Z = src->Z;
+
+ NormalizeXYZ(wtPt);
}
}
// New to lcms 2.0 -- have all parameters available.
*** 1136,1146 ****
// For backwards compatibility
cmsBool CMSEXPORT cmsChangeBuffersFormat(cmsHTRANSFORM hTransform,
cmsUInt32Number InputFormat,
cmsUInt32Number OutputFormat)
{
-
_cmsTRANSFORM* xform = (_cmsTRANSFORM*) hTransform;
cmsFormatter16 FromInput, ToOutput;
// We only can afford to change formatters if previous transform is at least 16 bits
--- 1327,1336 ----
< prev index next >