--- old/src/java.desktop/share/native/liblcms/cmstypes.c 2020-08-27 15:57:50.234102984 -0700 +++ new/src/java.desktop/share/native/liblcms/cmstypes.c 2020-08-27 15:57:49.934102989 -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"), @@ -195,7 +195,7 @@ cmsUInt32Number SizeOfTag); // Helper function to deal with position tables as described in ICC spec 4.3 -// A table of n elements is readed, where first comes n records containing offsets and sizes and +// A table of n elements is read, where first comes n records containing offsets and sizes and // then a block containing the data itself. This allows to reuse same data in more than one entry static cmsBool ReadPositionTable(struct _cms_typehandler_struct* self, @@ -1003,7 +1003,7 @@ len = cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, NULL, 0); // Specification ICC.1:2001-04 (v2.4.0): It has been found that textDescriptionType can contain misaligned data - //(see clause 4.1 for the definition of “aligned”). Because the Unicode language + //(see clause 4.1 for the definition of 'aligned'). Because the Unicode language // code and Unicode count immediately follow the ASCII description, their // alignment is not correct if the ASCII count is not a multiple of four. The // ScriptCode code is misaligned when the ASCII count is odd. Profile reading and @@ -1509,7 +1509,7 @@ // True begin of the string BeginOfThisString = Offset - SizeOfHeader - 8; - // Ajust to wchar_t elements + // Adjust to wchar_t elements mlu ->Entries[i].Len = (Len * sizeof(wchar_t)) / sizeof(cmsUInt16Number); mlu ->Entries[i].StrW = (BeginOfThisString * sizeof(wchar_t)) / sizeof(cmsUInt16Number); @@ -1882,7 +1882,7 @@ static cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems) { - cmsUInt32Number j, nTabSize; + cmsUInt32Number j, nTabSize, i, n; cmsUInt8Number val; cmsPipeline* NewLUT = (cmsPipeline*) Ptr; cmsStage* mpe; @@ -1931,22 +1931,19 @@ if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE; if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding + n = NewLUT->InputChannels * NewLUT->OutputChannels; if (MatMPE != NULL) { - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[0])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[1])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[2])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[3])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[4])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[5])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[6])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[7])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[8])) return FALSE; - + for (i = 0; i < n; i++) + { + if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE; + } } else { + if (n != 9) return FALSE; + if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; @@ -2170,7 +2167,7 @@ // Some empty defaults are created for missing parts static -cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems) +cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems) { cmsUInt32Number nTabSize; cmsPipeline* NewLUT = (cmsPipeline*) Ptr; @@ -2185,6 +2182,7 @@ if (mpe != NULL && mpe ->Type == cmsSigMatrixElemType) { MatMPE = (_cmsStageMatrixData*) mpe ->Data; + if (mpe->InputChannels != 3 || mpe->OutputChannels != 3) return FALSE; mpe = mpe -> Next; } @@ -2223,18 +2221,13 @@ if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE; if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding - if (MatMPE != NULL) { - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[0])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[1])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[2])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[3])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[4])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[5])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[6])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[7])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[8])) return FALSE; + for (i = 0; i < 9; i++) + { + if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE; + } + } else { @@ -2423,7 +2416,7 @@ return NULL; } - return CLUT; + return CLUT; } static @@ -2579,31 +2572,31 @@ static cmsBool WriteMatrix(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsStage* mpe) { + cmsUInt32Number i, n; + _cmsStageMatrixData* m = (_cmsStageMatrixData*) mpe -> Data; - // Write the Matrix - if (!_cmsWrite15Fixed16Number(io, m -> Double[0])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, m -> Double[1])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, m -> Double[2])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, m -> Double[3])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, m -> Double[4])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, m -> Double[5])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, m -> Double[6])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, m -> Double[7])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, m -> Double[8])) return FALSE; - - if (m ->Offset != NULL) { - - if (!_cmsWrite15Fixed16Number(io, m -> Offset[0])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, m -> Offset[1])) return FALSE; - if (!_cmsWrite15Fixed16Number(io, m -> Offset[2])) return FALSE; - } - else { - if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; - if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; - if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; + n = mpe->InputChannels * mpe->OutputChannels; - } + // Write the Matrix + for (i = 0; i < n; i++) + { + if (!_cmsWrite15Fixed16Number(io, m->Double[i])) return FALSE; + } + + if (m->Offset != NULL) { + + for (i = 0; i < mpe->OutputChannels; i++) + { + if (!_cmsWrite15Fixed16Number(io, m->Offset[i])) return FALSE; + } + } + else { + for (i = 0; i < mpe->OutputChannels; i++) + { + if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE; + } + } return TRUE; @@ -2707,9 +2700,9 @@ return FALSE; } - if (!_cmsWriteAlignment(io)) return FALSE; + if (!_cmsWriteAlignment(io)) return FALSE; - return TRUE; + return TRUE; } @@ -3120,10 +3113,10 @@ //The namedColor2Type is a count value and array of structures that provide color //coordinates for 7-bit ASCII color names. For each named color, a PCS and optional //device representation of the color are given. Both representations are 16-bit values. -//The device representation corresponds to the header’s “color space of data” field. -//This representation should be consistent with the “number of device components” +//The device representation corresponds to the header's 'color space of data' field. +//This representation should be consistent with the 'number of device components' //field in the namedColor2Type. If this field is 0, device coordinates are not provided. -//The PCS representation corresponds to the header’s PCS field. The PCS representation +//The PCS representation corresponds to the header's PCS field. The PCS representation //is always provided. Color names are fixed-length, 32-byte fields including null //termination. In order to maintain maximum portability, it is strongly recommended //that special characters of the 7-bit ASCII set not be used. @@ -3868,7 +3861,7 @@ // ******************************************************************************** // //This type represents a set of viewing condition parameters including: -//CIE ’absolute’ illuminant white point tristimulus values and CIE ’absolute’ +//CIE 'absolute' illuminant white point tristimulus values and CIE 'absolute' //surround tristimulus values. static @@ -3955,7 +3948,7 @@ } // Each curve is stored in one or more curve segments, with break-points specified between curve segments. -// The first curve segment always starts at –Infinity, and the last curve segment always ends at +Infinity. The +// The first curve segment always starts at -Infinity, and the last curve segment always ends at +Infinity. The // first and last curve segments shall be specified in terms of a formula, whereas the other segments shall be // specified either in terms of a formula, or by a sampled curve. @@ -4236,7 +4229,7 @@ // The matrix is organized as an array of PxQ+Q elements, where P is the number of input channels to the // matrix, and Q is the number of output channels. The matrix elements are each float32Numbers. The array // is organized as follows: -// array = [e11, e12, …, e1P, e21, e22, …, e2P, …, eQ1, eQ2, …, eQP, e1, e2, …, eQ] +// array = [e11, e12, ..., e1P, e21, e22, ..., e2P, ..., eQ1, eQ2, ..., eQP, e1, e2, ..., eQ] static void *Type_MPEmatrix_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag) @@ -4759,10 +4752,10 @@ // Y = cX + f | X < d // vcgt formula is: - // Y = (Max – Min) * (X ^ Gamma) + Min + // Y = (Max - Min) * (X ^ Gamma) + Min // So, the translation is - // a = (Max – Min) ^ ( 1 / Gamma) + // a = (Max - Min) ^ ( 1 / Gamma) // e = Min // b=c=d=f=0