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_internal.h contains APIs shared by skcms' internals and its test tools.
11 // Please don't use this header from outside the skcms repo.
12 
13 #include "skcms.h"
14 #include <stdbool.h>
15 #include <stdint.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 // ~~~~ General Helper Macros ~~~~
22     #define ARRAY_COUNT(arr) (int)(sizeof((arr)) / sizeof(*(arr)))
23 
24 // ~~~~ skcms_ICCProfile ~~~~
25     bool skcms_GetCHAD(const skcms_ICCProfile* profile, skcms_Matrix3x3* m);
26 
27     // 252 of a random shuffle of all possible bytes.
28     // 252 is evenly divisible by 3 and 4.  Only 192, 10, 241, and 43 are missing.
29     // Used for ICC profile equivalence testing.
30     extern const uint8_t skcms_252_random_bytes[252];
31 
32 // ~~~~ Portable Math ~~~~
floorf_(float x)33     static inline float floorf_(float x) {
34         float roundtrip = (float)((int)x);
35         return roundtrip > x ? roundtrip - 1 : roundtrip;
36     }
fabsf_(float x)37     static inline float fabsf_(float x) { return x < 0 ? -x : x; }
38     float powf_(float, float);
39 
40 // ~~~~ Does this pixel format need a palette pointer to be usable? ~~~~
needs_palette(skcms_PixelFormat fmt)41     static inline bool needs_palette(skcms_PixelFormat fmt) {
42         return (fmt >> 1) == (skcms_PixelFormat_RGBA_8888_Palette8 >> 1);
43     }
44 
45 #ifdef __cplusplus
46 }
47 #endif
48