30#ifndef DT_COLORPROFILES_IOP_PROFILE_H
31#define DT_COLORPROFILES_IOP_PROFILE_H
373 const char *message);
502 const char *message);
544 return l1 * (1.0f -
f) +
l2 *
f;
594#pragma omp declare simd \
595 aligned(rgb_in, rgb_out, unbounded_coeffs:16) \
597 uniform(lut, unbounded_coeffs)
603 for(
int c = 0; c < 3; c++)
630#pragma omp declare simd \
632 aligned(matrix_in:64) \
633 aligned(unbounded_coeffs_in:16) \
635 uniform(matrix_in, lut_in, unbounded_coeffs_in)
639 const float unbounded_coeffs_in[3][3],
640 const int lutsize,
const int nonlinearlut)
651 luminance = matrix_in[1][0] *
rgb[0] + matrix_in[1][1] *
rgb[1] + matrix_in[1][2] *
rgb[2];
673#pragma omp declare simd \
674 aligned(rgb, xyz:16) \
675 aligned(matrix_in_transposed:64) \
676 aligned(unbounded_coeffs_in:16) \
678 uniform(matrix_in_transposed, lut_in, unbounded_coeffs_in)
682 const float unbounded_coeffs_in[3][3],
683 const int lutsize,
const int nonlinearlut)
710#pragma omp declare simd \
711 aligned(lab, rgb:16) \
712 aligned(matrix_out_transposed:64) \
713 aligned(unbounded_coeffs_out:16) \
714 aligned(lut_out:64) \
715 uniform(matrix_out_transposed, lut_out, unbounded_coeffs_out)
719 const float unbounded_coeffs_out[3][3],
720 const int lutsize,
const int nonlinearlut)
749#pragma omp declare simd \
750 aligned(rgb, lab:16) \
751 aligned(matrix_in_transposed:64) \
752 aligned(unbounded_coeffs_in:16) \
754 uniform(matrix_in_transposed, lut_in, unbounded_coeffs_in)
758 const float unbounded_coeffs_in[3][3],
759 const int lutsize,
const int nonlinearlut)
798 return lab[0] * .01f;
int dt_colorspaces_apply_profile_cl(const char *const op_name, const char *const instance_name, const int devid, cl_mem dev_img_in, cl_mem dev_img_out, const int width, const int height, const int cst_from, const int cst_to, int *converted_cst, const dt_iop_order_iccprofile_info_t *const profile_info)
OpenCL counterpart of dt_colorspaces_apply_profile(), same contract.
static dt_aligned_pixel_t rgb_out
dt_iop_order_iccprofile_info_t * dt_colorspaces_add_profile(const dt_colorspaces_color_profile_type_t profile_type, const char *profile_filename, const int intent)
Find-or-build the derived matrix/LUT data for a profile identity, memoised.
void dt_ioppr_cleanup_profile_info(dt_iop_order_iccprofile_info_t **profile_info)
Release a profile info: its tone-curve LUTs, the struct itself, and the caller's pointer – must be ca...
void dt_colorspaces_init_cl_global(void)
Compile the colorspace kernels. Called once by common/opencl.c at device init.
void dt_ioppr_transform_image_colorspace_rgb(const float *const image_in, float *const image_out, const int width, const int height, const dt_iop_order_iccprofile_info_t *const profile_info_from, const dt_iop_order_iccprofile_info_t *const profile_info_to, const char *message)
Convert a 4-channel float buffer between two RGB profiles.
void dt_ioppr_transform_matrix(const char *op, const char *multi_name, const float *const image_in, float *const image_out, const int width, const int height, const dt_iop_colorspace_type_t cst_from, const dt_iop_colorspace_type_t cst_to, dt_iop_colorspace_type_t *converted_cst, const dt_iop_order_iccprofile_info_t *const profile_info)
The vectorised branch of dt_colorspaces_apply_profile(): RGB <-> Lab by matrix and tone-curve LUT.
int dt_ioppr_init_unbounded_coeffs(float *lutr, float *lutg, float *lutb, float *unbounded_coeffsr, float *unbounded_coeffsg, float *unbounded_coeffsb, const int lutsize)
Fit the power-law continuation of three tone curves past white.
const float *const const float coeff[3]
void dt_ioppr_get_profile_info_cl(const dt_iop_order_iccprofile_info_t *const profile_info, dt_colorspaces_iccprofile_info_cl_t *profile_info_cl)
sets profile_info_cl using profile_info, to be used as a parameter when calling opencl.
void dt_colorspaces_apply_profile(const char *const op_name, const char *const instance_name, const float *const image_in, float *const image_out, const int width, const int height, const int cst_from, const int cst_to, int *converted_cst, const dt_iop_order_iccprofile_info_t *const profile_info)
Convert a 4-channel float buffer between RGB and Lab through one profile.
void dt_colorspaces_free_cl_global(void)
Release the kernels and the struct from dt_colorspaces_init_cl_global(). NULL-safe.
void dt_ioppr_free_iccprofile_params_cl(dt_colorspaces_iccprofile_info_cl_t **_profile_info_cl, cl_float **_profile_lut_cl, cl_mem *_dev_profile_info, cl_mem *_dev_profile_lut)
free parameters build with the previous function.
static dt_aligned_pixel_t float *const const float unbounded_coeffs[3][3]
void dt_colorspaces_invalidate_display_profile_memo(void)
Drop the memoised DT_COLORSPACE_DISPLAY entry, whose source profile this module replaces on a monitor...
cl_float * dt_ioppr_get_trc_cl(const dt_iop_order_iccprofile_info_t *const profile_info)
returns the profile_info trc, to be used as a parameter when calling opencl.
const float const int lutsize
void dt_ioppr_clear_lut_curves(dt_iop_order_iccprofile_info_t *profile_info)
Mark all six tone curves linear, by writing -1.0 into entry 0 of each.
int dt_ioppr_transform_image_colorspace_rgb_cl(const int devid, cl_mem dev_img_in, cl_mem dev_img_out, const int width, const int height, const dt_iop_order_iccprofile_info_t *const profile_info_from, const dt_iop_order_iccprofile_info_t *const profile_info_to, const char *message)
OpenCL counterpart of dt_ioppr_transform_image_colorspace_rgb().
cl_int dt_ioppr_build_iccprofile_params_cl(const dt_iop_order_iccprofile_info_t *const profile_info, const int devid, dt_colorspaces_iccprofile_info_cl_t **_profile_info_cl, cl_float **_profile_lut_cl, cl_mem *_dev_profile_info, cl_mem *_dev_profile_lut)
build the required parameters for a kernel that uses a profile info.
void dt_colorspaces_flush_profile_memo(void)
Drop every memoised entry. Called by dt_colorprofiles_cleanup().
void dt_ioppr_transform_lcms2(const char *op, const char *multi_name, const float *const image_in, float *const image_out, const int width, const int height, const dt_iop_colorspace_type_t cst_from, const dt_iop_colorspace_type_t cst_to, dt_iop_colorspace_type_t *converted_cst, const dt_iop_order_iccprofile_info_t *const profile_info)
The lcms2 branch of dt_colorspaces_apply_profile(): RGB <-> Lab via cmsDoTransform.
void dt_ioppr_init_profile_info(dt_iop_order_iccprofile_info_t *profile_info, const int lutsize)
Put a freshly allocated dt_iop_order_iccprofile_info_t into its empty state – must be called before u...
static dt_aligned_pixel_t rgb
dt_apply_transposed_color_matrix(XYZ, xyz_to_srgb_matrix_transposed, sRGB)
float *const restrict luminance
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
float DT_ALIGNED_ARRAY dt_colormatrix_t[4][4]
#define __OMP_DECLARE_SIMD__(...)
The colour-profile vocabulary, and nothing else.
dt_iop_color_intent_t
ICC rendering intent, as stored in iop params and in conf.
#define DT_IOP_COLOR_ICC_LEN
Size of every ICC filename buffer that crosses a module boundary.
dt_colorspaces_color_profile_type_t
DT_ALIGNED_PIXEL float dt_aligned_pixel_t[4]
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Apply one channel's tone curve to each of the three colour channels, or pass the channel through unto...
The three colorspace kernels, compiled once and held by common/opencl.c.
int kernel_colorspaces_transform_rgb_matrix_to_rgb
int kernel_colorspaces_transform_lab_to_rgb_matrix
int kernel_colorspaces_transform_rgb_matrix_to_lab
The device-side view of a dt_iop_order_iccprofile_info_t: the scalar fields only.
float unbounded_coeffs_out[3][3]
float unbounded_coeffs_in[3][3]
A profile reduced to the arithmetic the pixel loop can run: two matrices and six tone-curve LUTs,...
int nonlinearlut
Non-zero when the profile has tone curves at all; tested as a boolean everywhere, but it is really th...
int lutsize
Entry count of each of the six LUTs. Always 65536 in practice: both callers of dt_ioppr_init_profile_...
dt_iop_color_intent_t intent
Rendering intent, passed to cmsCreateTransform on the lcms2 fallback only. The matrix path ignores it...
dt_colormatrix_t matrix_out_transposed
float grey
Luminance of 18.42% grey through this profile, used by the tone-mapping modules to place middle grey....
dt_colorspaces_color_profile_type_t type
Profile identity, half of the memo key. DT_COLORSPACE_NONE means "unset" and makes every apply functi...
float * lut_out[3]
Per-channel linear -> encoded tone curve, same convention as lut_in.
dt_colormatrix_t matrix_out
XYZ (D50) -> RGB, row-major; the inverse of matrix_in.
float * lut_in[3]
Per-channel encoded -> linear tone curve, lutsize entries each, sampled over [0,1]....
char filename[DT_IOP_COLOR_ICC_LEN]
ICC file name, the other half of the memo key; "" for every built-in. Compared with strcmp,...
float unbounded_coeffs_in[3][3] DT_ALIGNED_PIXEL
Power-law fit {a, b, c} of lut_in past 1.0, evaluated by eval_exp() as b * (a*x)^c....
dt_colormatrix_t matrix_in_transposed
dt_colormatrix_t matrix_in
RGB -> XYZ (D50), row-major. matrix_in[1][*] is the luminance row. NaN in [0][0] marks the whole prof...
float unbounded_coeffs_out[3][3] DT_ALIGNED_PIXEL
Same fit for lut_out.