1 /* 2 * Copyright 2018 Google LLC 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 #include <stddef.h> 11 #include <stdint.h> 12 13 // skcms_Transform.h contains skcms implementation details. 14 // Please don't use this header from outside the skcms repo. 15 16 namespace skcms_private { 17 18 /** All transform ops */ 19 20 #define SKCMS_WORK_OPS(M) \ 21 M(load_a8) \ 22 M(load_g8) \ 23 M(load_4444) \ 24 M(load_565) \ 25 M(load_888) \ 26 M(load_8888) \ 27 M(load_1010102) \ 28 M(load_101010x_XR) \ 29 M(load_10101010_XR) \ 30 M(load_161616LE) \ 31 M(load_16161616LE) \ 32 M(load_161616BE) \ 33 M(load_16161616BE) \ 34 M(load_hhh) \ 35 M(load_hhhh) \ 36 M(load_fff) \ 37 M(load_ffff) \ 38 \ 39 M(swap_rb) \ 40 M(clamp) \ 41 M(invert) \ 42 M(force_opaque) \ 43 M(premul) \ 44 M(unpremul) \ 45 M(matrix_3x3) \ 46 M(matrix_3x4) \ 47 \ 48 M(lab_to_xyz) \ 49 M(xyz_to_lab) \ 50 \ 51 M(gamma_r) \ 52 M(gamma_g) \ 53 M(gamma_b) \ 54 M(gamma_a) \ 55 M(gamma_rgb) \ 56 \ 57 M(tf_r) \ 58 M(tf_g) \ 59 M(tf_b) \ 60 M(tf_a) \ 61 M(tf_rgb) \ 62 \ 63 M(pq_r) \ 64 M(pq_g) \ 65 M(pq_b) \ 66 M(pq_a) \ 67 M(pq_rgb) \ 68 \ 69 M(hlg_r) \ 70 M(hlg_g) \ 71 M(hlg_b) \ 72 M(hlg_a) \ 73 M(hlg_rgb) \ 74 \ 75 M(hlginv_r) \ 76 M(hlginv_g) \ 77 M(hlginv_b) \ 78 M(hlginv_a) \ 79 M(hlginv_rgb) \ 80 \ 81 M(table_r) \ 82 M(table_g) \ 83 M(table_b) \ 84 M(table_a) \ 85 \ 86 M(clut_A2B) \ 87 M(clut_B2A) 88 89 #define SKCMS_STORE_OPS(M) \ 90 M(store_a8) \ 91 M(store_g8) \ 92 M(store_4444) \ 93 M(store_565) \ 94 M(store_888) \ 95 M(store_8888) \ 96 M(store_1010102) \ 97 M(store_161616LE) \ 98 M(store_16161616LE) \ 99 M(store_161616BE) \ 100 M(store_16161616BE) \ 101 M(store_101010x_XR) \ 102 M(store_hhh) \ 103 M(store_hhhh) \ 104 M(store_fff) \ 105 M(store_ffff) 106 107 enum class Op : int { 108 #define M(op) op, 109 SKCMS_WORK_OPS(M) 110 SKCMS_STORE_OPS(M) 111 #undef M 112 }; 113 114 /** Constants */ 115 116 #if defined(__clang__) || defined(__GNUC__) 117 static constexpr float INFINITY_ = __builtin_inff(); 118 #else 119 static const union { 120 uint32_t bits; 121 float f; 122 } inf_ = { 0x7f800000 }; 123 #define INFINITY_ inf_.f 124 #endif 125 126 /** Vector type */ 127 128 #if defined(__clang__) 129 template <int N, typename T> using Vec = T __attribute__((ext_vector_type(N))); 130 #elif defined(__GNUC__) 131 // Unfortunately, GCC does not allow us to omit the struct. This will not compile: 132 // template <int N, typename T> using Vec = T __attribute__((vector_size(N*sizeof(T)))); 133 template <int N, typename T> struct VecHelper { 134 typedef T __attribute__((vector_size(N * sizeof(T)))) V; 135 }; 136 template <int N, typename T> using Vec = typename VecHelper<N, T>::V; 137 #endif 138 139 /** Interface */ 140 141 namespace baseline { 142 143 void run_program(const Op* program, const void** contexts, ptrdiff_t programSize, 144 const char* src, char* dst, int n, 145 const size_t src_bpp, const size_t dst_bpp); 146 147 } 148 namespace hsw { 149 150 void run_program(const Op* program, const void** contexts, ptrdiff_t programSize, 151 const char* src, char* dst, int n, 152 const size_t src_bpp, const size_t dst_bpp); 153 154 } 155 namespace skx { 156 157 void run_program(const Op* program, const void** contexts, ptrdiff_t programSize, 158 const char* src, char* dst, int n, 159 const size_t src_bpp, const size_t dst_bpp); 160 161 } 162 } // namespace skcms_private 163