Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
gamma.c
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2009-2012 johannes hanika.
4 Copyright (C) 2010-2011 Bruce Guenter.
5 Copyright (C) 2010-2011 Henrik Andersson.
6 Copyright (C) 2010 José Carlos García Sogo.
7 Copyright (C) 2010 Pascal de Bruijn.
8 Copyright (C) 2011 Robert Bieber.
9 Copyright (C) 2012 Richard Wonka.
10 Copyright (C) 2012, 2014, 2017 Ulrich Pegelow.
11 Copyright (C) 2013, 2020 Aldric Renaudin.
12 Copyright (C) 2013-2014, 2016-2017, 2019 Tobias Ellinghaus.
13 Copyright (C) 2014-2016 Roman Lebedev.
14 Copyright (C) 2015 Pedro Côrte-Real.
15 Copyright (C) 2018, 2020, 2023, 2025-2026 Aurélien PIERRE.
16 Copyright (C) 2018-2019 Edgardo Hoszowski.
17 Copyright (C) 2019 Andreas Schneider.
18 Copyright (C) 2020 Diederik Ter Rahe.
19 Copyright (C) 2020 Harold le Clément de Saint-Marcq.
20 Copyright (C) 2020-2021 Pascal Obry.
21 Copyright (C) 2021 Ralf Brown.
22 Copyright (C) 2022 Martin Bařinka.
23 Copyright (C) 2022 Philipp Lutz.
24
25 darktable is free software: you can redistribute it and/or modify
26 it under the terms of the GNU General Public License as published by
27 the Free Software Foundation, either version 3 of the License, or
28 (at your option) any later version.
29
30 darktable is distributed in the hope that it will be useful,
31 but WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 GNU General Public License for more details.
34
35 You should have received a copy of the GNU General Public License
36 along with darktable. If not, see <http://www.gnu.org/licenses/>.
37*/
38#ifdef HAVE_CONFIG_H
39#include "system/mem_alloc.h"
40#include "common/conf.h"
42#include "common/logging.h"
43#include "system/openmp.h"
44#include "system/simd.h"
46#include "config.h"
47#endif
48#include "develop/imageop_gui.h"
49#include <assert.h>
50#include <math.h>
51#include <stdlib.h>
52#include <string.h>
53
55#include "common/opencl.h"
56#include "develop/develop.h"
57
58#include "iop/iop_api.h"
60
69
70
75
76#ifdef HAVE_OPENCL
81
89
103#endif
104
105const char *name()
106{
107 return C_("modulename", "display encoding");
108}
109
111{
112 return IOP_GROUP_TECHNICAL;
113}
114
119
124
127{
128 default_input_format(self, pipe, piece, dsc);
129 dsc->channels = 4;
130 dsc->datatype = TYPE_FLOAT;
131}
132
135{
136 dsc->channels = 4;
137 dsc->datatype = TYPE_UINT8;
138 dsc->cst = self->default_colorspace(self, pipe, piece);
139}
140
141
157
162static inline void _write_pixel(const float *const restrict in, uint8_t *const restrict out,
164 const size_t pixel_index, const float alpha)
165{
166 // Blend the image with the checker in linear RGB, then encode the result once.
167 const size_t y = pixel_index / preview->width;
168 const size_t x = pixel_index - y * preview->width;
169 const gboolean first_x = x % preview->checker_1 < x % preview->checker_2;
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;
173 dt_aligned_pixel_t pixel;
174 for(size_t c = 0; c < 3; c++)
175 {
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;
179 }
180
181 // the output of this module is BGR(A) instead of RGBA; can't use for_each_channel here due to the index swap
182 for(size_t c = 0; c < 3; c++)
183 {
184 const float value = roundf(255.0f * pixel[c]);
185 out[2 - c] = (uint8_t)(fminf(fmaxf(value, 0.0f), 255.0f));
186 }
187}
188__OMP_DECLARE_SIMD__(aligned(pixel: 16) uniform(norm))
189static inline __attribute__((always_inline)) void _normalize_color(float *const restrict pixel, const float norm)
190{
191 // color may not be black!
192 const float factor = norm / fmaxf(pixel[0], fmaxf(pixel[1], pixel[2]));
194 pixel[x] *= factor;
195}
196
197__OMP_DECLARE_SIMD__(aligned(XYZ, sRGB: 16) uniform(norm))
198static inline void _XYZ_to_REC_709_normalized(const float *const restrict XYZ, float *const restrict sRGB,
199 const float norm)
200{
202 _normalize_color(sRGB, norm);
203}
205static void _channel_display_monochrome(const float *const restrict in, uint8_t *const restrict out,
206 const size_t buffsize, const float alpha,
208{
209 // Render each selected channel value as a neutral image over the shared mask checkerboard.
210 __OMP_PARALLEL_FOR_SIMD__(aligned(in, out: 64))
211 for(size_t j = 0; j < buffsize; j += 4)
212 {
213 dt_aligned_pixel_t pixel = { in[j + 1], in[j + 1], in[j + 1], in[j + 1] };
214 _write_pixel(pixel, out + j, preview, j / 4, in[j + 3] * alpha);
215 }
216}
218static void _channel_display_false_color(const float *const restrict in, uint8_t *const restrict out,
219 const size_t buffsize, const float alpha,
222{
224 {
226 __OMP_PARALLEL_FOR_SIMD__(aligned(in, out: 64))
227 for(size_t j = 0; j < buffsize; j += 4)
228 {
230 dt_aligned_pixel_t pixel;
231 // colors with "a" exceeding the range [-56,56] range will yield colors not representable in sRGB
232 const float value = fminf(fmaxf(in[j + 1] * 256.0f - 128.0f, -56.0f), 56.0f);
233 const dt_aligned_pixel_t lab = { 79.0f - value * (11.0f / 56.0f), value, 0.0f, 0.0f };
234 dt_Lab_to_XYZ(lab, xyz);
235 _XYZ_to_REC_709_normalized(xyz, pixel, 0.75f);
236 _write_pixel(pixel, out + j, preview, j / 4, in[j + 3] * alpha);
237 }
238 break;
240 __OMP_PARALLEL_FOR_SIMD__(aligned(in, out: 64))
241 for(size_t j = 0; j < buffsize; j += 4)
242 {
243 dt_aligned_pixel_t xyz, pixel;
244 // colors with "b" exceeding the range [-65,65] range will yield colors not representable in sRGB
245 const float value = fminf(fmaxf(in[j + 1] * 256.0f - 128.0f, -65.0f), 65.0f);
246 const dt_aligned_pixel_t lab = { 60.0f + value * (2.0f / 65.0f), 0.0f, value, 0.0f };
247 dt_Lab_to_XYZ(lab, xyz);
248 _XYZ_to_REC_709_normalized(xyz, pixel, 0.75f);
249 _write_pixel(pixel, out + j, preview, j / 4, in[j + 3] * alpha);
250 }
251 break;
253 __OMP_PARALLEL_FOR_SIMD__(aligned(in, out: 64))
254 for(size_t j = 0; j < buffsize; j += 4)
255 {
256 const dt_aligned_pixel_t pixel = { in[j + 1], 0.0f, 0.0f, 0.0f };
257 _write_pixel(pixel, out + j, preview, j / 4, in[j + 3] * alpha);
258 }
259 break;
261 __OMP_PARALLEL_FOR_SIMD__(aligned(in, out: 64))
262 for(size_t j = 0; j < buffsize; j += 4)
263 {
264 const dt_aligned_pixel_t pixel = { 0.0f, in[j + 1], 0.0f, 0.0f };
265 _write_pixel(pixel, out + j, preview, j / 4, in[j + 3] * alpha);
266 }
267 break;
269 __OMP_PARALLEL_FOR_SIMD__(aligned(in, out: 64))
270 for(size_t j = 0; j < buffsize; j += 4)
271 {
272 const dt_aligned_pixel_t pixel = { 0.0f, 0.0f, in[j + 1], 0.0f };
273 _write_pixel(pixel, out + j, preview, j / 4, in[j + 3] * alpha);
274 }
275 break;
279 __OMP_PARALLEL_FOR_SIMD__(aligned(in, out: 64))
280 for(size_t j = 0; j < buffsize; j += 4)
281 {
282 const dt_aligned_pixel_t pixel = { 0.5f, 0.5f * (1.0f - in[j + 1]), 0.5f, 0.0f };
283 _write_pixel(pixel, out + j, preview, j / 4, in[j + 3] * alpha);
284 }
285 break;
287 __OMP_PARALLEL_FOR_SIMD__(aligned(in, out: 64))
288 for(size_t j = 0; j < buffsize; j += 4)
289 {
290 dt_aligned_pixel_t lch = { 65.0f, 37.0f, in[j + 1], 0.0f };
291 dt_aligned_pixel_t lab, xyz, pixel;
292 dt_LCH_2_Lab(lch, lab);
293 lab[3] = 0.0f;
294 dt_Lab_to_XYZ(lab, xyz);
295 _XYZ_to_REC_709_normalized(xyz, pixel, 0.75f);
296 _write_pixel(pixel, out + j, preview, j / 4, in[j + 3] * alpha);
297 }
298 break;
301 for(size_t j = 0; j < buffsize; j += 4)
302 {
303 dt_aligned_pixel_t hsl = { in[j + 1], 0.5f, 0.5f, 0.0f };
304 dt_aligned_pixel_t pixel;
305 dt_HSL_2_RGB(hsl, pixel);
306 _normalize_color(pixel, 0.75f);
307 _write_pixel(pixel, out + j, preview, j / 4, in[j + 3] * alpha);
308 }
309 break;
312 for(size_t j = 0; j < buffsize; j += 4)
313 {
314 const dt_aligned_pixel_t JzCzhz = { 0.011f, 0.01f, in[j + 1] };
317 dt_aligned_pixel_t pixel;
318 dt_JzCzhz_2_JzAzBz(JzCzhz, JzAzBz);
319 dt_JzAzBz_2_XYZ(JzAzBz, XYZ_D65);
320 dt_XYZ_to_Rec709_D65(XYZ_D65, pixel);
321 _normalize_color(pixel, 0.75f);
322 _write_pixel(pixel, out + j, preview, j / 4, in[j + 3] * alpha);
323 }
324 break;
329 default:
330 _channel_display_monochrome(in, out, buffsize, alpha, preview);
331 break;
332 }
333}
335static void _mask_display(const float *const restrict in, uint8_t *const restrict out, const size_t buffsize,
336 const float alpha, const dt_iop_gamma_mask_preview_t *const preview)
337{
338 // Loop over the displayed mask and preserve the image colors unless the global monochrome option is enabled.
339 __OMP_PARALLEL_FOR_SIMD__(aligned(in, out: 64))
340 for(size_t j = 0; j < buffsize; j += 4)
341 {
342 dt_aligned_pixel_t pixel = { in[j], in[j + 1], in[j + 2], 0.0f };
343 if(preview->black_and_white)
344 {
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;
347 }
348 const float hide = 1.0f - fminf(fmaxf(in[j + 3] * alpha, 0.0f), 1.0f);
349 _write_pixel(pixel, out + j, preview, j / 4, hide);
350 }
351}
353static void _copy_output(const float *const restrict in, uint8_t *const restrict out, const size_t buffsize)
354{
355 __OMP_PARALLEL_FOR_SIMD__(aligned(in, out: 64))
356 for(size_t j = 0; j < buffsize; j += 4)
357 {
358 // the output of this module is BGR(A) instead of RGBA, so we can't use for_each_channel
359 for(size_t c = 0; c < 3; c++)
360 {
361 out[j + 2 - c] = (uint8_t)(fminf(roundf(255.0f * fmaxf(in[j + c], 0.0f)), 255.0f));
362 }
363 }
364}
365
366
367int 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)
368{
369 const dt_iop_roi_t *const roi_out = &piece->roi_out;
370 const dt_dev_pixelpipe_display_mask_t mask_display = pipe->mask_display;
371 const size_t buffsize = (size_t)roi_out->width * roi_out->height * 4;
372
374 {
375 _copy_output((const float *const restrict)i, (uint8_t *const restrict)o, buffsize);
376 return 0;
377 }
378
379 const float alpha = (mask_display & DT_DEV_PIXELPIPE_DISPLAY_MASK) ? 1.0f : 0.0f;
380 const size_t checker_1
381 = MAX((size_t)DT_PIXEL_APPLY_DPI(dt_conf_get_int("plugins/darkroom/colorbalancergb/checker/size")), 2);
383 .checker_color_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),
387 0.0f
388 },
389 .checker_color_2 = {
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),
393 0.0f
394 },
395 .checker_1 = checker_1,
396 .checker_2 = 2 * checker_1,
397 .width = roi_out->width,
398 .black_and_white
399 = dt_conf_get_bool("plugins/darkroom/colorbalancergb/mask_preview/greyscaled")
400 };
401
402 if((mask_display & DT_DEV_PIXELPIPE_DISPLAY_CHANNEL) && (mask_display & DT_DEV_PIXELPIPE_DISPLAY_ANY))
403 {
404 if(dt_conf_is_equal("channel_display", "false color"))
405 {
406 _channel_display_false_color((const float *const restrict)i, (uint8_t *const restrict)o, buffsize, alpha,
407 mask_display, &preview);
408 }
409 else
410 {
411 _channel_display_monochrome((const float *const restrict)i, (uint8_t *const restrict)o, buffsize, alpha,
412 &preview);
413 }
414 return 0;
415 }
416
417 if(mask_display & DT_DEV_PIXELPIPE_DISPLAY_MASK)
418 {
419 _mask_display((const float *const restrict)i, (uint8_t *const restrict)o, buffsize, 1.0f, &preview);
420 return 0;
421 }
422
423 _copy_output((const float *const restrict)i, (uint8_t *const restrict)o, buffsize);
424 return 0;
425}
426
427#ifdef HAVE_OPENCL
460
461int 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)
462{
463 const dt_iop_roi_t *const roi_out = &piece->roi_out;
465 const int devid = pipe->devid;
466 cl_int err = CL_SUCCESS;
467
468 const int width = roi_out->width;
469 const int height = roi_out->height;
470
471 size_t sizes[] = { ROUNDUPDWD(width, devid), ROUNDUPDHT(height, devid), 1 };
472
473 const dt_dev_pixelpipe_display_mask_t mask_display = pipe->mask_display;
474 const gboolean fcolor = dt_conf_is_equal("channel_display", "false color");
475 int mode = DT_IOP_GAMMA_KERNEL_COPY;
476 int channel = DT_IOP_GAMMA_FALSE_COLOR_MONO;
477 float alpha = (mask_display & DT_DEV_PIXELPIPE_DISPLAY_MASK) ? 1.0f : 0.0f;
478 const dt_aligned_pixel_t checker_color_1 = {
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),
482 0.0f
483 };
484 const dt_aligned_pixel_t checker_color_2 = {
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),
488 0.0f
489 };
490 const int checker_1
491 = MAX(DT_PIXEL_APPLY_DPI(dt_conf_get_int("plugins/darkroom/colorbalancergb/checker/size")), 2);
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");
495
496 if((mask_display & DT_DEV_PIXELPIPE_DISPLAY_CHANNEL)
497 && (mask_display & DT_DEV_PIXELPIPE_DISPLAY_ANY))
498 {
499 if(fcolor)
500 {
502 channel = _false_color_channel_to_kernel_code(mask_display);
503 }
504 else
505 {
507 }
508 }
509 else if(mask_display & DT_DEV_PIXELPIPE_DISPLAY_MASK)
510 {
512 alpha = 1.0f;
513 }
514 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 0, sizeof(cl_mem), (void *)&dev_in);
515 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 1, sizeof(cl_mem), (void *)&dev_out);
516 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 2, sizeof(int), (void *)&width);
517 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 3, sizeof(int), (void *)&height);
518 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 4, sizeof(int), (void *)&mode);
519 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 5, sizeof(int), (void *)&channel);
520 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 6, sizeof(float), (void *)&alpha);
521 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 7, sizeof(checker_color_1), (void *)&checker_color_1);
522 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 8, sizeof(checker_color_2), (void *)&checker_color_2);
523 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 9, sizeof(int), (void *)&checker_1);
524 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 10, sizeof(int), (void *)&checker_2);
525 dt_opencl_set_kernel_arg(devid, gd->kernel_gamma_pack, 11, sizeof(int), (void *)&black_and_white);
526
527 err = dt_opencl_enqueue_kernel_2d(devid, gd->kernel_gamma_pack, sizes);
528 if(err == CL_SUCCESS) return TRUE;
529
530 dt_print(DT_DEBUG_OPENCL, "[opencl_gamma] couldn't enqueue kernel! %d\n", err);
531 return FALSE;
532}
533
535{
536 const int program = 2; // basic.cl, from programs.conf
538 if(!gd) return;
539 module->data = gd;
540 gd->kernel_gamma_pack = dt_opencl_create_kernel(program, "gamma_pack");
541}
542
549#endif
550
552{
553 // module->data = malloc(sizeof(dt_iop_gamma_data_t));
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;
559}
560
562{
563 piece->data = NULL;
564 piece->data_size = 0;
565}
566
568{
569}
570
573{
574 // Only GUI pipes return 8 bits unsigned integer BGRA
576 piece->enabled = 1;
577 else
578 piece->enabled = 0;
579}
580
581// clang-format off
582// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
583// vim: shiftwidth=2 expandtab tabstop=2 cindent
584// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
585// clang-format on
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
static const float x
dt_XYZ_to_Rec709_D50(XYZ, rgb)
dt_Lab_to_XYZ(Lab, XYZ)
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)
void dt_iop_params_t
Definition dev_history.h:43
void default_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_dev_pixelpipe_display_mask_t
Definition develop.h:121
@ DT_DEV_PIXELPIPE_DISPLAY_a
Definition develop.h:127
@ DT_DEV_PIXELPIPE_DISPLAY_OUTPUT
Definition develop.h:125
@ DT_DEV_PIXELPIPE_DISPLAY_G
Definition develop.h:130
@ DT_DEV_PIXELPIPE_DISPLAY_L
Definition develop.h:126
@ DT_DEV_PIXELPIPE_DISPLAY_CHANNEL
Definition develop.h:124
@ DT_DEV_PIXELPIPE_DISPLAY_ANY
Definition develop.h:143
@ DT_DEV_PIXELPIPE_DISPLAY_LCH_h
Definition develop.h:134
@ DT_DEV_PIXELPIPE_DISPLAY_JzCzhz_hz
Definition develop.h:140
@ DT_DEV_PIXELPIPE_DISPLAY_HSL_H
Definition develop.h:135
@ DT_DEV_PIXELPIPE_DISPLAY_HSL_S
Definition develop.h:136
@ DT_DEV_PIXELPIPE_DISPLAY_JzCzhz_Cz
Definition develop.h:139
@ DT_DEV_PIXELPIPE_DISPLAY_LCH_C
Definition develop.h:133
@ DT_DEV_PIXELPIPE_DISPLAY_b
Definition develop.h:128
@ DT_DEV_PIXELPIPE_DISPLAY_MASK
Definition develop.h:123
@ DT_DEV_PIXELPIPE_DISPLAY_JzCzhz_Jz
Definition develop.h:138
@ DT_DEV_PIXELPIPE_DISPLAY_HSL_l
Definition develop.h:137
@ DT_DEV_PIXELPIPE_DISPLAY_GRAY
Definition develop.h:132
@ DT_DEV_PIXELPIPE_DISPLAY_B
Definition develop.h:131
@ DT_DEV_PIXELPIPE_DISPLAY_R
Definition develop.h:129
GtkWidget * preview
what the selected row actually captures
@ IOP_CS_RGB_DISPLAY
Definition format.h:71
@ TYPE_FLOAT
Definition format.h:56
@ TYPE_UINT8
Definition format.h:58
void init(dt_iop_module_t *module)
Definition gamma.c:551
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)
Definition gamma.c:205
int default_group()
Definition gamma.c:110
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)
Definition gamma.c:367
static int _false_color_channel_to_kernel_code(const dt_dev_pixelpipe_display_mask_t mask_display)
Definition gamma.c:428
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)
Definition gamma.c:218
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.
Definition gamma.c:162
static __DT_CLONE_TARGETS__ void _copy_output(const float *const restrict in, uint8_t *const restrict out, const size_t buffsize)
Definition gamma.c:353
dt_iop_gamma_kernel_mode_t
Definition gamma.c:83
@ DT_IOP_GAMMA_KERNEL_MASK
Definition gamma.c:85
@ DT_IOP_GAMMA_KERNEL_CHANNEL_FALSE_COLOR
Definition gamma.c:87
@ DT_IOP_GAMMA_KERNEL_COPY
Definition gamma.c:84
@ DT_IOP_GAMMA_KERNEL_CHANNEL_MONO
Definition gamma.c:86
void init_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
Definition gamma.c:561
const char * name()
Definition gamma.c:105
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)
Definition gamma.c:133
dt_iop_gamma_false_color_t
Definition gamma.c:91
@ DT_IOP_GAMMA_FALSE_COLOR_MONO
Definition gamma.c:92
@ DT_IOP_GAMMA_FALSE_COLOR_G
Definition gamma.c:96
@ DT_IOP_GAMMA_FALSE_COLOR_C
Definition gamma.c:98
@ DT_IOP_GAMMA_FALSE_COLOR_A
Definition gamma.c:93
@ DT_IOP_GAMMA_FALSE_COLOR_R
Definition gamma.c:95
@ DT_IOP_GAMMA_FALSE_COLOR_B_CH
Definition gamma.c:97
@ DT_IOP_GAMMA_FALSE_COLOR_LCH_H
Definition gamma.c:99
@ DT_IOP_GAMMA_FALSE_COLOR_JZ_HZ
Definition gamma.c:101
@ DT_IOP_GAMMA_FALSE_COLOR_HSL_H
Definition gamma.c:100
@ DT_IOP_GAMMA_FALSE_COLOR_B
Definition gamma.c:94
void cleanup_global(dt_iop_module_so_t *module)
Definition gamma.c:543
int default_colorspace(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
Definition gamma.c:120
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)
Definition gamma.c:125
int flags()
Definition gamma.c:115
void commit_params(dt_iop_module_t *self, dt_iop_params_t *params, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
Definition gamma.c:571
void cleanup_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
Definition gamma.c:567
void init_global(dt_iop_module_so_t *module)
Definition gamma.c:534
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)
Definition gamma.c:461
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)
Definition gamma.c:335
@ IOP_FLAGS_HIDDEN
Definition imageop.h:189
@ IOP_FLAGS_UNSAFE_COPY
Definition imageop.h:196
@ IOP_FLAGS_ONE_INSTANCE
Definition imageop.h:191
@ IOP_FLAGS_NO_HISTORY_STACK
Definition imageop.h:193
@ IOP_GROUP_TECHNICAL
Definition imageop.h:162
@ linear
Definition lightroom.c:369
@ DT_DEBUG_OPENCL
Definition logging.h:57
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.
Definition mem_alloc.h:171
uint32_t width
Definition mipmap_cache.c:0
uint32_t height
Definition mipmap_cache.c:1
#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)
Definition opencl.c:2554
int dt_opencl_create_kernel(const int prog, const char *name)
Definition opencl.c:2448
void dt_opencl_free_kernel(const int kernel)
Definition opencl.c:2491
int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size, const void *arg)
Definition opencl.c:2545
#define ROUNDUPDHT(a, b)
Definition opencl.h:86
#define ROUNDUPDWD(a, b)
Definition opencl.h:85
#define __OMP_DECLARE_SIMD__(...)
Definition openmp.h:100
#define __OMP_PARALLEL_FOR__(...)
Definition openmp.h:95
#define __OMP_PARALLEL_FOR_SIMD__(...)
Definition openmp.h:96
const float factor
Definition pdf.h:91
@ DT_DEV_PIXELPIPE_PREVIEW
Definition pixelpipe.h:44
@ DT_DEV_PIXELPIPE_FULL
Definition pixelpipe.h:43
DT_ALIGNED_PIXEL float dt_aligned_pixel_t[4]
Definition simd.h:53
#define for_each_channel(_var,...)
Definition simd.h:87
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...
Definition simd.h:55
static const dt_aligned_pixel_simd_t value
Definition simd.h:144
struct dt_iop_module_t *void * data
dt_dev_pixelpipe_type_t type
unsigned int channels
Definition format.h:83
dt_iop_buffer_type_t datatype
Definition format.h:85
Shared appearance of mask previews rendered by the display encoding module.
Definition gamma.c:149
dt_aligned_pixel_t checker_color_2
Definition gamma.c:151
dt_aligned_pixel_t checker_color_1
Definition gamma.c:150
This module converts float32 RGBA pixels to uint8 BGRA pixels, for GUI pipelines only (darkroom main ...
Definition gamma.c:72
dt_iop_global_data_t * data
Definition imageop.h:238
dt_iop_global_data_t * global_data
Definition imageop.h:337
Region of interest passed through the pixelpipe.
Definition format.h:49
int width
Definition format.h:50
int height
Definition format.h:50
#define __DT_CLONE_TARGETS__
#define MAX(a, b)
Definition thinplate.c:29
#define DT_PIXEL_APPLY_DPI(value)