Add lerping to skcms_eval_curve

Change-Id: I17eaf5f80623904feb3d50db46a288936acb1863
Reviewed-on: https://skia-review.googlesource.com/128561
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
diff --git a/build/android b/build/android
index 57c0bc4..c775dc8 100644
--- a/build/android
+++ b/build/android
@@ -5,7 +5,7 @@
 
 cc      = $ndk/toolchains/llvm/prebuilt/*/bin/clang -target $target
 cflags  = -fcolor-diagnostics -Weverything $
-          -Wno-padded -Wno-double-promotion -Wno-float-equal $
+          -Wno-padded -Wno-double-promotion -Wno-float-equal -Wno-bad-function-cast $
           --sysroot $ndk/sysroot $
           -I $ndk/sysroot/usr/include/$target
 ldflags = -pie -fuse-ld=gold $
diff --git a/build/android-arm b/build/android-arm
index 843d6f7..173b7ff 100644
--- a/build/android-arm
+++ b/build/android-arm
@@ -5,7 +5,7 @@
 
 cc      = $ndk/toolchains/llvm/prebuilt/*/bin/clang -target $target
 cflags  = -fcolor-diagnostics -Weverything $
-          -Wno-padded -Wno-double-promotion -Wno-float-equal $
+          -Wno-padded -Wno-double-promotion -Wno-float-equal -Wno-bad-function-cast $
           -march=armv7-a -mthumb $
           --sysroot $ndk/sysroot $
           -I $ndk/sysroot/usr/include/$target
diff --git a/build/clang b/build/clang
index 9560053..5fa829b 100644
--- a/build/clang
+++ b/build/clang
@@ -1,6 +1,6 @@
 cc     = clang
 cflags = -fcolor-diagnostics -Weverything $
-         -Wno-padded -Wno-double-promotion -Wno-float-equal -Wno-reserved-id-macro
+         -Wno-padded -Wno-double-promotion -Wno-float-equal -Wno-bad-function-cast -Wno-reserved-id-macro
 out    = out/clang$mode
 
 include build/local
diff --git a/build/ios b/build/ios
index 3f51ef5..430ab6c 100644
--- a/build/ios
+++ b/build/ios
@@ -1,6 +1,6 @@
 cc     = clang -arch arm64 -isysroot `xcrun --sdk iphoneos --show-sdk-path`
 cflags = -fcolor-diagnostics -Weverything $
-         -Wno-padded -Wno-double-promotion -Wno-float-equal
+         -Wno-padded -Wno-double-promotion -Wno-float-equal -Wno-bad-function-cast
 out    = out/ios$mode
 
 rule run
diff --git a/profiles/color.org/Upper_Left.icc.txt b/profiles/color.org/Upper_Left.icc.txt
index 314f1c7..b4cebbd 100644
--- a/profiles/color.org/Upper_Left.icc.txt
+++ b/profiles/color.org/Upper_Left.icc.txt
@@ -20,11 +20,11 @@
  A2B : "M", Matrix, "B"
  "M" : 3 inputs
   M0 : 16-bit table with 256 entries
-  ~= : 2.198538, 0.01209223, -0.0006638874, 1.290439, 0.05490196, 0.07084764, 0 (Max error: 79.0266) (D-gap: 0)
+  ~= : 2.360165, 0.04138637, 0.2936969, 1.290439, 0.05490196, 0.01433209, 0 (Max error: 15.9174) (D-gap: -2.75224e-05)
   M1 : 16-bit table with 256 entries
-  ~= : 2.198538, 0.01209223, -0.0006638874, 1.290439, 0.05490196, 0.07084764, 0 (Max error: 79.0266) (D-gap: 0)
+  ~= : 2.360165, 0.04138637, 0.2936969, 1.290439, 0.05490196, 0.01433209, 0 (Max error: 15.9174) (D-gap: -2.75224e-05)
   M2 : 16-bit table with 256 entries
-  ~= : 2.198538, 0.01209223, -0.0006638874, 1.290439, 0.05490196, 0.07084764, 0 (Max error: 79.0266) (D-gap: 0)
+  ~= : 2.360165, 0.04138637, 0.2936969, 1.290439, 0.05490196, 0.01433209, 0 (Max error: 15.9174) (D-gap: -2.75224e-05)
 Mtrx : | 0.959396958 0.847338140 0.314814538 -0.503105104 |
        | 0.489433438 1.577521086 0.133390293 -0.521812081 |
        | 0.030578148 0.213589266 1.570868373 -0.430443883 |
diff --git a/profiles/color.org/sRGB2014.icc.txt b/profiles/color.org/sRGB2014.icc.txt
index 5822940..aee9d9f 100644
--- a/profiles/color.org/sRGB2014.icc.txt
+++ b/profiles/color.org/sRGB2014.icc.txt
@@ -23,12 +23,12 @@
  'chad' : 'sf32' :     44 : 2980
 
 rTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 gTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 bTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
-Best : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
+Best : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (D-gap: -1.02632e-06)
  XYZ : | 0.436065674 0.385147095 0.143066406 |
        | 0.222488403 0.716873169 0.060607910 |
        | 0.013916016 0.097076416 0.714096069 |
diff --git a/profiles/fuzz/inverse_tf_not_invertible.icc.txt b/profiles/fuzz/inverse_tf_not_invertible.icc.txt
index e895032..880adc9 100644
--- a/profiles/fuzz/inverse_tf_not_invertible.icc.txt
+++ b/profiles/fuzz/inverse_tf_not_invertible.icc.txt
@@ -16,8 +16,12 @@
  'bTRC' : 'curv' :   8204 : 320
 
 rTRC : 16-bit table with 4096 entries
+  ~= : 5.117306, 0.5631943, 0.8488205, 0.07707816, 0.04078144, -0.492599, 0 (Max error: 0.781518) (D-gap: -0.000447828)
 gTRC : 16-bit table with 4096 entries
+  ~= : 5.117306, 0.5631943, 0.8488205, 0.07707816, 0.04078144, -0.492599, 0 (Max error: 0.781518) (D-gap: -0.000447828)
 bTRC : 16-bit table with 4096 entries
+  ~= : 5.117306, 0.5631943, 0.8488205, 0.07707816, 0.04078144, -0.492599, 0 (Max error: 0.781518) (D-gap: -0.000447828)
+Best : 5.117306, 0.5631943, 0.8488205, 0.07707816, 0.04078144, -0.492599, 0 (D-gap: -0.000447828)
  XYZ : | 0.436065674 0.385070801 0.143051147 |
        | 0.222503662 0.716873169 0.060607910 |
        | 0.013916016 0.097061157 0.713989258 |
diff --git a/profiles/misc/Apple_Color_LCD.icc.txt b/profiles/misc/Apple_Color_LCD.icc.txt
index cc7b4c3..eec67d7 100644
--- a/profiles/misc/Apple_Color_LCD.icc.txt
+++ b/profiles/misc/Apple_Color_LCD.icc.txt
@@ -24,12 +24,12 @@
  'aagg' : 'para' :     32 : 3652
 
 rTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000251848) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000251848) (D-gap: -1.02632e-06)
 gTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000251848) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000251848) (D-gap: -1.02632e-06)
 bTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000251848) (D-gap: -1.07288e-06)
-Best : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000251848) (D-gap: -1.02632e-06)
+Best : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (D-gap: -1.02632e-06)
  XYZ : | 0.444335938 0.379440308 0.140411377 |
        | 0.224761963 0.726165771 0.049072266 |
        | 0.005477905 0.077972412 0.741455078 |
diff --git a/profiles/misc/Coated_FOGRA39_CMYK.icc.txt b/profiles/misc/Coated_FOGRA39_CMYK.icc.txt
index 78383a2..7fdc646 100644
--- a/profiles/misc/Coated_FOGRA39_CMYK.icc.txt
+++ b/profiles/misc/Coated_FOGRA39_CMYK.icc.txt
@@ -23,13 +23,13 @@
  A2B : "A", CLUT, "B"
  "A" : 4 inputs
   A0 : 16-bit table with 256 entries
-  ~= : 1.054479, 1.018631, -0.007989263, 0.8365758, 0.007843138, 0.00656138, 0 (Max error: 0.0166587) (D-gap: 4.65661e-10)
+  ~= : 1.05448, 1.018631, -0.007989263, 0.8365758, 0.007843138, 0.006561379, 0 (Max error: 0.0166625) (D-gap: 0)
   A1 : 16-bit table with 256 entries
-  ~= : 1.117218, 1.017532, 0.01265904, 0.7665369, 0.007843138, -0.00708606, 0 (Max error: 0.0235112) (D-gap: -2.25892e-06)
+  ~= : 1.117216, 1.017532, 0.01265455, 0.7665369, 0.007843138, -0.007083124, 0 (Max error: 0.0235106) (D-gap: -2.36277e-06)
   A2 : 16-bit table with 256 entries
-  ~= : 1.179159, 0.9974022, 0.03461417, 0.7081712, 0.007843138, -0.01853919, 0 (Max error: 0.0164243) (D-gap: -6.80797e-07)
+  ~= : 1.179158, 0.9974098, 0.03461254, 0.7081712, 0.007843138, -0.01853815, 0 (Max error: 0.0164376) (D-gap: -5.96978e-07)
   A3 : 16-bit table with 256 entries
-  ~= : 4.691178, 0.2260542, 0.8152651, 0.7798873, 0.227451, -0.3339215, 0 (Max error: 0.0967443) (D-gap: -0.000454813)
+  ~= : 2.925117, 0.6722183, 0.6647099, 0.7159533, 0.007843137, -0.304297, 0 (Max error: 0.359878) (D-gap: -2.91723e-05)
 CLUT : 11 x 11 x 11 x 11 (16 bpp)
  "B" : 3 outputs
   B0 : 1, 1, 0, 0, 0, 0, 0 (Identity)
diff --git a/profiles/misc/ColorLogic_ISO_Coated_CMYK.icc.txt b/profiles/misc/ColorLogic_ISO_Coated_CMYK.icc.txt
index 84b4fc2..a79bee4 100644
--- a/profiles/misc/ColorLogic_ISO_Coated_CMYK.icc.txt
+++ b/profiles/misc/ColorLogic_ISO_Coated_CMYK.icc.txt
@@ -23,13 +23,13 @@
  A2B : "A", CLUT, "B"
  "A" : 4 inputs
   A0 : 16-bit table with 256 entries
-  ~= : 0.3560936, 16.55835, 7.13326, 1.200778, 0.01960784, -2.021732, 0 (Max error: 0.0856557) (D-gap: -0.000201819)
+  ~= : 0.3393432, 25.72925, 12.38516, 1.200778, 0.01960784, -2.357529, 0 (Max error: 0.102451) (D-gap: -0.000214456)
   A1 : 16-bit table with 256 entries
-  ~= : 0.3578774, 16.33813, 7.193894, 1.205447, 0.01960784, -2.034516, 0 (Max error: 0.0820509) (D-gap: -0.000199202)
+  ~= : 0.3643354, 14.1637, 6.025175, 1.205447, 0.01960784, -1.932159, 0 (Max error: 0.0767835) (D-gap: -0.000144485)
   A2 : 16-bit table with 256 entries
-  ~= : 0.7475019, 0.9663048, -0.1072711, 1.241552, 0.1490196, 0.1004168, 0 (Max error: 0.0142915) (D-gap: -1.27107e-05)
+  ~= : 0.7474884, 0.96632, -0.1072647, 1.241552, 0.1490196, 0.1003987, 0 (Max error: 0.0142888) (D-gap: -1.12057e-05)
   A3 : 16-bit table with 256 entries
-  ~= : 0.8032399, 0.9340668, -0.01337326, 1.182879, 0.01568628, 0.01381122, 0 (Max error: 0.0662429) (D-gap: -8.62405e-07)
+  ~= : 0.8032417, 0.9340668, -0.01337395, 1.182879, 0.01568628, 0.01381338, 0 (Max error: 0.0662436) (D-gap: -8.79169e-07)
 CLUT : 17 x 17 x 17 x 17 (16 bpp)
  "B" : 3 outputs
   B0 : 16-bit table with 256 entries
diff --git a/profiles/misc/DisplayCal_ASUS_NonMonotonic.icc.txt b/profiles/misc/DisplayCal_ASUS_NonMonotonic.icc.txt
index 92d2ac4..3f34a65 100644
--- a/profiles/misc/DisplayCal_ASUS_NonMonotonic.icc.txt
+++ b/profiles/misc/DisplayCal_ASUS_NonMonotonic.icc.txt
@@ -31,12 +31,12 @@
  'meta' : 'dict' :   2312 : 738448
 
 rTRC : 16-bit table with 256 entries
-  ~= : 1.929508, 1.131073, -0.1330674, 0.03579766, 0.1176471, 0.00421149, 0 (Max error: 0.0831202) (D-gap: 0)
+  ~= : 1.929522, 1.131058, -0.1330656, 0.03579767, 0.1176471, 0.004211491, 0 (Max error: 0.0831201) (D-gap: 0)
 gTRC : 16-bit table with 256 entries
-  ~= : 2.287477, 0.9762115, 0.03632147, 0.0311284, 0.1921569, -0.02663411, 0 (Max error: 0.0558824) (D-gap: -1.81049e-05)
+  ~= : 2.287451, 0.976223, 0.03631073, 0.03112842, 0.1921569, -0.02663262, 0 (Max error: 0.0558824) (D-gap: -1.82879e-05)
 bTRC : 16-bit table with 256 entries
-  ~= : 2.195799, 1.024147, -0.01593353, 0.00389105, 0.1607843, -0.01461204, 0 (Max error: 0.152941) (D-gap: -7.77585e-06)
-Best : 2.195799, 1.024147, -0.01593353, 0.00389105, 0.1607843, -0.01461204, 0 (D-gap: -7.77585e-06)
+  ~= : 2.195809, 1.024139, -0.01592951, 0.00389105, 0.1607843, -0.01461231, 0 (Max error: 0.152941) (D-gap: -7.69203e-06)
+Best : 2.195809, 1.024139, -0.01592951, 0.00389105, 0.1607843, -0.01461231, 0 (D-gap: -7.69203e-06)
  XYZ : | 0.436737061 0.380325317 0.147140503 |
        | 0.217636108 0.729843140 0.052520752 |
        | 0.002655029 0.064407349 0.757827759 |
@@ -66,4 +66,4 @@
 	353137 2b1b32 1c3104 281330 170b14 161829 2f3347
 	152209 191244 08041b 2b1601 2c4c06 010108 282d55
 	315609 221416 1d231d 2e1d11 29481e 26180c 293144
-polyTF[1] = 0.221881 0.803375 0.0311284 0.192157
+polyTF[1] = 0.221881 0.803376 0.0311284 0.192157
diff --git a/profiles/misc/Dot_Gain_20_Grayscale.icc.txt b/profiles/misc/Dot_Gain_20_Grayscale.icc.txt
index 98bc131..a42eb41 100644
--- a/profiles/misc/Dot_Gain_20_Grayscale.icc.txt
+++ b/profiles/misc/Dot_Gain_20_Grayscale.icc.txt
@@ -12,12 +12,12 @@
  'kTRC' : 'curv' :    524 : 388
 
 rTRC : 16-bit table with 256 entries
-  ~= : 1.737032, 0.9999237, 3.456433e-05, 0.06290531, 0.02352941, -7.48676e-06, 0 (Max error: 0.000202142) (D-gap: -3.6438e-08)
+  ~= : 1.737027, 0.9999275, 3.289566e-05, 0.06290532, 0.02352941, -7.343342e-06, 0 (Max error: 0.000202144) (D-gap: -4.22588e-08)
 gTRC : 16-bit table with 256 entries
-  ~= : 1.737032, 0.9999237, 3.456433e-05, 0.06290531, 0.02352941, -7.48676e-06, 0 (Max error: 0.000202142) (D-gap: -3.6438e-08)
+  ~= : 1.737027, 0.9999275, 3.289566e-05, 0.06290532, 0.02352941, -7.343342e-06, 0 (Max error: 0.000202144) (D-gap: -4.22588e-08)
 bTRC : 16-bit table with 256 entries
-  ~= : 1.737032, 0.9999237, 3.456433e-05, 0.06290531, 0.02352941, -7.48676e-06, 0 (Max error: 0.000202142) (D-gap: -3.6438e-08)
-Best : 1.737032, 0.9999237, 3.456433e-05, 0.06290531, 0.02352941, -7.48676e-06, 0 (D-gap: -3.6438e-08)
+  ~= : 1.737027, 0.9999275, 3.289566e-05, 0.06290532, 0.02352941, -7.343342e-06, 0 (Max error: 0.000202144) (D-gap: -4.22588e-08)
+Best : 1.737027, 0.9999275, 3.289566e-05, 0.06290532, 0.02352941, -7.343342e-06, 0 (D-gap: -4.22588e-08)
  XYZ : | 0.964202881 0.000000000 0.000000000 |
        | 0.000000000 1.000000000 0.000000000 |
        | 0.000000000 0.000000000 0.824905396 |
diff --git a/profiles/misc/HD_709.icc.txt b/profiles/misc/HD_709.icc.txt
index c3cf1ec..f2740ff 100644
--- a/profiles/misc/HD_709.icc.txt
+++ b/profiles/misc/HD_709.icc.txt
@@ -24,12 +24,12 @@
  'aagg' : 'para' :     32 : 2696
 
 rTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000251848) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000251848) (D-gap: -1.02632e-06)
 gTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000251848) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000251848) (D-gap: -1.02632e-06)
 bTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000251848) (D-gap: -1.07288e-06)
-Best : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000251848) (D-gap: -1.02632e-06)
+Best : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (D-gap: -1.02632e-06)
  XYZ : | 0.358963013 0.446350098 0.158889771 |
        | 0.195922852 0.742843628 0.061233521 |
        | 0.009674072 0.043518066 0.771713257 |
diff --git a/profiles/misc/Japan_Color_2001_Coated.icc.txt b/profiles/misc/Japan_Color_2001_Coated.icc.txt
index 7a41e8f..36e992c 100644
--- a/profiles/misc/Japan_Color_2001_Coated.icc.txt
+++ b/profiles/misc/Japan_Color_2001_Coated.icc.txt
@@ -19,13 +19,13 @@
  A2B : "A", CLUT, "B"
  "A" : 4 inputs
   A0 : 16-bit table with 256 entries
-  ~= : 1.010961, 1.063446, -0.03336301, 0.7801556, 0.03137255, 0.02447547, 0 (Max error: 0.0512881) (D-gap: -1.86265e-09)
+  ~= : 1.010957, 1.063446, -0.03336301, 0.7801556, 0.03137255, 0.02447547, 0 (Max error: 0.0512881) (D-gap: -1.86265e-09)
   A1 : 16-bit table with 256 entries
-  ~= : 1.117949, 1.022003, -0.02805499, 0.6270149, 0.02745098, 0.01721218, 0 (Max error: 0.009296) (D-gap: 0)
+  ~= : 1.117948, 1.022003, -0.02805499, 0.6270149, 0.02745098, 0.01721218, 0 (Max error: 0.009296) (D-gap: 0)
   A2 : 16-bit table with 256 entries
-  ~= : 1.15892, 0.9902, 0.04166482, 0.6193255, 0.02352941, -0.02750144, 0 (Max error: 0.00840104) (D-gap: -6.04335e-06)
+  ~= : 1.158917, 0.9902077, 0.0416557, 0.6193256, 0.02352941, -0.02749484, 0 (Max error: 0.0083915) (D-gap: -5.88316e-06)
   A3 : 16-bit table with 256 entries
-  ~= : 1.833982, 0.7539101, 0.38013, 0.3229572, 0.003921569, -0.1708632, 0 (Max error: 0.0587234) (D-gap: -3.62739e-05)
+  ~= : 1.834799, 0.7538223, 0.3804165, 0.3229572, 0.003921569, -0.1709625, 0 (Max error: 0.058979) (D-gap: -3.45453e-05)
 CLUT : 9 x 9 x 9 x 9 (16 bpp)
  "B" : 3 outputs
   B0 : 1, 1, 0, 0, 0, 0, 0 (Identity)
diff --git a/profiles/misc/Kodak_sRGB.icc.txt b/profiles/misc/Kodak_sRGB.icc.txt
index 155ee06..e68a566 100644
--- a/profiles/misc/Kodak_sRGB.icc.txt
+++ b/profiles/misc/Kodak_sRGB.icc.txt
@@ -21,23 +21,23 @@
  'bTRC' : 'curv' :    524 : 149844
 
 rTRC : 16-bit table with 256 entries
-  ~= : 2.411186, 0.9417992, 0.05645653, 0.06968518, 0.04313726, 0.0033139, 0.003921568 (Max error: 0.0032602) (D-gap: -1.47521e-06)
+  ~= : 2.41119, 0.9417992, 0.05645788, 0.06968518, 0.04313726, 0.003313854, 0.003921568 (Max error: 0.00325973) (D-gap: -1.43191e-06)
 gTRC : 16-bit table with 256 entries
-  ~= : 2.411186, 0.9417992, 0.05645653, 0.06968518, 0.04313726, 0.0033139, 0.003921568 (Max error: 0.0032602) (D-gap: -1.47521e-06)
+  ~= : 2.41119, 0.9417992, 0.05645788, 0.06968518, 0.04313726, 0.003313854, 0.003921568 (Max error: 0.00325973) (D-gap: -1.43191e-06)
 bTRC : 16-bit table with 256 entries
-  ~= : 2.411186, 0.9417992, 0.05645653, 0.06968518, 0.04313726, 0.0033139, 0.003921568 (Max error: 0.0032602) (D-gap: -1.47521e-06)
-Best : 2.411186, 0.9417992, 0.05645653, 0.06968518, 0.04313726, 0.0033139, 0.003921568 (D-gap: -1.47521e-06)
+  ~= : 2.41119, 0.9417992, 0.05645788, 0.06968518, 0.04313726, 0.003313854, 0.003921568 (Max error: 0.00325973) (D-gap: -1.43191e-06)
+Best : 2.41119, 0.9417992, 0.05645788, 0.06968518, 0.04313726, 0.003313854, 0.003921568 (D-gap: -1.43191e-06)
  XYZ : | 0.437637329 0.388412476 0.142410278 |
        | 0.214950562 0.712905884 0.072128296 |
        | 0.011260986 0.080718994 0.725875854 |
  A2B : "A", CLUT, "B"
  "A" : 3 inputs
   A0 : 16-bit table with 256 entries
-  ~= : 0.7266448, 1.400414, 0.3512399, 0.7458658, 0.0627451, -0.5031613, 0 (Max error: 0.00319708) (D-gap: -0.000133157)
+  ~= : 0.7264283, 1.401436, 0.3523517, 0.7458658, 0.0627451, -0.5043284, 0 (Max error: 0.00319327) (D-gap: -0.000132978)
   A1 : 16-bit table with 256 entries
-  ~= : 0.7266448, 1.400414, 0.3512399, 0.7458658, 0.0627451, -0.5031613, 0 (Max error: 0.00319708) (D-gap: -0.000133157)
+  ~= : 0.7264283, 1.401436, 0.3523517, 0.7458658, 0.0627451, -0.5043284, 0 (Max error: 0.00319327) (D-gap: -0.000132978)
   A2 : 16-bit table with 256 entries
-  ~= : 0.7266448, 1.400414, 0.3512399, 0.7458658, 0.0627451, -0.5031613, 0 (Max error: 0.00319708) (D-gap: -0.000133157)
+  ~= : 0.7264283, 1.401436, 0.3523517, 0.7458658, 0.0627451, -0.5043284, 0 (Max error: 0.00319327) (D-gap: -0.000132978)
 CLUT : 8 x 8 x 8 (16 bpp)
  "B" : 3 outputs
   B0 : 16-bit table with 4096 entries
diff --git a/profiles/misc/Phase_One_P25.icc.txt b/profiles/misc/Phase_One_P25.icc.txt
index 0cb8fb5..daf2d33 100644
--- a/profiles/misc/Phase_One_P25.icc.txt
+++ b/profiles/misc/Phase_One_P25.icc.txt
@@ -19,10 +19,10 @@
  'tech' : 'sig ' :     12 : 219352
 
 rTRC : 16-bit table with 256 entries
-  ~= : 0.380209, 1.743309, 0.01529628, 3.844358, 0.007843138, -0.2300332, 0 (Max error: 0.0201116) (D-gap: -5.88894e-05)
+  ~= : 0.3802269, 1.743065, 0.01528687, 3.844358, 0.007843138, -0.2299772, 0 (Max error: 0.0201226) (D-gap: -5.8189e-05)
 gTRC : 16-bit table with 256 entries
 bTRC : 16-bit table with 256 entries
-  ~= : 0.7390666, 0.8478584, -0.009974806, 2.721141, 0.01176471, 0.03201343, 0 (Max error: 0.140045) (D-gap: 0)
+  ~= : 0.7390234, 0.8478966, -0.009975255, 2.721141, 0.01176471, 0.03201343, 0 (Max error: 0.139984) (D-gap: 0)
  XYZ : | 0.647903442 0.357360840 0.156417847 |
        | 0.382919312 1.109725952 0.000000000 |
        | 0.083267212 0.679275513 0.523422241 |
diff --git a/profiles/misc/SWOP_Coated_20_GCR_CMYK.icc.txt b/profiles/misc/SWOP_Coated_20_GCR_CMYK.icc.txt
index 3233c73..4228868 100644
--- a/profiles/misc/SWOP_Coated_20_GCR_CMYK.icc.txt
+++ b/profiles/misc/SWOP_Coated_20_GCR_CMYK.icc.txt
@@ -21,11 +21,8 @@
  "A" : 4 inputs
   A0 : 16-bit table with 256 entries
   A1 : 16-bit table with 256 entries
-  ~= : 1.334051, 0.04514098, 0.9326822, 0.7043535, 0.2078432, -0.7772038, 0 (Max error: 12.4244) (D-gap: -0.000270456)
   A2 : 16-bit table with 256 entries
-  ~= : 1.334051, 0.04514098, 0.9326822, 0.7043535, 0.2078432, -0.7772038, 0 (Max error: 12.4244) (D-gap: -0.000270456)
   A3 : 16-bit table with 256 entries
-  ~= : 1.334051, 0.04514098, 0.9326822, 0.7043535, 0.2078432, -0.7772038, 0 (Max error: 12.4244) (D-gap: -0.000270456)
 CLUT : 16 x 16 x 16 x 16 (16 bpp)
  "B" : 3 outputs
   B0 : 1, 1, 0, 0, 0, 0, 0 (Identity)
diff --git a/profiles/misc/US_Web_Coated_SWOP_CMYK.icc.txt b/profiles/misc/US_Web_Coated_SWOP_CMYK.icc.txt
index 7963771..777f600 100644
--- a/profiles/misc/US_Web_Coated_SWOP_CMYK.icc.txt
+++ b/profiles/misc/US_Web_Coated_SWOP_CMYK.icc.txt
@@ -19,11 +19,11 @@
  A2B : "A", CLUT, "B"
  "A" : 4 inputs
   A0 : 16-bit table with 256 entries
-  ~= : 0.7457057, 1.273026, 0.2826105, 2.132296, 0.003921569, -0.3865254, 0 (Max error: 0.00503409) (D-gap: -8.13985e-05)
+  ~= : 0.7457523, 1.272858, 0.2824373, 2.132296, 0.003921569, -0.3863242, 0 (Max error: 0.00503598) (D-gap: -8.04747e-05)
   A1 : 16-bit table with 256 entries
   ~= : 1.001741, 0.9817276, -0.01539965, 1.622568, 0.01568628, 0.02545205, 0 (Max error: 0.00967842) (D-gap: 0)
   A2 : 16-bit table with 256 entries
-  ~= : 1.043714, 0.997036, -0.01563978, 1.68677, 0.01568628, 0.02645914, 0 (Max error: 0.0163711) (D-gap: 0)
+  ~= : 1.043713, 0.997036, -0.01563978, 1.68677, 0.01568628, 0.02645914, 0 (Max error: 0.0163711) (D-gap: 0)
   A3 : 16-bit table with 256 entries
 CLUT : 9 x 9 x 9 x 9 (16 bpp)
  "B" : 3 outputs
diff --git a/profiles/misc/sRGB_Calibrated_Heterogeneous.icc.txt b/profiles/misc/sRGB_Calibrated_Heterogeneous.icc.txt
index dd2a878..2730c66 100644
--- a/profiles/misc/sRGB_Calibrated_Heterogeneous.icc.txt
+++ b/profiles/misc/sRGB_Calibrated_Heterogeneous.icc.txt
@@ -16,12 +16,12 @@
  'cprt' : 'mluc' :     60 : 1944
 
 rTRC : 16-bit table with 256 entries
-  ~= : 2.231977, 1.004654, -0.00410851, 0.01206226, 0.03921569, -0.0001004114, 0 (Max error: 0.00578362) (D-gap: -2.82831e-07)
+  ~= : 2.231975, 1.004654, -0.00410899, 0.01206226, 0.03921569, -0.0001003884, 0 (Max error: 0.00578362) (D-gap: -2.70957e-07)
 gTRC : 16-bit table with 256 entries
-  ~= : 2.198176, 1.010284, -0.008952498, 0.009727625, 0.02352941, 0.0001335609, 0 (Max error: 0.00396794) (D-gap: -3.38041e-08)
+  ~= : 2.198176, 1.010284, -0.008952621, 0.009727627, 0.02352941, 0.0001335621, 0 (Max error: 0.00396806) (D-gap: -3.45608e-08)
 bTRC : 16-bit table with 256 entries
-  ~= : 2.261966, 1.004623, -0.004006649, 0.0077821, 0.01960785, 6.966511e-05, 0 (Max error: 0.00376081) (D-gap: -3.40515e-09)
-Best : 2.231977, 1.004654, -0.00410851, 0.01206226, 0.03921569, -0.0001004114, 0 (D-gap: -2.82831e-07)
+  ~= : 2.261965, 1.004623, -0.004006829, 0.0077821, 0.01960785, 6.96676e-05, 0 (Max error: 0.00376099) (D-gap: -3.71074e-09)
+Best : 2.231975, 1.004654, -0.00410899, 0.01206226, 0.03921569, -0.0001003884, 0 (D-gap: -2.70957e-07)
  XYZ : | 0.449279785 0.382583618 0.132339478 |
        | 0.224472046 0.722351074 0.053176880 |
        | 0.001129150 0.053558350 0.770217896 |
diff --git a/profiles/misc/sRGB_Calibrated_Homogeneous.icc.txt b/profiles/misc/sRGB_Calibrated_Homogeneous.icc.txt
index 60165a3..7ab7340 100644
--- a/profiles/misc/sRGB_Calibrated_Homogeneous.icc.txt
+++ b/profiles/misc/sRGB_Calibrated_Homogeneous.icc.txt
@@ -17,12 +17,12 @@
  'MS00' : 'MS10' :   7838 : 2308
 
 rTRC : 16-bit table with 256 entries
-  ~= : 2.416184, 0.9430008, 0.06004674, 0.0774319, 0.03921569, -0.0005302608, 0 (Max error: 0.0031904) (D-gap: -1.40537e-06)
+  ~= : 2.41619, 0.9429932, 0.06004851, 0.0774319, 0.03921569, -0.0005303656, 0 (Max error: 0.00319278) (D-gap: -1.43563e-06)
 gTRC : 16-bit table with 256 entries
-  ~= : 2.416184, 0.9430008, 0.06004674, 0.0774319, 0.03921569, -0.0005302608, 0 (Max error: 0.0031904) (D-gap: -1.40537e-06)
+  ~= : 2.41619, 0.9429932, 0.06004851, 0.0774319, 0.03921569, -0.0005303656, 0 (Max error: 0.00319278) (D-gap: -1.43563e-06)
 bTRC : 16-bit table with 256 entries
-  ~= : 2.416184, 0.9430008, 0.06004674, 0.0774319, 0.03921569, -0.0005302608, 0 (Max error: 0.0031904) (D-gap: -1.40537e-06)
-Best : 2.416184, 0.9430008, 0.06004674, 0.0774319, 0.03921569, -0.0005302608, 0 (D-gap: -1.40537e-06)
+  ~= : 2.41619, 0.9429932, 0.06004851, 0.0774319, 0.03921569, -0.0005303656, 0 (Max error: 0.00319278) (D-gap: -1.43563e-06)
+Best : 2.41619, 0.9429932, 0.06004851, 0.0774319, 0.03921569, -0.0005303656, 0 (D-gap: -1.43563e-06)
  XYZ : | 0.435470581 0.388549805 0.140197754 |
        | 0.221725464 0.721969604 0.056304932 |
        | 0.013488770 0.087921143 0.723480225 |
diff --git a/profiles/misc/sRGB_HP.icc.txt b/profiles/misc/sRGB_HP.icc.txt
index 19cdaab..635628b 100644
--- a/profiles/misc/sRGB_HP.icc.txt
+++ b/profiles/misc/sRGB_HP.icc.txt
@@ -24,12 +24,12 @@
  'bTRC' : 'curv' :   2060 : 1084
 
 rTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 gTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 bTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
-Best : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
+Best : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (D-gap: -1.02632e-06)
  XYZ : | 0.436065674 0.385147095 0.143066406 |
        | 0.222488403 0.716873169 0.060607910 |
        | 0.013916016 0.097076416 0.714096069 |
diff --git a/profiles/misc/sRGB_HP_2.icc.txt b/profiles/misc/sRGB_HP_2.icc.txt
index f748041..cb3d6a1 100644
--- a/profiles/misc/sRGB_HP_2.icc.txt
+++ b/profiles/misc/sRGB_HP_2.icc.txt
@@ -24,12 +24,12 @@
  'bTRC' : 'curv' :   2060 : 5201
 
 rTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 gTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 bTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
-Best : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
+Best : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (D-gap: -1.02632e-06)
  XYZ : | 0.436065674 0.385147095 0.143066406 |
        | 0.222488403 0.716873169 0.060607910 |
        | 0.013916016 0.097076416 0.714096069 |
diff --git a/profiles/misc/sRGB_black_scaled.icc.txt b/profiles/misc/sRGB_black_scaled.icc.txt
index 755d1f2..d432d36 100644
--- a/profiles/misc/sRGB_black_scaled.icc.txt
+++ b/profiles/misc/sRGB_black_scaled.icc.txt
@@ -23,12 +23,12 @@
  'chad' : 'sf32' :     44 : 3004
 
 rTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 gTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 bTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
-Best : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
+Best : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (D-gap: -1.02632e-06)
  XYZ : | 0.436065674 0.385147095 0.143066406 |
        | 0.222488403 0.716873169 0.060607910 |
        | 0.013916016 0.097076416 0.714096069 |
diff --git a/profiles/mobile/Display_P3_LUT.icc.txt b/profiles/mobile/Display_P3_LUT.icc.txt
index 3db53bc..ea6934c 100644
--- a/profiles/mobile/Display_P3_LUT.icc.txt
+++ b/profiles/mobile/Display_P3_LUT.icc.txt
@@ -18,12 +18,12 @@
  'gTRC' : 'curv' :   2060 : 508
 
 rTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 gTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 bTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
-Best : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
+Best : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (D-gap: -1.02632e-06)
  XYZ : | 0.515121460 0.291976929 0.157104492 |
        | 0.241195679 0.692245483 0.066574097 |
        | -0.001037598 0.041885376 0.784072876 |
diff --git a/profiles/mobile/sRGB_LUT.icc.txt b/profiles/mobile/sRGB_LUT.icc.txt
index d6c7f25..969229b 100644
--- a/profiles/mobile/sRGB_LUT.icc.txt
+++ b/profiles/mobile/sRGB_LUT.icc.txt
@@ -18,12 +18,12 @@
  'gTRC' : 'curv' :   2060 : 520
 
 rTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 gTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
 bTRC : 16-bit table with 1024 entries
-  ~= : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (Max error: 0.000239041) (D-gap: -1.07288e-06)
-Best : 2.399978, 0.9477539, 0.05209779, 0.07771055, 0.04496579, -1.302708e-06, 0 (D-gap: -1.07288e-06)
+  ~= : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (Max error: 0.000239041) (D-gap: -1.02632e-06)
+Best : 2.399984, 0.9477577, 0.05209981, 0.07771055, 0.04496579, -1.405069e-06, 0 (D-gap: -1.02632e-06)
  XYZ : | 0.436035156 0.385116577 0.143051147 |
        | 0.222488403 0.716903687 0.060607910 |
        | 0.013916016 0.097061157 0.713912964 |
diff --git a/profiles/sRGB_Facebook.icc.txt b/profiles/sRGB_Facebook.icc.txt
index 7e5b62d..90308e8 100644
--- a/profiles/sRGB_Facebook.icc.txt
+++ b/profiles/sRGB_Facebook.icc.txt
@@ -17,12 +17,12 @@
  'bTRC' : 'curv' :     64 : 460
 
 rTRC : 16-bit table with 26 entries
-  ~= : 2.387403, 0.9515495, 0.04789115, 0.07743954, 0.04, 0.0002416593, 0 (Max error: 0.000975177) (D-gap: -6.06058e-07)
+  ~= : 2.387424, 0.9515533, 0.04789362, 0.07743954, 0.04, 0.0002416283, 0 (Max error: 0.000975654) (D-gap: -6.07222e-07)
 gTRC : 16-bit table with 26 entries
-  ~= : 2.387403, 0.9515495, 0.04789115, 0.07743954, 0.04, 0.0002416593, 0 (Max error: 0.000975177) (D-gap: -6.06058e-07)
+  ~= : 2.387424, 0.9515533, 0.04789362, 0.07743954, 0.04, 0.0002416283, 0 (Max error: 0.000975654) (D-gap: -6.07222e-07)
 bTRC : 16-bit table with 26 entries
-  ~= : 2.387403, 0.9515495, 0.04789115, 0.07743954, 0.04, 0.0002416593, 0 (Max error: 0.000975177) (D-gap: -6.06058e-07)
-Best : 2.387403, 0.9515495, 0.04789115, 0.07743954, 0.04, 0.0002416593, 0 (D-gap: -6.06058e-07)
+  ~= : 2.387424, 0.9515533, 0.04789362, 0.07743954, 0.04, 0.0002416283, 0 (Max error: 0.000975654) (D-gap: -6.07222e-07)
+Best : 2.387424, 0.9515533, 0.04789362, 0.07743954, 0.04, 0.0002416283, 0 (D-gap: -6.07222e-07)
  XYZ : | 0.436065674 0.385147095 0.143066406 |
        | 0.222488403 0.716873169 0.060607910 |
        | 0.013916016 0.097076416 0.714096069 |
@@ -61,7 +61,7 @@
   217: 0a -> 09, -1
   223: 97 -> 96, -1
   250: 60 -> 5f, -1
-polyTF[0] = 0.296537 0.701506 0.0774395 0.04
-polyTF[1] = 0.296537 0.701506 0.0774395 0.04
-polyTF[2] = 0.296537 0.701506 0.0774395 0.04
+polyTF[0] = 0.296538 0.701506 0.0774395 0.04
+polyTF[1] = 0.296538 0.701506 0.0774395 0.04
+polyTF[2] = 0.296538 0.701506 0.0774395 0.04
 This profile ≈ sRGB.
diff --git a/src/Curve.c b/src/Curve.c
index f52eb98..2b5a042 100644
--- a/src/Curve.c
+++ b/src/Curve.c
@@ -10,25 +10,36 @@
 #include "TransferFunction.h"
 #include <assert.h>
 
+static float minus_1_ulp(float x) {
+    int32_t bits;
+    memcpy(&bits, &x, sizeof(bits));
+    bits = bits - 1;
+    memcpy(&x, &bits, sizeof(bits));
+    return x;
+}
+
 float skcms_eval_curve(const skcms_Curve* curve, float x) {
     if (curve->table_entries == 0) {
         return skcms_TransferFunction_eval(&curve->parametric, x);
     }
 
-    // TODO: today we should always hit an entry exactly, but if that changes, lerp?
-    // (We add half to account for slight int -> float -> int round tripping issues.)
-    float fx = x*(curve->table_entries - 1);
-    int ix = (int)( fx + 0.5f );
+    float ix = fmaxf_(0, fminf_(x, 1)) * (curve->table_entries - 1);
+    int   lo = (int)            ix,
+          hi = (int)minus_1_ulp(ix + 1.0f);
+    float t = ix - (float)lo;
 
-    assert ( fabsf_(fx - (float)ix) < 0.0005 );
-
+    float l, h;
     if (curve->table_8) {
-        return curve->table_8[ix] * (1/255.0f);
+        l = curve->table_8[lo] * (1/255.0f);
+        h = curve->table_8[hi] * (1/255.0f);
     } else {
-        uint16_t be;
-        memcpy(&be, curve->table_16 + 2*ix, 2);
-
-        uint16_t le = ((be << 8) | (be >> 8)) & 0xffff;
-        return le * (1/65535.0f);
+        uint16_t be_l, be_h;
+        memcpy(&be_l, curve->table_16 + 2*lo, 2);
+        memcpy(&be_h, curve->table_16 + 2*hi, 2);
+        uint16_t le_l = ((be_l << 8) | (be_l >> 8)) & 0xffff;
+        uint16_t le_h = ((be_h << 8) | (be_h >> 8)) & 0xffff;
+        l = le_l * (1/65535.0f);
+        h = le_h * (1/65535.0f);
     }
+    return l + (h-l)*t;
 }