aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/skcms/src
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-05-17 18:42:40 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-17 19:22:43 +0000
commit8c29c14f54984e7848fc860571a7521889e6f012 (patch)
treede63c80088958a6e7192b9b98d2e4cfca80699c1 /third_party/skcms/src
parent12997b051e70920bda63713bcd115ebda25b4ac6 (diff)
Roll skia/third_party/skcms 3f444c5..3e527c6 (1 commits)
https://skia.googlesource.com/skcms.git/+log/3f444c5..3e527c6 2018-05-17 brianosman@google.com Added skcms_AreApproximateInverses(Curve, TransferFunction) 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. CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel TBR=herb@google.com Change-Id: Ia10c2fe8dc17972b8e5570819ff6ac197f4d77f8 Reviewed-on: https://skia-review.googlesource.com/128984 Commit-Queue: skcms-skia-autoroll <skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com> Reviewed-by: skcms-skia-autoroll <skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
Diffstat (limited to 'third_party/skcms/src')
-rw-r--r--third_party/skcms/src/Curve.c16
-rw-r--r--third_party/skcms/src/Curve.h2
-rw-r--r--third_party/skcms/src/ICCProfile.c26
-rw-r--r--third_party/skcms/src/TransferFunction.c7
-rw-r--r--third_party/skcms/src/Transform.c14
5 files changed, 46 insertions, 19 deletions
diff --git a/third_party/skcms/src/Curve.c b/third_party/skcms/src/Curve.c
index 2b5a042500..a1a3c62a3d 100644
--- a/third_party/skcms/src/Curve.c
+++ b/third_party/skcms/src/Curve.c
@@ -43,3 +43,19 @@ float skcms_eval_curve(const skcms_Curve* curve, float x) {
}
return l + (h-l)*t;
}
+
+float skcms_MaxRoundtripError(const skcms_Curve* curve, const skcms_TransferFunction* inv_tf) {
+ uint32_t N = curve->table_entries > 256 ? curve->table_entries : 256;
+ const float dx = 1.0f / (N - 1);
+ float err = 0;
+ for (uint32_t i = 0; i < N; i++) {
+ float x = i * dx,
+ y = skcms_eval_curve(curve, x);
+ err = fmaxf_(err, fabsf_(x - skcms_TransferFunction_eval(inv_tf, y)));
+ }
+ return err;
+}
+
+bool skcms_AreApproximateInverses(const skcms_Curve* curve, const skcms_TransferFunction* inv_tf) {
+ return skcms_MaxRoundtripError(curve, inv_tf) < (1/512.0f);
+}
diff --git a/third_party/skcms/src/Curve.h b/third_party/skcms/src/Curve.h
index af01d53b2f..1316562b56 100644
--- a/third_party/skcms/src/Curve.h
+++ b/third_party/skcms/src/Curve.h
@@ -11,3 +11,5 @@
// Evaluate an skcms_Curve at x.
float skcms_eval_curve(const skcms_Curve*, float x);
+
+float skcms_MaxRoundtripError(const skcms_Curve* curve, const skcms_TransferFunction* inv_tf);
diff --git a/third_party/skcms/src/ICCProfile.c b/third_party/skcms/src/ICCProfile.c
index 324a34cc06..ca28824b9f 100644
--- a/third_party/skcms/src/ICCProfile.c
+++ b/third_party/skcms/src/ICCProfile.c
@@ -863,6 +863,21 @@ const skcms_ICCProfile* skcms_XYZD50_profile() {
return &XYZD50_profile;
}
+const skcms_TransferFunction* skcms_sRGB_TransferFunction() {
+ return &skcms_sRGB_profile()->trc[0].parametric;
+}
+
+const skcms_TransferFunction* skcms_sRGB_Inverse_TransferFunction() {
+ static const skcms_TransferFunction sRGB_inv =
+ { (float)(1/2.4), 1.137119f, 0, 12.92f, 0.0031308f, -0.055f, 0 };
+ return &sRGB_inv;
+}
+
+const skcms_TransferFunction* skcms_Identity_TransferFunction() {
+ static const skcms_TransferFunction identity = {1,1,0,0,0,0,0};
+ return &identity;
+}
+
const uint8_t skcms_252_random_bytes[] = {
8, 179, 128, 204, 253, 38, 134, 184, 68, 102, 32, 138, 99, 39, 169, 215,
119, 26, 3, 223, 95, 239, 52, 132, 114, 74, 81, 234, 97, 116, 244, 205, 30,
@@ -928,6 +943,17 @@ bool skcms_ApproximatelyEqualProfiles(const skcms_ICCProfile* A, const skcms_ICC
return true;
}
+bool skcms_TRCs_AreApproximateInverse(const skcms_ICCProfile* profile,
+ const skcms_TransferFunction* inv_tf) {
+ if (!profile || !profile->has_trc) {
+ return false;
+ }
+
+ return skcms_AreApproximateInverses(&profile->trc[0], inv_tf) &&
+ skcms_AreApproximateInverses(&profile->trc[1], inv_tf) &&
+ skcms_AreApproximateInverses(&profile->trc[2], inv_tf);
+}
+
static bool is_zero_to_one(float x) {
return 0 <= x && x <= 1;
}
diff --git a/third_party/skcms/src/TransferFunction.c b/third_party/skcms/src/TransferFunction.c
index a27bd13bd2..8f8fb36c9d 100644
--- a/third_party/skcms/src/TransferFunction.c
+++ b/third_party/skcms/src/TransferFunction.c
@@ -351,12 +351,7 @@ bool skcms_ApproximateCurve(const skcms_Curve* curve,
continue;
}
- float err = 0;
- for (int i = 0; i < N; i++) {
- float x = i * dx,
- y = skcms_eval_curve(curve, x);
- err = fmaxf_(err, fabsf_(x - skcms_TransferFunction_eval(&tf_inv, y)));
- }
+ float err = skcms_MaxRoundtripError(curve, &tf_inv);
if (*max_error > err) {
*max_error = err;
*approx = tf;
diff --git a/third_party/skcms/src/Transform.c b/third_party/skcms/src/Transform.c
index 791671e6f9..9bf66118f2 100644
--- a/third_party/skcms/src/Transform.c
+++ b/third_party/skcms/src/Transform.c
@@ -605,18 +605,6 @@ static void assert_usable_as_destination(const skcms_ICCProfile* profile) {
#endif
}
-static float max_roundtrip_error(const skcms_TransferFunction* inv_tf, const skcms_Curve* curve) {
- int N = curve->table_entries ? (int)curve->table_entries : 256;
- const float x_scale = 1.0f / (N - 1);
- float err = 0;
- for (int i = 0; i < N; i++) {
- float x = i * x_scale,
- y = skcms_eval_curve(curve, x);
- err = fmaxf_(err, fabsf_(x - skcms_TransferFunction_eval(inv_tf, y)));
- }
- return err;
-}
-
bool skcms_MakeUsableAsDestination(skcms_ICCProfile* profile) {
skcms_Matrix3x3 fromXYZD50;
if (!profile->has_trc || !profile->has_toXYZD50
@@ -664,7 +652,7 @@ bool skcms_MakeUsableAsDestinationWithSingleCurve(skcms_ICCProfile* profile) {
float err = 0;
for (int j = 0; j < 3; ++j) {
- err = fmaxf_(err, max_roundtrip_error(&inv, &profile->trc[j]));
+ err = fmaxf_(err, skcms_MaxRoundtripError(&profile->trc[j], &inv));
}
if (min_max_error > err) {
min_max_error = err;