diff options
-rw-r--r-- | third_party/skcms/skcms.h | 2 | ||||
-rw-r--r-- | third_party/skcms/src/ICCProfile.c | 100 | ||||
-rw-r--r-- | third_party/skcms/src/RandomBytes.h | 14 |
3 files changed, 68 insertions, 48 deletions
diff --git a/third_party/skcms/skcms.h b/third_party/skcms/skcms.h index 4d0ffc9add..39e3cbcdb7 100644 --- a/third_party/skcms/skcms.h +++ b/third_party/skcms/skcms.h @@ -101,6 +101,8 @@ typedef struct skcms_ICCProfile { // The sRGB color profile is so commonly used that we offer a canonical skcms_ICCProfile for it. extern const skcms_ICCProfile skcms_sRGB_profile; +// Ditto for XYZD50, the most common profile connection space. +extern const skcms_ICCProfile skcms_XYZD50_profile; // Practical equality test for two skcms_ICCProfiles. // The implementation is subject to change, but it will always try to answer diff --git a/third_party/skcms/src/ICCProfile.c b/third_party/skcms/src/ICCProfile.c index 42c942b58f..c9b7065524 100644 --- a/third_party/skcms/src/ICCProfile.c +++ b/third_party/skcms/src/ICCProfile.c @@ -8,6 +8,7 @@ #include "../skcms.h" #include "Macros.h" #include "PortableMath.h" +#include "RandomBytes.h" #include "TransferFunction.h" #include <assert.h> #include <limits.h> @@ -802,6 +803,49 @@ const skcms_ICCProfile skcms_sRGB_profile = { }}, }; +const skcms_ICCProfile skcms_XYZD50_profile = { + .buffer = NULL, + .size = 0, + .tag_count = 0, + + .data_color_space = make_signature('R', 'G', 'B', ' '), + .pcs = make_signature('X', 'Y', 'Z', ' '), + .has_trc = true, + .has_toXYZD50 = true, + .has_A2B = false, + + .trc = { + {{0, {1,1,0,0,0,0,0}}}, + {{0, {1,1,0,0,0,0,0}}}, + {{0, {1,1,0,0,0,0,0}}}, + }, + + .toXYZD50 = {{ + {1,0,0}, + {0,1,0}, + {0,0,1}, + }}, +}; + +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, + 154, 173, 12, 51, 159, 122, 153, 61, 226, 236, 178, 229, 55, 181, 220, 191, + 194, 160, 126, 168, 82, 131, 18, 180, 245, 163, 22, 246, 69, 235, 252, 57, + 108, 14, 6, 152, 240, 255, 171, 242, 20, 227, 177, 238, 96, 85, 16, 211, + 70, 200, 149, 155, 146, 127, 145, 100, 151, 109, 19, 165, 208, 195, 164, + 137, 254, 182, 248, 64, 201, 45, 209, 5, 147, 207, 210, 113, 162, 83, 225, + 9, 31, 15, 231, 115, 37, 58, 53, 24, 49, 197, 56, 120, 172, 48, 21, 214, + 129, 111, 11, 50, 187, 196, 34, 60, 103, 71, 144, 47, 203, 77, 80, 232, + 140, 222, 250, 206, 166, 247, 139, 249, 221, 72, 106, 27, 199, 117, 54, + 219, 135, 118, 40, 79, 41, 251, 46, 93, 212, 92, 233, 148, 28, 121, 63, + 123, 158, 105, 59, 29, 42, 143, 23, 0, 107, 176, 87, 104, 183, 156, 193, + 189, 90, 188, 65, 190, 17, 198, 7, 186, 161, 1, 124, 78, 125, 170, 133, + 174, 218, 67, 157, 75, 101, 89, 217, 62, 33, 141, 228, 25, 35, 91, 230, 4, + 2, 13, 73, 86, 167, 237, 84, 243, 44, 185, 66, 130, 110, 150, 142, 216, 88, + 112, 36, 224, 136, 202, 76, 94, 98, 175, 213 +}; + bool skcms_ApproximatelyEqualProfiles(const skcms_ICCProfile* A, const skcms_ICCProfile* B) { // For now this is the essentially the same strategy we use in test_only.c // for our skcms_Transform() smoke tests: @@ -812,48 +856,6 @@ bool skcms_ApproximatelyEqualProfiles(const skcms_ICCProfile* A, const skcms_ICC // Here are 252 of a random shuffle of all possible bytes. // 252 is evenly divisible by 3 and 4. Only 192, 10, 241, and 43 are missing. - static const uint8_t k252_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, - 154, 173, 12, 51, 159, 122, 153, 61, 226, 236, 178, 229, 55, 181, 220, 191, - 194, 160, 126, 168, 82, 131, 18, 180, 245, 163, 22, 246, 69, 235, 252, 57, - 108, 14, 6, 152, 240, 255, 171, 242, 20, 227, 177, 238, 96, 85, 16, 211, - 70, 200, 149, 155, 146, 127, 145, 100, 151, 109, 19, 165, 208, 195, 164, - 137, 254, 182, 248, 64, 201, 45, 209, 5, 147, 207, 210, 113, 162, 83, 225, - 9, 31, 15, 231, 115, 37, 58, 53, 24, 49, 197, 56, 120, 172, 48, 21, 214, - 129, 111, 11, 50, 187, 196, 34, 60, 103, 71, 144, 47, 203, 77, 80, 232, - 140, 222, 250, 206, 166, 247, 139, 249, 221, 72, 106, 27, 199, 117, 54, - 219, 135, 118, 40, 79, 41, 251, 46, 93, 212, 92, 233, 148, 28, 121, 63, - 123, 158, 105, 59, 29, 42, 143, 23, 0, 107, 176, 87, 104, 183, 156, 193, - 189, 90, 188, 65, 190, 17, 198, 7, 186, 161, 1, 124, 78, 125, 170, 133, - 174, 218, 67, 157, 75, 101, 89, 217, 62, 33, 141, 228, 25, 35, 91, 230, 4, - 2, 13, 73, 86, 167, 237, 84, 243, 44, 185, 66, 130, 110, 150, 142, 216, 88, - 112, 36, 224, 136, 202, 76, 94, 98, 175, 213 - }; - - static const skcms_ICCProfile kXYZD50 = { - .buffer = NULL, - .size = 0, - .tag_count = 0, - - .data_color_space = make_signature('R', 'G', 'B', ' '), - .pcs = make_signature('X', 'Y', 'Z', ' '), - .has_trc = true, - .has_toXYZD50 = true, - .has_A2B = false, - - .trc = { - {{0, {1,1,0,0,0,0,0}}}, - {{0, {1,1,0,0,0,0,0}}}, - {{0, {1,1,0,0,0,0,0}}}, - }, - - .toXYZD50 = {{ - {1,0,0}, - {0,1,0}, - {0,0,1}, - }}, - }; if (A->data_color_space != B->data_color_space) { return false; @@ -869,14 +871,16 @@ bool skcms_ApproximatelyEqualProfiles(const skcms_ICCProfile* A, const skcms_ICC uint8_t dstA[252], dstB[252]; - if (!skcms_Transform(k252_bytes, fmt, skcms_AlphaFormat_Unpremul, A, - dstA, skcms_PixelFormat_RGB_888, skcms_AlphaFormat_Unpremul, &kXYZD50, - npixels)) { + if (!skcms_Transform( + skcms_252_random_bytes, fmt, skcms_AlphaFormat_Unpremul, A, + dstA, skcms_PixelFormat_RGB_888, skcms_AlphaFormat_Unpremul, &skcms_XYZD50_profile, + npixels)) { return false; } - if (!skcms_Transform(k252_bytes, fmt, skcms_AlphaFormat_Unpremul, B, - dstB, skcms_PixelFormat_RGB_888, skcms_AlphaFormat_Unpremul, &kXYZD50, - npixels)) { + if (!skcms_Transform( + skcms_252_random_bytes, fmt, skcms_AlphaFormat_Unpremul, B, + dstB, skcms_PixelFormat_RGB_888, skcms_AlphaFormat_Unpremul, &skcms_XYZD50_profile, + npixels)) { return false; } diff --git a/third_party/skcms/src/RandomBytes.h b/third_party/skcms/src/RandomBytes.h new file mode 100644 index 0000000000..a6191a5e96 --- /dev/null +++ b/third_party/skcms/src/RandomBytes.h @@ -0,0 +1,14 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#pragma once + +#include <stdint.h> + +// 252 of a random shuffle of all possible bytes. +// 252 is evenly divisible by 3 and 4. Only 192, 10, 241, and 43 are missing. +extern const uint8_t skcms_252_random_bytes[252]; |