From a75e6ec3ed2f64a01280821a208f342ae4e70638 Mon Sep 17 00:00:00 2001 From: Marti Maria Date: Sun, 19 Sep 2021 18:36:12 +0200 Subject: Exclude softproofing and gamut check from fast float plug-in Fast float plug-in doesn't handle soft proofing and gamut checking transforms. Add a check in the optimization dispatcher. Add a case in the test bed. Fixes #279 --- plugins/fast_float/include/lcms2_fast_float.h | 1 - plugins/fast_float/src/fast_float_sup.c | 2 + plugins/fast_float/testbed/fast_float_testbed.c | 74 ++++++++++++++++++++++++- 3 files changed, 74 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/fast_float/include/lcms2_fast_float.h b/plugins/fast_float/include/lcms2_fast_float.h index 7d47ceb..5f061cc 100644 --- a/plugins/fast_float/include/lcms2_fast_float.h +++ b/plugins/fast_float/include/lcms2_fast_float.h @@ -116,7 +116,6 @@ CMSAPI void* CMSEXPORT cmsFastFloatExtensions(void); #define TYPE_AGRAY_8 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|DOSWAP_SH(1)|BYTES_SH(1)) #define TYPE_AGRAY_16 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|DOSWAP_SH(1)|BYTES_SH(2)) #define TYPE_AGRAY_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|DOSWAP_SH(1)|BYTES_SH(4)) -#define TYPE_GRAYA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(4)) #define TYPE_AGRAY_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|DOSWAP_SH(1)|BYTES_SH(0)) #define TYPE_ACMYK_8 (COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(1)|SWAPFIRST_SH(1)) diff --git a/plugins/fast_float/src/fast_float_sup.c b/plugins/fast_float/src/fast_float_sup.c index 1384928..9e059c7 100644 --- a/plugins/fast_float/src/fast_float_sup.c +++ b/plugins/fast_float/src/fast_float_sup.c @@ -33,6 +33,8 @@ cmsBool Floating_Point_Transforms_Dispatcher(_cmsTransform2Fn* TransformFn, cmsUInt32Number* OutputFormat, cmsUInt32Number* dwFlags) { + // Softproofing & gamut check does not use plugin, both are activated via following flag. + if (*dwFlags & cmsFLAGS_SOFTPROOFING) 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 79b2276..792c7d3 100644 --- a/plugins/fast_float/testbed/fast_float_testbed.c +++ b/plugins/fast_float/testbed/fast_float_testbed.c @@ -1210,6 +1210,73 @@ void CheckLab2RGB(void) +static +void CheckSoftProofing(void) +{ + cmsHPROFILE hRGB1 = cmsOpenProfileFromFile("test5.icc", "r"); + cmsHPROFILE hRGB2 = cmsOpenProfileFromFile("test3.icc", "r"); + cmsContext noPlugin = cmsCreateContext(0, 0); + + cmsHTRANSFORM hXformNoPlugin = cmsCreateProofingTransformTHR(noPlugin, hRGB1, TYPE_RGB_FLT, hRGB1, TYPE_RGB_FLT, hRGB2, INTENT_RELATIVE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_GAMUTCHECK | cmsFLAGS_SOFTPROOFING); + cmsHTRANSFORM hXformPlugin = cmsCreateProofingTransformTHR(0, hRGB1, TYPE_RGB_FLT, hRGB1, TYPE_RGB_FLT, hRGB2, INTENT_RELATIVE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_GAMUTCHECK | cmsFLAGS_SOFTPROOFING); + + cmsUInt32Number Mb, j, r, g, b; + + Scanline_rgbFloat* In; + Scanline_rgbFloat* Out1, *Out2; + + + trace("Checking soft proofing and gamut check ..."); + + cmsCloseProfile(hRGB1); + cmsCloseProfile(hRGB2); + + Mb = 256 * 256 * 256 * sizeof(Scanline_rgbFloat); + In = (Scanline_rgb8bits*)malloc(Mb); + Out1 = (Scanline_rgb8bits*)malloc(Mb); + Out2 = (Scanline_rgb8bits*)malloc(Mb); + + + j = 0; + for (r = 0; r < 256; r++) + for (g = 0; g < 256; g++) + for (b = 0; b < 256; b++) + { + + In[j].r = (cmsFloat32Number)r / 255.0f; + In[j].g = (cmsFloat32Number)g / 255.0f; + In[j].b = (cmsFloat32Number)b / 255.0f; + j++; + } + + + cmsDoTransform(hXformNoPlugin, In, Out1, 256 * 256 * 256); + cmsDoTransform(hXformPlugin, In, Out2, 256 * 256 * 256); + + j = 0; + for (r = 0; r < 256; r++) + for (g = 0; g < 256; g++) + for (b = 0; b < 256; b++) { + + // Check for same values + if (!ValidFloat(Out1[j].r, Out2[j].r) || + !ValidFloat(Out1[j].g, Out2[j].g) || + !ValidFloat(Out1[j].b, Out2[j].b)) + Fail("Conversion failed at (%f %f %f) != (%f %f %f)", Out1[j].r, Out1[j].g, Out1[j].b, + Out2[j].r, Out2[j].g, Out2[j].b); + + j++; + } + + cmsDeleteTransform(hXformNoPlugin); + cmsDeleteTransform(hXformPlugin); + + cmsDeleteContext(noPlugin); + + trace("Ok\n"); +} + + // -------------------------------------------------------------------------------------------------- // P E R F O R M A N C E C H E C K S @@ -2325,7 +2392,7 @@ void TestGrayTransformPerformance1() // The harness test int main() { - trace("FastFloating point extensions testbed - 1.4\n"); + trace("FastFloating point extensions testbed - 1.5\n"); trace("Copyright (c) 1998-2021 Marti Maria Saguer, all rights reserved\n"); trace("\nInstalling error logger ... "); @@ -2335,7 +2402,7 @@ int main() trace("Installing plug-in ... "); cmsPlugin(cmsFastFloatExtensions()); trace("done.\n\n"); - + CheckComputeIncrements(); // 15 bit functionality @@ -2351,6 +2418,9 @@ int main() // Change format CheckChangeFormat(); + // Soft proofing + CheckSoftProofing(); + // Floating point functionality CheckConversionFloat(); trace("All floating point tests passed OK\n"); -- cgit v1.2.3