summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lcms2mt/src/cmsopt.c')
-rw-r--r--lcms2mt/src/cmsopt.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/lcms2mt/src/cmsopt.c b/lcms2mt/src/cmsopt.c
index 8fca60f8..562911ec 100644
--- a/lcms2mt/src/cmsopt.c
+++ b/lcms2mt/src/cmsopt.c
@@ -648,7 +648,6 @@ cmsBool OptimizeByResampling(cmsContext ContextID, cmsPipeline** Lut, cmsUInt32N
{
cmsPipeline* Src = NULL;
cmsPipeline* Dest = NULL;
- cmsStage* mpe;
cmsStage* CLUT;
cmsStage *KeepPreLin = NULL, *KeepPostLin = NULL;
cmsUInt32Number nGridPoints;
@@ -670,7 +669,7 @@ cmsBool OptimizeByResampling(cmsContext ContextID, cmsPipeline** Lut, cmsUInt32N
if (ColorSpace == (cmsColorSpaceSignature)0 ||
OutputColorSpace == (cmsColorSpaceSignature)0) return FALSE;
- nGridPoints = _cmsReasonableGridpointsByColorspace(ContextID, ColorSpace, *dwFlags);
+ nGridPoints = _cmsReasonableGridpointsByColorspace(ContextID, ColorSpace, *dwFlags);
// For empty LUTs, 2 points are enough
if (cmsPipelineStageCount(ContextID, *Lut) == 0)
@@ -678,13 +677,6 @@ cmsBool OptimizeByResampling(cmsContext ContextID, cmsPipeline** Lut, cmsUInt32N
Src = *Lut;
- // Named color pipelines cannot be optimized either
- for (mpe = cmsPipelineGetPtrToFirstStage(ContextID, Src);
- mpe != NULL;
- mpe = cmsStageNext(ContextID, mpe)) {
- if (cmsStageType(ContextID, mpe) == cmsSigNamedColorElemType) return FALSE;
- }
-
// Allocate an empty LUT
Dest = cmsPipelineAlloc(ContextID, Src ->InputChannels, Src ->OutputChannels);
if (!Dest) return FALSE;
@@ -1053,7 +1045,6 @@ cmsBool OptimizeByComputingLinearization(cmsContext ContextID, cmsPipeline** Lut
cmsStage* OptimizedCLUTmpe;
cmsColorSpaceSignature ColorSpace, OutputColorSpace;
cmsStage* OptimizedPrelinMpe;
- cmsStage* mpe;
cmsToneCurve** OptimizedPrelinCurves;
_cmsStageCLutData* OptimizedPrelinCLUT;
@@ -1074,14 +1065,6 @@ cmsBool OptimizeByComputingLinearization(cmsContext ContextID, cmsPipeline** Lut
}
OriginalLut = *Lut;
-
- // Named color pipelines cannot be optimized either
- for (mpe = cmsPipelineGetPtrToFirstStage(ContextID, OriginalLut);
- mpe != NULL;
- mpe = cmsStageNext(ContextID, mpe)) {
- if (cmsStageType(ContextID, mpe) == cmsSigNamedColorElemType) return FALSE;
- }
-
ColorSpace = _cmsICCcolorSpace(ContextID, (int) T_COLORSPACE(*InputFormat));
OutputColorSpace = _cmsICCcolorSpace(ContextID, (int) T_COLORSPACE(*OutputFormat));
@@ -1699,6 +1682,10 @@ cmsBool OptimizeMatrixShaper(cmsContext ContextID, cmsPipeline** Lut, cmsUInt32N
// Only works on 8 bit input
if (!_cmsFormatterIs8bit(*InputFormat)) return FALSE;
+ // Does not work in the presence of premultiplied alpha, as that causes the values
+ // passed in to not actually be '8 bit' in the way that we rely on.
+ if (*dwFlags & cmsFLAGS_PREMULT) return FALSE;
+
// Seems suitable, proceed
Src = *Lut;
@@ -1926,6 +1913,7 @@ cmsBool CMSEXPORT _cmsOptimizePipeline(cmsContext ContextID,
_cmsOptimizationPluginChunkType* ctx = ( _cmsOptimizationPluginChunkType*) _cmsContextGetClientChunk(ContextID, OptimizationPlugin);
_cmsOptimizationCollection* Opts;
cmsBool AnySuccess = FALSE;
+ cmsStage* mpe;
// A CLUT is being asked, so force this specific optimization
if (*dwFlags & cmsFLAGS_FORCE_CLUT) {
@@ -1940,6 +1928,13 @@ cmsBool CMSEXPORT _cmsOptimizePipeline(cmsContext ContextID,
return TRUE;
}
+ // Named color pipelines cannot be optimized
+ for (mpe = cmsPipelineGetPtrToFirstStage(ContextID, *PtrLut);
+ mpe != NULL;
+ mpe = cmsStageNext(ContextID, mpe)) {
+ if (cmsStageType(ContextID, mpe) == cmsSigNamedColorElemType) return FALSE;
+ }
+
// Try to get rid of identities and trivial conversions.
AnySuccess = PreOptimize(ContextID, *PtrLut);