summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/fast_float/src/fast_float_sup.c4
-rw-r--r--plugins/fast_float/testbed/fast_float_testbed.c27
-rw-r--r--src/cmsxform.c13
3 files changed, 42 insertions, 2 deletions
diff --git a/plugins/fast_float/src/fast_float_sup.c b/plugins/fast_float/src/fast_float_sup.c
index a3362b4..2955525 100644
--- a/plugins/fast_float/src/fast_float_sup.c
+++ b/plugins/fast_float/src/fast_float_sup.c
@@ -22,7 +22,6 @@
#include "fast_float_internal.h"
-
// This is the main dispatcher
static
cmsBool Floating_Point_Transforms_Dispatcher(_cmsTransform2Fn* TransformFn,
@@ -39,6 +38,9 @@ cmsBool Floating_Point_Transforms_Dispatcher(_cmsTransform2Fn* TransformFn,
// Special flags for reversing are not supported
if (T_FLAVOR(*InputFormat) || T_FLAVOR(*OutputFormat)) return FALSE;
+ // Check consistency for alpha channel copy
+ if (*dwFlags & cmsFLAGS_COPY_ALPHA && (T_EXTRA(*InputFormat) != T_EXTRA(*OutputFormat))) return FALSE;
+
// Try to optimize as a set of curves plus a matrix plus a set of curves
if (OptimizeMatrixShaper15(TransformFn, UserData, FreeUserData, Lut, InputFormat, OutputFormat, dwFlags)) return TRUE;
diff --git a/plugins/fast_float/testbed/fast_float_testbed.c b/plugins/fast_float/testbed/fast_float_testbed.c
index f00b4cf..5e4fb4d 100644
--- a/plugins/fast_float/testbed/fast_float_testbed.c
+++ b/plugins/fast_float/testbed/fast_float_testbed.c
@@ -1142,10 +1142,33 @@ void CheckLab2Roundtrip(void)
}
+static
+void CheckAlphaDetect(void)
+{
+ cmsHPROFILE hsRGB;
+ cmsHTRANSFORM xform;
+
+ cmsSetLogErrorHandler(NULL);
+
+ hsRGB = cmsCreate_sRGBProfile();
+
+ xform = cmsCreateTransform(hsRGB, TYPE_RGB_FLT, hsRGB, TYPE_RGBA_FLT, INTENT_PERCEPTUAL, cmsFLAGS_COPY_ALPHA);
+ cmsCloseProfile(hsRGB);
+
+ if (xform != NULL)
+ Fail("Copy alpha with mismatched channels should not succeed");
+
+ cmsSetLogErrorHandler(FatalErrorQuit);
+}
+
// Convert some known values
static
void CheckConversionFloat(void)
{
+ trace("Check alpha detection.");
+ CheckAlphaDetect();
+ trace("Ok\n");
+
trace("Crash test.");
TryAllValuesFloatAlpha(cmsOpenProfileFromFile(PROFILES_DIR "test5.icc", "r"), cmsOpenProfileFromFile(PROFILES_DIR "test0.icc", "r"), INTENT_PERCEPTUAL, FALSE);
@@ -1186,6 +1209,8 @@ void CheckConversionFloat(void)
TryAllValuesFloatVs16(cmsOpenProfileFromFile(PROFILES_DIR "test0.icc", "r"), cmsOpenProfileFromFile(PROFILES_DIR "test0.icc", "r"), INTENT_PERCEPTUAL);
TryAllValuesFloat(cmsOpenProfileFromFile(PROFILES_DIR "test0.icc", "r"), cmsOpenProfileFromFile(PROFILES_DIR "test0.icc", "r"), INTENT_PERCEPTUAL);
trace("Ok\n");
+
+
}
@@ -2470,7 +2495,7 @@ int main()
trace("Installing plug-in ... ");
cmsPlugin(cmsFastFloatExtensions());
trace("done.\n\n");
-
+
CheckComputeIncrements();
// 15 bit functionality
diff --git a/src/cmsxform.c b/src/cmsxform.c
index c70b7cb..93e07f8 100644
--- a/src/cmsxform.c
+++ b/src/cmsxform.c
@@ -989,6 +989,19 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
}
}
+ /**
+ * Check consistency for alpha channel copy
+ */
+ if (*dwFlags & cmsFLAGS_COPY_ALPHA)
+ {
+ if (T_EXTRA(*InputFormat) != T_EXTRA(*OutputFormat))
+ {
+ cmsSignalError(ContextID, cmsERROR_NOT_SUITABLE, "Mismatched alpha channels");
+ cmsDeleteTransform(p);
+ return NULL;
+ }
+ }
+
p ->InputFormat = *InputFormat;
p ->OutputFormat = *OutputFormat;
p ->dwOriginalFlags = *dwFlags;