102 { 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,
103 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,
104 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,
105 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f },
106 { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
107 { 0 }, 0, 0,
FALSE };
110 gboolean is_scene_referred)
114 switch(module->blend_colorspace(module, NULL, NULL))
202 const int32_t blend_csp = params->blend_cst;
203 const uint32_t blendif = params->blendif;
204 const float *blendif_parameters = params->blendif_parameters;
205 const float *boost_factors = params->blendif_boost_factors;
208 if(blendif & (1 <<
i))
216 parameters[j + 0] = (blendif_parameters[
i * 4 + 0] - offset) * exp2f(boost_factors[
i]);
217 parameters[j + 1] = (blendif_parameters[
i * 4 + 1] - offset) * exp2f(boost_factors[
i]);
218 parameters[j + 2] = (blendif_parameters[
i * 4 + 2] - offset) * exp2f(boost_factors[
i]);
219 parameters[j + 3] = (blendif_parameters[
i * 4 + 3] - offset) * exp2f(boost_factors[
i]);
221 parameters[j + 4] = 1.0f / fmaxf(0.001f, parameters[j + 1] - parameters[j + 0]);
222 parameters[j + 5] = 1.0f / fmaxf(0.001f, parameters[j + 3] - parameters[j + 2]);
224 if(blendif_parameters[
i * 4 + 0] <= 0.0f && blendif_parameters[
i * 4 + 1] <= 0.0f)
226 parameters[j + 0] = -INFINITY;
227 parameters[j + 1] = -INFINITY;
229 if(blendif_parameters[
i * 4 + 2] >= 1.0f && blendif_parameters[
i * 4 + 3] >= 1.0f)
231 parameters[j + 2] = INFINITY;
232 parameters[j + 3] = INFINITY;
237 parameters[j + 0] = -INFINITY;
238 parameters[j + 1] = -INFINITY;
239 parameters[j + 2] = INFINITY;
240 parameters[j + 3] = INFINITY;
241 parameters[j + 4] = 0.0f;
242 parameters[j + 5] = 0.0f;
249 gboolean *top_enabled,
250 gboolean *raster_used,
251 gboolean *drawn_used,
252 gboolean *parametric_used)
260 const uint32_t mask_mode = params->mask_mode;
266 gboolean raster = raster_mode
267 && (params->raster_mask_id > 0
268 || params->raster_mask_source[0] !=
'\0'
271 gboolean drawn =
FALSE;
278 gboolean parametric =
FALSE;
281 const float threshold_epsilon = 1e-6f;
285 uint32_t active_channels = 0;
288 const uint32_t bit = 1u <<
ch;
289 if(!(channel_mask & bit) || !(params->blendif & bit))
continue;
290 const float *channel = ¶ms->blendif_parameters[
ch * 4];
291 if(fabsf(channel[0]) > threshold_epsilon
292 || fabsf(channel[1]) > threshold_epsilon
293 || fabsf(channel[2] - 1.0f) > threshold_epsilon
294 || fabsf(channel[3] - 1.0f) > threshold_epsilon)
295 active_channels |= bit;
297 parametric = active_channels != 0;
301 if(!
IS_NULL_PTR(raster_used)) *raster_used = raster;
303 if(!
IS_NULL_PTR(parametric_used)) *parametric_used = parametric;
314 { 0.9555766f, -0.0230393f, 0.0631636f, 0.0f },
315 { -0.0282895f, 1.0099416f, 0.0210077f, 0.0f },
316 { 0.0122982f, -0.0204830f, 1.3299098f, 0.0f },
325 for(
size_t y = 0; y < 3; y++)
327 for(
size_t x = 0;
x < 3;
x++)
330 for(
size_t i = 0;
i < 3;
i++)
343 return 0.005f * (detail ? powf(level, 2.0f) : 1.0f - powf(fabs(level), 0.5f ));
351 if(level == 0.0f)
return;
354 const gboolean detail = (level > 0.0f);
359 float *warp_mask = NULL;
360 float *rawdetail_mask = NULL;
366 const int iwidth =
p->rawdetail_mask_roi.width;
367 const int iheight =
p->rawdetail_mask_roi.height;
368 const int owidth = roi_out->
width;
369 const int oheight = roi_out->
height;
370 if(info) fprintf(stderr,
"[_refine_with_detail_mask] in module %s %ix%i --> %ix%i\n", self->
op, iwidth, iheight, owidth, oheight);
372 const int bufsize =
MAX(iwidth * iheight, owidth * oheight);
385 const gboolean warp_mask_aliases_lum = (warp_mask == lum);
386 if(!warp_mask_aliases_lum)
394 const int msize = owidth * oheight;
396 for(
int idx =0; idx < msize; idx++)
398 mask[idx] = mask[idx] * warp_mask[idx];
401 if(warp_mask_aliases_lum) lum = NULL;
416 const gboolean mask_feather = params->feathering_radius > 0.1f && piece->
dsc_in.
channels >= 3;
417 const gboolean mask_blur = params->blur_radius > 0.1f;
418 const gboolean mask_tone_curve = fabsf(params->contrast) >= 0.01f || fabsf(params->brightness) >= 0.01f;
423 const float opacity = fminf(fmaxf(params->opacity / 100.0f, 0.0f), 1.0f);
430 if(mask_blur && mask_feather_before)
447 if(mask_tone_curve && opacity > 1e-4f)
457 const size_t xoffs,
const size_t yoffs,
458 const size_t owidth,
const size_t oheight)
460 const size_t ioffset = yoffs * iwidth + xoffs;
461 float *
const restrict output =
468 for(
size_t y = 0; y < oheight; y++)
470 const size_t iindex = y * iwidth + ioffset;
471 const size_t oindex = y * owidth;
472 memcpy(output + oindex, input + iindex,
sizeof(
float) * owidth);
489 if(source && !strcmp(source->
op, params->raster_mask_source)
493 if(
IS_NULL_PTR(self->
dev) || params->raster_mask_source[0] ==
'\0')
return NULL;
495 for(GList *iter = g_list_first(self->
dev->
iop); iter; iter = g_list_next(iter))
498 if(!strcmp(candidate->
op, params->raster_mask_source)
510 float *
const restrict mask,
512 const size_t oheight,
513 int *
const raster_error)
515 int local_raster_error = 0;
517 float *raster_mask = raster_source
519 self, &local_raster_error)
524 if(params->raster_mask_invert)
527 for(
size_t i = 0;
i < owidth * oheight;
i++)
528 mask[
i] = 1.0f - raster_mask[
i];
539 const float value = params->raster_mask_invert ? 0.0f : 1.0f;
543 if(!
IS_NULL_PTR(raster_error)) *raster_error = local_raster_error;
551 float *
const restrict mask,
553 const size_t oheight)
579 const float *
const restrict other_mask,
580 const size_t buffsize)
583 for(
size_t i = 0;
i < buffsize;
i++)
584 mask[
i] *= other_mask[
i];
589 const size_t height,
const int ch,
const float guide_weight,
590 const float feathering_radius,
const float scale)
592 const float sqrt_eps = 1.f;
593 int w = (int)(2 * feathering_radius * scale + 0.5f);
596 float *
const restrict mask_bak =
600 memcpy(mask_bak, mask,
sizeof(
float) *
width *
height);
601 if(
guided_filter(guide, mask_bak, mask,
width,
height,
ch, w, sqrt_eps, guide_weight, 0.f, 1.f) != 0)
612 const float contrast,
const float brightness,
615 const float mask_epsilon = 16 * FLT_EPSILON;
616 const float e = expf(3.f * contrast);
618 for(
size_t k = 0;
k < buffsize;
k++)
620 float x = mask[
k] / opacity;
622 if (1.f - brightness <= 0.f)
623 x = mask[
k] <= mask_epsilon ? -1.f : 1.f;
624 else if (1.f + brightness <= 0.f)
625 x = mask[
k] >= 1.f - mask_epsilon ? 1.f : -1.f;
626 else if (brightness > 0.f)
628 x = (
x + brightness) / (1.f - brightness);
633 x = (
x + brightness) / (1.f + brightness);
637 ((
x * e / (1.f + (e - 1.f) * fabsf(
x))) / 2.f + 0.5f) * opacity, 0.f, 1.f);
653 gboolean top_enabled =
FALSE;
654 gboolean raster_used =
FALSE;
655 gboolean drawn_used =
FALSE;
656 gboolean parametric_used =
FALSE;
658 if(!top_enabled)
return 0;
662 const gboolean preview_mask_mode = top_enabled;
665 const int xoffs = roi_out->
x - roi_in->
x;
666 const int yoffs = roi_out->
y - roi_in->
y;
667 const int iwidth = roi_in->
width;
668 const int iheight = roi_in->
height;
669 const int owidth = roi_out->
width;
670 const int oheight = roi_out->
height;
671 const size_t buffsize = (size_t)owidth * oheight;
673 const float oscale = roi_out->
scale;
674 const gboolean rois_equal = iwidth == owidth || iheight == oheight || xoffs == 0 || yoffs == 0;
683 if(oscale !=
iscale || xoffs < 0 || yoffs < 0
684 || ((xoffs > 0 || yoffs > 0) && (owidth + xoffs > iwidth || oheight + yoffs > iheight)))
686 dt_control_log(_(
"skipped blending in module '%s': roi's do not match"), self->
op);
693 && preview_mask_mode)
706 const float opacity = fminf(fmaxf(
d->opacity / 100.0f, 0.0f), 1.0f);
715 int raster_error = 0;
716 float *
const restrict mask = _mask;
717 const gboolean use_masks = raster_used || drawn_used || parametric_used;
718 const gboolean raster_only = raster_used && !drawn_used && !parametric_used;
733 if(!raster_used && !drawn_used)
781 (
const float *
const restrict)
ovoid, mask);
785 (
const float *
const restrict)
ovoid, mask);
789 (
const float *
const restrict)
ovoid, mask);
793 (
const float *
const restrict)
ovoid, mask);
800 for(
size_t index = 0; index < post_operations_size; ++index)
806 float *restrict guide = (
float *restrict)ivoid;
809 ch * owidth,
ch * oheight);
816 d->feathering_radius, roi_out->
scale) != 0)
830 guide_weight,
d->feathering_radius, roi_out->
scale) != 0)
838 const float sigma =
d->blur_radius * roi_out->
scale;
839 const float mmax[] = { 1.0f };
840 const float mmin[] = { 0.0f };
862 mask, request_mask_display);
866 mask, request_mask_display);
870 mask, request_mask_display);
874 mask, request_mask_display);
891 void *cache_data = NULL;
894 "raster mask", pipe->
type,
TRUE, &cache_data, &mask_entry);
914 memcpy(cache_data, _mask,
sizeof(
float) * buffsize);
925 piece->module->multi_priority),
927 piece->module->multi_priority, piece->module->iop_order,
933 "[raster masks] %s mask id 0 for module %s (%s) for pipe %s"
934 " with cache hash %" PRIu64
"\n",
935 created ?
"published" :
"reused cached",
936 piece->module->op, piece->module->multi_name,
942 "[raster masks] discarding unpublished mask id 0 for module %s (%s) for pipe %s\n",
943 piece->module->op, piece->module->multi_name,
954 const float level,
const int devid)
957 if(level == 0.0f)
return;
960 const int detail = (level > 0.0f);
963 float *rawdetail_mask = NULL;
972 const int iwidth =
p->rawdetail_mask_roi.width;
973 const int iheight =
p->rawdetail_mask_roi.height;
974 const int owidth = roi_out->
width;
975 const int oheight = roi_out->
height;
976 if(info) fprintf(stderr,
"[_refine_with_detail_mask_cl] in module %s %ix%i --> %ix%i\n", self->
op, iwidth, iheight, owidth, oheight);
989 if(err != CL_SUCCESS)
goto error;
1000 if(err != CL_SUCCESS)
goto error;
1013 if(err != CL_SUCCESS)
goto error;
1019 cl_mem dev_blurmat = NULL;
1032 if(err != CL_SUCCESS)
goto error;
1049 if(err != CL_SUCCESS)
goto error;
1054 if(err != CL_SUCCESS)
goto error;
1060 tmp = blur =
out = NULL;
1066 const gboolean warp_mask_aliases_lum = (warp_mask == lum);
1067 if(!warp_mask_aliases_lum)
1073 const int msize = owidth * oheight;
1075 for(
int idx = 0; idx < msize; idx++)
1077 mask[idx] = mask[idx] * warp_mask[idx];
1080 if(warp_mask_aliases_lum) lum = NULL;
1108 gboolean top_enabled =
FALSE;
1109 gboolean raster_used =
FALSE;
1110 gboolean drawn_used =
FALSE;
1111 gboolean parametric_used =
FALSE;
1113 if(!top_enabled)
return 0;
1114 const unsigned int mask_mode =
d->mask_mode;
1118 const gboolean preview_mask_mode = top_enabled;
1121 const int xoffs = roi_out->
x - roi_in->
x;
1122 const int yoffs = roi_out->
y - roi_in->
y;
1123 const int iwidth = roi_in->
width;
1124 const int iheight = roi_in->
height;
1125 const int owidth = roi_out->
width;
1126 const int oheight = roi_out->
height;
1127 const size_t buffsize = (size_t)owidth * oheight;
1129 const float oscale = roi_out->
scale;
1130 const gboolean rois_equal = iwidth == owidth || iheight == oheight || xoffs == 0 || yoffs == 0;
1139 if(oscale !=
iscale || xoffs < 0 || yoffs < 0
1140 || ((xoffs > 0 || yoffs > 0) && (owidth + xoffs > iwidth || oheight + yoffs > iheight)))
1142 dt_control_log(_(
"skipped blending in module '%s': roi's do not match"), self->
op);
1152 && preview_mask_mode)
1165 const float opacity = fminf(fmaxf(
d->opacity / 100.0f, 0.0f), 1.0f);
1166 const gboolean use_masks = raster_used || drawn_used || parametric_used;
1167 const gboolean raster_only = raster_used && !drawn_used && !parametric_used;
1176 float *
const mask = _mask;
1208 const int devid = pipe->
devid;
1209 const int offs[2] = { xoffs, yoffs };
1213 cl_mem dev_blendif_params = NULL;
1214 cl_mem dev_boost_factors = NULL;
1215 cl_mem dev_mask_1 = NULL;
1216 cl_mem dev_mask_2 = NULL;
1217 cl_mem dev_tmp = NULL;
1218 cl_mem dev_guide = NULL;
1220 cl_mem dev_profile_info = NULL;
1221 cl_mem dev_profile_lut = NULL;
1223 cl_float *profile_lut_cl = NULL;
1225 cl_mem dev_work_profile_info = NULL;
1226 cl_mem dev_work_profile_lut = NULL;
1228 cl_float *work_profile_lut_cl = NULL;
1230 size_t origin[] = { 0, 0, 0 };
1231 size_t region[] = { owidth, oheight, 1 };
1248 &profile_lut_cl, &dev_profile_info, &dev_profile_lut);
1249 if(err != CL_SUCCESS)
goto error;
1261 if(err != CL_SUCCESS)
goto error;
1263 else if(raster_only)
1265 int raster_error = 0;
1267 if(raster_error)
goto error;
1271 if(err != CL_SUCCESS)
goto error;
1275 if(!raster_used && !drawn_used)
1283 else if(raster_used)
1285 int raster_error = 0;
1287 if(raster_error)
goto error;
1315 if(err != CL_SUCCESS)
goto error;
1318 const unsigned blendif =
d->blendif;
1319 const unsigned int mask_combine =
d->mask_combine;
1336 if(err != CL_SUCCESS)
1338 fprintf(stderr,
"[dt_develop_blend_process_cl] error %i enqueue kernel\n", err);
1346 for(
size_t index = 0; index < post_operations_size; ++index)
1351 int w = (int)(2 *
d->feathering_radius * roi_out->
scale + 0.5f);
1353 const float sqrt_eps = 1.0f;
1356 cl_mem guide = dev_in;
1362 size_t origin_1[] = { xoffs, yoffs, 0 };
1363 size_t origin_2[] = { 0, 0, 0 };
1365 if(err != CL_SUCCESS)
goto error;
1367 if(
guided_filter_cl(devid, guide, dev_mask_1, dev_mask_2, owidth, oheight,
ch, w, sqrt_eps, guide_weight,
1379 int w = (int)(2 *
d->feathering_radius * roi_out->
scale + 0.5f);
1381 const float sqrt_eps = 1.0f;
1384 if(
guided_filter_cl(devid, dev_out, dev_mask_1, dev_mask_2, owidth, oheight,
ch, w, sqrt_eps, guide_weight,
1391 const float sigma =
d->blur_radius * roi_out->
scale;
1392 const float mmax[] = { 1.0f };
1393 const float mmin[] = { 0.0f };
1399 if(err != CL_SUCCESS)
goto error;
1404 const float e = expf(3.f *
d->contrast);
1405 const float brightness =
d->brightness;
1414 if(err != CL_SUCCESS)
goto error;
1429 if(err != CL_SUCCESS)
goto error;
1435 d->blendif_boost_factors);
1441 const int use_work_profile = !
IS_NULL_PTR(work_profile);
1444 &dev_work_profile_info, &dev_work_profile_lut);
1445 if(err != CL_SUCCESS)
goto error;
1464 if(err != CL_SUCCESS)
1466 fprintf(stderr,
"[dt_develop_blend_process_cl] error %i enqueue kernel\n", err);
1473 const unsigned int blend_mode =
d->blend_mode;
1474 const float blend_parameter = exp2f(
d->blend_parameter);
1486 if(err != CL_SUCCESS)
goto error;
1503 if(err != CL_SUCCESS)
goto error;
1508 void *cache_data = NULL;
1511 "raster mask", pipe->
type,
TRUE, &cache_data, &mask_entry);
1530 memcpy(cache_data, _mask,
sizeof(
float) * buffsize);
1542 piece->module->multi_priority),
1544 piece->module->multi_priority, piece->module->iop_order,
1550 "[raster masks] %s mask id 0 for module %s (%s) for pipe %s"
1551 " with cache hash %" PRIu64
"\n",
1552 created ?
"published" :
"reused cached",
1553 piece->module->op, piece->module->multi_name,
1559 "[raster masks] discarding unpublished mask id 0 for module %s (%s) for pipe %s\n",
1560 piece->module->op, piece->module->multi_name,
1571 &dev_work_profile_lut);
1584 &dev_work_profile_lut);
1596 const int program = 3;
1609 const int program_rcd = 31;
1680 const char *data = (
const char *)params;
1682 for(
size_t k = 0;
k < length;
k++)
1683 if(data[
k])
return FALSE;
1691 gboolean blend_reverse =
FALSE;
1692 switch(blend_mode) {
1698 blend_reverse =
TRUE;
1706 blend_reverse =
TRUE;
1716 const int old_version,
void *new_params,
const int new_version,
1733 *
n = default_display_blend_params;
1737 if(old_version == 1 && new_version == 11)
1740 typedef struct dt_develop_blend_params1_t
1745 } dt_develop_blend_params1_t;
1747 if(length !=
sizeof(dt_develop_blend_params1_t))
return 1;
1749 dt_develop_blend_params1_t *o = (dt_develop_blend_params1_t *)old_params;
1752 *
n = default_display_blend_params;
1755 n->opacity = o->opacity;
1756 n->mask_id = o->mask_id;
1760 if(old_version == 2 && new_version == 11)
1763 typedef struct dt_develop_blend_params2_t
1774 float blendif_parameters[4 * 8];
1775 } dt_develop_blend_params2_t;
1777 if(length !=
sizeof(dt_develop_blend_params2_t))
return 1;
1779 dt_develop_blend_params2_t *o = (dt_develop_blend_params2_t *)old_params;
1782 *
n = default_display_blend_params;
1788 n->opacity = o->opacity;
1789 n->mask_id = o->mask_id;
1790 n->blendif = o->blendif & 0xff;
1793 for(
int i = 0;
i < (4 * 8);
i++)
n->blendif_parameters[
i] = o->blendif_parameters[
i];
1798 if(old_version == 3 && new_version == 11)
1801 typedef struct dt_develop_blend_params3_t
1813 } dt_develop_blend_params3_t;
1815 if(length !=
sizeof(dt_develop_blend_params3_t))
return 1;
1817 dt_develop_blend_params3_t *o = (dt_develop_blend_params3_t *)old_params;
1820 *
n = default_display_blend_params;
1826 n->opacity = o->opacity;
1827 n->mask_id = o->mask_id;
1834 if(old_version == 4 && new_version == 11)
1837 typedef struct dt_develop_blend_params4_t
1851 } dt_develop_blend_params4_t;
1853 if(length !=
sizeof(dt_develop_blend_params4_t))
return 1;
1855 dt_develop_blend_params4_t *o = (dt_develop_blend_params4_t *)old_params;
1858 *
n = default_display_blend_params;
1864 n->opacity = o->opacity;
1865 n->mask_id = o->mask_id;
1866 n->blur_radius = o->radius;
1873 if(old_version == 5 && new_version == 11)
1876 typedef struct dt_develop_blend_params5_t
1881 uint32_t blend_mode;
1885 uint32_t mask_combine;
1893 uint32_t reserved[4];
1896 } dt_develop_blend_params5_t;
1898 if(length !=
sizeof(dt_develop_blend_params5_t))
return 1;
1900 dt_develop_blend_params5_t *o = (dt_develop_blend_params5_t *)old_params;
1903 *
n = default_display_blend_params;
1906 n->opacity = o->opacity;
1907 n->mask_combine = o->mask_combine;
1908 n->mask_id = o->mask_id;
1909 n->blur_radius = o->radius;
1921 if(old_version == 6 && new_version == 11)
1924 typedef struct dt_develop_blend_params6_t
1929 uint32_t blend_mode;
1933 uint32_t mask_combine;
1941 uint32_t reserved[4];
1944 } dt_develop_blend_params6_t;
1946 if(length !=
sizeof(dt_develop_blend_params6_t))
return 1;
1948 dt_develop_blend_params6_t *o = (dt_develop_blend_params6_t *)old_params;
1951 *
n = default_display_blend_params;
1954 n->opacity = o->opacity;
1955 n->mask_combine = o->mask_combine;
1956 n->mask_id = o->mask_id;
1957 n->blur_radius = o->radius;
1958 n->blendif = o->blendif;
1963 if(old_version == 7 && new_version == 11)
1966 typedef struct dt_develop_blend_params7_t
1971 uint32_t blend_mode;
1975 uint32_t mask_combine;
1983 uint32_t reserved[4];
1986 } dt_develop_blend_params7_t;
1988 if(length !=
sizeof(dt_develop_blend_params7_t))
return 1;
1990 dt_develop_blend_params7_t *o = (dt_develop_blend_params7_t *)old_params;
1993 *
n = default_display_blend_params;
1996 n->opacity = o->opacity;
1997 n->mask_combine = o->mask_combine;
1998 n->mask_id = o->mask_id;
1999 n->blur_radius = o->radius;
2000 n->blendif = o->blendif;
2005 if(old_version == 8 && new_version == 11)
2008 typedef struct dt_develop_blend_params8_t
2013 uint32_t blend_mode;
2017 uint32_t mask_combine;
2023 float feathering_radius;
2025 uint32_t feathering_guide;
2033 uint32_t reserved[4];
2036 } dt_develop_blend_params8_t;
2038 if(length !=
sizeof(dt_develop_blend_params8_t))
return 1;
2040 dt_develop_blend_params8_t *o = (dt_develop_blend_params8_t *)old_params;
2043 *
n = default_display_blend_params;
2046 n->opacity = o->opacity;
2047 n->mask_combine = o->mask_combine;
2048 n->mask_id = o->mask_id;
2049 n->blendif = o->blendif;
2050 n->feathering_radius = o->feathering_radius;
2051 n->feathering_guide = o->feathering_guide;
2052 n->blur_radius = o->blur_radius;
2053 n->contrast = o->contrast;
2054 n->brightness = o->brightness;
2059 if(old_version == 9 && new_version == 11)
2062 typedef struct dt_develop_blend_params9_t
2068 uint32_t blend_mode;
2072 uint32_t mask_combine;
2078 float feathering_radius;
2080 uint32_t feathering_guide;
2088 uint32_t reserved[4];
2092 int raster_mask_instance;
2094 gboolean raster_mask_invert;
2095 } dt_develop_blend_params9_t;
2097 if(length !=
sizeof(dt_develop_blend_params9_t))
return 1;
2099 dt_develop_blend_params9_t *o = (dt_develop_blend_params9_t *)old_params;
2102 *
n = default_display_blend_params;
2105 n->opacity = o->opacity;
2106 n->mask_combine = o->mask_combine;
2107 n->mask_id = o->mask_id;
2108 n->blendif = o->blendif;
2109 n->feathering_radius = o->feathering_radius;
2110 n->feathering_guide = o->feathering_guide;
2111 n->blur_radius = o->blur_radius;
2112 n->contrast = o->contrast;
2113 n->brightness = o->brightness;
2115 memcpy(
n->raster_mask_source, o->raster_mask_source,
sizeof(
n->raster_mask_source));
2116 n->raster_mask_instance = o->raster_mask_instance;
2117 n->raster_mask_id = o->raster_mask_id;
2118 n->raster_mask_invert = o->raster_mask_invert;
2122 if(old_version == 10 && new_version == 11)
2125 typedef struct dt_develop_blend_params10_t
2133 uint32_t blend_mode;
2135 float blend_parameter;
2139 uint32_t mask_combine;
2145 float feathering_radius;
2147 uint32_t feathering_guide;
2155 uint32_t reserved[4];
2160 int raster_mask_instance;
2162 gboolean raster_mask_invert;
2163 } dt_develop_blend_params10_t;
2165 if(length !=
sizeof(dt_develop_blend_params10_t))
return 1;
2167 dt_develop_blend_params10_t *o = (dt_develop_blend_params10_t *)old_params;
2170 *
n = default_display_blend_params;
2172 n->blend_cst = o->blend_cst;
2174 n->blend_parameter = o->blend_parameter;
2175 n->opacity = o->opacity;
2176 n->mask_combine = o->mask_combine;
2177 n->mask_id = o->mask_id;
2178 n->blendif = o->blendif;
2179 n->feathering_radius = o->feathering_radius;
2180 n->feathering_guide = o->feathering_guide;
2181 n->blur_radius = o->blur_radius;
2182 n->contrast = o->contrast;
2183 n->brightness = o->brightness;
2185 memcpy(&
n->details, &o->reserved,
sizeof(
float));
2186 if(isnan(
n->details))
n->details = 0.0f;
2187 n->details = fminf(1.0f, fmaxf(-1.0f,
n->details));
2191 memcpy(
n->raster_mask_source, o->raster_mask_source,
sizeof(
n->raster_mask_source));
2192 n->raster_mask_instance = o->raster_mask_instance;
2193 n->raster_mask_id = o->raster_mask_id;
2194 n->raster_mask_invert = o->raster_mask_invert;
2202 const int old_version,
void *new_params,
const int new_version,
2206 dt_iop_module_t *
module = (dt_iop_module_t *)calloc(1, sizeof(dt_iop_module_t));
2213 if(module->params_size == 0)
static void error(char *msg)
static dt_develop_blend_colorspace_t _blend_default_module_blend_colorspace(dt_iop_module_t *module, gboolean is_scene_referred)
_develop_mask_post_processing
@ DEVELOP_MASK_POST_TONE_CURVE
@ DEVELOP_MASK_POST_FEATHER_IN
@ DEVELOP_MASK_POST_FEATHER_OUT
void dt_develop_blend_init_blend_parameters(dt_develop_blend_params_t *blend_params, dt_develop_blend_colorspace_t cst)
static void _develop_blend_combine_masks(float *const restrict mask, const float *const restrict other_mask, const size_t buffsize)
int dt_develop_blend_process_cl(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out)
static void _develop_blend_init_raster_mask(const dt_develop_blend_params_t *const params, dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, float *const restrict mask, const size_t owidth, const size_t oheight, int *const raster_error)
static void _refine_with_detail_mask_cl(struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, float *mask, const float level, const int devid)
static size_t _develop_mask_get_post_operations(const dt_develop_blend_params_t *const params, const dt_dev_pixelpipe_iop_t *const piece, _develop_mask_post_processing operations[3])
static float * _develop_blend_process_copy_region(const float *const restrict input, const size_t iwidth, const size_t xoffs, const size_t yoffs, const size_t owidth, const size_t oheight)
void tiling_callback_blendop(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)
static uint32_t _blend_legacy_blend_mode(uint32_t legacy_blend_mode)
dt_blendop_cl_global_t * dt_develop_blend_init_cl_global(void)
void dt_develop_blendif_process_parameters(float *const restrict parameters, const dt_develop_blend_params_t *const params)
void dt_develop_blend_free_cl_global(dt_blendop_cl_global_t *b)
dt_iop_colorspace_type_t dt_develop_blend_colorspace(const dt_dev_pixelpipe_iop_t *const piece, dt_iop_colorspace_type_t cst)
int dt_develop_blendif_init_masking_profile(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, dt_iop_order_iccprofile_info_t *blending_profile, dt_develop_blend_colorspace_t cst)
int dt_develop_blend_legacy_params_from_so(dt_iop_module_so_t *module_so, const void *const old_params, const int old_version, void *new_params, const int new_version, const int length)
static void _refine_with_detail_mask(struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, float *mask, const float level)
dt_develop_blend_colorspace_t dt_develop_blend_default_module_blend_colorspace(dt_iop_module_t *module)
int dt_develop_blend_version(void)
int dt_develop_blend_legacy_params(dt_iop_module_t *module, const void *const old_params, const int old_version, void *new_params, const int new_version, const int length)
static const dt_iop_module_t * _develop_blend_get_raster_source_module(const dt_develop_blend_params_t *const params, const dt_iop_module_t *const self)
void dt_develop_blend_get_mask_usage(const dt_iop_module_t *module, const dt_develop_blend_params_t *params, gboolean *top_enabled, gboolean *raster_used, gboolean *drawn_used, gboolean *parametric_used)
int dt_develop_blend_process(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid)
static void _blend_init_blendif_boost_parameters(dt_develop_blend_params_t *blend_params, dt_develop_blend_colorspace_t cst)
static const char * dt_pipe_type_to_str(dt_dev_pixelpipe_type_t pipe_type)
gboolean dt_develop_blend_params_is_all_zero(const void *params, size_t length)
static dt_develop_blend_params_t _default_blendop_params
static void _develop_blend_process_mask_tone_curve(float *const restrict mask, const size_t buffsize, const float contrast, const float brightness, const float opacity)
static void _develop_blend_process_free_region(float *const restrict input)
static float _detail_mask_threshold(const float level, const gboolean detail)
static int _develop_blend_init_drawn_mask(const dt_develop_blend_params_t *const params, dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const struct dt_iop_roi_t *const roi_out, float *const restrict mask, const size_t owidth, const size_t oheight)
void dt_develop_blend_init_blendif_parameters(dt_develop_blend_params_t *blend_params, dt_develop_blend_colorspace_t cst)
static int _develop_blend_process_feather(const float *const guide, float *const mask, const size_t width, const size_t height, const int ch, const float guide_weight, const float feathering_radius, const float scale)
static void _blend_process_cl_exchange(cl_mem *a, cl_mem *b)
void dt_develop_blendif_raw_blend(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, float *const b, const float *const mask, const dt_dev_pixelpipe_display_mask_t request_mask_display)
void dt_develop_blendif_rgb_jzczhz_blend(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, float *const b, const float *const mask, const dt_dev_pixelpipe_display_mask_t request_mask_display)
void dt_develop_blendif_rgb_hsl_make_mask(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, const float *const b, float *const mask)
@ DEVELOP_MASK_GUIDE_OUT_BEFORE_BLUR
@ DEVELOP_MASK_GUIDE_IN_AFTER_BLUR
@ DEVELOP_MASK_GUIDE_OUT_AFTER_BLUR
@ DEVELOP_MASK_GUIDE_IN_BEFORE_BLUR
dt_develop_blend_colorspace_t
@ DEVELOP_BLEND_CS_RGB_SCENE
@ DEVELOP_BLEND_CS_RGB_DISPLAY
@ DEVELOP_COMBINE_MASKS_POS
@ DEVELOP_COMBINE_NORM_EXCL
void dt_develop_blendif_rgb_jzczhz_make_mask(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, const float *const b, float *const mask)
void dt_develop_blendif_lab_blend(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, float *const b, const float *const mask, const dt_dev_pixelpipe_display_mask_t request_mask_display)
void dt_develop_blendif_raw_make_mask(const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, const float *const b, float *const mask)
void dt_develop_blendif_rgb_hsl_blend(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, float *const b, const float *const mask, const dt_dev_pixelpipe_display_mask_t request_mask_display)
void dt_develop_blendif_lab_make_mask(const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, const float *const b, float *const mask)
@ DEVELOP_BLENDIF_Lab_MASK
@ DEVELOP_BLENDIF_RGB_MASK
#define DEVELOP_BLENDIF_PARAMETER_ITEMS
@ DEVELOP_BLEND_MODE_MASK
@ DEVELOP_BLEND_MULTIPLY_REVERSE_OBSOLETE
@ DEVELOP_BLEND_DISABLED_OBSOLETE
@ DEVELOP_BLEND_NORMAL_OBSOLETE
@ DEVELOP_BLEND_UNBOUNDED_OBSOLETE
@ DEVELOP_BLEND_INVERSE_OBSOLETE
@ DEVELOP_MASK_PARAMETRIC
#define DEVELOP_BLEND_VERSION
static const dt_aligned_pixel_simd_t const dt_adaptation_t const float p
const dt_colormatrix_t dt_aligned_pixel_t out
static const dt_colormatrix_t M
void dt_control_log(const char *msg,...)
void dt_print(dt_debug_thread_t thread, const char *msg,...)
#define dt_pixelpipe_cache_alloc_align_float_cache(pixels, id)
#define dt_pixelpipe_cache_free_align(mem)
#define dt_pixelpipe_cache_alloc_align_float(pixels, pipe)
#define __OMP_PARALLEL_FOR__(...)
static const dt_aligned_pixel_simd_t value
#define __OMP_FOR_SIMD__(...)
#define __OMP_PARALLEL_FOR_SIMD__(...)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
dt_dev_pixelpipe_display_mask_t
@ DT_DEV_PIXELPIPE_DISPLAY_CHANNEL
@ DT_DEV_PIXELPIPE_DISPLAY_ANY
@ DT_DEV_PIXELPIPE_DISPLAY_MASK
@ DT_DEV_PIXELPIPE_DISPLAY_NONE
void dt_gaussian_free(dt_gaussian_t *g)
void dt_gaussian_free_cl(dt_gaussian_cl_t *g)
cl_int dt_gaussian_blur_cl(dt_gaussian_cl_t *g, cl_mem dev_in, cl_mem dev_out)
__DT_CLONE_TARGETS__ void dt_gaussian_blur(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)
int guided_filter_cl(int devid, cl_mem guide, cl_mem in, cl_mem out, const int width, const int height, const int ch, const int w, const float sqrt_eps, const float guide_weight, const float min, const float max)
__DT_CLONE_TARGETS__ int guided_filter(const float *const guide, const float *const in, float *const out, const int width, const int height, const int ch, const int w, const float sqrt_eps, const float guide_weight, const float min, const float max)
__DT_CLONE_TARGETS__ void dt_iop_image_mul_const(float *const buf, const float mul_value, const size_t width, const size_t height, const size_t ch)
__DT_CLONE_TARGETS__ void dt_iop_image_invert(float *const buf, const float max_value, const size_t width, const size_t height, const size_t ch)
__DT_CLONE_TARGETS__ void dt_iop_image_fill(float *const buf, const float fill_value, const size_t width, const size_t height, const size_t ch)
__DT_CLONE_TARGETS__ void dt_iop_image_scaled_copy(float *const restrict buf, const float *const restrict src, const float scale, const size_t width, const size_t height, const size_t ch)
gboolean dt_iop_is_raster_mask_used(dt_iop_module_t *module, int id)
void dt_iop_cleanup_module(dt_iop_module_t *module)
int dt_iop_load_module_by_so(dt_iop_module_t *module, dt_iop_module_so_t *so, dt_develop_t *dev)
static gboolean dt_iop_colorspace_is_rgb(const dt_iop_colorspace_type_t cst)
@ IOP_FLAGS_SUPPORTS_BLENDING
static float kernel(const float *x, const float *y)
dt_iop_order_iccprofile_info_t * dt_ioppr_get_pipe_work_profile_info(const struct dt_dev_pixelpipe_t *pipe)
dt_iop_order_iccprofile_info_t * dt_ioppr_get_pipe_current_profile_info(dt_iop_module_t *module, const struct dt_dev_pixelpipe_t *pipe)
void dt_ioppr_free_iccprofile_params_cl(dt_colorspaces_iccprofile_info_cl_t **_profile_info_cl, cl_float **_profile_lut_cl, cl_mem *_dev_profile_info, cl_mem *_dev_profile_lut)
dt_iop_order_iccprofile_info_t * dt_ioppr_get_iop_work_profile_info(struct dt_iop_module_t *module, GList *iop_list)
cl_int dt_ioppr_build_iccprofile_params_cl(const dt_iop_order_iccprofile_info_t *const profile_info, const int devid, dt_colorspaces_iccprofile_info_cl_t **_profile_info_cl, cl_float **_profile_lut_cl, cl_mem *_dev_profile_info, cl_mem *_dev_profile_lut)
#define DEVELOP_BLENDIF_SIZE
float *const restrict const size_t k
float *const restrict const size_t const size_t ch
int dt_masks_group_render_roi(dt_iop_module_t *module, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, dt_masks_form_t *form, const dt_iop_roi_t *roi, float *buffer)
void dt_masks_calc_detail_mask(float *const src, float *const out, float *const tmp, const int width, const int height, const float threshold, const gboolean detail)
void dt_masks_blur_9x9_coeff(float *coeffs, const float sigma)
dt_masks_form_t * dt_masks_get_from_id(dt_develop_t *dev, int id)
static float clamp_range_f(const float x, const float low, const float high)
float DT_ALIGNED_ARRAY dt_colormatrix_t[4][4]
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_copy_device_to_host(const int devid, void *host, void *device, const int width, const int height, const int bpp)
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)
int dt_opencl_read_host_from_device(const int devid, void *host, void *device, const int width, const int height, const int bpp)
void dt_opencl_release_mem_object(cl_mem mem)
int dt_opencl_write_host_to_device(const int devid, void *host, void *device, const int width, const int height, const int bpp)
uint64_t dt_dev_pixelpipe_raster_mask_hash(const dt_dev_pixelpipe_iop_t *piece, const int raster_mask_id)
@ DT_DEV_PIXELPIPE_THUMBNAIL
@ DT_DEV_PIXELPIPE_EXPORT
@ DT_DEV_PIXELPIPE_PREVIEW
void dt_dev_pixelpipe_cache_ref_count_entry(dt_dev_pixelpipe_cache_t *cache, gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Increase/Decrease the reference count on the cache line as to prevent LRU item removal....
int dt_dev_pixelpipe_cache_get(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash, const size_t size, const char *name, const int id, const gboolean alloc, void **data, dt_pixel_cache_entry_t **entry)
Get a cache line from the cache.
int dt_dev_pixelpipe_cache_remove(dt_dev_pixelpipe_cache_t *cache, const gboolean force, dt_pixel_cache_entry_t *cache_entry)
Arbitrarily remove the cache entry matching hash. Entries having a reference count > 0 (inter-thread ...
void dt_dev_pixelpipe_cache_wrlock_entry(dt_dev_pixelpipe_cache_t *cache, gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Lock or release the write lock on the entry.
float * dt_dev_retrieve_rawdetail_mask(const dt_dev_pixelpipe_t *pipe, const struct dt_iop_module_t *target_module)
float * dt_dev_get_raster_mask(dt_dev_pixelpipe_t *pipe, const struct dt_iop_module_t *raster_mask_source, const int raster_mask_id, const struct dt_iop_module_t *target_module, int *error)
Retrieve a provider mask from the global cache and transform it to a consumer.
float * dt_dev_distort_detail_mask(const dt_dev_pixelpipe_t *pipe, float *src, const struct dt_iop_module_t *target_module)
char dt_dev_operation_t[20]
unsigned __int64 uint64_t
struct dt_dev_pixelpipe_cache_t * pixelpipe_cache
struct dt_opencl_t * opencl
int kernel_blendop_mask_RAW
int kernel_blendop_mask_rgb_jzczhz
int kernel_blendop_display_channel
int kernel_blendop_rgb_jzczhz
int kernel_blendop_mask_rgb_hsl
int kernel_blendop_rgb_hsl
int kernel_blendop_mask_tone_curve
int kernel_blendop_set_mask
int kernel_blendop_mask_Lab
dt_iop_buffer_dsc_t dsc_in
dt_dev_pixelpipe_type_t type
gboolean store_all_raster_masks
GArray * raster_mask_hashes
float blendif_parameters[4 *DEVELOP_BLENDIF_SIZE]
float blendif_boost_factors[DEVELOP_BLENDIF_SIZE]
struct dt_iop_module_t * gui_module
struct dt_dev_pixelpipe_t * pipe
struct dt_develop_t * dev
GModule *dt_dev_operation_t op
struct dt_iop_module_t::@29 raster_mask
struct dt_iop_module_t::@29::@30 source
struct dt_iop_module_t::@29::@31 sink
dt_colormatrix_t matrix_out_transposed
dt_colormatrix_t matrix_out
dt_colormatrix_t matrix_in
Region of interest passed through the pixelpipe.
struct dt_blendop_cl_global_t * blendop
uint64_t dt_supervisor_node_key(const int pipe_type, const char *op_name, const int multi_priority)
void dt_supervisor_cacheline_create(const uint64_t hash, const uint64_t node_hash, const uint64_t param_hash, const uint64_t input_hash, const char *op_name, const int multi_priority, const int iop_order, const int pipe_type, const int32_t imgid, const int roi_w, const int roi_h, const int devid, const size_t size, const char *name)
static gboolean dt_supervisor_active(void)