summaryrefslogtreecommitdiff
path: root/src/cmsio1.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmsio1.c')
-rw-r--r--src/cmsio1.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/cmsio1.c b/src/cmsio1.c
index 91cf06d..c367627 100644
--- a/src/cmsio1.c
+++ b/src/cmsio1.c
@@ -386,6 +386,27 @@ cmsPipeline* BuildRGBOutputMatrixShaper(cmsHPROFILE hProfile)
return Lut;
}
+
+// Change CLUT interpolation to trilinear
+static
+void ChangeInterpolationToTrilinear(cmsPipeline* Lut)
+{
+ cmsStage* Stage;
+
+ for (Stage = cmsPipelineGetPtrToFirstStage(Lut);
+ Stage != NULL;
+ Stage = cmsStageNext(Stage)) {
+
+ if (cmsStageType(Stage) == cmsSigCLutElemType) {
+
+ _cmsStageCLutData* CLUT = (_cmsStageCLutData*) Stage ->Data;
+
+ CLUT ->Params->dwFlags |= CMS_LERP_FLAGS_TRILINEAR;
+ _cmsSetInterpolationRoutine(CLUT ->Params);
+ }
+ }
+}
+
// Create an output MPE LUT from agiven profile. Version mismatches are handled here
cmsPipeline* _cmsReadOutputLUT(cmsHPROFILE hProfile, int Intent)
{
@@ -419,6 +440,12 @@ cmsPipeline* _cmsReadOutputLUT(cmsHPROFILE hProfile, int Intent)
// The profile owns the Lut, so we need to copy it
Lut = cmsPipelineDup(Lut);
+ // Now it is time for a controversial stuff. I found that for 3D LUTS using
+ // Lab used as indexer space, trilinear interpolation should be used
+
+ if (cmsGetPCS(hProfile) == cmsSigLabData)
+ ChangeInterpolationToTrilinear(Lut);
+
// We need to adjust data only for Lab and Lut16 type
if (OriginalType != cmsSigLut16Type || cmsGetPCS(hProfile) != cmsSigLabData)
return Lut;