From bbcdf92c1789d1cd6a90f4d64b723ed7a4c62184 Mon Sep 17 00:00:00 2001 From: Marti Maria Date: Sun, 13 Aug 2023 18:27:54 +0200 Subject: [PATCH] Added Qt experimental project Added Qt experimental project Fixed minor complains of lint --- Projects/Qt/lcms2/lcms2.pro | 53 +++++++++++++++++++++++++++++++++++++ src/cmsalpha.c | 28 +++++++++++--------- src/cmsgmt.c | 2 +- src/cmsnamed.c | 3 +++ src/cmsopt.c | 7 +++-- src/cmstypes.c | 6 +++-- 6 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 Projects/Qt/lcms2/lcms2.pro diff --git a/Projects/Qt/lcms2/lcms2.pro b/Projects/Qt/lcms2/lcms2.pro new file mode 100644 index 000000000..1b6e839e2 --- /dev/null +++ b/Projects/Qt/lcms2/lcms2.pro @@ -0,0 +1,53 @@ +QT -= gui + +TEMPLATE = lib +CONFIG += staticlib + +CONFIG += c++17 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +INCLUDEPATH += ../../../include ../../../src + +HEADERS += \ + ../../../include/lcms2.h \ + ../../../include/lcms2_plugin.h \ + ../../../src/lcms2_internal.h + +SOURCES += \ + ../../../src/cmsalpha.c \ + ../../../src/cmscam02.c \ + ../../../src/cmscgats.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/cmsmd5.c \ + ../../../src/cmsmtrx.c \ + ../../../src/cmsnamed.c \ + ../../../src/cmsopt.c \ + ../../../src/cmspack.c \ + ../../../src/cmspcs.c \ + ../../../src/cmsplugin.c \ + ../../../src/cmsps2.c \ + ../../../src/cmssamp.c \ + ../../../src/cmssm.c \ + ../../../src/cmstypes.c \ + ../../../src/cmsvirt.c \ + ../../../src/cmswtpnt.c \ + ../../../src/cmsxform.c + + + +# Default rules for deployment. +unix { + target.path = $$[QT_INSTALL_PLUGINS]/generic +} +!isEmpty(target.path): INSTALLS += target diff --git a/src/cmsalpha.c b/src/cmsalpha.c index 806577f99..ef9dad5cf 100644 --- a/src/cmsalpha.c +++ b/src/cmsalpha.c @@ -402,7 +402,7 @@ static cmsFormatterAlphaFn FormattersAlpha[6][6] = { // This function computes the distance from each component to the next one in bytes. static -void ComputeIncrementsForChunky(cmsUInt32Number Format, +cmsBool ComputeIncrementsForChunky(cmsUInt32Number Format, cmsUInt32Number ComponentStartingOrder[], cmsUInt32Number ComponentPointerIncrements[]) { @@ -416,7 +416,7 @@ void ComputeIncrementsForChunky(cmsUInt32Number Format, // Sanity check if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS) - return; + return FALSE; memset(channels, 0, sizeof(channels)); @@ -453,13 +453,15 @@ void ComputeIncrementsForChunky(cmsUInt32Number Format, for (i = 0; i < extra; i++) ComponentStartingOrder[i] = channels[i + nchannels]; + + return TRUE; } // On planar configurations, the distance is the stride added to any non-negative static -void ComputeIncrementsForPlanar(cmsUInt32Number Format, +cmsBool ComputeIncrementsForPlanar(cmsUInt32Number Format, cmsUInt32Number BytesPerPlane, cmsUInt32Number ComponentStartingOrder[], cmsUInt32Number ComponentPointerIncrements[]) @@ -473,7 +475,7 @@ void ComputeIncrementsForPlanar(cmsUInt32Number Format, // Sanity check if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS) - return; + return FALSE; memset(channels, 0, sizeof(channels)); @@ -509,29 +511,29 @@ void ComputeIncrementsForPlanar(cmsUInt32Number Format, for (i = 0; i < extra; i++) ComponentStartingOrder[i] = channels[i + nchannels]; + + return TRUE; } // Dispatcher por chunky and planar RGB static -void ComputeComponentIncrements(cmsUInt32Number Format, +cmsBool ComputeComponentIncrements(cmsUInt32Number Format, cmsUInt32Number BytesPerPlane, cmsUInt32Number ComponentStartingOrder[], cmsUInt32Number ComponentPointerIncrements[]) { if (T_PLANAR(Format)) { - ComputeIncrementsForPlanar(Format, BytesPerPlane, ComponentStartingOrder, ComponentPointerIncrements); + return ComputeIncrementsForPlanar(Format, BytesPerPlane, ComponentStartingOrder, ComponentPointerIncrements); } else { - ComputeIncrementsForChunky(Format, ComponentStartingOrder, ComponentPointerIncrements); + return ComputeIncrementsForChunky(Format, ComponentStartingOrder, ComponentPointerIncrements); } } - - // Handles extra channels copying alpha if requested by the flags void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in, void* out, @@ -565,9 +567,11 @@ void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in, if (nExtra == 0) return; - // Compute the increments - ComputeComponentIncrements(p->InputFormat, Stride->BytesPerPlaneIn, SourceStartingOrder, SourceIncrements); - ComputeComponentIncrements(p->OutputFormat, Stride->BytesPerPlaneOut, DestStartingOrder, DestIncrements); + // Compute the increments + if (!ComputeComponentIncrements(p->InputFormat, Stride->BytesPerPlaneIn, SourceStartingOrder, SourceIncrements)) + return; + if (!ComputeComponentIncrements(p->OutputFormat, Stride->BytesPerPlaneOut, DestStartingOrder, DestIncrements)) + return; // Check for conversions 8, 16, half, float, dbl copyValueFn = _cmsGetFormatterAlpha(p->ContextID, p->InputFormat, p->OutputFormat); diff --git a/src/cmsgmt.c b/src/cmsgmt.c index d4b2d7dd0..3ad6269c2 100644 --- a/src/cmsgmt.c +++ b/src/cmsgmt.c @@ -219,7 +219,7 @@ int GamutSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Nu cmsUInt16Number Proof[cmsMAXCHANNELS], Proof2[cmsMAXCHANNELS]; cmsFloat64Number dE1, dE2, ErrorRatio; - // Assume in-gamut by default. + // Assume in-gamut by default. NEVER READ, USED FOR DEBUG PURPOSES. ErrorRatio = 1.0; // Convert input to Lab diff --git a/src/cmsnamed.c b/src/cmsnamed.c index 54d1abf91..1d9ee5c5b 100644 --- a/src/cmsnamed.c +++ b/src/cmsnamed.c @@ -814,6 +814,9 @@ void CMSEXPORT cmsFreeProfileSequenceDescription(cmsSEQ* pseq) { cmsUInt32Number i; + if (pseq == NULL) + return; + for (i=0; i < pseq ->n; i++) { if (pseq ->seq[i].Manufacturer != NULL) cmsMLUfree(pseq ->seq[i].Manufacturer); if (pseq ->seq[i].Model != NULL) cmsMLUfree(pseq ->seq[i].Model); diff --git a/src/cmsopt.c b/src/cmsopt.c index b3d831cbd..8d40c522a 100644 --- a/src/cmsopt.c +++ b/src/cmsopt.c @@ -1113,14 +1113,17 @@ cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Inte // Store result in curve for (t=0; t < OriginalLut ->InputChannels; t++) - Trans[t] ->Table16[i] = _cmsQuickSaturateWord(Out[t] * 65535.0); + { + if (Trans[t]->Table16 != NULL) + Trans[t] ->Table16[i] = _cmsQuickSaturateWord(Out[t] * 65535.0); + } } // Slope-limit the obtained curves for (t = 0; t < OriginalLut ->InputChannels; t++) SlopeLimiting(Trans[t]); - // Check for validity + // Check for validity. lIsLinear is here for debug purposes lIsSuitable = TRUE; lIsLinear = TRUE; for (t=0; (lIsSuitable && (t < OriginalLut ->InputChannels)); t++) { diff --git a/src/cmstypes.c b/src/cmstypes.c index 2ec79f308..9c5c5830c 100644 --- a/src/cmstypes.c +++ b/src/cmstypes.c @@ -5221,11 +5221,13 @@ cmsBool WriteOneMLUC(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, _c } Before = io ->Tell(io); - e ->Offsets[i] = Before - BaseOffset; + if (e->Offsets != NULL) + e ->Offsets[i] = Before - BaseOffset; if (!Type_MLU_Write(self, io, (void*) mlu, 1)) return FALSE; - e ->Sizes[i] = io ->Tell(io) - Before; + if (e->Sizes != NULL) + e ->Sizes[i] = io ->Tell(io) - Before; return TRUE; }