54 const int n_lut,
const int lutsize)
64 const float f = ft -
t;
65 const int tx =
t & 0xff;
66 const int ty = (
t >> 8) + n_lut * 256;
73 const int2 p1 = (int2)(tx, ty);
74 const int2 p2 = (int2)(0, ty + 1);
84static inline float lookup(read_only image2d_t
lut,
const float x)
86 const int xi =
clamp((
int)(
x * 0x10000ul), 0, 0xffff);
87 const int2
p = (int2)((xi & 0xff), (xi >> 8));
99 const int xi =
clamp((
int)(
x * 0x10000ul), 0, 0xffff);
100 const int2
p = (int2)((xi & 0xff), (xi >> 8));
103 else return a[1] * native_powr(
x*a[0], a[2]);
110 read_only image2d_t
lut)
113 const float G =
lerp_lookup_unbounded(rgb_in.y,
lut, profile_info->unbounded_coeffs_in[1], 1, profile_info->lutsize);
115 const float a = rgb_in.w;
116 return (float4)(
R, G,
B, a);
121 read_only image2d_t
lut)
124 const float G =
lerp_lookup_unbounded(rgb_in.y,
lut, profile_info->unbounded_coeffs_out[1], 4, profile_info->lutsize);
126 const float a = rgb_in.w;
127 return (float4)(
R, G,
B, a);
132 constant
const float *
const matrix, read_only image2d_t
lut)
136 if(profile_info->nonlinearlut)
151 constant
const float *
const matrix, read_only image2d_t
lut)
154 if(profile_info->nonlinearlut)
168 const float4 coeffs = { 0.2225045f, 0.7168786f, 0.0606169f, 0.0f };
169 return dot(
rgb, coeffs);
static const dt_aligned_pixel_simd_t const dt_adaptation_t const float p
static float4 apply_trc_in(const float4 rgb_in, constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info, read_only image2d_t lut)
static float4 rgb_matrix_to_xyz(const float4 rgb, constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info, constant const float *const matrix, read_only image2d_t lut)
static float lookup(read_only image2d_t lut, const float x)
struct dt_colorspaces_iccprofile_info_cl_t dt_colorspaces_iccprofile_info_cl_t
static float lookup_unbounded(read_only image2d_t lut, const float x, constant const float *const a)
static float dt_camera_rgb_luminance(const float4 rgb)
static float get_rgb_matrix_luminance(const float4 rgb, constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info, constant const float *const matrix, read_only image2d_t lut)
static float lerp_lookup_unbounded(const float x, read_only image2d_t lut, constant const float *const unbounded_coeffs, const int n_lut, const int lutsize)
static float4 apply_trc_out(const float4 rgb_in, constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info, read_only image2d_t lut)
static float4 matrix_product(const float4 xyz, constant const float *const matrix)
static dt_aligned_pixel_t rgb
const dt_aligned_pixel_t f
const dt_colormatrix_t dt_aligned_pixel_t out
const dt_colormatrix_t matrix
constant sampler_t sampleri
constant sampler_t samplerf
const float const int lutsize
static dt_aligned_pixel_t float *const const float unbounded_coeffs[3][3]
float *const restrict luminance
static float clamp(float f, float m, float M)
Shared drawlayer runtime helpers used across module/runtime files.
float unbounded_coeffs_out[3][3]
float unbounded_coeffs_in[3][3]