diff options
author | Marti Maria <info@littlecms.com> | 2013-03-14 10:07:38 +0100 |
---|---|---|
committer | Marti Maria <info@littlecms.com> | 2013-03-14 10:07:38 +0100 |
commit | a4847b0b3a782230f3ace3f55ca10590b40da39a (patch) | |
tree | f78351ac505a144122d4292c1a91bd0b4708c543 | |
parent | ceef4d3cf7c575a01dc0a84e08d6b91204522b99 (diff) | |
download | lcms2-a4847b0b3a782230f3ace3f55ca10590b40da39a.tar.gz |
Several fixes
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Projects/VC2010/lcms2.rc | 41 | ||||
-rw-r--r-- | src/cmsgamma.c | 29 | ||||
-rw-r--r-- | src/cmsplugin.c | 8 | ||||
-rw-r--r-- | testbed/testcms2.c | 108 |
5 files changed, 152 insertions, 37 deletions
@@ -94,4 +94,5 @@ Fixed some 64 bit warnings on size_t to uint32 conversions update black point detection algorithm to reflect ICC changes Added new cmsPlugInTHR() and fixed some race conditions (thanks to Artifex) Added error descriptions on cmsSmoothToneCurve - +Fixed a bug on big endian platforms not supporting uint64 or long long. +Fixed some bugs on floating point curves. diff --git a/Projects/VC2010/lcms2.rc b/Projects/VC2010/lcms2.rc index 1eb4e04..9f8f938 100644 --- a/Projects/VC2010/lcms2.rc +++ b/Projects/VC2010/lcms2.rc @@ -1,4 +1,4 @@ -//Microsoft Developer Studio generated resource script. +// Microsoft Visual C++ generated resource script. // #include "resource.h" @@ -15,23 +15,20 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// Spanish (Modern) resources +// Spanish (Spain, International Sort) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESN) -#ifdef _WIN32 LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN #pragma code_page(1252) -#endif //_WIN32 -#ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // 1 VERSIONINFO - FILEVERSION 2,3,0,0 - PRODUCTVERSION 2,3,0,0 + FILEVERSION 2,5,0,0 + PRODUCTVERSION 2,5,0,0 FILEFLAGSMASK 0x0L #ifdef _DEBUG FILEFLAGS 0x1L @@ -46,18 +43,14 @@ BEGIN BEGIN BLOCK "040904e4" BEGIN - VALUE "Comments", "\0" - VALUE "CompanyName", "Marti Maria\0" - VALUE "FileDescription", "lcms color engine\0" - VALUE "FileVersion", "2.3\0" - VALUE "InternalName", "lcms\0" - VALUE "LegalCopyright", "Copyright © Marti Maria 2011\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "lcms2.dll\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", "LittleCMS color engine\0" - VALUE "ProductVersion", "2, 0, 3, 0\0" - VALUE "SpecialBuild", "\0" + VALUE "CompanyName", "Marti Maria" + VALUE "FileDescription", "lcms color engine" + VALUE "FileVersion", "2.5.0.0" + VALUE "InternalName", "lcms" + VALUE "LegalCopyright", "Copyright © Marti Maria 2013" + VALUE "OriginalFilename", "lcms2.dll" + VALUE "ProductName", "LittleCMS color engine" + VALUE "ProductVersion", "2.5.0.0" END END BLOCK "VarFileInfo" @@ -66,8 +59,6 @@ BEGIN END END -#endif // !_MAC - #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -75,12 +66,12 @@ END // TEXTINCLUDE // -1 TEXTINCLUDE DISCARDABLE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE DISCARDABLE +2 TEXTINCLUDE BEGIN "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" "#include ""windows.h""\r\n" @@ -88,7 +79,7 @@ BEGIN "\0" END -3 TEXTINCLUDE DISCARDABLE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -96,7 +87,7 @@ END #endif // APSTUDIO_INVOKED -#endif // Spanish (Modern) resources +#endif // Spanish (Spain, International Sort) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/cmsgamma.c b/src/cmsgamma.c index 9fdf79e..7471d25 100644 --- a/src/cmsgamma.c +++ b/src/cmsgamma.c @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------------- // // Little Color Management System -// Copyright (c) 1998-2012 Marti Maria Saguer +// Copyright (c) 1998-2013 Marti Maria Saguer // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), @@ -515,7 +515,7 @@ cmsFloat64Number EvalSegmentedFn(const cmsToneCurve *g, cmsFloat64Number R) // Type == 0 means segment is sampled if (g ->Segments[i].Type == 0) { - cmsFloat32Number R1 = (cmsFloat32Number) (R - g ->Segments[i].x0); + cmsFloat32Number R1 = (cmsFloat32Number) (R - g ->Segments[i].x0) / (g ->Segments[i].x1 - g ->Segments[i].x0); cmsFloat32Number Out; // Setup the table (TODO: clean that) @@ -600,20 +600,21 @@ cmsToneCurve* CMSEXPORT cmsBuildSegmentedToneCurve(cmsContext ContextID, // Use a segmented curve to store the floating point table cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cmsUInt32Number nEntries, const cmsFloat32Number values[]) { - cmsCurveSegment Seg[2]; + cmsCurveSegment Seg[3]; - // Initialize segmented curve part up to 0 - Seg[0].x0 = -1; + // A segmented tone curve should have function segments in the first and last positions + // Initialize segmented curve part up to 0 to constant value = samples[0] + Seg[0].x0 = MINUS_INF; Seg[0].x1 = 0; Seg[0].Type = 6; Seg[0].Params[0] = 1; Seg[0].Params[1] = 0; Seg[0].Params[2] = 0; - Seg[0].Params[3] = 0; + Seg[0].Params[3] = values[0]; Seg[0].Params[4] = 0; - // From zero to any + // From zero to 1 Seg[1].x0 = 0; Seg[1].x1 = 1.0; Seg[1].Type = 0; @@ -621,7 +622,19 @@ cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cm Seg[1].nGridPoints = nEntries; Seg[1].SampledPoints = (cmsFloat32Number*) values; - return cmsBuildSegmentedToneCurve(ContextID, 2, Seg); + // Final segment is constant = lastsample + Seg[2].x0 = 1.0; + Seg[2].x1 = PLUS_INF; + Seg[2].Type = 6; + + Seg[2].Params[0] = 1; + Seg[2].Params[1] = 0; + Seg[2].Params[2] = 0; + Seg[2].Params[3] = values[nEntries-1]; + Seg[2].Params[4] = 0; + + + return cmsBuildSegmentedToneCurve(ContextID, 3, Seg); } // Parametric curves diff --git a/src/cmsplugin.c b/src/cmsplugin.c index 53379eb..ff4bae7 100644 --- a/src/cmsplugin.c +++ b/src/cmsplugin.c @@ -96,10 +96,14 @@ void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* pOut[0] = pIn[7]; #else - _cmsAssert(Result != NULL); - *Result = *QWord; +# ifdef CMS_DONT_USE_INT64 + (*Result)[0] = QWord[0]; + (*Result)[1] = QWord[1]; +# else + *Result = QWord; +# endif #endif } diff --git a/testbed/testcms2.c b/testbed/testcms2.c index 7e3f390..e18d0b5 100644 --- a/testbed/testcms2.c +++ b/testbed/testcms2.c @@ -7341,6 +7341,111 @@ cmsInt32Number CheckParametricRec709(void) return 1; } + +#define kNumPoints 10 + +typedef cmsFloat32Number(*Function)(cmsFloat32Number x); + +static cmsFloat32Number StraightLine( cmsFloat32Number x) +{ + return (cmsFloat32Number) (0.1 + 0.9 * x); +} + +static cmsInt32Number TestCurve( const char* label, cmsToneCurve* curve, Function fn) +{ + cmsInt32Number ok = 1; + int i; + for (i = 0; i < kNumPoints*3; i++) { + + cmsFloat32Number x = (cmsFloat32Number)i / (kNumPoints*3 - 1); + cmsFloat32Number expectedY = fn(x); + cmsFloat32Number out = cmsEvalToneCurveFloat( curve, x); + + if (!IsGoodVal(label, expectedY, out, FLOAT_PRECISSION)) { + ok = 0; + } + } + return ok; +} + +static +cmsInt32Number CheckFloatSamples(void) +{ + cmsFloat32Number y[kNumPoints]; + int i; + cmsToneCurve *curve; + cmsInt32Number ok; + + for (i = 0; i < kNumPoints; i++) { + cmsFloat32Number x = (cmsFloat32Number)i / (kNumPoints-1); + + y[i] = StraightLine(x); + } + + curve = cmsBuildTabulatedToneCurveFloat(NULL, kNumPoints, y); + ok = TestCurve( "Float Samples", curve, StraightLine); + cmsFreeToneCurve(curve); + + return ok; +} + +static +cmsInt32Number CheckFloatSegments(void) +{ + cmsInt32Number ok = 1; + int i; + cmsToneCurve *curve; + + cmsFloat32Number y[ kNumPoints]; + + // build a segmented curve with a sampled section... + cmsCurveSegment Seg[3]; + + // Initialize segmented curve part up to 0.1 + Seg[0].x0 = -1e22; // -infinity + Seg[0].x1 = 0.1; + Seg[0].Type = 6; // Y = (a * X + b) ^ Gamma + c + Seg[0].Params[0] = 1.0; // gamma + Seg[0].Params[1] = 0.9; // a + Seg[0].Params[2] = 0; // b + Seg[0].Params[3] = 0.1; // c + Seg[0].Params[4] = 0; + + // From zero to 1 + Seg[1].x0 = 0.1; + Seg[1].x1 = 0.9; + Seg[1].Type = 0; + + Seg[1].nGridPoints = kNumPoints; + Seg[1].SampledPoints = y; + + for (i = 0; i < kNumPoints; i++) { + cmsFloat32Number x = (cmsFloat32Number) (0.1 + ((cmsFloat32Number)i / (kNumPoints-1)) * (0.9 - 0.1)); + y[i] = StraightLine(x); + } + + // from 1 to +infinity + Seg[2].x0 = 0.9; + Seg[2].x1 = 1e22; // +infinity + Seg[2].Type = 6; + + Seg[2].Params[0] = 1.0; + Seg[2].Params[1] = 0.9; + Seg[2].Params[2] = 0; + Seg[2].Params[3] = 0.1; + Seg[2].Params[4] = 0; + + curve = cmsBuildSegmentedToneCurve(0, 3, Seg); + + ok = TestCurve( "Float Segmented Curve", curve, StraightLine); + + cmsFreeToneCurve( curve); + + return ok; +} + + + // -------------------------------------------------------------------------------------------------- // P E R F O R M A N C E C H E C K S // -------------------------------------------------------------------------------------------------- @@ -8211,7 +8316,8 @@ int main(int argc, char* argv[]) Check("floating point tags on XYZ", CheckFloatXYZ); Check("RGB->Lab->RGB with alpha on FLT", ChecksRGB2LabFLT); Check("Parametric curve on Rec709", CheckParametricRec709); - + Check("Floating Point sampled curve with non-zero start", CheckFloatSamples); + Check("Floating Point segmented curve with short sampled segement", CheckFloatSegments); } |