summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lcms2mt/utils/tificc')
-rw-r--r--lcms2mt/utils/tificc/Makefile.am2
-rw-r--r--lcms2mt/utils/tificc/Makefile.in19
-rw-r--r--lcms2mt/utils/tificc/tifdiff.c2
-rw-r--r--lcms2mt/utils/tificc/tificc.c100
4 files changed, 69 insertions, 54 deletions
diff --git a/lcms2mt/utils/tificc/Makefile.am b/lcms2mt/utils/tificc/Makefile.am
index 50f5dc44..9e3643f2 100644
--- a/lcms2mt/utils/tificc/Makefile.am
+++ b/lcms2mt/utils/tificc/Makefile.am
@@ -16,7 +16,7 @@ else
bin_PROGRAMS =
endif
-tificc_LDADD = $(top_builddir)/src/liblcms2.la @TIFFICC_DEPLIBS@
+tificc_LDADD = $(top_builddir)/src/liblcms2mt.la @TIFFICC_DEPLIBS@
tificc_LDFLAGS = @LDFLAGS@
tificc_SOURCES = tificc.c ../common/xgetopt.c ../common/vprf.c ../common/utils.h
man_MANS = tificc.1
diff --git a/lcms2mt/utils/tificc/Makefile.in b/lcms2mt/utils/tificc/Makefile.in
index de4d9c29..c85c881d 100644
--- a/lcms2mt/utils/tificc/Makefile.in
+++ b/lcms2mt/utils/tificc/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -117,7 +117,7 @@ am__dirstamp = $(am__leading_dot)dirstamp
am_tificc_OBJECTS = tificc.$(OBJEXT) ../common/xgetopt.$(OBJEXT) \
../common/vprf.$(OBJEXT)
tificc_OBJECTS = $(am_tificc_OBJECTS)
-tificc_DEPENDENCIES = $(top_builddir)/src/liblcms2.la
+tificc_DEPENDENCIES = $(top_builddir)/src/liblcms2mt.la
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
@@ -139,7 +139,7 @@ am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp =
-am__depfiles_maybe =
+am__maybe_remake_depfiles =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -362,7 +362,7 @@ AUTOMAKE_OPTIONS = 1.7 foreign no-dependencies
AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \
-I$(top_srcdir)/utils/common -I$(top_builddir)/utils/common
-tificc_LDADD = $(top_builddir)/src/liblcms2.la @TIFFICC_DEPLIBS@
+tificc_LDADD = $(top_builddir)/src/liblcms2mt.la @TIFFICC_DEPLIBS@
tificc_LDFLAGS = @LDFLAGS@
tificc_SOURCES = tificc.c ../common/xgetopt.c ../common/vprf.c ../common/utils.h
man_MANS = tificc.1
@@ -388,8 +388,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -576,7 +576,10 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
diff --git a/lcms2mt/utils/tificc/tifdiff.c b/lcms2mt/utils/tificc/tifdiff.c
index 6719ec1c..fb12b3c4 100644
--- a/lcms2mt/utils/tificc/tifdiff.c
+++ b/lcms2mt/utils/tificc/tifdiff.c
@@ -1,7 +1,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"),
diff --git a/lcms2mt/utils/tificc/tificc.c b/lcms2mt/utils/tificc/tificc.c
index 2d2c70f3..445cc338 100644
--- a/lcms2mt/utils/tificc/tificc.c
+++ b/lcms2mt/utils/tificc/tificc.c
@@ -1,7 +1,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"),
@@ -237,7 +237,7 @@ cmsFormatter TiffFormatterFactory(cmsContext ContextID, cmsUInt32Number Type,
return Result;
}
-static cmsPluginFormatters TiffLabPlugin = { {cmsPluginMagicNumber, 2000, cmsPluginFormattersSig, NULL}, TiffFormatterFactory };
+static cmsPluginFormatters TiffLabPlugin = { {cmsPluginMagicNumber, 2000-2000, cmsPluginFormattersSig, NULL}, TiffFormatterFactory };
@@ -375,7 +375,7 @@ cmsUInt32Number ComputeOutputFormatDescriptor(cmsUInt32Number dwInput, int OutCo
// Tile based transforms
static
-int TileBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
+int TileBasedXform(cmsContext ContextID, cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
{
tsize_t BufSizeIn = TIFFTileSize(in);
tsize_t BufSizeOut = TIFFTileSize(out);
@@ -385,16 +385,20 @@ int TileBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
int PixelCount, j;
+ // Check for bad tiffs
+ if (BufSizeIn > INT_MAX || BufSizeOut > INT_MAX)
+ FatalError("Probably corrupted TIFF, tile too big.");
+
TIFFGetFieldDefaulted(in, TIFFTAG_TILEWIDTH, &tw);
TIFFGetFieldDefaulted(in, TIFFTAG_TILELENGTH, &tl);
PixelCount = (int) tw * tl;
BufferIn = (unsigned char *) _TIFFmalloc(BufSizeIn * nPlanes);
- if (!BufferIn) OutOfMem(BufSizeIn * nPlanes);
+ if (!BufferIn) OutOfMem((cmsUInt32Number) BufSizeIn * nPlanes);
BufferOut = (unsigned char *) _TIFFmalloc(BufSizeOut * nPlanes);
- if (!BufferOut) OutOfMem(BufSizeOut * nPlanes);
+ if (!BufferOut) OutOfMem((cmsUInt32Number) BufSizeOut * nPlanes);
for (i = 0; i < TileCount; i++) {
@@ -405,7 +409,7 @@ int TileBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
BufferIn + (j*BufSizeIn), BufSizeIn) < 0) goto cleanup;
}
- cmsDoTransform(NULL, hXForm, BufferIn, BufferOut, PixelCount);
+ cmsDoTransform(ContextID, hXForm, BufferIn, BufferOut, PixelCount);
for (j=0; j < nPlanes; j++) {
@@ -431,7 +435,7 @@ cleanup:
// Strip based transforms
static
-int StripBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
+int StripBasedXform(cmsContext ContextID, cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
{
tsize_t BufSizeIn = TIFFStripSize(in);
tsize_t BufSizeOut = TIFFStripSize(out);
@@ -443,6 +447,10 @@ int StripBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
int j;
int PixelCount;
+ // Check for bad tiffs
+ if (BufSizeIn > INT_MAX || BufSizeOut > INT_MAX)
+ FatalError("Probably corrupted TIFF, strip too big.");
+
TIFFGetFieldDefaulted(in, TIFFTAG_IMAGEWIDTH, &sw);
TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &sl);
TIFFGetFieldDefaulted(in, TIFFTAG_IMAGELENGTH, &iml);
@@ -452,10 +460,10 @@ int StripBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
sl = iml; // One strip for whole image
BufferIn = (unsigned char *) _TIFFmalloc(BufSizeIn * nPlanes);
- if (!BufferIn) OutOfMem(BufSizeIn * nPlanes);
+ if (!BufferIn) OutOfMem((cmsUInt32Number) BufSizeIn * nPlanes);
BufferOut = (unsigned char *) _TIFFmalloc(BufSizeOut * nPlanes);
- if (!BufferOut) OutOfMem(BufSizeOut * nPlanes);
+ if (!BufferOut) OutOfMem((cmsUInt32Number) BufSizeOut * nPlanes);
for (i = 0; i < StripCount; i++) {
@@ -469,7 +477,7 @@ int StripBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
PixelCount = (int) sw * (iml < sl ? iml : sl);
iml -= sl;
- cmsDoTransform(NULL, hXForm, BufferIn, BufferOut, PixelCount);
+ cmsDoTransform(ContextID, hXForm, BufferIn, BufferOut, PixelCount);
for (j=0; j < nPlanes; j++) {
if (TIFFWriteEncodedStrip(out, i + (j * StripCount),
@@ -667,7 +675,7 @@ void DoEmbedProfile(TIFF* Out, const char* ProfileFile)
size = cmsfilelength(f);
if (size < 0) return;
- EmbedBuffer = (cmsUInt8Number*) malloc(size + 1);
+ EmbedBuffer = (cmsUInt8Number*) malloc((size_t) size + 1);
if (EmbedBuffer == NULL) {
OutOfMem(size+1);
return;
@@ -675,7 +683,7 @@ void DoEmbedProfile(TIFF* Out, const char* ProfileFile)
EmbedLen = (cmsUInt32Number) fread(EmbedBuffer, 1, (size_t) size, f);
- if (EmbedLen != size)
+ if (EmbedLen != (cmsUInt32Number) size)
FatalError("Cannot read %ld bytes to %s", size, ProfileFile);
fclose(f);
@@ -688,7 +696,7 @@ void DoEmbedProfile(TIFF* Out, const char* ProfileFile)
static
-cmsHPROFILE GetTIFFProfile(TIFF* in)
+cmsHPROFILE GetTIFFProfile(cmsContext ContextID, TIFF* in)
{
cmsCIExyYTRIPLE Primaries;
cmsFloat32Number* chr;
@@ -705,13 +713,13 @@ cmsHPROFILE GetTIFFProfile(TIFF* in)
if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &EmbedLen, &EmbedBuffer)) {
- hProfile = cmsOpenProfileFromMem(EmbedBuffer, EmbedLen);
+ hProfile = cmsOpenProfileFromMem(ContextID, EmbedBuffer, EmbedLen);
// Print description found in the profile
if (Verbose && (hProfile != NULL)) {
fprintf(stdout, "\n[Embedded profile]\n");
- PrintProfileInformation(NULL, hProfile);
+ PrintProfileInformation(ContextID, hProfile);
fflush(stdout);
}
@@ -747,14 +755,14 @@ cmsHPROFILE GetTIFFProfile(TIFF* in)
&gmg,
&gmb);
- Curve[0] = cmsBuildTabulatedToneCurve16(NULL, 256, gmr);
- Curve[1] = cmsBuildTabulatedToneCurve16(NULL, 256, gmg);
- Curve[2] = cmsBuildTabulatedToneCurve16(NULL, 256, gmb);
+ Curve[0] = cmsBuildTabulatedToneCurve16(ContextID, 256, gmr);
+ Curve[1] = cmsBuildTabulatedToneCurve16(ContextID, 256, gmg);
+ Curve[2] = cmsBuildTabulatedToneCurve16(ContextID, 256, gmb);
- hProfile = cmsCreateRGBProfileTHR(NULL, &WhitePoint, &Primaries, Curve);
+ hProfile = cmsCreateRGBProfile(ContextID, &WhitePoint, &Primaries, Curve);
for (i=0; i < 3; i++)
- cmsFreeToneCurve(NULL, Curve[i]);
+ cmsFreeToneCurve(ContextID, Curve[i]);
if (Verbose) {
fprintf(stdout, "\n[Colorimetric TIFF]\n");
@@ -771,7 +779,7 @@ cmsHPROFILE GetTIFFProfile(TIFF* in)
// Transform one image
static
-int TransformImage(TIFF* in, TIFF* out, const char *cDefInpProf)
+int TransformImage(cmsContext ContextID, TIFF* in, TIFF* out, const char *cDefInpProf)
{
cmsHPROFILE hIn, hOut, hProof, hInkLimit = NULL;
cmsHTRANSFORM xform;
@@ -783,7 +791,7 @@ int TransformImage(TIFF* in, TIFF* out, const char *cDefInpProf)
// Observer adaptation state (only meaningful on absolute colorimetric intent)
- cmsSetAdaptationState(ObserverAdaptationState);
+ cmsSetAdaptationState(ContextID, ObserverAdaptationState);
if (EmbedProfile && cOutProf)
DoEmbedProfile(out, cOutProf);
@@ -811,20 +819,20 @@ int TransformImage(TIFF* in, TIFF* out, const char *cDefInpProf)
if (lIsDeviceLink) {
- hIn = cmsOpenProfileFromFile(cDefInpProf, "r");
+ hIn = cmsOpenProfileFromFile(ContextID, cDefInpProf, "r");
}
else {
- hIn = GetTIFFProfile(in);
+ hIn = GetTIFFProfile(ContextID, in);
if (hIn == NULL)
- hIn = OpenStockProfile(NULL, cDefInpProf);
+ hIn = OpenStockProfile(ContextID, cDefInpProf);
- hOut = OpenStockProfile(NULL, cOutProf);
+ hOut = OpenStockProfile(ContextID, cOutProf);
if (cProofing != NULL) {
- hProof = OpenStockProfile(NULL, cProofing);
+ hProof = OpenStockProfile(ContextID, cProofing);
dwFlags |= cmsFLAGS_SOFTPROOFING;
}
}
@@ -835,14 +843,14 @@ int TransformImage(TIFF* in, TIFF* out, const char *cDefInpProf)
// Assure both, input profile and input TIFF are on same colorspace
- if (_cmsLCMScolorSpace(NULL, cmsGetColorSpace(NULL, hIn)) != (int) T_COLORSPACE(wInput))
+ if (_cmsLCMScolorSpace(ContextID, cmsGetColorSpace(ContextID, hIn)) != (int) T_COLORSPACE(wInput))
FatalError("Input profile is not operating in proper color space");
if (!lIsDeviceLink)
- OutputColorSpace = _cmsLCMScolorSpace(NULL, cmsGetColorSpace(NULL, hOut));
+ OutputColorSpace = _cmsLCMScolorSpace(ContextID, cmsGetColorSpace(ContextID, hOut));
else
- OutputColorSpace = _cmsLCMScolorSpace(NULL, cmsGetPCS(NULL, hIn));
+ OutputColorSpace = _cmsLCMScolorSpace(ContextID, cmsGetPCS(ContextID, hIn));
wOutput = ComputeOutputFormatDescriptor(wInput, OutputColorSpace, bps);
@@ -857,7 +865,7 @@ int TransformImage(TIFF* in, TIFF* out, const char *cDefInpProf)
int nProfiles = 0;
- hInkLimit = cmsCreateInkLimitingDeviceLink(cmsGetColorSpace(NULL, hOut), InkLimit);
+ hInkLimit = cmsCreateInkLimitingDeviceLink(ContextID, cmsGetColorSpace(ContextID, hOut), InkLimit);
hProfiles[nProfiles++] = hIn;
if (hProof) {
@@ -868,26 +876,26 @@ int TransformImage(TIFF* in, TIFF* out, const char *cDefInpProf)
hProfiles[nProfiles++] = hOut;
hProfiles[nProfiles++] = hInkLimit;
- xform = cmsCreateMultiprofileTransform(hProfiles, nProfiles,
+ xform = cmsCreateMultiprofileTransform(ContextID, hProfiles, nProfiles,
wInput, wOutput, Intent, dwFlags);
}
else {
- xform = cmsCreateProofingTransform(hIn, wInput,
+ xform = cmsCreateProofingTransform(ContextID, hIn, wInput,
hOut, wOutput,
hProof, Intent,
ProofingIntent,
dwFlags);
}
- cmsCloseProfile(NULL, hIn);
- cmsCloseProfile(NULL, hOut);
+ cmsCloseProfile(ContextID, hIn);
+ cmsCloseProfile(ContextID, hOut);
if (hInkLimit)
- cmsCloseProfile(NULL, hInkLimit);
+ cmsCloseProfile(ContextID, hInkLimit);
if (hProof)
- cmsCloseProfile(NULL, hProof);
+ cmsCloseProfile(ContextID, hProof);
if (xform == NULL) return 0;
@@ -901,14 +909,14 @@ int TransformImage(TIFF* in, TIFF* out, const char *cDefInpProf)
// Handle tile by tile or strip by strip
if (TIFFIsTiled(in)) {
- TileBasedXform(xform, in, out, nPlanes);
+ TileBasedXform(ContextID, xform, in, out, nPlanes);
}
else {
- StripBasedXform(xform, in, out, nPlanes);
+ StripBasedXform(ContextID, xform, in, out, nPlanes);
}
- cmsDeleteTransform(NULL, xform);
+ cmsDeleteTransform(ContextID, xform);
TIFFWriteDirectory(out);
@@ -1134,11 +1142,14 @@ void HandleSwitches(int argc, char *argv[])
int main(int argc, char* argv[])
{
+ cmsContext ContextID;
TIFF *in, *out;
- cmsPlugin(&TiffLabPlugin);
+ ContextID = cmsCreateContext(NULL, NULL);
+
+ cmsPlugin(ContextID, &TiffLabPlugin);
- InitUtils(NULL, "tificc");
+ InitUtils(ContextID, "tificc");
HandleSwitches(argc, argv);
@@ -1164,7 +1175,7 @@ int main(int argc, char* argv[])
do {
- TransformImage(in, out, cInpProf);
+ TransformImage(ContextID, in, out, cInpProf);
} while (TIFFReadDirectory(in));
@@ -1175,6 +1186,7 @@ int main(int argc, char* argv[])
TIFFClose(in);
TIFFClose(out);
+ cmsDeleteContext(ContextID);
+
return 0;
}
-