--- old/src/java.desktop/share/native/liblcms/cmsxform.c 2020-08-27 15:57:51.818102958 -0700 +++ new/src/java.desktop/share/native/liblcms/cmsxform.c 2020-08-27 15:57:51.554102962 -0700 @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------------- // // 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"), @@ -200,6 +200,23 @@ _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, @@ -212,8 +229,8 @@ 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); } @@ -370,7 +387,7 @@ // 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, @@ -417,8 +434,8 @@ 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; @@ -471,7 +488,7 @@ 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, @@ -510,7 +527,7 @@ } -// No gamut check, Caché, 16 bits, +// No gamut check, Cache, 16 bits, static void CachedXFORM(_cmsTRANSFORM* p, const void* in, @@ -809,43 +826,46 @@ // Let's see if any plug-in want to do the transform by itself if (p->Lut != NULL) { - for (Plugin = ctx->TransformCollection; - Plugin != NULL; - Plugin = Plugin->Next) { - - if (Plugin->Factory(&p->xform, &p->UserData, &p->FreeUserData, &p->Lut, InputFormat, OutputFormat, dwFlags)) { - - // Last plugin in the declaration order takes control. We just keep - // the original parameters as a logging. - // Note that cmsFLAGS_CAN_CHANGE_FORMATTER is not set, so by default - // an optimized transform is not reusable. The plug-in can, however, change - // the flags and make it suitable. - - p->ContextID = ContextID; - p->InputFormat = *InputFormat; - p->OutputFormat = *OutputFormat; - p->dwOriginalFlags = *dwFlags; - - // Fill the formatters just in case the optimized routine is interested. - // No error is thrown if the formatter doesn't exist. It is up to the optimization - // factory to decide what to do in those cases. - 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? (Ignore the warning) - if (Plugin->OldXform) { - p->OldXform = (_cmsTransformFn)(void*) p->xform; - p->xform = _cmsTransform2toTransformAdaptor; - } - - return p; - } - } + 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)) { + + // Last plugin in the declaration order takes control. We just keep + // the original parameters as a logging. + // Note that cmsFLAGS_CAN_CHANGE_FORMATTER is not set, so by default + // an optimized transform is not reusable. The plug-in can, however, change + // the flags and make it suitable. + + p->ContextID = ContextID; + p->InputFormat = *InputFormat; + p->OutputFormat = *OutputFormat; + p->dwOriginalFlags = *dwFlags; + + // Fill the formatters just in case the optimized routine is interested. + // No error is thrown if the formatter doesn't exist. It is up to the optimization + // factory to decide what to do in those cases. + 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? (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); + // Not suitable for the transform plug-in, let's check the pipeline plug-in + _cmsOptimizePipeline(ContextID, &p->Lut, Intent, InputFormat, OutputFormat, dwFlags); } // Check whatever this is a true floating point transform @@ -868,7 +888,7 @@ 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; } @@ -907,16 +927,16 @@ 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 } }