160 _(
"linear or non-linear, Lab, scene-referred"),
161 _(
"frequential, Lab"),
162 _(
"special, Lab, scene-referred"));
181 void *new_params,
const int new_version)
183 if(old_version == 1 && new_version == 4)
188 new->radius = fabs(old->
radius);
191 new->brightness = 0.0f;
197 if(old_version == 2 && new_version == 4)
202 new->radius = fabs(old->
radius);
211 if(old_version == 3 && new_version == 4)
216 new->radius = fabs(old->
radius);
238 const int devid = pipe->
devid;
244 const float radius = fmax(0.1f,
d->radius);
246 const float saturation =
d->saturation;
247 const int order =
d->order;
248 const int unbound =
d->unbound;
250 cl_mem dev_cm = NULL;
251 cl_mem dev_ccoeffs = NULL;
252 cl_mem dev_lm = NULL;
253 cl_mem dev_lcoeffs = NULL;
254 cl_mem dev_tmp = NULL;
259 float Labmax[] = { 100.0f, 128.0f, 128.0f, 1.0f };
260 float Labmin[] = { 0.0f, -128.0f, -128.0f, 0.0f };
264 for(
int k = 0;
k < 4;
k++) Labmax[
k] = INFINITY;
265 for(
int k = 0;
k < 4;
k++) Labmin[
k] = -INFINITY;
273 if(err != CL_SUCCESS)
goto error;
281 const float detail = -1.0f;
286 if(err != CL_SUCCESS)
goto error;
288 if(err != CL_SUCCESS)
goto error;
290 if(err != CL_SUCCESS)
goto error;
310 size_t origin[] = { 0, 0, 0 };
313 if(err != CL_SUCCESS)
goto error;
328 if(err != CL_SUCCESS)
goto error;
358 const float radius = fmax(0.1f,
d->radius);
367 const size_t basebuffer =
sizeof(float) * channels *
width *
height;
399 float *in = (
float *)ivoid;
407 const float radius = fmax(0.1f, data->
radius);
409 const int order = data->
order;
410 const int unbound = data->
unbound;
412 float Labmax[] = { 100.0f, 128.0f, 128.0f, 1.0f };
413 float Labmin[] = { 0.0f, -128.0f, -128.0f, 0.0f };
417 for(
int k = 0;
k < 4;
k++) Labmax[
k] = INFINITY;
418 for(
int k = 0;
k < 4;
k++) Labmin[
k] = -INFINITY;
432 const float detail = -1.0f;
443 const float *
const Labminf = (
float *)&Labmin;
444 const float *
const Labmaxf = (
float *)&Labmax;
446 for(
size_t k = 0;
k < (size_t)roi_out->
width * roi_out->
height;
k++)
449 ? data->
ctable[CLAMP((
int)(
out[
k *
ch + 0] / 100.0f * 0x10000ul), 0, 0xffff)]
452 ? data->
ltable[CLAMP((
int)(
out[
k *
ch + 0] / 100.0f * 0x10000ul), 0, 0xffff)]
465order_changed (GtkComboBox *combo, gpointer user_data)
470 p->order = gtk_combo_box_get_active(combo);
481 d->radius =
p->radius;
482 d->contrast =
p->contrast;
483 d->brightness =
p->brightness;
484 d->saturation =
p->saturation;
485 d->lowpass_algo =
p->lowpass_algo;
486 d->unbound =
p->unbound;
495 if(fabs(
d->contrast) <= 1.0f)
498 for(
int k = 0;
k < 0x10000;
k++)
d->ctable[
k] =
d->contrast * (100.0f *
k / 0x10000 - 50.0f) + 50.0f;
504 const float boost = 5.0f;
505 const float contrastm1sq = boost * (fabs(
d->contrast) - 1.0f) * (fabs(
d->contrast) - 1.0f);
506 const float contrastscale = copysign(sqrtf(1.0f + contrastm1sq),
d->contrast);
508 for(
int k = 0;
k < 0x10000;
k++)
510 float kx2m1 = 2.0f * (float)
k / 0x10000 - 1.0f;
511 d->ctable[
k] = 50.0f * (contrastscale * kx2m1 / sqrtf(1.0f + contrastm1sq * kx2m1 * kx2m1) + 1.0f);
516 const float xc[4] = { 0.7f, 0.8f, 0.9f, 1.0f };
517 const float yc[4] = {
d->ctable[CLAMP((
int)(xc[0] * 0x10000ul), 0, 0xffff)],
518 d->ctable[CLAMP((
int)(xc[1] * 0x10000ul), 0, 0xffff)],
519 d->ctable[CLAMP((
int)(xc[2] * 0x10000ul), 0, 0xffff)],
520 d->ctable[CLAMP((
int)(xc[3] * 0x10000ul), 0, 0xffff)] };
525 const float gamma = (
d->brightness >= 0.0f) ? 1.0f / (1.0f +
d->brightness) : (1.0f -
d->brightness);
527 for(
int k = 0;
k < 0x10000;
k++)
529 d->ltable[
k] = 100.0f * powf((
float)
k / 0x10000, gamma);
533 const float xl[4] = { 0.7f, 0.8f, 0.9f, 1.0f };
534 const float yl[4] = {
d->ltable[CLAMP((
int)(xl[0] * 0x10000ul), 0, 0xffff)],
535 d->ltable[CLAMP((
int)(xl[1] * 0x10000ul), 0, 0xffff)],
536 d->ltable[CLAMP((
int)(xl[2] * 0x10000ul), 0, 0xffff)],
537 d->ltable[CLAMP((
int)(xl[3] * 0x10000ul), 0, 0xffff)] };
544 piece->
data = (
void *)
d;
546 for(
int k = 0;
k < 0x10000;
k++)
d->ctable[
k] =
d->ltable[
k] = 100.0f *
k / 0x10000;
557 const int program = 6;
592 gtk_widget_set_tooltip_text(
g->radius, _(
"radius of gaussian/bilateral blur"));
593 gtk_widget_set_tooltip_text(
g->contrast, _(
"contrast of lowpass filter"));
594 gtk_widget_set_tooltip_text(
g->brightness, _(
"brightness adjustment of lowpass filter"));
595 gtk_widget_set_tooltip_text(
g->saturation, _(
"color saturation of lowpass filter"));
596 gtk_widget_set_tooltip_text(
g->lowpass_algo, _(
"which filter to use for blurring"));
599 g_signal_connect (G_OBJECT (
g->order),
"changed",
600 G_CALLBACK (order_changed), self);
static void error(char *msg)
void dt_bilateral_free(dt_bilateral_t *b)
__DT_CLONE_TARGETS__ void dt_bilateral_splat(const dt_bilateral_t *b, const float *const in)
size_t dt_bilateral_memory_use(const int width, const int height, const float sigma_s, const float sigma_r)
dt_bilateral_t * dt_bilateral_init(const int width, const int height, const float sigma_s, const float sigma_r)
size_t dt_bilateral_singlebuffer_size(const int width, const int height, const float sigma_s, const float sigma_r)
__DT_CLONE_TARGETS__ void dt_bilateral_slice(const dt_bilateral_t *const b, const float *const in, float *out, const float detail)
void dt_bilateral_blur(const dt_bilateral_t *b)
void dt_bilateral_free_cl(dt_bilateral_cl_t *b)
cl_int dt_bilateral_slice_cl(dt_bilateral_cl_t *b, cl_mem in, cl_mem out, const float detail)
dt_bilateral_cl_t * dt_bilateral_init_cl(const int devid, const int width, const int height, const float sigma_s, const float sigma_r)
cl_int dt_bilateral_blur_cl(dt_bilateral_cl_t *b)
cl_int dt_bilateral_splat_cl(dt_bilateral_cl_t *b, cl_mem in)
@ DEVELOP_BLEND_CS_RGB_DISPLAY
static const dt_aligned_pixel_simd_t const dt_adaptation_t const float p
const dt_colormatrix_t dt_aligned_pixel_t out
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
void dt_print(dt_debug_thread_t thread, const char *msg,...)
#define dt_free_align(ptr)
static void * dt_calloc_align(size_t size)
#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE)
#define __DT_CLONE_TARGETS__
#define __OMP_PARALLEL_FOR__(...)
#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_database_start_transaction(db)
#define dt_database_release_transaction(db)
#define dt_dev_add_history_item(dev, module, enable, redraw)
void dt_gaussian_free(dt_gaussian_t *g)
void dt_gaussian_free_cl(dt_gaussian_cl_t *g)
size_t dt_gaussian_memory_use_cl(const int width, const int height, const int channels)
size_t dt_gaussian_singlebuffer_size(const int width, const int height, const int channels)
cl_int dt_gaussian_blur_cl(dt_gaussian_cl_t *g, cl_mem dev_in, cl_mem dev_out)
void dt_gaussian_blur_4c(dt_gaussian_t *g, const float *const in, float *const out)
dt_gaussian_cl_t * dt_gaussian_init_cl(const int devid, const int width, const int height, const int channels, const float *max, const float *min, const float sigma, const int order)
dt_gaussian_t * dt_gaussian_init(const int width, const int height, const int channels, const float *max, const float *min, const float sigma, const int order)
size_t dt_gaussian_memory_use(const int width, const int height, const int channels)
void dt_gui_presets_add_generic(const char *name, dt_dev_operation_t op, const int32_t version, const void *params, const int32_t params_size, const int32_t enabled, const dt_develop_blend_colorspace_t blend_cst)
const char ** dt_iop_set_description(dt_iop_module_t *module, const char *main_text, const char *purpose, const char *input, const char *process, const char *output)
@ IOP_FLAGS_INCLUDE_IN_STYLES
@ IOP_FLAGS_SUPPORTS_BLENDING
#define IOP_GUI_ALLOC(module)
GtkWidget * dt_bauhaus_slider_from_params(dt_iop_module_t *self, const char *param)
GtkWidget * dt_bauhaus_combobox_from_params(dt_iop_module_t *self, const char *param)
static void dt_iop_estimate_exp(const float *const x, const float *const y, const int num, float *coeff)
static float dt_iop_eval_exp(const float *const coeff, const float x)
void commit_params(struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
const char ** description(struct dt_iop_module_t *self)
__DT_CLONE_TARGETS__ int process(struct 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 init_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void gui_init(struct dt_iop_module_t *self)
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 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 init_presets(dt_iop_module_so_t *self)
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)
int legacy_params(dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
float *const restrict const size_t k
float *const restrict const size_t const size_t ch
#define CLAMPF(a, mn, mx)
int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes)
void * dt_opencl_alloc_device(const int devid, const int width, const int height, const int bpp)
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_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)
int dt_opencl_avoid_atomics(const int devid)
struct _GtkWidget GtkWidget
struct dt_gui_gtk_t * gui
const struct dt_database_t * db
struct dt_develop_t * develop
dt_iop_buffer_dsc_t dsc_in
struct dt_iop_module_t *void * data
dt_gaussian_order_t order
dt_iop_lowpass_algo_t lowpass_algo
float lunbounded_coeffs[3]
float cunbounded_coeffs[3]
dt_gaussian_order_t order
dt_gaussian_order_t order
dt_gaussian_order_t order
dt_iop_lowpass_algo_t lowpass_algo
dt_gaussian_order_t order
GModule *dt_dev_operation_t op
dt_iop_global_data_t * data
dt_iop_global_data_t * global_data
Region of interest passed through the pixelpipe.