-
Notifications
You must be signed in to change notification settings - Fork 2
/
skcms_internal.h
55 lines (42 loc) · 1.52 KB
/
skcms_internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* 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
// skcms_internal.h contains APIs shared by skcms' internals and its test tools.
// Please don't use this header from outside the skcms repo.
#include "skcms.h" // NO_G3_REWRITE
#include <stdbool.h>
#include <stdint.h>
namespace gfx {
#ifdef __cplusplus
extern "C" {
#endif
// ~~~~ General Helper Macros ~~~~
#define ARRAY_COUNT(arr) (int)(sizeof((arr)) / sizeof(*(arr)))
typedef struct skcms_ICCTag {
uint32_t signature;
uint32_t type;
uint32_t size;
const uint8_t* buf;
} skcms_ICCTag;
void skcms_GetTagByIndex (const skcms_ICCProfile*, uint32_t idx, skcms_ICCTag*);
bool skcms_GetTagBySignature(const skcms_ICCProfile*, uint32_t sig, skcms_ICCTag*);
float skcms_MaxRoundtripError(const skcms_Curve* curve, const skcms_TransferFunction* inv_tf);
// 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.
// Used for ICC profile equivalence testing.
extern const uint8_t skcms_252_random_bytes[252];
// ~~~~ Portable Math ~~~~
static inline float floorf_(float x) {
float roundtrip = (float)((int)x);
return roundtrip > x ? roundtrip - 1 : roundtrip;
}
static inline float fabsf_(float x) { return x < 0 ? -x : x; }
float powf_(float, float);
#ifdef __cplusplus
}
#endif
} // namespace gfx