Coverage Report

Created: 2026-06-13 08:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libjxl/third_party/skcms/src/skcms_public.h
Line
Count
Source
1
/*
2
 * Copyright 2018 Google Inc.
3
 *
4
 * Use of this source code is governed by a BSD-style license that can be
5
 * found in the LICENSE file.
6
 */
7
8
#pragma once
9
10
// skcms_public.h contains the entire public API for skcms.
11
12
#ifndef SKCMS_API
13
    #define SKCMS_API
14
#endif
15
16
#include <stdbool.h>
17
#include <stddef.h>
18
#include <stdint.h>
19
#include <string.h>
20
21
#ifdef __cplusplus
22
extern "C" {
23
#endif
24
25
// A row-major 3x3 matrix (ie vals[row][col])
26
typedef struct skcms_Matrix3x3 {
27
    float vals[3][3];
28
} skcms_Matrix3x3;
29
30
// It is _not_ safe to alias the pointers to invert in-place.
31
SKCMS_API bool            skcms_Matrix3x3_invert(const skcms_Matrix3x3*, skcms_Matrix3x3*);
32
SKCMS_API skcms_Matrix3x3 skcms_Matrix3x3_concat(const skcms_Matrix3x3*, const skcms_Matrix3x3*);
33
34
// A row-major 3x4 matrix (ie vals[row][col])
35
typedef struct skcms_Matrix3x4 {
36
    float vals[3][4];
37
} skcms_Matrix3x4;
38
39
// A transfer function mapping encoded values to linear values,
40
// represented by this 7-parameter piecewise function:
41
//
42
//   linear = sign(encoded) *  (c*|encoded| + f)       , 0 <= |encoded| < d
43
//          = sign(encoded) * ((a*|encoded| + b)^g + e), d <= |encoded|
44
//
45
// (A simple gamma transfer function sets g to gamma and a to 1.)
46
typedef struct skcms_TransferFunction {
47
    float g, a,b,c,d,e,f;
48
} skcms_TransferFunction;
49
50
SKCMS_API float skcms_TransferFunction_eval  (const skcms_TransferFunction*, float);
51
SKCMS_API bool  skcms_TransferFunction_invert(const skcms_TransferFunction*,
52
                                              skcms_TransferFunction*);
53
54
typedef enum skcms_TFType {
55
    skcms_TFType_Invalid,
56
    skcms_TFType_sRGBish,
57
    skcms_TFType_PQish,
58
    skcms_TFType_HLGish,
59
    skcms_TFType_HLGinvish,
60
    skcms_TFType_PQ,
61
    skcms_TFType_HLG,
62
} skcms_TFType;
63
64
// Identify which kind of transfer function is encoded in an skcms_TransferFunction
65
SKCMS_API skcms_TFType skcms_TransferFunction_getType(const skcms_TransferFunction*);
66
67
// We can jam a couple alternate transfer function forms into skcms_TransferFunction,
68
// including those matching the general forms of the SMPTE ST 2084 PQ function or HLG.
69
//
70
// PQish:
71
//                              max(A + B|encoded|^C, 0)
72
//    linear = sign(encoded) * (------------------------) ^ F
73
//                                  D + E|encoded|^C
74
SKCMS_API bool skcms_TransferFunction_makePQish(skcms_TransferFunction*,
75
                                                float A, float B, float C,
76
                                                float D, float E, float F);
77
// HLGish:
78
//            { K * sign(encoded) * ( (R|encoded|)^G )          when 0   <= |encoded| <= 1/R
79
//   linear = { K * sign(encoded) * ( e^(a(|encoded|-c)) + b )  when 1/R <  |encoded|
80
SKCMS_API bool skcms_TransferFunction_makeScaledHLGish(skcms_TransferFunction*,
81
                                                       float K, float R, float G,
82
                                                       float a, float b, float c);
83
84
// Compatibility shim with K=1 for old callers.
85
static inline bool skcms_TransferFunction_makeHLGish(skcms_TransferFunction* fn,
86
                                                     float R, float G,
87
1
                                                     float a, float b, float c) {
88
1
    return skcms_TransferFunction_makeScaledHLGish(fn, 1.0f, R,G, a,b,c);
89
1
}
Unexecuted instantiation: jxl_cms.cc:skcms_TransferFunction_makeHLGish(skcms_TransferFunction*, float, float, float, float, float)
skcms.cc:skcms_TransferFunction_makeHLGish(skcms_TransferFunction*, float, float, float, float, float)
Line
Count
Source
87
1
                                                     float a, float b, float c) {
88
1
    return skcms_TransferFunction_makeScaledHLGish(fn, 1.0f, R,G, a,b,c);
89
1
}
Unexecuted instantiation: skcms_TransformBaseline.cc:skcms_TransferFunction_makeHLGish(skcms_TransferFunction*, float, float, float, float, float)
Unexecuted instantiation: skcms_TransformHsw.cc:skcms_TransferFunction_makeHLGish(skcms_TransferFunction*, float, float, float, float, float)
Unexecuted instantiation: skcms_TransformSkx.cc:skcms_TransferFunction_makeHLGish(skcms_TransferFunction*, float, float, float, float, float)
90
91
// The PQ transfer function. The function skcms_TransferFunction_eval will always evaluate to the
92
// unit PQ EOTF, which maps [0, 1] to [0, 1], regardless of the other parameters.
93
// This is stored differently from PQish transfer functions. In particular:
94
//   - the constant -5 is stored in g
95
//   - the hdr_reference_white_luminance parameter is stored in a
96
//   - all other parameters are set to 0
97
// When this is used as an SkColorSpace, the transformation to XYZD50 will be as follows:
98
//   1. Apply the unit PQ EOTF to each channel
99
//   2. Multiply by 10,000 nits
100
//   3. Divide by hdr_reference_white_luminance nits (default is 203)
101
//   4. Transform primaries to XYZD50
102
SKCMS_API void skcms_TransferFunction_makePQ(
103
    skcms_TransferFunction*,
104
    float hdr_reference_white_luminance);
105
106
// The HLG transfer function. The function skcms_TransferFunction_eval will always evaluate to the
107
// HLG inverse OETF, which maps [0, 1] to [0, 1], regardless of the other parameters.
108
// This is stored differently from PQish transfer functions. In particular:
109
//   - the constant -6 is stored in g
110
//   - the hdr_reference_white_luminance parameter is stored in a
111
//   - the peak_white_luminance parameter is stored in b
112
//   - the system_gamma parameter is stored in c
113
//   - all other parameters are set to 0
114
// When this is used as an SkColorSpace, the transformation to XYZD50 will be as follows:
115
//   1. Apply the HLG inverse OETF to each channel
116
//   2. Transform primaries to Rec2020
117
//   3. Apply the channel-mixing HLG OOTF using system_gamma (default is 1.2)
118
//   4. Multiply by peak_luminance nits (default is 1,000)
119
//   5. Divide by hdr_reference_white nits (default is 203)
120
//   6. Transform primaries to XYZD50
121
SKCMS_API void skcms_TransferFunction_makeHLG(
122
    skcms_TransferFunction*,
123
    float hdr_reference_white_luminance,
124
    float peak_luminance,
125
    float system_gamma);
126
127
// Is this an ordinary sRGB-ish transfer function, or one of the HDR forms we support?
128
SKCMS_API bool skcms_TransferFunction_isSRGBish(const skcms_TransferFunction*);
129
SKCMS_API bool skcms_TransferFunction_isPQish  (const skcms_TransferFunction*);
130
SKCMS_API bool skcms_TransferFunction_isHLGish (const skcms_TransferFunction*);
131
SKCMS_API bool skcms_TransferFunction_isPQ     (const skcms_TransferFunction*);
132
SKCMS_API bool skcms_TransferFunction_isHLG    (const skcms_TransferFunction*);
133
134
// Unified representation of 'curv' or 'para' tag data, or a 1D table from 'mft1' or 'mft2'
135
typedef union skcms_Curve {
136
    struct {
137
        // this needs to line up with alias_of_table_entries so we can tell if there are or
138
        // are not table entries. If this is 0, this struct is a parametric function,
139
        // otherwise it's a table entry.
140
        uint32_t alias_of_table_entries;
141
        skcms_TransferFunction parametric;
142
    };
143
    struct {
144
        uint32_t table_entries;
145
        const uint8_t* table_8;
146
        const uint8_t* table_16;
147
    };
148
} skcms_Curve;
149
150
// Complex transforms between device space (A) and profile connection space (B):
151
//   A2B:  device -> [ "A" curves -> CLUT ] -> [ "M" curves -> matrix ] -> "B" curves -> PCS
152
//   B2A:  device <- [ "A" curves <- CLUT ] <- [ "M" curves <- matrix ] <- "B" curves <- PCS
153
154
typedef struct skcms_A2B {
155
    // Optional: N 1D "A" curves, followed by an N-dimensional CLUT.
156
    // If input_channels == 0, these curves and CLUT are skipped,
157
    // Otherwise, input_channels must be in [1, 4].
158
    skcms_Curve     input_curves[4];
159
    const uint8_t*  grid_8;
160
    const uint8_t*  grid_16;
161
    uint32_t        input_channels;
162
    uint8_t         grid_points[4];
163
164
    // Optional: 3 1D "M" curves, followed by a color matrix.
165
    // If matrix_channels == 0, these curves and matrix are skipped,
166
    // Otherwise, matrix_channels must be 3.
167
    skcms_Curve     matrix_curves[3];
168
    skcms_Matrix3x4 matrix;
169
    uint32_t        matrix_channels;
170
171
    // Required: 3 1D "B" curves. Always present, and output_channels must be 3.
172
    uint32_t        output_channels; // list first to pack with matrix_channels
173
    skcms_Curve     output_curves[3];
174
} skcms_A2B;
175
176
typedef struct skcms_B2A {
177
    // Required: 3 1D "B" curves. Always present, and input_channels must be 3.
178
    skcms_Curve     input_curves[3];
179
    uint32_t        input_channels;
180
181
    // Optional: a color matrix, followed by 3 1D "M" curves.
182
    // If matrix_channels == 0, this matrix and these curves are skipped,
183
    // Otherwise, matrix_channels must be 3.
184
    uint32_t        matrix_channels; // list first to pack with input_channels
185
    skcms_Curve     matrix_curves[3];
186
    skcms_Matrix3x4 matrix;
187
188
    // Optional: an N-dimensional CLUT, followed by N 1D "A" curves.
189
    // If output_channels == 0, this CLUT and these curves are skipped,
190
    // Otherwise, output_channels must be in [1, 4].
191
    skcms_Curve     output_curves[4];
192
    const uint8_t*  grid_8;
193
    const uint8_t*  grid_16;
194
    uint8_t         grid_points[4];
195
    uint32_t        output_channels;
196
} skcms_B2A;
197
198
typedef struct skcms_CICP {
199
    uint8_t color_primaries;
200
    uint8_t transfer_characteristics;
201
    uint8_t matrix_coefficients;
202
    uint8_t video_full_range_flag;
203
} skcms_CICP;
204
205
typedef struct skcms_ICCProfile {
206
    const uint8_t* buffer;
207
208
    uint32_t size;
209
    uint32_t data_color_space;
210
    uint32_t pcs;
211
    uint32_t tag_count;
212
213
    // skcms_Parse() will set commonly-used fields for you when possible:
214
215
    // If we can parse red, green and blue transfer curves from the profile,
216
    // trc will be set to those three curves, and has_trc will be true.
217
    skcms_Curve            trc[3];
218
219
    // If this profile's gamut can be represented by a 3x3 transform to XYZD50,
220
    // skcms_Parse() sets toXYZD50 to that transform and has_toXYZD50 to true.
221
    skcms_Matrix3x3        toXYZD50;
222
223
    // If the profile has a valid A2B0 or A2B1 tag, skcms_Parse() sets A2B to
224
    // that data, and has_A2B to true.  skcms_ParseWithA2BPriority() does the
225
    // same following any user-provided prioritization of A2B0, A2B1, or A2B2.
226
    skcms_A2B              A2B;
227
228
    // If the profile has a valid B2A0 or B2A1 tag, skcms_Parse() sets B2A to
229
    // that data, and has_B2A to true.  skcms_ParseWithA2BPriority() does the
230
    // same following any user-provided prioritization of B2A0, B2A1, or B2A2.
231
    skcms_B2A              B2A;
232
233
    // If the profile has a valid CICP tag, skcms_Parse() sets CICP to that data,
234
    // and has_CICP to true.
235
    skcms_CICP             CICP;
236
237
    bool                   has_trc;
238
    bool                   has_toXYZD50;
239
    bool                   has_A2B;
240
    bool                   has_B2A;
241
    bool                   has_CICP;
242
} skcms_ICCProfile;
243
244
// The sRGB color profile is so commonly used that we offer a canonical skcms_ICCProfile for it.
245
SKCMS_API const skcms_ICCProfile* skcms_sRGB_profile(void);
246
// Ditto for XYZD50, the most common profile connection space.
247
SKCMS_API const skcms_ICCProfile* skcms_XYZD50_profile(void);
248
249
SKCMS_API const skcms_TransferFunction* skcms_sRGB_TransferFunction(void);
250
SKCMS_API const skcms_TransferFunction* skcms_sRGB_Inverse_TransferFunction(void);
251
SKCMS_API const skcms_TransferFunction* skcms_Identity_TransferFunction(void);
252
253
// Practical equality test for two skcms_ICCProfiles.
254
// The implementation is subject to change, but it will always try to answer
255
// "can I substitute A for B?" and "can I skip transforming from A to B?".
256
SKCMS_API bool skcms_ApproximatelyEqualProfiles(const skcms_ICCProfile* A,
257
                                                const skcms_ICCProfile* B);
258
259
// Practical test that answers: Is curve roughly the inverse of inv_tf? Typically used by passing
260
// the inverse of a known parametric transfer function (like sRGB), to determine if a particular
261
// curve is very close to sRGB.
262
SKCMS_API bool skcms_AreApproximateInverses(const skcms_Curve* curve,
263
                                            const skcms_TransferFunction* inv_tf);
264
265
// Similar to above, answering the question for all three TRC curves of the given profile. Again,
266
// passing skcms_sRGB_InverseTransferFunction as inv_tf will answer the question:
267
// "Does this profile have a transfer function that is very close to sRGB?"
268
SKCMS_API bool skcms_TRCs_AreApproximateInverse(const skcms_ICCProfile* profile,
269
                                                const skcms_TransferFunction* inv_tf);
270
271
// Parse an ICC profile and return true if possible, otherwise return false.
272
// Selects an A2B profile (if present) according to priority list (each entry 0-2).
273
// The buffer is not copied; it must remain valid as long as the skcms_ICCProfile will be used.
274
SKCMS_API bool skcms_ParseWithA2BPriority(const void*, size_t,
275
                                          const int priority[], int priorities,
276
                                          skcms_ICCProfile*);
277
278
2.76k
static inline bool skcms_Parse(const void* buf, size_t len, skcms_ICCProfile* profile) {
279
    // For continuity of existing user expectations,
280
    // prefer A2B0 (perceptual) over A2B1 (relative colormetric), and ignore A2B2 (saturation).
281
2.76k
    const int priority[] = {0,1};
282
2.76k
    return skcms_ParseWithA2BPriority(buf, len,
283
2.76k
                                      priority, sizeof(priority)/sizeof(*priority),
284
2.76k
                                      profile);
285
2.76k
}
jxl_cms.cc:skcms_Parse(void const*, unsigned long, skcms_ICCProfile*)
Line
Count
Source
278
2.76k
static inline bool skcms_Parse(const void* buf, size_t len, skcms_ICCProfile* profile) {
279
    // For continuity of existing user expectations,
280
    // prefer A2B0 (perceptual) over A2B1 (relative colormetric), and ignore A2B2 (saturation).
281
2.76k
    const int priority[] = {0,1};
282
2.76k
    return skcms_ParseWithA2BPriority(buf, len,
283
2.76k
                                      priority, sizeof(priority)/sizeof(*priority),
284
2.76k
                                      profile);
285
2.76k
}
Unexecuted instantiation: skcms.cc:skcms_Parse(void const*, unsigned long, skcms_ICCProfile*)
Unexecuted instantiation: skcms_TransformBaseline.cc:skcms_Parse(void const*, unsigned long, skcms_ICCProfile*)
Unexecuted instantiation: skcms_TransformHsw.cc:skcms_Parse(void const*, unsigned long, skcms_ICCProfile*)
Unexecuted instantiation: skcms_TransformSkx.cc:skcms_Parse(void const*, unsigned long, skcms_ICCProfile*)
286
287
SKCMS_API bool skcms_ApproximateCurve(const skcms_Curve* curve,
288
                                      skcms_TransferFunction* approx,
289
                                      float* max_error);
290
291
SKCMS_API bool skcms_GetCHAD(const skcms_ICCProfile*, skcms_Matrix3x3*);
292
SKCMS_API bool skcms_GetWTPT(const skcms_ICCProfile*, float xyz[3]);
293
294
// Returns the number of channels of input data that are expected on the "A" side of the profile.
295
// This is useful for image codecs, where the image data and the accompanying profile might have
296
// conflicting data shapes. In some cases, the result is unclear or invalid. In that case, the
297
// function will return a negative value to signal an error.
298
SKCMS_API int skcms_GetInputChannelCount(const skcms_ICCProfile*);
299
300
// These are common ICC signature values
301
enum {
302
    // common data_color_space values
303
    skcms_Signature_CMYK = 0x434D594B,
304
    skcms_Signature_Gray = 0x47524159,
305
    skcms_Signature_RGB  = 0x52474220,
306
307
    // pcs (or data_color_space)
308
    skcms_Signature_Lab  = 0x4C616220,
309
    skcms_Signature_XYZ  = 0x58595A20,
310
311
    // other, less common data_color_space values
312
    skcms_Signature_CIELUV = 0x4C757620,
313
    skcms_Signature_YCbCr  = 0x59436272,
314
    skcms_Signature_CIEYxy = 0x59787920,
315
    skcms_Signature_HSV    = 0x48535620,
316
    skcms_Signature_HLS    = 0x484C5320,
317
    skcms_Signature_CMY    = 0x434D5920,
318
    skcms_Signature_2CLR   = 0x32434C52,
319
    skcms_Signature_3CLR   = 0x33434C52,
320
    skcms_Signature_4CLR   = 0x34434C52,
321
    skcms_Signature_5CLR   = 0x35434C52,
322
    skcms_Signature_6CLR   = 0x36434C52,
323
    skcms_Signature_7CLR   = 0x37434C52,
324
    skcms_Signature_8CLR   = 0x38434C52,
325
    skcms_Signature_9CLR   = 0x39434C52,
326
    skcms_Signature_10CLR  = 0x41434C52,
327
    skcms_Signature_11CLR  = 0x42434C52,
328
    skcms_Signature_12CLR  = 0x43434C52,
329
    skcms_Signature_13CLR  = 0x44434C52,
330
    skcms_Signature_14CLR  = 0x45434C52,
331
    skcms_Signature_15CLR  = 0x46434C52,
332
};
333
334
typedef enum skcms_PixelFormat {
335
    skcms_PixelFormat_A_8,
336
    skcms_PixelFormat_A_8_,
337
    skcms_PixelFormat_G_8,
338
    skcms_PixelFormat_G_8_,
339
    skcms_PixelFormat_GA_88,  // Grayscale with alpha.
340
    skcms_PixelFormat_GA_88_,
341
342
    skcms_PixelFormat_RGB_565,
343
    skcms_PixelFormat_BGR_565,
344
345
    skcms_PixelFormat_ABGR_4444,
346
    skcms_PixelFormat_ARGB_4444,
347
348
    skcms_PixelFormat_RGB_888,
349
    skcms_PixelFormat_BGR_888,
350
    skcms_PixelFormat_RGBA_8888,
351
    skcms_PixelFormat_BGRA_8888,
352
    skcms_PixelFormat_RGBA_8888_sRGB,  // Automatic sRGB encoding / decoding.
353
    skcms_PixelFormat_BGRA_8888_sRGB,  // (Generally used with linear transfer functions.)
354
355
    skcms_PixelFormat_RGBA_1010102,
356
    skcms_PixelFormat_BGRA_1010102,
357
358
    skcms_PixelFormat_RGB_161616LE,  // Little-endian.  Pointers must be 16-bit aligned.
359
    skcms_PixelFormat_BGR_161616LE,
360
    skcms_PixelFormat_RGBA_16161616LE,
361
    skcms_PixelFormat_BGRA_16161616LE,
362
363
    skcms_PixelFormat_RGB_161616BE,  // Big-endian.  Pointers must be 16-bit aligned.
364
    skcms_PixelFormat_BGR_161616BE,
365
    skcms_PixelFormat_RGBA_16161616BE,
366
    skcms_PixelFormat_BGRA_16161616BE,
367
368
    skcms_PixelFormat_RGB_hhh_Norm,  // 1-5-10 half-precision float in [0,1]
369
    skcms_PixelFormat_BGR_hhh_Norm,  // Pointers must be 16-bit aligned.
370
    skcms_PixelFormat_RGBA_hhhh_Norm,
371
    skcms_PixelFormat_BGRA_hhhh_Norm,
372
373
    skcms_PixelFormat_RGB_hhh,  // 1-5-10 half-precision float.
374
    skcms_PixelFormat_BGR_hhh,  // Pointers must be 16-bit aligned.
375
    skcms_PixelFormat_RGBA_hhhh,
376
    skcms_PixelFormat_BGRA_hhhh,
377
378
    skcms_PixelFormat_RGB_fff,  // 1-8-23 single-precision float (the normal kind).
379
    skcms_PixelFormat_BGR_fff,  // Pointers must be 32-bit aligned.
380
    skcms_PixelFormat_RGBA_ffff,
381
    skcms_PixelFormat_BGRA_ffff,
382
383
    skcms_PixelFormat_RGB_101010x_XR,    // Note: This is located here to signal no clamping.
384
    skcms_PixelFormat_BGR_101010x_XR,    // Compatible with MTLPixelFormatBGR10_XR.
385
    skcms_PixelFormat_RGBA_10101010_XR,  // Note: This is located here to signal no clamping.
386
    skcms_PixelFormat_BGRA_10101010_XR,  // Compatible with MTLPixelFormatBGRA10_XR.
387
} skcms_PixelFormat;
388
389
// We always store any alpha channel linearly.  In the chart below, tf-1() is the inverse
390
// transfer function for the given color profile (applying the transfer function linearizes).
391
392
// We treat opaque as a strong requirement, not just a performance hint: we will ignore
393
// any source alpha and treat it as 1.0, and will make sure that any destination alpha
394
// channel is filled with the equivalent of 1.0.
395
396
// We used to offer multiple types of premultiplication, but now just one, PremulAsEncoded.
397
// This is the premul you're probably used to working with.
398
399
typedef enum skcms_AlphaFormat {
400
    skcms_AlphaFormat_Opaque,          // alpha is always opaque
401
                                       //   tf-1(r),   tf-1(g),   tf-1(b),   1.0
402
    skcms_AlphaFormat_Unpremul,        // alpha and color are unassociated
403
                                       //   tf-1(r),   tf-1(g),   tf-1(b),   a
404
    skcms_AlphaFormat_PremulAsEncoded, // premultiplied while encoded
405
                                       //   tf-1(r)*a, tf-1(g)*a, tf-1(b)*a, a
406
} skcms_AlphaFormat;
407
408
// Convert npixels pixels from src format and color profile to dst format and color profile
409
// and return true, otherwise return false.  It is safe to alias dst == src if dstFmt == srcFmt.
410
SKCMS_API bool skcms_Transform(const void*             src,
411
                               skcms_PixelFormat       srcFmt,
412
                               skcms_AlphaFormat       srcAlpha,
413
                               const skcms_ICCProfile* srcProfile,
414
                               void*                   dst,
415
                               skcms_PixelFormat       dstFmt,
416
                               skcms_AlphaFormat       dstAlpha,
417
                               const skcms_ICCProfile* dstProfile,
418
                               size_t                  npixels);
419
420
// If profile can be used as a destination in skcms_Transform, return true. Otherwise, attempt to
421
// rewrite it with approximations where reasonable. If successful, return true. If no reasonable
422
// approximation exists, leave the profile unchanged and return false.
423
SKCMS_API bool skcms_MakeUsableAsDestination(skcms_ICCProfile* profile);
424
425
// If profile can be used as a destination with a single parametric transfer function (ie for
426
// rasterization), return true. Otherwise, attempt to rewrite it with approximations where
427
// reasonable. If successful, return true. If no reasonable approximation exists, leave the
428
// profile unchanged and return false.
429
SKCMS_API bool skcms_MakeUsableAsDestinationWithSingleCurve(skcms_ICCProfile* profile);
430
431
// Returns a matrix to adapt XYZ color from given the whitepoint to D50.
432
SKCMS_API bool skcms_AdaptToXYZD50(float wx, float wy,
433
                                   skcms_Matrix3x3* toXYZD50);
434
435
// Returns a matrix to convert RGB color into XYZ adapted to D50, given the
436
// primaries and whitepoint of the RGB model.
437
SKCMS_API bool skcms_PrimariesToXYZD50(float rx, float ry,
438
                                       float gx, float gy,
439
                                       float bx, float by,
440
                                       float wx, float wy,
441
                                       skcms_Matrix3x3* toXYZD50);
442
443
// Call before your first call to skcms_Transform() to skip runtime CPU detection.
444
SKCMS_API void skcms_DisableRuntimeCPUDetection(void);
445
446
// Utilities for programmatically constructing profiles
447
0
static inline void skcms_Init(skcms_ICCProfile* p) {
448
0
    memset(p, 0, sizeof(*p));
449
0
    p->data_color_space = skcms_Signature_RGB;
450
0
    p->pcs = skcms_Signature_XYZ;
451
0
}
Unexecuted instantiation: jxl_cms.cc:skcms_Init(skcms_ICCProfile*)
Unexecuted instantiation: skcms.cc:skcms_Init(skcms_ICCProfile*)
Unexecuted instantiation: skcms_TransformBaseline.cc:skcms_Init(skcms_ICCProfile*)
Unexecuted instantiation: skcms_TransformHsw.cc:skcms_Init(skcms_ICCProfile*)
Unexecuted instantiation: skcms_TransformSkx.cc:skcms_Init(skcms_ICCProfile*)
452
453
static inline void skcms_SetTransferFunction(skcms_ICCProfile* p,
454
0
                                             const skcms_TransferFunction* tf) {
455
0
    p->has_trc = true;
456
0
    for (int i = 0; i < 3; ++i) {
457
0
        p->trc[i].table_entries = 0;
458
0
        p->trc[i].parametric = *tf;
459
0
    }
460
0
}
Unexecuted instantiation: jxl_cms.cc:skcms_SetTransferFunction(skcms_ICCProfile*, skcms_TransferFunction const*)
Unexecuted instantiation: skcms.cc:skcms_SetTransferFunction(skcms_ICCProfile*, skcms_TransferFunction const*)
Unexecuted instantiation: skcms_TransformBaseline.cc:skcms_SetTransferFunction(skcms_ICCProfile*, skcms_TransferFunction const*)
Unexecuted instantiation: skcms_TransformHsw.cc:skcms_SetTransferFunction(skcms_ICCProfile*, skcms_TransferFunction const*)
Unexecuted instantiation: skcms_TransformSkx.cc:skcms_SetTransferFunction(skcms_ICCProfile*, skcms_TransferFunction const*)
461
462
0
static inline void skcms_SetXYZD50(skcms_ICCProfile* p, const skcms_Matrix3x3* m) {
463
0
    p->has_toXYZD50 = true;
464
0
    p->toXYZD50 = *m;
465
0
}
Unexecuted instantiation: jxl_cms.cc:skcms_SetXYZD50(skcms_ICCProfile*, skcms_Matrix3x3 const*)
Unexecuted instantiation: skcms.cc:skcms_SetXYZD50(skcms_ICCProfile*, skcms_Matrix3x3 const*)
Unexecuted instantiation: skcms_TransformBaseline.cc:skcms_SetXYZD50(skcms_ICCProfile*, skcms_Matrix3x3 const*)
Unexecuted instantiation: skcms_TransformHsw.cc:skcms_SetXYZD50(skcms_ICCProfile*, skcms_Matrix3x3 const*)
Unexecuted instantiation: skcms_TransformSkx.cc:skcms_SetXYZD50(skcms_ICCProfile*, skcms_Matrix3x3 const*)
466
467
#ifdef __cplusplus
468
}
469
#endif