51#include <glib/gi18n.h>
52#include <gtk/gtktypes.h>
64static const float dt_iop_rawoverexposed_colors[][4]
__attribute__((aligned(64))) = {
65 { 1.0f, 0.0f, 0.0f, 1.0f },
66 { 0.0f, 1.0f, 0.0f, 1.0f },
67 { 0.0f, 0.0f, 1.0f, 1.0f },
68 { 0.0f, 0.0f, 0.0f, 1.0f }
85 return _(
"raw overexposed");
115 for(
int k = 0;
k <
ch;
k++)
125 d->threshold[
k] = (
unsigned int)chthr;
131 const void *
const ivoid,
void *
const ovoid)
144 const double iop_order = self->
iop_order;
148 const float *
const color = dt_iop_rawoverexposed_colors[colorscheme];
162 const float in_scale = roi_in->
scale;
163 dt_boundingbox_t pts = {(float)(roi_out->
x) / in_scale, (float)(roi_out->
y) / in_scale,
164 (float)(roi_out->
x + roi_out->
width) / in_scale, (float)(roi_out->
y + roi_out->
height) / in_scale};
165 printf(
"in %f %f %f %f\n", pts[0], pts[1], pts[2], pts[3]);
167 printf(
"out %f %f %f %f\n\n", pts[0], pts[1], pts[2], pts[3]);
170 const uint16_t *
const raw = (
const uint16_t *
const)buf.
buf;
175 const uint8_t(*
const xtrans)[6] = (
const uint8_t(*
const)[6])image->
dsc.
xtrans;
186 for(
int j = 0; j < roi_out->
height; j++)
191 for(
int i = 0;
i < roi_out->
width;
i++)
193 bufptr[2 *
i] = (float)(roi_out->
x +
i) / roi_in->
scale;
194 bufptr[2 *
i + 1] = (float)(roi_out->
y + j) / roi_in->
scale;
201 for(
int i = 0;
i < roi_out->
width;
i++)
203 const size_t pout = (size_t)
ch * (j * roi_out->
width +
i);
206 const int i_raw = (int)bufptr[2 *
i];
207 const int j_raw = (int)bufptr[2 *
i + 1];
209 if(i_raw < 0 || j_raw < 0 || i_raw >= buf.
width || j_raw >= buf.
height)
continue;
214 c =
FCxtrans(j_raw, i_raw, NULL, xtrans);
218 c =
FC(j_raw, i_raw, filters);
221 const size_t pin = (size_t)j_raw * buf.
width + i_raw;
222 const float in = raw[pin];
230 memcpy(
out + pout, dt_iop_rawoverexposed_colors[c],
sizeof(
float) * 4);
233 memcpy(
out + pout, color,
sizeof(
float) * 4);
259 cl_mem dev_raw = NULL;
260 float *coordbuf = NULL;
261 cl_mem dev_coord = NULL;
262 cl_mem dev_thresholds = NULL;
263 cl_mem dev_colors = NULL;
264 cl_mem dev_xtrans = NULL;
279 const int devid = pipe->
devid;
284 size_t origin[] = { 0, 0, 0 };
290 if(err != CL_SUCCESS)
goto error;
293 const float *
const color = dt_iop_rawoverexposed_colors[colorscheme];
298 const int raw_width = buf.
width;
299 const int raw_height = buf.
height;
304 const size_t coordbufsize = (size_t)
height *
width * 2 *
sizeof(
float);
309 for(
int j = 0; j <
height; j++)
311 float *bufptr = ((
float *)coordbuf) + (size_t)2 * j *
width;
314 for(
int i = 0;
i < roi_out->
width;
i++)
316 bufptr[2 *
i] = (float)(roi_out->
x +
i) / roi_in->
scale;
317 bufptr[2 *
i + 1] = (float)(roi_out->
y + j) / roi_in->
scale;
329 if(err != CL_SUCCESS)
goto error;
342 sizeof(dt_iop_rawoverexposed_colors), CL_TRUE);
343 if(err != CL_SUCCESS)
goto error;
384 if(err != CL_SUCCESS)
goto error;
425 raw_width = buf.
width;
433 tiling->overhead = (size_t)raw_width * raw_height *
sizeof(uint16_t);
456 const int program = 2;
457 module->data = malloc(sizeof(dt_iop_rawoverexposed_global_data_t));
488 module->params = calloc(1, sizeof(dt_iop_rawoverexposed_t));
489 module->default_params = calloc(1, sizeof(dt_iop_rawoverexposed_t));
490 module->hide_enable_button = 1;
491 module->default_enabled = 1;
492 module->params_size = sizeof(dt_iop_rawoverexposed_t);
493 module->gui_data = NULL;
static void error(char *msg)
const dt_colormatrix_t dt_aligned_pixel_t out
void dt_control_log(const char *msg,...)
void dt_print(dt_debug_thread_t thread, const char *msg,...)
#define dt_free_align(ptr)
static void * dt_calloc_align(size_t size)
float dt_boundingbox_t[4]
#define dt_pixelpipe_cache_alloc_align_cache(size, id)
#define DT_MODULE(MODVER)
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_pixelpipe_cache_free_align(mem)
#define __DT_CLONE_TARGETS__
#define dt_get_perthread(buf, padsize)
#define __OMP_PARALLEL_FOR_SIMD__(...)
#define dt_pixelpipe_cache_alloc_perthread_float(n, padded_size)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
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
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)
float *const restrict const size_t k
float *const restrict const size_t const size_t ch
#define dt_mipmap_cache_get(A, B, C, D, E, F)
#define dt_mipmap_cache_release(A, B)
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)
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)
struct dt_mipmap_cache_t * mipmap_cache
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::@22 rawoverexposed
struct dt_dev_pixelpipe_t * pipe
char filename[DT_MAX_FILENAME_LEN]
struct dt_iop_buffer_dsc_t::@29 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.