From c60ea48180760c4c4b1631cb8a272b488b96e43e Mon Sep 17 00:00:00 2001 From: Marti Maria Date: Mon, 25 May 2020 14:16:04 +0200 Subject: Changes from Artifex Many thanks for sharing! --- .../VC2019/lcms2_fast_float_plugin_testbed.vcxproj | 8 ++-- plugins/fast_float/testbed/fast_float_testbed.c | 46 ++++++++++++++++++++-- src/cmsalpha.c | 6 +++ src/cmsgamma.c | 3 +- src/cmslut.c | 28 ++++++------- src/lcms2_internal.h | 2 +- 6 files changed, 67 insertions(+), 26 deletions(-) diff --git a/plugins/fast_float/Projects/VC2019/lcms2_fast_float_plugin_testbed.vcxproj b/plugins/fast_float/Projects/VC2019/lcms2_fast_float_plugin_testbed.vcxproj index b9f4b42..8244865 100644 --- a/plugins/fast_float/Projects/VC2019/lcms2_fast_float_plugin_testbed.vcxproj +++ b/plugins/fast_float/Projects/VC2019/lcms2_fast_float_plugin_testbed.vcxproj @@ -70,22 +70,22 @@ true $(Platform)\testbed_$(Configuration)\ - $(ProjectDir)..\..\testbed + $(ProjectDir)..\..\testbed\ true $(Platform)\testbed_$(Configuration)\ - $(ProjectDir)..\..\testbed + $(ProjectDir)..\..\testbed\ false $(Platform)\testbed_$(Configuration)\ - $(ProjectDir)..\..\testbed + $(ProjectDir)..\..\testbed\ false $(Platform)\testbed_$(Configuration)\ - $(ProjectDir)..\..\testbed + $(ProjectDir)..\..\testbed\ diff --git a/plugins/fast_float/testbed/fast_float_testbed.c b/plugins/fast_float/testbed/fast_float_testbed.c index 96e67b9..1852bf2 100644 --- a/plugins/fast_float/testbed/fast_float_testbed.c +++ b/plugins/fast_float/testbed/fast_float_testbed.c @@ -1297,6 +1297,42 @@ cmsFloat64Number SpeedTest16bitsRGB(cmsContext ct, cmsHPROFILE hlcmsProfileIn, c } + +static +void SpeedTest8(void) +{ + cmsContext noPlugin = cmsCreateContext(0, 0); + + cmsFloat64Number t[10]; + + printf("\n\n"); + printf("P E R F O R M A N C E T E S T S 8 B I T S (D E F A U L T)\n"); + printf("==============================================================\n\n"); + fflush(stdout); + + PerformanceHeader(); + t[0] = Performance("8 bits on CLUT profiles ", SpeedTest8bitsRGB, noPlugin, "test5.icc", "test3.icc", sizeof(Scanline_rgb8bits), 0); + t[1] = Performance("8 bits on Matrix-Shaper ", SpeedTest8bitsRGB, noPlugin, "test5.icc", "test0.icc", sizeof(Scanline_rgb8bits), 0); + t[2] = Performance("8 bits on same MatrixSh ", SpeedTest8bitsRGB, noPlugin, "test0.icc", "test0.icc", sizeof(Scanline_rgb8bits), 0); + t[3] = Performance("8 bits on curves ", SpeedTest8bitsRGB, noPlugin, NULL, NULL, sizeof(Scanline_rgb8bits), 0); + + // Note that context 0 has the plug-in installed + + printf("\n\n"); + printf("P E R F O R M A N C E T E S T S 8 B I T S (P L U G I N)\n"); + printf("===========================================================\n\n"); + fflush(stdout); + + PerformanceHeader(); + Performance("8 bits on CLUT profiles ", SpeedTest8bitsRGB, 0, "test5.icc", "test3.icc", sizeof(Scanline_rgb8bits), t[0]); + Performance("8 bits on Matrix-Shaper ", SpeedTest8bitsRGB, 0, "test5.icc", "test0.icc", sizeof(Scanline_rgb8bits), t[1]); + Performance("8 bits on same MatrixSh ", SpeedTest8bitsRGB, 0, "test0.icc", "test0.icc", sizeof(Scanline_rgb8bits), t[2]); + Performance("8 bits on curves ", SpeedTest8bitsRGB, 0, NULL, NULL, sizeof(Scanline_rgb8bits), t[3]); + + cmsDeleteContext(noPlugin); +} + +#if 0 static void SpeedTest8(void) { @@ -1308,8 +1344,9 @@ void SpeedTest8(void) Performance("8 bits on Matrix-Shaper profiles", SpeedTest8bitsRGB, 0, "test5.icc", "test0.icc", sizeof(Scanline_rgb8bits), 0); Performance("8 bits on same Matrix-Shaper ", SpeedTest8bitsRGB, 0, "test0.icc", "test0.icc", sizeof(Scanline_rgb8bits), 0); Performance("8 bits on curves ", SpeedTest8bitsRGB, 0, NULL, NULL, sizeof(Scanline_rgb8bits), 0); - // Performance("8 bits on CMYK CLUT profiles ", SpeedTest8bitsCMYK, 0, "test1.icc", "test2.icc", sizeof(Scanline_rgba15bits), 0); + } +#endif static @@ -1419,6 +1456,10 @@ void SpeedTestFloat(void) } + + + + static cmsFloat64Number SpeedTestFloatByUsing16BitsRGB(cmsContext ct, cmsHPROFILE hlcmsProfileIn, cmsHPROFILE hlcmsProfileOut) { @@ -1768,8 +1809,7 @@ int main() printf("Installing plug-in ... "); cmsPlugin(cmsFastFloatExtensions()); printf("done.\n\n"); - - CheckLab2Roundtrip(); + CheckComputeIncrements(); diff --git a/src/cmsalpha.c b/src/cmsalpha.c index e6c80c9..f747bc6 100644 --- a/src/cmsalpha.c +++ b/src/cmsalpha.c @@ -138,21 +138,25 @@ void from16to16(void* dst, const void* src) *(cmsUInt16Number*)dst = CHANGE_ENDIAN(n); } +static void from16toFLT(void* dst, const void* src) { *(cmsFloat32Number*)dst = (*(cmsUInt16Number*)src) / 65535.0f; } +static void from16SEtoFLT(void* dst, const void* src) { *(cmsFloat32Number*)dst = (CHANGE_ENDIAN(*(cmsUInt16Number*)src)) / 65535.0f; } +static void from16toDBL(void* dst, const void* src) { *(cmsFloat64Number*)dst = (*(cmsUInt16Number*)src) / 65535.0f; } +static void from16SEtoDBL(void* dst, const void* src) { *(cmsFloat64Number*)dst = (CHANGE_ENDIAN(*(cmsUInt16Number*)src)) / 65535.0f; @@ -271,6 +275,7 @@ void fromHLFto16SE(void* dst, const void* src) cmsUNUSED_PARAMETER(src); #endif } + static void fromHLFtoFLT(void* dst, const void* src) { @@ -315,6 +320,7 @@ void fromDBLto16SE(void* dst, const void* src) cmsUInt16Number i = _cmsQuickSaturateWord(n * 65535.0f); *(cmsUInt16Number*)dst = CHANGE_ENDIAN(i); } + static void fromDBLtoFLT(void* dst, const void* src) { diff --git a/src/cmsgamma.c b/src/cmsgamma.c index 1358252..b538b07 100644 --- a/src/cmsgamma.c +++ b/src/cmsgamma.c @@ -300,7 +300,8 @@ cmsToneCurve* AllocateToneCurveStruct(cmsContext ContextID, cmsUInt32Number nEnt return p; Error: - if (p -> Segments) _cmsFree(ContextID, p ->Segments); + if (p -> SegInterp) _cmsFree(ContextID, p -> SegInterp); + if (p -> Segments) _cmsFree(ContextID, p -> Segments); if (p -> Evals) _cmsFree(ContextID, p -> Evals); if (p ->Table16) _cmsFree(ContextID, p ->Table16); _cmsFree(ContextID, p); diff --git a/src/cmslut.c b/src/cmslut.c index ee6372a..e77f035 100644 --- a/src/cmslut.c +++ b/src/cmslut.c @@ -397,37 +397,31 @@ cmsStage* CMSEXPORT cmsStageAllocMatrix(cmsContext ContextID, cmsUInt32Number R NewElem = (_cmsStageMatrixData*) _cmsMallocZero(ContextID, sizeof(_cmsStageMatrixData)); - if (NewElem == NULL) return NULL; - + if (NewElem == NULL) goto Error; + NewMPE->Data = (void*)NewElem; NewElem ->Double = (cmsFloat64Number*) _cmsCalloc(ContextID, n, sizeof(cmsFloat64Number)); - - if (NewElem->Double == NULL) { - MatrixElemTypeFree(NewMPE); - return NULL; - } - + if (NewElem->Double == NULL) goto Error; + for (i=0; i < n; i++) { NewElem ->Double[i] = Matrix[i]; } - if (Offset != NULL) { NewElem ->Offset = (cmsFloat64Number*) _cmsCalloc(ContextID, Rows, sizeof(cmsFloat64Number)); - if (NewElem->Offset == NULL) { - MatrixElemTypeFree(NewMPE); - return NULL; - } - + if (NewElem->Offset == NULL) goto Error; + for (i=0; i < Rows; i++) { NewElem ->Offset[i] = Offset[i]; } - } - - NewMPE ->Data = (void*) NewElem; + return NewMPE; + +Error: + cmsStageFree(NewMPE); + return NULL; } diff --git a/src/lcms2_internal.h b/src/lcms2_internal.h index 816eaf8..683ec4c 100644 --- a/src/lcms2_internal.h +++ b/src/lcms2_internal.h @@ -106,7 +106,7 @@ /// Properly define some macros to accommodate /// older MSVC versions. -# if _MSC_VER <= 1700 +# if defined(_MSC_VER) && _MSC_VER <= 1700 #include #define isnan _isnan #define isinf(x) (!_finite((x))) -- cgit v1.2.1