diff --git a/third_party/skcms/skcms.h b/third_party/skcms/skcms.h index 36ac4a0fbc..1cfb5b644b 100644 --- a/third_party/skcms/skcms.h +++ b/third_party/skcms/skcms.h @@ -209,18 +209,6 @@ SKCMS_API bool skcms_Transform(const void* src, const skcms_ICCProfile* dstProfile, size_t npixels); -// If profile cannot be used as a destination profile in skcms_Transform(), -// rewrite it with approximations where reasonable or by pulling from fallback -// (e.g. skcms_sRGB_profile) where not. -SKCMS_API void skcms_EnsureUsableAsDestination(skcms_ICCProfile* profile, - const skcms_ICCProfile* fallback); - -// If profile cannot be used as a destination profile with a single parametric transfer function, -// (ie for rasterization), rewrite it with approximations where reasonable or by pulling from -// fallback (e.g. skcms_sRGB_profile) where not. -SKCMS_API void skcms_EnsureUsableAsDestinationWithSingleCurve(skcms_ICCProfile* profile, - const skcms_ICCProfile* fallback); - // If profile can be used as a destination in skcms_Transform, return true. Otherwise, attempt to // rewrite it with approximations where reasonable. If successful, return true. If no reasonable // approximation exists, leave the profile unchanged and return false. @@ -228,7 +216,7 @@ SKCMS_API bool skcms_MakeUsableAsDestination(skcms_ICCProfile* profile); // If profile can be used as a destination with a single parametric transfer function (ie for // rasterization), return true. Otherwise, attempt to rewrite it with approximations where -// reasonable. If successful, return true. If not reasonable approximation exists, leave the +// reasonable. If successful, return true. If no reasonable approximation exists, leave the // profile unchanged and return false. SKCMS_API bool skcms_MakeUsableAsDestinationWithSingleCurve(skcms_ICCProfile* profile); diff --git a/third_party/skcms/src/Transform.c b/third_party/skcms/src/Transform.c index ae26e71804..33b8438655 100644 --- a/third_party/skcms/src/Transform.c +++ b/third_party/skcms/src/Transform.c @@ -622,39 +622,6 @@ static void assert_usable_as_destination(const skcms_ICCProfile* profile) { #endif } -void skcms_EnsureUsableAsDestination(skcms_ICCProfile* profile, const skcms_ICCProfile* fallback) { - assert_usable_as_destination(fallback); - - skcms_Matrix3x3 fromXYZD50; - if (!profile->has_toXYZD50 || !skcms_Matrix3x3_invert(&profile->toXYZD50, &fromXYZD50)) { - profile->toXYZD50 = fallback->toXYZD50; - } - - for (int i = 0; i < 3; i++) { - skcms_TransferFunction inv; - if (profile->has_trc && profile->trc[i].table_entries == 0 - && skcms_TransferFunction_invert(&profile->trc[i].parametric, &inv)) { - continue; - } - - // Note there's a little gap here that we could fill by allowing fitting - // parametric curves to non-invertible parametric curves. - - float max_error; - skcms_TransferFunction tf = fallback->trc[i].parametric; - // Parametric curves from skcms_ApproximateCurve() are guaranteed to be invertible. - // If approximation fails, tf will still hold fallback's parametric TRC curve. - (void)skcms_ApproximateCurve(&profile->trc[i], &tf, &max_error); - profile->trc[i].table_entries = 0; - profile->trc[i].parametric = tf; - } - - profile->has_toXYZD50 = true; - profile->has_trc = true; - - assert_usable_as_destination(profile); -} - 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); @@ -667,37 +634,6 @@ static float max_roundtrip_error(const skcms_TransferFunction* inv_tf, const skc return err; } -void skcms_EnsureUsableAsDestinationWithSingleCurve(skcms_ICCProfile* profile, - const skcms_ICCProfile* fallback) { - // Operate on a copy of profile, so we can choose the best TF for the original curves - skcms_ICCProfile result = *profile; - skcms_EnsureUsableAsDestination(&result, fallback); - - int best_tf = 0; - float min_max_error = INFINITY_; - const skcms_ICCProfile* ref = profile->has_trc ? profile : fallback; - for (int i = 0; i < 3; i++) { - skcms_TransferFunction inv; - skcms_TransferFunction_invert(&result.trc[i].parametric, &inv); - - float err = 0; - for (int j = 0; j < 3; ++j) { - err = fmaxf_(err, max_roundtrip_error(&inv, &ref->trc[j])); - } - if (min_max_error > err) { - min_max_error = err; - best_tf = i; - } - } - - for (int i = 0; i < 3; i++) { - result.trc[i].parametric = result.trc[best_tf].parametric; - } - - *profile = result; - assert_usable_as_destination(profile); -} - bool skcms_MakeUsableAsDestination(skcms_ICCProfile* profile) { skcms_Matrix3x3 fromXYZD50; if (!profile->has_trc || !profile->has_toXYZD50 diff --git a/third_party/skcms/version.sha1 b/third_party/skcms/version.sha1 index d75996c241..e8af40ad8b 100755 --- a/third_party/skcms/version.sha1 +++ b/third_party/skcms/version.sha1 @@ -1 +1 @@ -baef14ce357a67a20251276475241f574cc5e2ee \ No newline at end of file +aee343ca3bc90ac49f2c410ed3578efad8012710 \ No newline at end of file