107 return C_(
"modulename",
"display encoding");
138 dsc->
cst = self->default_colorspace(self, pipe, piece);
162static inline
void _write_pixel(const
float *const restrict in, uint8_t *const restrict
out,
164 const
size_t pixel_index, const
float alpha)
168 const size_t x = pixel_index - y *
preview->width;
170 const gboolean first_y = y %
preview->checker_1 < y %
preview->checker_2;
171 const float *
const checker_color
172 = first_x == first_y ?
preview->checker_color_2 :
preview->checker_color_1;
174 for(
size_t c = 0; c < 3; c++)
176 const float value = in[c] * (1.0f - alpha) + checker_color[c] * alpha;
177 pixel[c] =
value <= 0.0031308f ? 12.92f *
value
178 : (1.0f + 0.055f) * powf(
value, 1.0f / 2.4f) - 0.055f;
182 for(
size_t c = 0; c < 3; c++)
184 const float value = roundf(255.0f * pixel[c]);
185 out[2 - c] = (uint8_t)(fminf(fmaxf(
value, 0.0f), 255.0f));
189static inline
__attribute__((always_inline))
void _normalize_color(float *const restrict pixel, const float norm)
192 const float factor = norm / fmaxf(pixel[0], fmaxf(pixel[1], pixel[2]));
198static inline
void _XYZ_to_REC_709_normalized(const float *const restrict
XYZ, float *const restrict
sRGB,
202 _normalize_color(
sRGB, norm);
206 const size_t buffsize,
const float alpha,
211 for(
size_t j = 0; j < buffsize; j += 4)
219 const size_t buffsize,
const float alpha,
227 for(
size_t j = 0; j < buffsize; j += 4)
232 const float value = fminf(fmaxf(in[j + 1] * 256.0f - 128.0f, -56.0f), 56.0f);
235 _XYZ_to_REC_709_normalized(xyz, pixel, 0.75f);
241 for(
size_t j = 0; j < buffsize; j += 4)
245 const float value = fminf(fmaxf(in[j + 1] * 256.0f - 128.0f, -65.0f), 65.0f);
248 _XYZ_to_REC_709_normalized(xyz, pixel, 0.75f);
254 for(
size_t j = 0; j < buffsize; j += 4)
262 for(
size_t j = 0; j < buffsize; j += 4)
270 for(
size_t j = 0; j < buffsize; j += 4)
280 for(
size_t j = 0; j < buffsize; j += 4)
288 for(
size_t j = 0; j < buffsize; j += 4)
292 dt_LCH_2_Lab(lch, lab);
295 _XYZ_to_REC_709_normalized(xyz, pixel, 0.75f);
301 for(
size_t j = 0; j < buffsize; j += 4)
305 dt_HSL_2_RGB(hsl, pixel);
306 _normalize_color(pixel, 0.75f);
312 for(
size_t j = 0; j < buffsize; j += 4)
318 dt_JzCzhz_2_JzAzBz(JzCzhz,
JzAzBz);
320 dt_XYZ_to_Rec709_D65(
XYZ_D65, pixel);
321 _normalize_color(pixel, 0.75f);
335static void _mask_display(
const float *
const restrict in, uint8_t *
const restrict
out,
const size_t buffsize,
340 for(
size_t j = 0; j < buffsize; j += 4)
345 const float gray = 0.3f * in[j + 0] + 0.59f * in[j + 1] + 0.11f * in[j + 2];
346 pixel[0] = pixel[1] = pixel[2] = gray;
348 const float hide = 1.0f - fminf(fmaxf(in[j + 3] * alpha, 0.0f), 1.0f);
353static void _copy_output(
const float *
const restrict in, uint8_t *
const restrict
out,
const size_t buffsize)
356 for(
size_t j = 0; j < buffsize; j += 4)
359 for(
size_t c = 0; c < 3; c++)
361 out[j + 2 - c] = (uint8_t)(fminf(roundf(255.0f * fmaxf(in[j + c], 0.0f)), 255.0f));
371 const size_t buffsize = (size_t)roi_out->
width * roi_out->
height * 4;
375 _copy_output((
const float *
const restrict)
i, (uint8_t *
const restrict)o, buffsize);
380 const size_t checker_1
384 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/red"), 0.0f, 1.0f),
385 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/green"), 0.0f, 1.0f),
386 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/blue"), 0.0f, 1.0f),
390 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/red"), 0.0f, 1.0f),
391 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/green"), 0.0f, 1.0f),
392 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/blue"), 0.0f, 1.0f),
395 .checker_1 = checker_1,
396 .checker_2 = 2 * checker_1,
397 .width = roi_out->
width,
399 =
dt_conf_get_bool(
"plugins/darkroom/colorbalancergb/mask_preview/greyscaled")
423 _copy_output((
const float *
const restrict)
i, (uint8_t *
const restrict)o, buffsize);
465 const int devid = pipe->
devid;
466 cl_int err = CL_SUCCESS;
479 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/red"), 0.0f, 1.0f),
480 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/green"), 0.0f, 1.0f),
481 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker1/blue"), 0.0f, 1.0f),
485 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/red"), 0.0f, 1.0f),
486 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/green"), 0.0f, 1.0f),
487 CLAMP(
dt_conf_get_float(
"plugins/darkroom/colorbalancergb/checker2/blue"), 0.0f, 1.0f),
492 const int checker_2 = 2 * checker_1;
493 const int black_and_white
494 =
dt_conf_get_bool(
"plugins/darkroom/colorbalancergb/mask_preview/greyscaled");
528 if(err == CL_SUCCESS)
return TRUE;
536 const int program = 2;
554 module->params = calloc(1, sizeof(dt_iop_gamma_params_t));
555 module->default_params = calloc(1, sizeof(dt_iop_gamma_params_t));
556 module->params_size = sizeof(dt_iop_gamma_params_t);
557 module->hide_enable_button = 1;
558 module->default_enabled = 1;
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
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
int dt_conf_get_bool(const char *name)
float dt_conf_get_float(const char *name)
Float for name, clamped to its declared bounds.
int dt_conf_get_int(const char *name)
Integer for name, clamped to the bounds declared in the XML.
gboolean dt_conf_is_equal(const char *name, const char *value)
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
GtkWidget * preview
what the selected row actually captures
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)
@ IOP_FLAGS_NO_HISTORY_STACK
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 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_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)
#define __OMP_DECLARE_SIMD__(...)
#define __OMP_PARALLEL_FOR__(...)
#define __OMP_PARALLEL_FOR_SIMD__(...)
@ DT_DEV_PIXELPIPE_PREVIEW
DT_ALIGNED_PIXEL float dt_aligned_pixel_t[4]
#define for_each_channel(_var,...)
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...
static const dt_aligned_pixel_simd_t value
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.
#define __DT_CLONE_TARGETS__