diff options
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/skcms/skcms.gni | 1 | ||||
-rw-r--r-- | third_party/skcms/src/ICCProfile.c | 31 | ||||
-rw-r--r-- | third_party/skcms/src/ICCProfile.h | 12 | ||||
-rwxr-xr-x | third_party/skcms/version.sha1 | 2 |
4 files changed, 45 insertions, 1 deletions
diff --git a/third_party/skcms/skcms.gni b/third_party/skcms/skcms.gni index 8577de3465..f2004ad0a1 100644 --- a/third_party/skcms/skcms.gni +++ b/third_party/skcms/skcms.gni @@ -7,6 +7,7 @@ skcms_sources = [ "src/Curve.c", "src/Curve.h", "src/ICCProfile.c", + "src/ICCProfile.h", "src/LinearAlgebra.c", "src/LinearAlgebra.h", "src/Macros.h", diff --git a/third_party/skcms/src/ICCProfile.c b/third_party/skcms/src/ICCProfile.c index ca28824b9f..1f25d1611f 100644 --- a/third_party/skcms/src/ICCProfile.c +++ b/third_party/skcms/src/ICCProfile.c @@ -6,6 +6,7 @@ */ #include "../skcms.h" +#include "ICCProfile.h" #include "LinearAlgebra.h" #include "Macros.h" #include "PortableMath.h" @@ -35,11 +36,14 @@ enum { skcms_Signature_A2B1 = 0x41324231, skcms_Signature_mAB = 0x6D414220, + skcms_Signature_CHAD = 0x63686164, + // Type signatures skcms_Signature_curv = 0x63757276, skcms_Signature_mft1 = 0x6D667431, skcms_Signature_mft2 = 0x6D667432, skcms_Signature_para = 0x70617261, + skcms_Signature_sf32 = 0x73663332, // XYZ is also a PCS signature, so it's defined in skcms.h // skcms_Signature_XYZ = 0x58595A20, }; @@ -108,6 +112,33 @@ static const tag_Layout* get_tag_table(const skcms_ICCProfile* profile) { return (const tag_Layout*)(profile->buffer + SAFE_SIZEOF(header_Layout)); } +// s15Fixed16ArrayType is technically variable sized, holding N values. However, the only valid +// use of the type is for the CHAD tag that stores exactly nine values. +typedef struct { + uint8_t type [ 4]; + uint8_t reserved [ 4]; + uint8_t values [36]; +} sf32_Layout; + +bool skcms_GetCHAD(const skcms_ICCProfile* profile, skcms_Matrix3x3* m) { + skcms_ICCTag tag; + if (!skcms_GetTagBySignature(profile, skcms_Signature_CHAD, &tag)) { + return false; + } + + if (tag.type != skcms_Signature_sf32 || tag.size < SAFE_SIZEOF(sf32_Layout)) { + return false; + } + + const sf32_Layout* sf32Tag = (const sf32_Layout*)tag.buf; + const uint8_t* values = sf32Tag->values; + for (int r = 0; r < 3; ++r) + for (int c = 0; c < 3; ++c, values += 4) { + m->vals[r][c] = read_big_fixed(values); + } + return true; +} + // XYZType is technically variable sized, holding N XYZ triples. However, the only valid uses of // the type are for tags/data that store exactly one triple. typedef struct { diff --git a/third_party/skcms/src/ICCProfile.h b/third_party/skcms/src/ICCProfile.h new file mode 100644 index 0000000000..39967a1cb2 --- /dev/null +++ b/third_party/skcms/src/ICCProfile.h @@ -0,0 +1,12 @@ +/* + * 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 <stdbool.h> + +bool skcms_GetCHAD(const skcms_ICCProfile* profile, skcms_Matrix3x3* m); diff --git a/third_party/skcms/version.sha1 b/third_party/skcms/version.sha1 index cfc5d9610e..b56792eab7 100755 --- a/third_party/skcms/version.sha1 +++ b/third_party/skcms/version.sha1 @@ -1 +1 @@ -5bfec7723e0fefd2a257e8be4710282cd033eeb2
\ No newline at end of file +b01dbd249b2e6cfc44e4e9831223c89b6009434f
\ No newline at end of file |