Commit f550f624 authored by Alexandre Julliard's avatar Alexandre Julliard

libs: Import code from upstream lcms2 2.12.

parent d36615ee
......@@ -707,6 +707,8 @@ TIFF_PE_LIBS
TIFF_PE_CFLAGS
PNG_PE_LIBS
PNG_PE_CFLAGS
LCMS2_PE_LIBS
LCMS2_PE_CFLAGS
JPEG_PE_LIBS
JPEG_PE_CFLAGS
EXCESS_PRECISION_CFLAGS
......@@ -1785,6 +1787,7 @@ enable_dxerr8
enable_dxerr9
enable_dxguid
enable_jpeg
enable_lcms2
enable_mfuuid
enable_png
enable_strmiids
......@@ -1926,6 +1929,8 @@ OBJCFLAGS
OBJCPP
JPEG_PE_CFLAGS
JPEG_PE_LIBS
LCMS2_PE_CFLAGS
LCMS2_PE_LIBS
PNG_PE_CFLAGS
PNG_PE_LIBS
TIFF_PE_CFLAGS
......@@ -2714,6 +2719,11 @@ Some influential environment variables:
C compiler flags for the PE jpeg, overriding the bundled version
JPEG_PE_LIBS
Linker flags for the PE jpeg, overriding the bundled version
LCMS2_PE_CFLAGS
C compiler flags for the PE lcms2, overriding the bundled
version
LCMS2_PE_LIBS
Linker flags for the PE lcms2, overriding the bundled version
PNG_PE_CFLAGS
C compiler flags for the PE png, overriding the bundled version
PNG_PE_LIBS Linker flags for the PE png, overriding the bundled version
......@@ -10720,6 +10730,19 @@ fi
$as_echo "$as_me:${as_lineno-$LINENO}: jpeg cflags: $JPEG_PE_CFLAGS" >&5
$as_echo "$as_me:${as_lineno-$LINENO}: jpeg libs: $JPEG_PE_LIBS" >&5
if ${LCMS2_PE_CFLAGS:+false} :; then :
LCMS2_PE_CFLAGS="-I\$(top_srcdir)/libs/lcms2/include"
else
enable_lcms2=no
fi
if ${LCMS2_PE_LIBS:+false} :; then :
LCMS2_PE_LIBS=lcms2
else
enable_lcms2=no
fi
$as_echo "$as_me:${as_lineno-$LINENO}: lcms2 cflags: $LCMS2_PE_CFLAGS" >&5
$as_echo "$as_me:${as_lineno-$LINENO}: lcms2 libs: $LCMS2_PE_LIBS" >&5
if ${PNG_PE_CFLAGS:+false} :; then :
PNG_PE_CFLAGS="-I\$(top_srcdir)/libs/png"
else
......@@ -19487,6 +19510,8 @@ METAL_LIBS = $METAL_LIBS
EXCESS_PRECISION_CFLAGS = $EXCESS_PRECISION_CFLAGS
JPEG_PE_CFLAGS = $JPEG_PE_CFLAGS
JPEG_PE_LIBS = $JPEG_PE_LIBS
LCMS2_PE_CFLAGS = $LCMS2_PE_CFLAGS
LCMS2_PE_LIBS = $LCMS2_PE_LIBS
PNG_PE_CFLAGS = $PNG_PE_CFLAGS
PNG_PE_LIBS = $PNG_PE_LIBS
TIFF_PE_CFLAGS = $TIFF_PE_CFLAGS
......@@ -20782,6 +20807,7 @@ wine_fn_config_makefile libs/dxerr8 enable_dxerr8
wine_fn_config_makefile libs/dxerr9 enable_dxerr9
wine_fn_config_makefile libs/dxguid enable_dxguid
wine_fn_config_makefile libs/jpeg enable_jpeg
wine_fn_config_makefile libs/lcms2 enable_lcms2
wine_fn_config_makefile libs/mfuuid enable_mfuuid
wine_fn_config_makefile libs/png enable_png
wine_fn_config_makefile libs/strmiids enable_strmiids
......
......@@ -1062,6 +1062,7 @@ WINE_NOTICE_WITH(mingw,[test "x$CROSSTARGET" = "x"],
dnl **** External libraries ****
WINE_EXTLIB_FLAGS(JPEG, jpeg, jpeg, "-I\$(top_srcdir)/libs/jpeg")
WINE_EXTLIB_FLAGS(LCMS2, lcms2, lcms2, "-I\$(top_srcdir)/libs/lcms2/include")
WINE_EXTLIB_FLAGS(PNG, png, "png \$(ZLIB_PE_LIBS)", "-I\$(top_srcdir)/libs/png")
WINE_EXTLIB_FLAGS(TIFF, tiff, tiff, "-I\$(top_srcdir)/libs/tiff/libtiff")
WINE_EXTLIB_FLAGS(ZLIB, zlib, z, "-I\$(top_srcdir)/libs/zlib -DFAR= -DZ_SOLO")
......@@ -3781,6 +3782,7 @@ WINE_CONFIG_MAKEFILE(libs/dxerr8)
WINE_CONFIG_MAKEFILE(libs/dxerr9)
WINE_CONFIG_MAKEFILE(libs/dxguid)
WINE_CONFIG_MAKEFILE(libs/jpeg)
WINE_CONFIG_MAKEFILE(libs/lcms2)
WINE_CONFIG_MAKEFILE(libs/mfuuid)
WINE_CONFIG_MAKEFILE(libs/png)
WINE_CONFIG_MAKEFILE(libs/strmiids)
......
Main Author
------------
Marti Maria
Contributors
------------
Bob Friesenhahn
Kai-Uwe Behrmann
Stuart Nixon
Jordi Vilar
Richard Hughes
Auke Nauta
Chris Evans (Google)
Lorenzo Ridolfi
Robin Watts (Artifex)
Shawn Pedersen
Andrew Brygin
Samuli Suominen
Florian Hch
Aurelien Jarno
Claudiu Cebuc
Michael Vhrel (Artifex)
Michal Cihar
Daniel Kaneider
Mateusz Jurczyk (Google)
Paul Miller
Sbastien Lon
Christian Schmitz
XhmikosR
Stanislav Brabec (SuSe)
Leonhard Gruenschloss (Google)
Patrick Noffke
Christopher James Halse Rogers
John Hein
Thomas Weber (Debian)
Mark Allen
Noel Carboni
Sergei Trofimovic
Philipp Knechtges
Special Thanks
--------------
Artifex software
AlienSkin software
Jan Morovic
Jos Vernon (WebSupergoo)
Harald Schneider (Maxon)
Christian Albrecht
Dimitrios Anastassakis
Lemke Software
Tim Zaman
Little CMS
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, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
EXTLIB = liblcms2.a
EXTRAINCL = -I$(srcdir)/include
C_SRCS = \
src/cmsalpha.c \
src/cmscnvrt.c \
src/cmserr.c \
src/cmsgamma.c \
src/cmsgmt.c \
src/cmshalf.c \
src/cmsintrp.c \
src/cmsio0.c \
src/cmsio1.c \
src/cmslut.c \
src/cmsmtrx.c \
src/cmsnamed.c \
src/cmsopt.c \
src/cmspack.c \
src/cmspcs.c \
src/cmsplugin.c \
src/cmssamp.c \
src/cmstypes.c \
src/cmsvirt.c \
src/cmswtpnt.c \
src/cmsxform.c
//---------------------------------------------------------------------------------
//
// 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,
// and/or sell copies of the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//---------------------------------------------------------------------------------
//
#include "lcms2_internal.h"
#define DSWAP(x, y) {cmsFloat64Number tmp = (x); (x)=(y); (y)=tmp;}
// Initiate a vector
void CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y, cmsFloat64Number z)
{
r -> n[VX] = x;
r -> n[VY] = y;
r -> n[VZ] = z;
}
// Vector subtraction
void CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b)
{
r -> n[VX] = a -> n[VX] - b -> n[VX];
r -> n[VY] = a -> n[VY] - b -> n[VY];
r -> n[VZ] = a -> n[VZ] - b -> n[VZ];
}
// Vector cross product
void CMSEXPORT _cmsVEC3cross(cmsVEC3* r, const cmsVEC3* u, const cmsVEC3* v)
{
r ->n[VX] = u->n[VY] * v->n[VZ] - v->n[VY] * u->n[VZ];
r ->n[VY] = u->n[VZ] * v->n[VX] - v->n[VZ] * u->n[VX];
r ->n[VZ] = u->n[VX] * v->n[VY] - v->n[VX] * u->n[VY];
}
// Vector dot product
cmsFloat64Number CMSEXPORT _cmsVEC3dot(const cmsVEC3* u, const cmsVEC3* v)
{
return u->n[VX] * v->n[VX] + u->n[VY] * v->n[VY] + u->n[VZ] * v->n[VZ];
}
// Euclidean length
cmsFloat64Number CMSEXPORT _cmsVEC3length(const cmsVEC3* a)
{
return sqrt(a ->n[VX] * a ->n[VX] +
a ->n[VY] * a ->n[VY] +
a ->n[VZ] * a ->n[VZ]);
}
// Euclidean distance
cmsFloat64Number CMSEXPORT _cmsVEC3distance(const cmsVEC3* a, const cmsVEC3* b)
{
cmsFloat64Number d1 = a ->n[VX] - b ->n[VX];
cmsFloat64Number d2 = a ->n[VY] - b ->n[VY];
cmsFloat64Number d3 = a ->n[VZ] - b ->n[VZ];
return sqrt(d1*d1 + d2*d2 + d3*d3);
}
// 3x3 Identity
void CMSEXPORT _cmsMAT3identity(cmsMAT3* a)
{
_cmsVEC3init(&a-> v[0], 1.0, 0.0, 0.0);
_cmsVEC3init(&a-> v[1], 0.0, 1.0, 0.0);
_cmsVEC3init(&a-> v[2], 0.0, 0.0, 1.0);
}
static
cmsBool CloseEnough(cmsFloat64Number a, cmsFloat64Number b)
{
return fabs(b - a) < (1.0 / 65535.0);
}
cmsBool CMSEXPORT _cmsMAT3isIdentity(const cmsMAT3* a)
{
cmsMAT3 Identity;
int i, j;
_cmsMAT3identity(&Identity);
for (i=0; i < 3; i++)
for (j=0; j < 3; j++)
if (!CloseEnough(a ->v[i].n[j], Identity.v[i].n[j])) return FALSE;
return TRUE;
}
// Multiply two matrices
void CMSEXPORT _cmsMAT3per(cmsMAT3* r, const cmsMAT3* a, const cmsMAT3* b)
{
#define ROWCOL(i, j) \
a->v[i].n[0]*b->v[0].n[j] + a->v[i].n[1]*b->v[1].n[j] + a->v[i].n[2]*b->v[2].n[j]
_cmsVEC3init(&r-> v[0], ROWCOL(0,0), ROWCOL(0,1), ROWCOL(0,2));
_cmsVEC3init(&r-> v[1], ROWCOL(1,0), ROWCOL(1,1), ROWCOL(1,2));
_cmsVEC3init(&r-> v[2], ROWCOL(2,0), ROWCOL(2,1), ROWCOL(2,2));
#undef ROWCOL //(i, j)
}
// Inverse of a matrix b = a^(-1)
cmsBool CMSEXPORT _cmsMAT3inverse(const cmsMAT3* a, cmsMAT3* b)
{
cmsFloat64Number det, c0, c1, c2;
c0 = a -> v[1].n[1]*a -> v[2].n[2] - a -> v[1].n[2]*a -> v[2].n[1];
c1 = -a -> v[1].n[0]*a -> v[2].n[2] + a -> v[1].n[2]*a -> v[2].n[0];
c2 = a -> v[1].n[0]*a -> v[2].n[1] - a -> v[1].n[1]*a -> v[2].n[0];
det = a -> v[0].n[0]*c0 + a -> v[0].n[1]*c1 + a -> v[0].n[2]*c2;
if (fabs(det) < MATRIX_DET_TOLERANCE) return FALSE; // singular matrix; can't invert
b -> v[0].n[0] = c0/det;
b -> v[0].n[1] = (a -> v[0].n[2]*a -> v[2].n[1] - a -> v[0].n[1]*a -> v[2].n[2])/det;
b -> v[0].n[2] = (a -> v[0].n[1]*a -> v[1].n[2] - a -> v[0].n[2]*a -> v[1].n[1])/det;
b -> v[1].n[0] = c1/det;
b -> v[1].n[1] = (a -> v[0].n[0]*a -> v[2].n[2] - a -> v[0].n[2]*a -> v[2].n[0])/det;
b -> v[1].n[2] = (a -> v[0].n[2]*a -> v[1].n[0] - a -> v[0].n[0]*a -> v[1].n[2])/det;
b -> v[2].n[0] = c2/det;
b -> v[2].n[1] = (a -> v[0].n[1]*a -> v[2].n[0] - a -> v[0].n[0]*a -> v[2].n[1])/det;
b -> v[2].n[2] = (a -> v[0].n[0]*a -> v[1].n[1] - a -> v[0].n[1]*a -> v[1].n[0])/det;
return TRUE;
}
// Solve a system in the form Ax = b
cmsBool CMSEXPORT _cmsMAT3solve(cmsVEC3* x, cmsMAT3* a, cmsVEC3* b)
{
cmsMAT3 m, a_1;
memmove(&m, a, sizeof(cmsMAT3));
if (!_cmsMAT3inverse(&m, &a_1)) return FALSE; // Singular matrix
_cmsMAT3eval(x, &a_1, b);
return TRUE;
}
// Evaluate a vector across a matrix
void CMSEXPORT _cmsMAT3eval(cmsVEC3* r, const cmsMAT3* a, const cmsVEC3* v)
{
r->n[VX] = a->v[0].n[VX]*v->n[VX] + a->v[0].n[VY]*v->n[VY] + a->v[0].n[VZ]*v->n[VZ];
r->n[VY] = a->v[1].n[VX]*v->n[VX] + a->v[1].n[VY]*v->n[VY] + a->v[1].n[VZ]*v->n[VZ];
r->n[VZ] = a->v[2].n[VX]*v->n[VX] + a->v[2].n[VY]*v->n[VY] + a->v[2].n[VZ]*v->n[VZ];
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment