Skip to content

Commit 8954d05

Browse files
committed
8375065: Update LCMS to 2.18
Backport-of: 3871b88
1 parent 01a70bc commit 8954d05

30 files changed

Lines changed: 166 additions & 107 deletions

src/java.desktop/share/legal/lcms.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
## Little Color Management System (LCMS) v2.17
1+
## Little Color Management System (LCMS) v2.18
22

33
### LCMS License
44
<pre>
55

66
MIT License
77

8-
Copyright (C) 1998-2025 Marti Maria Saguer
8+
Copyright (C) 1998-2026 Marti Maria Saguer
99

1010
Permission is hereby granted, free of charge, to any person obtaining
1111
a copy of this software and associated documentation files (the "Software"),

src/java.desktop/share/native/liblcms/cmsalpha.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//---------------------------------------------------------------------------------
3131
//
3232
// Little Color Management System
33-
// Copyright (c) 1998-2024 Marti Maria Saguer
33+
// Copyright (c) 1998-2026 Marti Maria Saguer
3434
//
3535
// Permission is hereby granted, free of charge, to any person obtaining
3636
// a copy of this software and associated documentation files (the "Software"),
@@ -406,7 +406,7 @@ int FormatterPos(cmsUInt32Number frm)
406406
static
407407
cmsFormatterAlphaFn _cmsGetFormatterAlpha(cmsContext id, cmsUInt32Number in, cmsUInt32Number out)
408408
{
409-
static cmsFormatterAlphaFn FormattersAlpha[6][6] = {
409+
static const cmsFormatterAlphaFn FormattersAlpha[6][6] = {
410410

411411
/* from 8 */ { copy8, from8to16, from8to16SE, from8toHLF, from8toFLT, from8toDBL },
412412
/* from 16*/ { from16to8, copy16, from16to16, from16toHLF, from16toFLT, from16toDBL },

src/java.desktop/share/native/liblcms/cmscam02.c

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//---------------------------------------------------------------------------------
3131
//
3232
// Little Color Management System
33-
// Copyright (c) 1998-2024 Marti Maria Saguer
33+
// Copyright (c) 1998-2026 Marti Maria Saguer
3434
//
3535
// Permission is hereby granted, free of charge, to any person obtaining
3636
// a copy of this software and associated documentation files (the "Software"),
@@ -285,27 +285,32 @@ CAM02COLOR InverseCorrelates(CAM02COLOR clr, cmsCIECAM02* pMod)
285285
(clr.J / 100.0),
286286
(1.0 / (pMod->c * pMod->z)));
287287

288-
p1 = e / t;
289288
p2 = (clr.A / pMod->Nbb) + 0.305;
290-
p3 = 21.0 / 20.0;
291289

292-
hr = clr.h * d2r;
293-
294-
if (fabs(sin(hr)) >= fabs(cos(hr))) {
295-
p4 = p1 / sin(hr);
296-
clr.b = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
297-
(p4 + (2.0 + p3) * (220.0 / 1403.0) *
298-
(cos(hr) / sin(hr)) - (27.0 / 1403.0) +
299-
p3 * (6300.0 / 1403.0));
300-
clr.a = clr.b * (cos(hr) / sin(hr));
290+
if ( t <= 0.0 ) { // special case from spec notes, avoid divide by zero
291+
clr.a = clr.b = 0.0;
301292
}
302293
else {
303-
p5 = p1 / cos(hr);
304-
clr.a = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
305-
(p5 + (2.0 + p3) * (220.0 / 1403.0) -
306-
((27.0 / 1403.0) - p3 * (6300.0 / 1403.0)) *
307-
(sin(hr) / cos(hr)));
308-
clr.b = clr.a * (sin(hr) / cos(hr));
294+
hr = clr.h * d2r;
295+
p1 = e / t;
296+
p3 = 21.0 / 20.0;
297+
298+
if (fabs(sin(hr)) >= fabs(cos(hr))) {
299+
p4 = p1 / sin(hr);
300+
clr.b = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
301+
(p4 + (2.0 + p3) * (220.0 / 1403.0) *
302+
(cos(hr) / sin(hr)) - (27.0 / 1403.0) +
303+
p3 * (6300.0 / 1403.0));
304+
clr.a = clr.b * (cos(hr) / sin(hr));
305+
}
306+
else {
307+
p5 = p1 / cos(hr);
308+
clr.a = (p2 * (2.0 + p3) * (460.0 / 1403.0)) /
309+
(p5 + (2.0 + p3) * (220.0 / 1403.0) -
310+
((27.0 / 1403.0) - p3 * (6300.0 / 1403.0)) *
311+
(sin(hr) / cos(hr)));
312+
clr.b = clr.a * (sin(hr) / cos(hr));
313+
}
309314
}
310315

311316
clr.RGBpa[0] = ((460.0 / 1403.0) * p2) +

src/java.desktop/share/native/liblcms/cmscgats.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//---------------------------------------------------------------------------------
3131
//
3232
// Little Color Management System
33-
// Copyright (c) 1998-2024 Marti Maria Saguer
33+
// Copyright (c) 1998-2026 Marti Maria Saguer
3434
//
3535
// Permission is hereby granted, free of charge, to any person obtaining
3636
// a copy of this software and associated documentation files (the "Software"),
@@ -295,7 +295,7 @@ typedef struct {
295295
WRITEMODE as; // How is supposed to be written
296296
} PROPERTY;
297297

298-
static PROPERTY PredefinedProperties[] = {
298+
static const PROPERTY PredefinedProperties[] = {
299299

300300
{"NUMBER_OF_FIELDS", WRITE_UNCOOKED}, // Required - NUMBER OF FIELDS
301301
{"NUMBER_OF_SETS", WRITE_UNCOOKED}, // Required - NUMBER OF SETS
@@ -458,7 +458,7 @@ cmsBool StringAppend(string* s, char c)
458458
new_ptr = (char*) AllocChunk(s->it8, s->max);
459459
if (new_ptr == NULL) return FALSE;
460460

461-
if (new_ptr != NULL && s->begin != NULL)
461+
if (s->begin != NULL)
462462
memcpy(new_ptr, s->begin, s->len);
463463

464464
s->begin = new_ptr;
@@ -899,6 +899,11 @@ void InSymbol(cmsIT8* it8)
899899
sign = -1;
900900
NextCh(it8);
901901
}
902+
else
903+
if (it8->ch == '+') {
904+
sign = +1;
905+
NextCh(it8);
906+
}
902907

903908
it8->inum = 0;
904909
it8->sy = SINUM;
@@ -3206,7 +3211,7 @@ cmsBool ParseCube(cmsIT8* cube, cmsStage** Shaper, cmsStage** CLUT, char title[]
32063211

32073212
int nodes = lut_size * lut_size * lut_size;
32083213

3209-
cmsFloat32Number* lut_table = _cmsMalloc(cube->ContextID, nodes * 3 * sizeof(cmsFloat32Number));
3214+
cmsFloat32Number* lut_table = (cmsFloat32Number*) _cmsMalloc(cube->ContextID, nodes * 3 * sizeof(cmsFloat32Number));
32103215
if (lut_table == NULL) return FALSE;
32113216

32123217
for (i = 0; i < nodes; i++) {

src/java.desktop/share/native/liblcms/cmscnvrt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//---------------------------------------------------------------------------------
3131
//
3232
// Little Color Management System
33-
// Copyright (c) 1998-2024 Marti Maria Saguer
33+
// Copyright (c) 1998-2026 Marti Maria Saguer
3434
//
3535
// Permission is hereby granted, free of charge, to any person obtaining
3636
// a copy of this software and associated documentation files (the "Software"),

src/java.desktop/share/native/liblcms/cmserr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//---------------------------------------------------------------------------------
3131
//
3232
// Little Color Management System
33-
// Copyright (c) 1998-2024 Marti Maria Saguer
33+
// Copyright (c) 1998-2026 Marti Maria Saguer
3434
//
3535
// Permission is hereby granted, free of charge, to any person obtaining
3636
// a copy of this software and associated documentation files (the "Software"),

src/java.desktop/share/native/liblcms/cmsgamma.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//---------------------------------------------------------------------------------
3131
//
3232
// Little Color Management System
33-
// Copyright (c) 1998-2024 Marti Maria Saguer
33+
// Copyright (c) 1998-2026 Marti Maria Saguer
3434
//
3535
// Permission is hereby granted, free of charge, to any person obtaining
3636
// a copy of this software and associated documentation files (the "Software"),
@@ -1187,6 +1187,7 @@ cmsBool smooth2(cmsContext ContextID, cmsFloat32Number w[], cmsFloat32Number y[]
11871187
cmsFloat32Number *c, *d, *e;
11881188
cmsBool st;
11891189

1190+
if (m < 4 || lambda < MATRIX_DET_TOLERANCE) return FALSE;
11901191

11911192
c = (cmsFloat32Number*) _cmsCalloc(ContextID, MAX_NODES_IN_CURVE, sizeof(cmsFloat32Number));
11921193
d = (cmsFloat32Number*) _cmsCalloc(ContextID, MAX_NODES_IN_CURVE, sizeof(cmsFloat32Number));

src/java.desktop/share/native/liblcms/cmsgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//---------------------------------------------------------------------------------
3131
//
3232
// Little Color Management System
33-
// Copyright (c) 1998-2024 Marti Maria Saguer
33+
// Copyright (c) 1998-2026 Marti Maria Saguer
3434
//
3535
// Permission is hereby granted, free of charge, to any person obtaining
3636
// a copy of this software and associated documentation files (the "Software"),

src/java.desktop/share/native/liblcms/cmshalf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//---------------------------------------------------------------------------------
3131
//
3232
// Little Color Management System
33-
// Copyright (c) 1998-2024 Marti Maria Saguer
33+
// Copyright (c) 1998-2026 Marti Maria Saguer
3434
//
3535
// Permission is hereby granted, free of charge, to any person obtaining
3636
// a copy of this software and associated documentation files (the "Software"),

src/java.desktop/share/native/liblcms/cmsintrp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//---------------------------------------------------------------------------------
3131
//
3232
// Little Color Management System
33-
// Copyright (c) 1998-2024 Marti Maria Saguer
33+
// Copyright (c) 1998-2026 Marti Maria Saguer
3434
//
3535
// Permission is hereby granted, free of charge, to any person obtaining
3636
// a copy of this software and associated documentation files (the "Software"),
@@ -984,9 +984,9 @@ void Eval4Inputs(CMSREGISTER const cmsUInt16Number Input[],
984984
c1 = c2 = c3 = 0;
985985
}
986986

987-
Rest = c1 * rx + c2 * ry + c3 * rz;
987+
Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
988988

989-
Tmp1[OutChan] = (cmsUInt16Number)(c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
989+
Tmp1[OutChan] = (cmsUInt16Number)c0 + ((Rest + (Rest >> 16)) >> 16);
990990
}
991991

992992

@@ -1048,9 +1048,9 @@ void Eval4Inputs(CMSREGISTER const cmsUInt16Number Input[],
10481048
c1 = c2 = c3 = 0;
10491049
}
10501050

1051-
Rest = c1 * rx + c2 * ry + c3 * rz;
1051+
Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
10521052

1053-
Tmp2[OutChan] = (cmsUInt16Number) (c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
1053+
Tmp2[OutChan] = (cmsUInt16Number) c0 + ((Rest + (Rest >> 16)) >> 16);
10541054
}
10551055

10561056

0 commit comments

Comments
 (0)