aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party
diff options
context:
space:
mode:
authorGravatar skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com <skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>2018-04-25 17:28:32 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-25 17:52:07 +0000
commitde5cffbc48fce4decd1caf84d5a5e4fc0b5b48ed (patch)
tree009345d21b9dc19c70d8d772e4d175c8a6fab58e /third_party
parent412d411d662e38b3a3f18599983174e533048d0d (diff)
Roll skia/third_party/skcms 9e351c0..48c6ca0 (1 commits)
https://skia.googlesource.com/skcms.git/+log/9e351c0..48c6ca0 2018-04-25 mtklein@chromium.org evaluate skcms_PolyTF carefully The AutoRoll server is located here: https://skcms-skia-roll.skia.org Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary. TBR=stani@google.com Change-Id: I8fb39fbacfe84a0ceec668b5221f8f32cc225f26 Reviewed-on: https://skia-review.googlesource.com/123657 Reviewed-by: skcms-skia-autoroll <skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com> Commit-Queue: skcms-skia-autoroll <skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
Diffstat (limited to 'third_party')
-rw-r--r--third_party/skcms/src/PolyTF.c13
-rw-r--r--third_party/skcms/src/Transform_inl.h2
-rwxr-xr-xthird_party/skcms/version.sha12
3 files changed, 9 insertions, 8 deletions
diff --git a/third_party/skcms/src/PolyTF.c b/third_party/skcms/src/PolyTF.c
index 451a4272b7..f4aaa4877d 100644
--- a/third_party/skcms/src/PolyTF.c
+++ b/third_party/skcms/src/PolyTF.c
@@ -14,20 +14,18 @@
#include <stdlib.h>
// f(x) = skcms_PolyTF{A,B,C,D}(x) =
-// Cx x < D
-// Ax^3 + Bx^2 + (1-A-B) x ≥ D
+// Cx x < D
+// A(x^3-1) + B(x^2-1) + 1 x ≥ D
//
// We'll fit C and D directly, and then hold them constant
// and fit the other part using Gauss-Newton, subject to
// the constraint that both parts meet at x=D:
//
-// CD = AD^3 + BD^2 + (1-A-B)
+// CD = A(D^3-1) + B(D^2-1) + 1
//
// This lets us solve for B, reducing the optimization problem
// for that part down to just a single parameter A:
//
-// CD = A(D^3-1) + B(D^2-1) + 1
-//
// CD - A(D^3-1) - 1
// B = -----------------
// D^2-1
@@ -39,6 +37,9 @@
// (x^2-1) (D^3-1)
// ∂f/∂A = x^3-1 - ---------------
// D^2-1
+//
+// It's important to evaluate as f(x) as A(x^3-1) + B(x^2-1) + 1
+// and not Ax^3 + Bx^2 + (1-A-B) to ensure that f(1.0f) == 1.0f.
static float eval_poly_tf(float x, const void* ctx, const float P[4]) {
const skcms_PolyTF* tf = (const skcms_PolyTF*)ctx;
@@ -49,7 +50,7 @@ static float eval_poly_tf(float x, const void* ctx, const float P[4]) {
float B = (C*D - A*(D*D*D - 1) - 1) / (D*D - 1);
return x < D ? C*x
- : A*x*x*x + B*x*x + (1-A-B);
+ : A*(x*x*x-1) + B*(x*x-1) + 1;
}
static void grad_poly_tf(float x, const void* ctx, const float P[4], float dfdP[4]) {
diff --git a/third_party/skcms/src/Transform_inl.h b/third_party/skcms/src/Transform_inl.h
index 529780ab7b..debdf68a88 100644
--- a/third_party/skcms/src/Transform_inl.h
+++ b/third_party/skcms/src/Transform_inl.h
@@ -249,7 +249,7 @@ SI ATTR F NS(apply_transfer_function_)(const skcms_TransferFunction* tf, F x) {
SI ATTR F NS(apply_poly_tf_)(const skcms_PolyTF* tf, F x) {
// TODO: handle x<0
return (F)if_then_else(x < tf->D, tf->C*x
- , tf->A*x*x*x + tf->B*x*x + (1 - tf->A - tf->B));
+ , tf->A*(x*x*x-1) + tf->B*(x*x-1) + 1);
}
#define apply_poly_tf NS(apply_poly_tf_)
diff --git a/third_party/skcms/version.sha1 b/third_party/skcms/version.sha1
index 613794e829..d55a1c447d 100755
--- a/third_party/skcms/version.sha1
+++ b/third_party/skcms/version.sha1
@@ -1 +1 @@
-9e351c034c2b8f6f3166efeaa65c0d4d4f4fa641 \ No newline at end of file
+48c6ca003569d11bdb00847ed2619e40af591f44 \ No newline at end of file