58#include <glib/gi18n.h>
59#include <gtk/gtktypes.h>
71static const float dt_iop_rawoverexposed_colors[][4]
__attribute__((aligned(64))) = {
72 { 1.0f, 0.0f, 0.0f, 1.0f },
73 { 0.0f, 1.0f, 0.0f, 1.0f },
74 { 0.0f, 0.0f, 1.0f, 1.0f },
75 { 0.0f, 0.0f, 0.0f, 1.0f }
99 return _(
"raw overexposed");
127 for(
int k = 0;
k <
ch;
k++)
130 float chthr =
d->threshold;
133 chthr *=
piece->dsc_in.rawprepare.raw_white_point -
piece->dsc_in.rawprepare.raw_black_level;
134 chthr +=
piece->dsc_in.rawprepare.raw_black_level;
143 const void *
const ivoid,
void *
const ovoid)
156 const int ch =
piece->dsc_in.channels;
157 const double iop_order = self->
iop_order;
160 const int colorscheme =
d->colorscheme;
161 const float *
const color = dt_iop_rawoverexposed_colors[colorscheme];
175 const float in_scale = roi_in->
scale;
176 dt_boundingbox_t pts = {(float)(roi_out->
x) / in_scale, (float)(roi_out->
y) / in_scale,
177 (float)(roi_out->
x + roi_out->
width) / in_scale, (float)(roi_out->
y + roi_out->
height) / in_scale};
178 printf(
"in %f %f %f %f\n", pts[0], pts[1], pts[2], pts[3]);
180 printf(
"out %f %f %f %f\n\n", pts[0], pts[1], pts[2], pts[3]);
183 const uint16_t *
const raw = (
const uint16_t *
const)buf.
buf;
188 const uint8_t(*
const xtrans)[6] = (
const uint8_t(*
const)[6])image->
dsc.
xtrans;
199 for(
int j = 0; j < roi_out->
height; j++)
204 for(
int i = 0;
i < roi_out->
width;
i++)
206 bufptr[2 *
i] = (float)(roi_out->
x +
i) / roi_in->
scale;
207 bufptr[2 *
i + 1] = (float)(roi_out->
y + j) / roi_in->
scale;
214 for(
int i = 0;
i < roi_out->
width;
i++)
216 const size_t pout = (size_t)
ch * (j * roi_out->
width +
i);
219 const int i_raw = (int)bufptr[2 *
i];
220 const int j_raw = (int)bufptr[2 *
i + 1];
222 if(i_raw < 0 || j_raw < 0 || i_raw >= buf.
width || j_raw >= buf.
height)
continue;
227 c =
FCxtrans(j_raw, i_raw, NULL, xtrans);
231 c =
FC(j_raw, i_raw, filters);
234 const size_t pin = (size_t)j_raw * buf.
width + i_raw;
235 const float in = raw[pin];
243 memcpy(
out + pout, dt_iop_rawoverexposed_colors[c],
sizeof(
float) * 4);
246 memcpy(
out + pout,
color,
sizeof(
float) * 4);
272 cl_mem dev_raw = NULL;
273 float *coordbuf = NULL;
274 cl_mem dev_coord = NULL;
275 cl_mem dev_thresholds = NULL;
276 cl_mem dev_colors = NULL;
277 cl_mem dev_xtrans = NULL;
297 size_t origin[] = { 0, 0, 0 };
304 if(err != CL_SUCCESS)
goto error;
306 const int colorscheme =
d->colorscheme;
307 const float *
const color = dt_iop_rawoverexposed_colors[colorscheme];
312 const int raw_width = buf.
width;
313 const int raw_height = buf.
height;
318 const size_t coordbufsize = (size_t)
height *
width * 2 *
sizeof(
float);
323 for(
int j = 0; j <
height; j++)
325 float *bufptr = ((
float *)coordbuf) + (size_t)2 * j *
width;
328 for(
int i = 0;
i < roi_out->
width;
i++)
330 bufptr[2 *
i] = (float)(roi_out->
x +
i) / roi_in->
scale;
331 bufptr[2 *
i + 1] = (float)(roi_out->
y + j) / roi_in->
scale;
343 if(err != CL_SUCCESS)
goto error;
356 sizeof(dt_iop_rawoverexposed_colors), CL_TRUE);
357 if(err != CL_SUCCESS)
goto error;
398 if(err != CL_SUCCESS)
goto error;
439 raw_width = buf.
width;
447 tiling->overhead = (size_t)raw_width * raw_height *
sizeof(uint16_t);
481 const int program = 2;
482 module->data = malloc(sizeof(dt_iop_rawoverexposed_global_data_t));
513 module->params = calloc(1, sizeof(dt_iop_rawoverexposed_t));
514 module->default_params = calloc(1, sizeof(dt_iop_rawoverexposed_t));
515 module->hide_enable_button = 1;
516 module->default_enabled = 1;
517 module->params_size = sizeof(dt_iop_rawoverexposed_t);
static void error(char *msg)
const dt_colormatrix_t dt_aligned_pixel_t out
void dt_control_log(const char *msg,...)
static int FCxtrans(const int row, const int col, global const unsigned char(*const xtrans)[6])
static int FC(const int row, const int col, const unsigned int filters)
int dt_dev_distort_backtransform_plus(const dt_dev_pixelpipe_t *pipe, const double iop_order, const int transf_direction, float *points, size_t points_count)
@ DT_DEV_PIXELPIPE_DISPLAY_MASK
@ DT_DEV_TRANSFORM_DIR_BACK_INCL
dt_dev_rawoverexposed_mode_t
@ DT_DEV_RAWOVEREXPOSED_MODE_FALSECOLOR
@ DT_DEV_RAWOVEREXPOSED_MODE_MARK_CFA
@ DT_DEV_RAWOVEREXPOSED_MODE_MARK_SOLID
dt_dev_rawoverexposed_colorscheme_t
float dt_boundingbox_t[4]
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)
void dt_iop_set_cache_bypass(dt_iop_module_t *module, gboolean state)
@ IOP_FLAGS_NO_HISTORY_STACK
static float kernel(const float *x, const float *y)
static const dt_dev_pixelpipe_t * pipe
static const dt_dev_pixelpipe_t const dt_dev_pixelpipe_iop_t * piece
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.
float *const restrict const size_t k
float *const restrict const size_t const size_t ch
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#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_mipmap_cache_get(B, C, D, E, F)
#define dt_mipmap_cache_release(B)
#define DT_MODULE(MODVER)
Instantiate the version handshake every module must export. Use once, at file scope,...
int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes)
void * dt_opencl_alloc_device_buffer(const int devid, const size_t size)
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_write_buffer_to_device(const int devid, void *host, void *device, const size_t offset, const size_t size, const int blocking)
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)
#define __OMP_PARALLEL_FOR_SIMD__(...)
#define dt_pixelpipe_cache_alloc_align_cache(size, id)
#define dt_pixelpipe_cache_free_align(mem)
#define dt_get_perthread(buf, padsize)
#define dt_pixelpipe_cache_alloc_perthread_float(n, padded_size)
void init(dt_iop_module_t *module)
__DT_CLONE_TARGETS__ int process(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 tiling_callback(struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, struct dt_develop_tiling_t *tiling)
void commit_params(dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void cleanup_global(dt_iop_module_so_t *module)
gboolean runtime_data_hash(dt_iop_module_t *self __attribute__((unused)), dt_dev_pixelpipe_t *pipe __attribute__((unused)), const dt_dev_pixelpipe_iop_t *piece __attribute__((unused)))
void cleanup_pipe(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
int default_colorspace(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
static __DT_CLONE_TARGETS__ void process_common_setup(const dt_iop_module_t *self, const dt_dev_pixelpipe_iop_t *piece, unsigned int threshold[4])
void init_pipe(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)
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...
dt_dev_pixelpipe_type_t type
dt_clipping_preview_mode_t mode
dt_dev_overexposed_colorscheme_t colorscheme
struct dt_develop_t::@16 rawoverexposed
struct dt_dev_pixelpipe_t * pipe
char filename[DT_MAX_FILENAME_LEN]
dt_iop_buffer_type_t datatype
dt_iop_global_data_t * data
struct dt_develop_t * dev
dt_iop_global_data_t * global_data
dt_dev_rawoverexposed_mode_t mode
dt_dev_rawoverexposed_colorscheme_t colorscheme
int kernel_rawoverexposed_falsecolor
int kernel_rawoverexposed_mark_cfa
int kernel_rawoverexposed_mark_solid
Region of interest passed through the pixelpipe.
#define __DT_CLONE_TARGETS__
Telling the user something happened.