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 }
92 return _(
"raw overexposed");
122 for(
int k = 0;
k <
ch;
k++)
132 d->threshold[
k] = (
unsigned int)chthr;
138 const void *
const ivoid,
void *
const ovoid)
151 const double iop_order = self->
iop_order;
155 const float *
const color = dt_iop_rawoverexposed_colors[colorscheme];
169 const float in_scale = roi_in->
scale;
170 dt_boundingbox_t pts = {(float)(roi_out->
x) / in_scale, (float)(roi_out->
y) / in_scale,
171 (float)(roi_out->
x + roi_out->
width) / in_scale, (float)(roi_out->
y + roi_out->
height) / in_scale};
172 printf(
"in %f %f %f %f\n", pts[0], pts[1], pts[2], pts[3]);
174 printf(
"out %f %f %f %f\n\n", pts[0], pts[1], pts[2], pts[3]);
177 const uint16_t *
const raw = (
const uint16_t *
const)buf.
buf;
182 const uint8_t(*
const xtrans)[6] = (
const uint8_t(*
const)[6])image->
dsc.
xtrans;
193 for(
int j = 0; j < roi_out->
height; j++)
198 for(
int i = 0;
i < roi_out->
width;
i++)
200 bufptr[2 *
i] = (float)(roi_out->
x +
i) / roi_in->
scale;
201 bufptr[2 *
i + 1] = (float)(roi_out->
y + j) / roi_in->
scale;
208 for(
int i = 0;
i < roi_out->
width;
i++)
210 const size_t pout = (size_t)
ch * (j * roi_out->
width +
i);
213 const int i_raw = (int)bufptr[2 *
i];
214 const int j_raw = (int)bufptr[2 *
i + 1];
216 if(i_raw < 0 || j_raw < 0 || i_raw >= buf.
width || j_raw >= buf.
height)
continue;
221 c =
FCxtrans(j_raw, i_raw, NULL, xtrans);
225 c =
FC(j_raw, i_raw, filters);
228 const size_t pin = (size_t)j_raw * buf.
width + i_raw;
229 const float in = raw[pin];
237 memcpy(
out + pout, dt_iop_rawoverexposed_colors[c],
sizeof(
float) * 4);
240 memcpy(
out + pout,
color,
sizeof(
float) * 4);
266 cl_mem dev_raw = NULL;
267 float *coordbuf = NULL;
268 cl_mem dev_coord = NULL;
269 cl_mem dev_thresholds = NULL;
270 cl_mem dev_colors = NULL;
271 cl_mem dev_xtrans = NULL;
286 const int devid = pipe->
devid;
291 size_t origin[] = { 0, 0, 0 };
297 if(err != CL_SUCCESS)
goto error;
300 const float *
const color = dt_iop_rawoverexposed_colors[colorscheme];
305 const int raw_width = buf.
width;
306 const int raw_height = buf.
height;
311 const size_t coordbufsize = (size_t)
height *
width * 2 *
sizeof(
float);
316 for(
int j = 0; j <
height; j++)
318 float *bufptr = ((
float *)coordbuf) + (size_t)2 * j *
width;
321 for(
int i = 0;
i < roi_out->
width;
i++)
323 bufptr[2 *
i] = (float)(roi_out->
x +
i) / roi_in->
scale;
324 bufptr[2 *
i + 1] = (float)(roi_out->
y + j) / roi_in->
scale;
336 if(err != CL_SUCCESS)
goto error;
349 sizeof(dt_iop_rawoverexposed_colors), CL_TRUE);
350 if(err != CL_SUCCESS)
goto error;
391 if(err != CL_SUCCESS)
goto error;
432 raw_width = buf.
width;
440 tiling->overhead = (size_t)raw_width * raw_height *
sizeof(uint16_t);
463 const int program = 2;
464 module->data = malloc(sizeof(dt_iop_rawoverexposed_global_data_t));
495 module->params = calloc(1, sizeof(dt_iop_rawoverexposed_t));
496 module->default_params = calloc(1, sizeof(dt_iop_rawoverexposed_t));
497 module->hide_enable_button = 1;
498 module->default_enabled = 1;
499 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
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)
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)
static __DT_CLONE_TARGETS__ void process_common_setup(dt_iop_module_t *self, const dt_dev_pixelpipe_iop_t *piece)
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)
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)
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_iop_buffer_dsc_t dsc_in
struct dt_iop_module_t *void * data
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]
struct dt_iop_buffer_dsc_t::@55 rawprepare
dt_iop_buffer_type_t datatype
dt_iop_global_data_t * data
struct dt_develop_t * dev
dt_iop_global_data_t * global_data
unsigned int threshold[4]
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.