101 return C_(
"modulename",
"display encoding");
132 dsc->
cst = self->default_colorspace(self, pipe, piece);
156static inline
void _write_pixel(const
float *const restrict in, uint8_t *const restrict
out,
158 const
size_t pixel_index, const
float alpha)
161 const size_t y = pixel_index / preview->
width;
162 const size_t x = pixel_index - y * preview->width;
163 const gboolean first_x =
x % preview->checker_1 <
x % preview->checker_2;
164 const gboolean first_y = y % preview->checker_1 < y % preview->checker_2;
165 const float *
const checker_color
166 = first_x == first_y ? preview->checker_color_2 : preview->checker_color_1;
168 for(
size_t c = 0; c < 3; c++)
170 const float value = in[c] * (1.0f - alpha) + checker_color[c] * alpha;
171 pixel[c] =
value <= 0.0031308f ? 12.92f *
value
172 : (1.0f + 0.055f) * powf(
value, 1.0f / 2.4f) - 0.055f;
176 for(
size_t c = 0; c < 3; c++)
178 const float value = roundf(255.0f * pixel[c]);
179 out[2 - c] = (uint8_t)(fminf(fmaxf(
value, 0.0f), 255.0f));
183static inline
__attribute__((always_inline))
void _normalize_color(float *const restrict pixel, const float norm)
186 const float factor = norm / fmaxf(pixel[0], fmaxf(pixel[1], pixel[2]));
192static inline
void _XYZ_to_REC_709_normalized(const float *const restrict
XYZ, float *const restrict
sRGB,
196 _normalize_color(
sRGB, norm);
200 const size_t buffsize,
const float alpha,
205 for(
size_t j = 0; j < buffsize; j += 4)
213 const size_t buffsize,
const float alpha,
221 for(
size_t j = 0; j < buffsize; j += 4)
226 const float value = fminf(fmaxf(in[j + 1] * 256.0f - 128.0f, -56.0f), 56.0f);
229 _XYZ_to_REC_709_normalized(xyz, pixel, 0.75f);
235 for(
size_t j = 0; j < buffsize; j += 4)
239 const float value = fminf(fmaxf(in[j + 1] * 256.0f - 128.0f, -65.0f), 65.0f);
242 _XYZ_to_REC_709_normalized(xyz, pixel, 0.75f);
248 for(
size_t j = 0; j < buffsize; j += 4)
256 for(
size_t j = 0; j < buffsize; j += 4)
264 for(
size_t j = 0; j < buffsize; j += 4)
274 for(
size_t j = 0; j < buffsize; j += 4)
282 for(
size_t j = 0; j < buffsize; j += 4)
286 dt_LCH_2_Lab(lch, lab);
289 _XYZ_to_REC_709_normalized(xyz, pixel, 0.75f);
295 for(
size_t j = 0; j < buffsize; j += 4)
299 dt_HSL_2_RGB(hsl, pixel);
300 _normalize_color(pixel, 0.75f);
306 for(
size_t j = 0; j < buffsize; j += 4)
312 dt_JzCzhz_2_JzAzBz(JzCzhz,
JzAzBz);
314 dt_XYZ_to_Rec709_D65(
XYZ_D65, pixel);
315 _normalize_color(pixel, 0.75f);
329static void _mask_display(
const float *
const restrict in, uint8_t *
const restrict
out,
const size_t buffsize,
334 for(
size_t j = 0; j < buffsize; j += 4)
339 const float gray = 0.3f * in[j + 0] + 0.59f * in[j + 1] + 0.11f * in[j + 2];
340 pixel[0] = pixel[1] = pixel[2] = gray;
342 const float hide = 1.0f - fminf(fmaxf(in[j + 3] * alpha, 0.0f), 1.0f);
347static void _copy_output(
const float *
const restrict in, uint8_t *
const restrict
out,
const size_t buffsize)
350 for(
size_t j = 0; j < buffsize; j += 4)
353 for(
size_t c = 0; c < 3; c++)
355 out[j + 2 - c] = (uint8_t)(fminf(roundf(255.0f * fmaxf(in[j + c], 0.0f)), 255.0f));
365 const size_t buffsize = (size_t)roi_out->
width * roi_out->
height * 4;
369 _copy_output((
const float *
const restrict)
i, (uint8_t *
const restrict)o, buffsize);
374 const size_t checker_1
378 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/red"), 0.0f, 1.0f),
379 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/green"), 0.0f, 1.0f),
380 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/blue"), 0.0f, 1.0f),
384 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/red"), 0.0f, 1.0f),
385 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/green"), 0.0f, 1.0f),
386 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/blue"), 0.0f, 1.0f),
389 .checker_1 = checker_1,
390 .checker_2 = 2 * checker_1,
391 .width = roi_out->
width,
393 =
dt_conf_get_bool(
"plugins/darkroom/colorbalancergb/mask_preview/greyscaled")
401 mask_display, &preview);
413 _mask_display((
const float *
const restrict)
i, (uint8_t *
const restrict)o, buffsize, 1.0f, &preview);
417 _copy_output((
const float *
const restrict)
i, (uint8_t *
const restrict)o, buffsize);
459 const int devid = pipe->
devid;
460 cl_int err = CL_SUCCESS;
473 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/red"), 0.0f, 1.0f),
474 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/green"), 0.0f, 1.0f),
475 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/blue"), 0.0f, 1.0f),
479 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/red"), 0.0f, 1.0f),
480 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/green"), 0.0f, 1.0f),
481 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/blue"), 0.0f, 1.0f),
486 const int checker_2 = 2 * checker_1;
487 const int black_and_white
488 =
dt_conf_get_bool(
"plugins/darkroom/colorbalancergb/mask_preview/greyscaled");
522 if(err == CL_SUCCESS)
return TRUE;
530 const int program = 2;
548 module->params = calloc(1, sizeof(dt_iop_gamma_params_t));
549 module->default_params = calloc(1, sizeof(dt_iop_gamma_params_t));
550 module->params_size = sizeof(dt_iop_gamma_params_t);
551 module->gui_data = NULL;
552 module->hide_enable_button = 1;
553 module->default_enabled = 1;
dt_XYZ_to_Rec709_D50(XYZ, rgb)
static dt_aligned_pixel_t XYZ
static dt_aligned_pixel_t sRGB
static dt_aligned_pixel_t XYZ_D65
const dt_colormatrix_t dt_aligned_pixel_t out
static dt_aligned_pixel_t JzAzBz
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
int dt_conf_get_bool(const char *name)
float dt_conf_get_float(const char *name)
int dt_conf_get_int(const char *name)
gboolean dt_conf_is_equal(const char *name, const char *value)
void dt_print(dt_debug_thread_t thread, const char *msg,...)
#define for_each_channel(_var,...)
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Enable aggressive floating-point arithmetic optimizations, in denormals handling. Set through user pr...
#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE)
#define __OMP_DECLARE_SIMD__(...)
#define __DT_CLONE_TARGETS__
#define __OMP_PARALLEL_FOR__(...)
static const dt_aligned_pixel_simd_t value
#define __OMP_PARALLEL_FOR_SIMD__(...)
dt_dev_pixelpipe_display_mask_t
@ DT_DEV_PIXELPIPE_DISPLAY_a
@ DT_DEV_PIXELPIPE_DISPLAY_OUTPUT
@ DT_DEV_PIXELPIPE_DISPLAY_G
@ DT_DEV_PIXELPIPE_DISPLAY_L
@ DT_DEV_PIXELPIPE_DISPLAY_CHANNEL
@ DT_DEV_PIXELPIPE_DISPLAY_ANY
@ DT_DEV_PIXELPIPE_DISPLAY_LCH_h
@ DT_DEV_PIXELPIPE_DISPLAY_JzCzhz_hz
@ DT_DEV_PIXELPIPE_DISPLAY_HSL_H
@ DT_DEV_PIXELPIPE_DISPLAY_HSL_S
@ DT_DEV_PIXELPIPE_DISPLAY_JzCzhz_Cz
@ DT_DEV_PIXELPIPE_DISPLAY_LCH_C
@ DT_DEV_PIXELPIPE_DISPLAY_b
@ DT_DEV_PIXELPIPE_DISPLAY_MASK
@ DT_DEV_PIXELPIPE_DISPLAY_JzCzhz_Jz
@ DT_DEV_PIXELPIPE_DISPLAY_HSL_l
@ DT_DEV_PIXELPIPE_DISPLAY_GRAY
@ DT_DEV_PIXELPIPE_DISPLAY_B
@ DT_DEV_PIXELPIPE_DISPLAY_R
void init(dt_iop_module_t *module)
static __DT_CLONE_TARGETS__ void _channel_display_monochrome(const float *const restrict in, uint8_t *const restrict out, const size_t buffsize, const float alpha, const dt_iop_gamma_mask_preview_t *const preview)
int process(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const i, void *const o)
static int _false_color_channel_to_kernel_code(const dt_dev_pixelpipe_display_mask_t mask_display)
static __DT_CLONE_TARGETS__ void _channel_display_false_color(const float *const restrict in, uint8_t *const restrict out, const size_t buffsize, const float alpha, dt_dev_pixelpipe_display_mask_t channel, const dt_iop_gamma_mask_preview_t *const preview)
static void _write_pixel(const float *const restrict in, uint8_t *const restrict out, const dt_iop_gamma_mask_preview_t *const preview, const size_t pixel_index, const float alpha)
Blend one linear RGB pixel with its mask checker and encode it for display.
static __DT_CLONE_TARGETS__ void _copy_output(const float *const restrict in, uint8_t *const restrict out, const size_t buffsize)
dt_iop_gamma_kernel_mode_t
@ DT_IOP_GAMMA_KERNEL_MASK
@ DT_IOP_GAMMA_KERNEL_CHANNEL_FALSE_COLOR
@ DT_IOP_GAMMA_KERNEL_COPY
@ DT_IOP_GAMMA_KERNEL_CHANNEL_MONO
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)
dt_iop_gamma_false_color_t
@ DT_IOP_GAMMA_FALSE_COLOR_MONO
@ DT_IOP_GAMMA_FALSE_COLOR_G
@ DT_IOP_GAMMA_FALSE_COLOR_C
@ DT_IOP_GAMMA_FALSE_COLOR_A
@ DT_IOP_GAMMA_FALSE_COLOR_R
@ DT_IOP_GAMMA_FALSE_COLOR_B_CH
@ DT_IOP_GAMMA_FALSE_COLOR_LCH_H
@ DT_IOP_GAMMA_FALSE_COLOR_JZ_HZ
@ DT_IOP_GAMMA_FALSE_COLOR_HSL_H
@ DT_IOP_GAMMA_FALSE_COLOR_B
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)
void commit_params(dt_iop_module_t *self, dt_iop_params_t *params, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
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)
static __DT_CLONE_TARGETS__ void _mask_display(const float *const restrict in, uint8_t *const restrict out, const size_t buffsize, const float alpha, const dt_iop_gamma_mask_preview_t *const preview)
#define DT_PIXEL_APPLY_DPI(value)
@ IOP_FLAGS_NO_HISTORY_STACK
float dt_aligned_pixel_t[4]
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_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)
@ DT_DEV_PIXELPIPE_PREVIEW
struct dt_iop_module_t *void * data
dt_dev_pixelpipe_type_t type
dt_iop_buffer_type_t datatype
Shared appearance of mask previews rendered by the display encoding module.
dt_aligned_pixel_t checker_color_2
dt_aligned_pixel_t checker_color_1
This module converts float32 RGBA pixels to uint8 BGRA pixels, for GUI pipelines only (darkroom main ...
dt_iop_global_data_t * data
dt_iop_global_data_t * global_data
Region of interest passed through the pixelpipe.