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 typedef struct skcms_ICCTag { 25 uint32_t signature; 26 uint32_t type; 27 uint32_t size; 28 const uint8_t* buf; 29 } skcms_ICCTag; 30 31 void skcms_GetTagByIndex (const skcms_ICCProfile*, uint32_t idx, skcms_ICCTag*); 32 bool skcms_GetTagBySignature(const skcms_ICCProfile*, uint32_t sig, skcms_ICCTag*); 33 34 float skcms_MaxRoundtripError(const skcms_Curve* curve, const skcms_TransferFunction* inv_tf); 35 36 // 252 of a random shuffle of all possible bytes. 37 // 252 is evenly divisible by 3 and 4. Only 192, 10, 241, and 43 are missing. 38 // Used for ICC profile equivalence testing. 39 extern const uint8_t skcms_252_random_bytes[252]; 40 41 // ~~~~ Portable Math ~~~~ floorf_(float x)42 static inline float floorf_(float x) { 43 float roundtrip = (float)((int)x); 44 return roundtrip > x ? roundtrip - 1 : roundtrip; 45 } fabsf_(float x)46 static inline float fabsf_(float x) { return x < 0 ? -x : x; } 47 float powf_(float, float); 48 49 // ~~~~ Does this pixel format need a palette pointer to be usable? ~~~~ needs_palette(skcms_PixelFormat fmt)50 static inline bool needs_palette(skcms_PixelFormat fmt) { 51 return (fmt >> 1) == (skcms_PixelFormat_RGBA_8888_Palette8 >> 1); 52 } 53 54 #ifdef __cplusplus 55 } 56 #endif 57