[gs-commits] rev 10843 - branches/icc_work/lcms/src

mvrhel at ghostscript.com mvrhel at ghostscript.com
Wed Mar 3 06:14:59 UTC 2010


Author: mvrhel
Date: 2010-03-03 06:14:58 +0000 (Wed, 03 Mar 2010)
New Revision: 10843

Modified:
   branches/icc_work/lcms/src/cmsintrp.c
Log:
Fix in lcms that should be kicked up to Marti.  He is doing a new release of lcms soon, which does a different approach to this problem so it may not be relevant.  The issue is that he uses a binary search algorithm to invert a nonlinear 1-D LUT.  As he approaches the black point, he may hit a value of zero before getting to zero.  This ends up causing black (0) to be mapped to something close to black (e.g. rgb = [3,3,3]).  I am fixing this here, since it is the source of a lot of regressions from the trunk.

Modified: branches/icc_work/lcms/src/cmsintrp.c
===================================================================
--- branches/icc_work/lcms/src/cmsintrp.c	2010-03-02 22:49:02 UTC (rev 10842)
+++ branches/icc_work/lcms/src/cmsintrp.c	2010-03-03 06:14:58 UTC (rev 10843)
@@ -561,6 +561,16 @@
                 r = b + 1;
         }
 
+        /* If input was zero check if output is same.  If so, use 
+           that to maintain the black.  This avoids quantization 
+           error at zero point due to binary search approach below.
+           e.g.  as we approach a value of zero interpolation provides
+           it before we get there.  Black is not a good location to
+           introduce an error. */
+        if ( Value == 0 ) {
+            res = (int) cmsLinearInterpLUT16((WORD) (0), LutTable, p);
+            if ( res == 0 ) return (WORD) 0;
+        }
 
         // Seems not a degenerated case... apply binary search
 
@@ -572,7 +582,7 @@
 
                 if (res == Value) {
 
-                    // Found exact match. 
+                    // Found exact match.
                     
                     return (WORD) (x - 1);
                 }



More information about the gs-commits mailing list