82#include <gdk/gdkkeysyms.h>
90#define DT_IOP_COLOR_ICC_LEN 512
131 return _(
"output color profile");
138 "using color profiles to remap RGB values"),
140 _(
"linear or non-linear, RGB or Lab, display-referred"),
141 _(
"defined by profile"),
142 _(
"non-linear, RGB or Lab, display-referred"));
200 void *new_params,
const int new_version)
202#define DT_IOP_COLOR_ICC_LEN_V4 100
211 if((old_version == 2 || old_version == 3) && new_version == 5)
213 typedef struct dt_iop_colorout_params_v3_t
219 char softproof_enabled;
222 } dt_iop_colorout_params_v3_t;
225 dt_iop_colorout_params_v3_t *o = (dt_iop_colorout_params_v3_t *)old_params;
229 if(!strcmp(o->iccprofile,
"sRGB"))
231 else if(!strcmp(o->iccprofile,
"linear_rec709_rgb") || !strcmp(o->iccprofile,
"linear_rgb"))
233 else if(!strcmp(o->iccprofile,
"linear_rec2020_rgb"))
235 else if(!strcmp(o->iccprofile,
"adobergb"))
237 else if(!strcmp(o->iccprofile,
"X profile"))
242 g_strlcpy(
n->filename, o->iccprofile,
sizeof(
n->filename));
245 n->intent = o->intent;
249 if(old_version == 4 && new_version == 5)
251 typedef struct dt_iop_colorout_params_v4_t
256 } dt_iop_colorout_params_v4_t;
259 dt_iop_colorout_params_v4_t *o = (dt_iop_colorout_params_v4_t *)old_params;
264 g_strlcpy(
n->filename, o->filename,
sizeof(
n->filename));
265 n->intent = o->intent;
271#undef DT_IOP_COLOR_ICC_LEN_V4
276 const int program = 2;
297 cl_mem dev_m = NULL, dev_r = NULL, dev_g = NULL, dev_b = NULL, dev_coeffs = NULL;
300 const int devid = pipe->
devid;
306 size_t origin[] = { 0, 0, 0 };
307 size_t region[] = { roi_in->
width, roi_in->
height, 1 };
309 if(err != CL_SUCCESS)
goto error;
352 if(err != CL_SUCCESS)
goto error;
399 const int force_lcms2 =
dt_conf_get_bool(
"plugins/lighttable/export/force_lcms2");
402 gchar *out_filename = NULL;
406 const char *work_filename =
"";
427 d->conversion = NULL;
431 d->conversion_id = 0;
450 p->type = icc_input->
type;
451 g_strlcpy(
p->filename, icc_input->
filename,
sizeof(
p->filename));
464 if(icc_input)
p->intent = icc_input->
intent;
468 out_filename =
p->filename;
469 out_intent =
p->intent;
494 work_type = work_profile->
type;
495 work_filename = work_profile->
filename;
518 dt_control_log(_(
"missing output profile has been replaced by sRGB!"));
519 fprintf(stderr,
"missing output profile `%s' has been replaced by sRGB!\n",
527 .filename = work_filename ? work_filename :
"",
530 .filename = out_filename,
532 .resolved = image_output };
535 .role = output_role };
542 "[colorout] could not resolve pipeline work profile, assuming input is already in output profile\n");
550 dt_control_log(_(
"missing softproof profile has been replaced by sRGB!"));
551 fprintf(stderr,
"missing softproof profile `%s' has been replaced by sRGB!\n",
567 softproofing ? &proof : NULL, out_intent,
flags);
574 dt_control_log(_(
"unsupported output profile has been replaced by sRGB!"));
575 fprintf(stderr,
"unsupported output profile `%s' has been replaced by sRGB!\n",
582 softproofing ? &proof : NULL, out_intent,
flags);
596 d->conversion = conversion;
631 module->hide_enable_button = 1;
632 module->default_enabled = 1;
644 gtk_label_set_markup(GTK_LABEL(self->
gui->
widget),_(
"Convert images to the display or export RGB color space. "
645 "The color profile is set in the export module or in the display preferences. "));
646 gtk_widget_set_halign(self->
gui->
widget, GTK_ALIGN_START);
647 gtk_label_set_xalign (GTK_LABEL(self->
gui->
widget), 0.0f);
static void error(char *msg)
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
void commit_params(struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void init(dt_iop_module_t *module)
const char ** description(struct dt_iop_module_t *self)
static dt_iop_colorspace_type_t _colorout_input_format_cst(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe)
__DT_CLONE_TARGETS__ int process(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid)
void init_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void output_format(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_buffer_dsc_t *dsc)
#define DT_IOP_COLOR_ICC_LEN
void gui_init(dt_iop_module_t *self)
static dt_iop_colorspace_type_t _colorout_output_format_cst(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe)
void cleanup_global(dt_iop_module_so_t *module)
int default_colorspace(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
void input_format(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_buffer_dsc_t *dsc)
dt_iop_colorout_gui_data_t dummy
void cleanup_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void init_global(dt_iop_module_so_t *module)
int process_cl(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out)
int legacy_params(dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
#define DT_IOP_COLOR_ICC_LEN_V4
gboolean runtime_data_hash(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
void dt_colorspaces_free_image_profile(struct dt_colorspaces_color_profile_t *profile)
Release a profile container owned by an image, closing the LCMS2 handle inside it if and only if the ...
gboolean dt_colorspaces_profile_exists(const dt_colorspaces_profile_role_t role, const dt_colorspaces_color_profile_type_t type, const char *const filename)
Is this identity registered for this direction?
const char * dt_colorspaces_get_name(dt_colorspaces_color_profile_type_t type, const char *filename)
Printable name for a profile identity, without touching the profile list.
void dt_colorprofiles_get_settings(dt_colorprofiles_settings_t *const out)
Copy the current settings into caller-provided storage, under one lock.
The colour-profile module's API: which profiles exist, and how to apply one.
int dt_conf_get_bool(const char *name)
void dt_control_log(const char *msg,...)
gboolean dt_colorspaces_conversion_matrix(const dt_colorspaces_conversion_t *const conversion, dt_colormatrix_t matrix)
The composed source-to-target matrix, row-major.
const float * dt_colorspaces_conversion_target_curve(const dt_colorspaces_conversion_t *const conversion, const int channel)
One channel of the target encoding curves. Same contract as dt_colorspaces_conversion_source_curve().
gboolean dt_colorspaces_conversion_is_matrix(const dt_colorspaces_conversion_t *const conversion)
Whether the conversion reduced to matrices and curves, and can therefore be run by a device kernel at...
const float * dt_colorspaces_conversion_target_coeffs(const dt_colorspaces_conversion_t *const conversion)
The same fits for the target curves. Same contract.
uint64_t dt_colorspaces_conversion_identity(const dt_colorspaces_conversion_t *const conversion)
What this conversion IS, as a number: equal for two conversions that render the same pixels,...
void dt_colorspaces_free_conversion(dt_colorspaces_conversion_t **conversion)
Release a conversion and NULL the caller's pointer.
dt_colorspaces_conversion_t * dt_colorspaces_prepare_conversion(const dt_colorspaces_endpoint_t *const from, const dt_colorspaces_endpoint_t *const to, const dt_colorspaces_endpoint_t *const clip, const dt_colorspaces_endpoint_t *const proof, const dt_iop_color_intent_t intent, const dt_colorspaces_conversion_flags_t flags)
Build a conversion from from to to. The expensive call; do it once.
void dt_colorspaces_apply_conversion(const dt_colorspaces_conversion_t *const conversion, const float *const in, float *const out, const size_t width, const size_t height)
Convert a 4-channel float image through a prepared conversion.
A PREPARED CONVERSION: everything needed to turn pixels in one colour space into pixels in another,...
dt_colorspaces_conversion_flags_t
What the caller wants, and what the caller can consume.
@ DT_CONVERSION_FORCE_LCMS2
Never take the matrix path, even when both profiles reduce to matrices. Backs the plugins/lighttable/...
@ DT_CONVERSION_GAMUTCHECK
Mark out-of-gamut pixels rather than merely proofing them. Requires a soft-proof endpoint,...
@ DT_CONVERSION_TARGET_CURVES
The caller can apply the TARGET profile's encoding curves after the matrix. Without this,...
void dt_ioppr_get_work_profile_type(struct dt_develop_t *dev, dt_colorspaces_color_profile_type_t *profile_type, const char **profile_filename)
dt_iop_order_iccprofile_info_t * dt_ioppr_get_pipe_work_profile_info(const struct dt_dev_pixelpipe_t *pipe)
dt_iop_order_iccprofile_info_t * dt_ioppr_set_pipe_output_profile_info(struct dt_develop_t *dev, struct dt_dev_pixelpipe_t *pipe, const dt_colorspaces_color_profile_type_t type, const char *filename, const int intent)
dt_iop_order_iccprofile_info_t * dt_ioppr_get_pipe_input_profile_info(const struct dt_dev_pixelpipe_t *pipe)
@ DT_DEV_PIXELPIPE_DISPLAY_MASK
static void dt_iop_image_copy_by_size(float *const __restrict__ out, const float *const __restrict__ in, const size_t width, const size_t height, const size_t ch)
struct dt_colorspaces_color_profile_t * dt_image_get_embedded_output_profile(const int32_t imgid, dt_colorspaces_color_profile_type_t *type)
Resolve the ICC profile embedded in an image's own file, into an opaque container.
void dt_iop_default_init(dt_iop_module_t *module)
const char ** dt_iop_set_description(dt_iop_module_t *module, const char *main_text, const char *purpose, const char *input, const char *process, const char *output)
void dt_iop_set_cache_bypass(dt_iop_module_t *module, gboolean state)
@ IOP_FLAGS_NO_HISTORY_STACK
#define IOP_GUI_ALLOC(module)
_lib_location_type_t type
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
Print to stdout when thread is enabled, prefixed with seconds since startup.
#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]
static void pack_3xSSE_to_3x4(const dt_colormatrix_t input, float output[12])
#define dt_free_align(ptr)
Release memory from dt_alloc_align() and set ptr to NULL.
static void * dt_calloc_align(size_t size)
dt_alloc_align() followed by a zero fill.
#define DT_IS_ALIGNED(x)
Promise the compiler that x is already cacheline-aligned, and return it.
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE)
DT_MODULE() for a module whose params struct is introspected.
int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes)
int dt_opencl_create_kernel(const int prog, const char *name)
void * dt_opencl_copy_host_to_device_constant(const int devid, const size_t size, void *host)
int dt_opencl_enqueue_copy_image(const int devid, cl_mem src, cl_mem dst, size_t *orig_src, size_t *orig_dst, size_t *region)
void dt_opencl_free_kernel(const int kernel)
int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size, const void *arg)
void * dt_opencl_copy_host_to_device(const int devid, void *host, const int width, const int height, const int bpp)
void dt_opencl_release_mem_object(cl_mem mem)
@ DT_DEV_PIXELPIPE_THUMBNAIL
@ DT_DEV_PIXELPIPE_EXPORT
dt_iop_color_intent_t
ICC rendering intent, as stored in iop params and in conf.
@ DT_INTENT_LAST
Count of real intents, and the codebase's "unset" marker – never a user choice.
dt_colorspaces_color_profile_type_t
@ DT_COLORSPACE_FILE
A user ICC file on disk; the only type whose filename is meaningful.
@ DT_COLORSPACE_DISPLAY
The monitor profile – the one list entry that mutates after init.
@ DT_COLORSPACE_SRGB
sRGB – registered TWICE, and the two entries are not interchangeable.
@ DT_COLORSPACE_NONE
No profile / "take it from the image settings". Never matches a list entry.
@ DT_COLORSPACE_LIN_REC2020
@ DT_COLORSPACE_LIN_REC709
dt_colorspaces_profile_role_t
Which use a profile is eligible for – the mandatory filter on every lookup and enumeration.
@ DT_PROFILE_ROLE_OUTPUT
Listed in the output/export-profile combo (colorout, export).
@ DT_PROFILE_ROLE_MONITOR
Eligible for the monitor-profile menu.
@ DT_PROFILE_ROLE_ANY
All four roles, in registration order.
dt_colorspaces_color_mode_t
What the output transform is being asked to show: the picture, or a proof of it.
unsigned __int64 uint64_t
Consistent snapshot of the display and soft-proofing settings.
char softproof_filename[DT_IOP_COLOR_ICC_LEN]
only meaningful for DT_COLORSPACE_FILE
dt_colorspaces_color_profile_type_t softproof_type
proofing target identity
char display_filename[DT_IOP_COLOR_ICC_LEN]
only meaningful for DT_COLORSPACE_FILE
dt_colorspaces_color_profile_type_t display_type
monitor profile identity
dt_iop_color_intent_t display_intent
rendering intent to the monitor
dt_colorspaces_color_mode_t mode
NORMAL / SOFTPROOF / GAMUTCHECK.
One registered profile: its identity, its LCMS handle, and where it sits in each combo box.
One end of a conversion: a profile, named either by identity or by handing over one this module alrea...
const struct dt_colorspaces_color_profile_t * resolved
An already-resolved, image-owned profile, or NULL to resolve type / filename from the registered list...
dt_colorspaces_color_profile_type_t type
Profile identity. Ignored when resolved is set, except for tracing.
const char * filename
ICC file name, or "" / NULL for a built-in. Ignored when resolved is set.
struct dt_iop_module_t *void * data
dt_colorspaces_color_profile_type_t icc_type
dt_iop_color_intent_t icc_intent
dt_dev_pixelpipe_type_t type
struct dt_develop_t * dev
dt_iop_buffer_type_t datatype
dt_colorspaces_color_mode_t mode
dt_colorspaces_color_profile_type_t type
dt_colorspaces_conversion_t * conversion
dt_iop_color_intent_t intent
dt_colorspaces_color_profile_type_t type
dt_iop_global_data_t * data
struct dt_iop_module_gui_t * gui
struct dt_develop_t * dev
dt_iop_global_data_t * global_data
A profile reduced to the arithmetic the pixel loop can run: two matrices and six tone-curve LUTs,...
dt_iop_color_intent_t intent
Rendering intent, passed to cmsCreateTransform on the lcms2 fallback only. The matrix path ignores it...
dt_colorspaces_color_profile_type_t type
Profile identity, half of the memo key. DT_COLORSPACE_NONE means "unset" and makes every apply functi...
char filename[DT_IOP_COLOR_ICC_LEN]
ICC file name, the other half of the memo key; "" for every built-in. Compared with strcmp,...
Region of interest passed through the pixelpipe.
#define __DT_CLONE_TARGETS__
Telling the user something happened.