101 { 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,
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, 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 },
106 { 0 }, 0, 0,
FALSE };
109 gboolean is_scene_referred)
113 switch(module->blend_colorspace(module, NULL, NULL))
201 const int32_t blend_csp = params->blend_cst;
202 const uint32_t blendif = params->blendif;
203 const float *blendif_parameters = params->blendif_parameters;
204 const float *boost_factors = params->blendif_boost_factors;
207 if(blendif & (1 <<
i))
215 parameters[j + 0] = (blendif_parameters[
i * 4 + 0] - offset) * exp2f(boost_factors[
i]);
216 parameters[j + 1] = (blendif_parameters[
i * 4 + 1] - offset) * exp2f(boost_factors[
i]);
217 parameters[j + 2] = (blendif_parameters[
i * 4 + 2] - offset) * exp2f(boost_factors[
i]);
218 parameters[j + 3] = (blendif_parameters[
i * 4 + 3] - offset) * exp2f(boost_factors[
i]);
220 parameters[j + 4] = 1.0f / fmaxf(0.001f, parameters[j + 1] - parameters[j + 0]);
221 parameters[j + 5] = 1.0f / fmaxf(0.001f, parameters[j + 3] - parameters[j + 2]);
223 if(blendif_parameters[
i * 4 + 0] <= 0.0f && blendif_parameters[
i * 4 + 1] <= 0.0f)
225 parameters[j + 0] = -INFINITY;
226 parameters[j + 1] = -INFINITY;
228 if(blendif_parameters[
i * 4 + 2] >= 1.0f && blendif_parameters[
i * 4 + 3] >= 1.0f)
230 parameters[j + 2] = INFINITY;
231 parameters[j + 3] = INFINITY;
236 parameters[j + 0] = -INFINITY;
237 parameters[j + 1] = -INFINITY;
238 parameters[j + 2] = INFINITY;
239 parameters[j + 3] = INFINITY;
240 parameters[j + 4] = 0.0f;
241 parameters[j + 5] = 0.0f;
248 gboolean *top_enabled,
249 gboolean *raster_used,
250 gboolean *drawn_used,
251 gboolean *parametric_used)
259 const uint32_t mask_mode = params->mask_mode;
265 gboolean raster = raster_mode
266 && (params->raster_mask_id > 0
267 || params->raster_mask_source[0] !=
'\0'
270 gboolean drawn =
FALSE;
277 gboolean parametric =
FALSE;
280 const float threshold_epsilon = 1e-6f;
284 uint32_t active_channels = 0;
287 const uint32_t bit = 1u <<
ch;
288 if(!(channel_mask & bit) || !(params->blendif & bit))
continue;
289 const float *channel = ¶ms->blendif_parameters[
ch * 4];
290 if(fabsf(channel[0]) > threshold_epsilon
291 || fabsf(channel[1]) > threshold_epsilon
292 || fabsf(channel[2] - 1.0f) > threshold_epsilon
293 || fabsf(channel[3] - 1.0f) > threshold_epsilon)
294 active_channels |= bit;
296 parametric = active_channels != 0;
300 if(!
IS_NULL_PTR(raster_used)) *raster_used = raster;
302 if(!
IS_NULL_PTR(parametric_used)) *parametric_used = parametric;
313 { 0.9555766f, -0.0230393f, 0.0631636f, 0.0f },
314 { -0.0282895f, 1.0099416f, 0.0210077f, 0.0f },
315 { 0.0122982f, -0.0204830f, 1.3299098f, 0.0f },
324 for(
size_t y = 0; y < 3; y++)
326 for(
size_t x = 0;
x < 3;
x++)
329 for(
size_t i = 0;
i < 3;
i++)
342 return 0.005f * (detail ? powf(level, 2.0f) : 1.0f - powf(fabs(level), 0.5f ));
350 if(level == 0.0f)
return;
353 const gboolean detail = (level > 0.0f);
358 float *warp_mask = NULL;
359 float *rawdetail_mask = NULL;
365 const int iwidth =
p->rawdetail_mask_roi.width;
366 const int iheight =
p->rawdetail_mask_roi.height;
367 const int owidth = roi_out->
width;
368 const int oheight = roi_out->
height;
369 if(info) fprintf(stderr,
"[_refine_with_detail_mask] in module %s %ix%i --> %ix%i\n", self->
op, iwidth, iheight, owidth, oheight);
371 const int bufsize =
MAX(iwidth * iheight, owidth * oheight);
384 const gboolean warp_mask_aliases_lum = (warp_mask == lum);
385 if(!warp_mask_aliases_lum)
393 const int msize = owidth * oheight;
395 for(
int idx =0; idx < msize; idx++)
397 mask[idx] = mask[idx] * warp_mask[idx];
400 if(warp_mask_aliases_lum) lum = NULL;
415 const gboolean mask_feather = params->feathering_radius > 0.1f && piece->
dsc_in.
channels >= 3;
416 const gboolean mask_blur = params->blur_radius > 0.1f;
417 const gboolean mask_tone_curve = fabsf(params->contrast) >= 0.01f || fabsf(params->brightness) >= 0.01f;
422 const float opacity = fminf(fmaxf(params->opacity / 100.0f, 0.0f), 1.0f);
429 if(mask_blur && mask_feather_before)
446 if(mask_tone_curve && opacity > 1e-4f)
456 const size_t xoffs,
const size_t yoffs,
457 const size_t owidth,
const size_t oheight)
459 const size_t ioffset = yoffs * iwidth + xoffs;
460 float *
const restrict output =
467 for(
size_t y = 0; y < oheight; y++)
469 const size_t iindex = y * iwidth + ioffset;
470 const size_t oindex = y * owidth;
471 memcpy(output + oindex, input + iindex,
sizeof(
float) * owidth);
488 if(source && !strcmp(source->
op, params->raster_mask_source)
492 if(
IS_NULL_PTR(self->
dev) || params->raster_mask_source[0] ==
'\0')
return NULL;
494 for(GList *iter = g_list_first(self->
dev->
iop); iter; iter = g_list_next(iter))
497 if(!strcmp(candidate->
op, params->raster_mask_source)
509 float *
const restrict mask,
511 const size_t oheight,
512 int *
const raster_error)
514 int local_raster_error = 0;
516 float *raster_mask = raster_source
518 self, &local_raster_error)
523 if(params->raster_mask_invert)
526 for(
size_t i = 0;
i < owidth * oheight;
i++)
527 mask[
i] = 1.0f - raster_mask[
i];
538 const float value = params->raster_mask_invert ? 0.0f : 1.0f;
542 if(!
IS_NULL_PTR(raster_error)) *raster_error = local_raster_error;
550 float *
const restrict mask,
552 const size_t oheight)
578 const float *
const restrict other_mask,
579 const size_t buffsize)
582 for(
size_t i = 0;
i < buffsize;
i++)
583 mask[
i] *= other_mask[
i];
588 const size_t height,
const int ch,
const float guide_weight,
589 const float feathering_radius,
const float scale)
591 const float sqrt_eps = 1.f;
592 int w = (int)(2 * feathering_radius * scale + 0.5f);
595 float *
const restrict mask_bak =
599 memcpy(mask_bak, mask,
sizeof(
float) *
width *
height);
600 if(
guided_filter(guide, mask_bak, mask,
width,
height,
ch, w, sqrt_eps, guide_weight, 0.f, 1.f) != 0)
611 const float contrast,
const float brightness,
614 const float mask_epsilon = 16 * FLT_EPSILON;
615 const float e = expf(3.f * contrast);
617 for(
size_t k = 0;
k < buffsize;
k++)
619 float x = mask[
k] / opacity;
621 if (1.f - brightness <= 0.f)
622 x = mask[
k] <= mask_epsilon ? -1.f : 1.f;
623 else if (1.f + brightness <= 0.f)
624 x = mask[
k] >= 1.f - mask_epsilon ? 1.f : -1.f;
625 else if (brightness > 0.f)
627 x = (
x + brightness) / (1.f - brightness);
632 x = (
x + brightness) / (1.f + brightness);
636 ((
x * e / (1.f + (e - 1.f) * fabsf(
x))) / 2.f + 0.5f) * opacity, 0.f, 1.f);
652 gboolean top_enabled =
FALSE;
653 gboolean raster_used =
FALSE;
654 gboolean drawn_used =
FALSE;
655 gboolean parametric_used =
FALSE;
657 if(!top_enabled)
return 0;
661 const gboolean preview_mask_mode = top_enabled;
664 const int xoffs = roi_out->
x - roi_in->
x;
665 const int yoffs = roi_out->
y - roi_in->
y;
666 const int iwidth = roi_in->
width;
667 const int iheight = roi_in->
height;
668 const int owidth = roi_out->
width;
669 const int oheight = roi_out->
height;
670 const size_t buffsize = (size_t)owidth * oheight;
672 const float oscale = roi_out->
scale;
673 const gboolean rois_equal = iwidth == owidth || iheight == oheight || xoffs == 0 || yoffs == 0;
682 if(oscale !=
iscale || xoffs < 0 || yoffs < 0
683 || ((xoffs > 0 || yoffs > 0) && (owidth + xoffs > iwidth || oheight + yoffs > iheight)))
685 dt_control_log(_(
"skipped blending in module '%s': roi's do not match"), self->
op);
692 && preview_mask_mode)
705 const float opacity = fminf(fmaxf(
d->opacity / 100.0f, 0.0f), 1.0f);
714 int raster_error = 0;
715 float *
const restrict mask = _mask;
716 const gboolean use_masks = raster_used || drawn_used || parametric_used;
717 const gboolean raster_only = raster_used && !drawn_used && !parametric_used;
732 if(!raster_used && !drawn_used)
780 (
const float *
const restrict)
ovoid, mask);
784 (
const float *
const restrict)
ovoid, mask);
788 (
const float *
const restrict)
ovoid, mask);
792 (
const float *
const restrict)
ovoid, mask);
799 for(
size_t index = 0; index < post_operations_size; ++index)
805 float *restrict guide = (
float *restrict)ivoid;
808 ch * owidth,
ch * oheight);
815 d->feathering_radius, roi_out->
scale) != 0)
829 guide_weight,
d->feathering_radius, roi_out->
scale) != 0)
837 const float sigma =
d->blur_radius * roi_out->
scale;
838 const float mmax[] = { 1.0f };
839 const float mmin[] = { 0.0f };
861 mask, request_mask_display);
865 mask, request_mask_display);
869 mask, request_mask_display);
873 mask, request_mask_display);
890 void *cache_data = NULL;
893 "raster mask", pipe->
type,
TRUE, &cache_data, &mask_entry);
913 memcpy(cache_data, _mask,
sizeof(
float) * buffsize);
922 "[raster masks] %s mask id 0 for module %s (%s) for pipe %s"
923 " with cache hash %" PRIu64
"\n",
924 created ?
"published" :
"reused cached",
925 piece->module->op, piece->module->multi_name,
931 "[raster masks] discarding unpublished mask id 0 for module %s (%s) for pipe %s\n",
932 piece->module->op, piece->module->multi_name,
943 const float level,
const int devid)
946 if(level == 0.0f)
return;
949 const int detail = (level > 0.0f);
952 float *rawdetail_mask = NULL;
961 const int iwidth =
p->rawdetail_mask_roi.width;
962 const int iheight =
p->rawdetail_mask_roi.height;
963 const int owidth = roi_out->
width;
964 const int oheight = roi_out->
height;
965 if(info) fprintf(stderr,
"[_refine_with_detail_mask_cl] in module %s %ix%i --> %ix%i\n", self->
op, iwidth, iheight, owidth, oheight);
978 if(err != CL_SUCCESS)
goto error;
989 if(err != CL_SUCCESS)
goto error;
1002 if(err != CL_SUCCESS)
goto error;
1008 cl_mem dev_blurmat = NULL;
1021 if(err != CL_SUCCESS)
goto error;
1038 if(err != CL_SUCCESS)
goto error;
1043 if(err != CL_SUCCESS)
goto error;
1049 tmp = blur =
out = NULL;
1055 const gboolean warp_mask_aliases_lum = (warp_mask == lum);
1056 if(!warp_mask_aliases_lum)
1062 const int msize = owidth * oheight;
1064 for(
int idx = 0; idx < msize; idx++)
1066 mask[idx] = mask[idx] * warp_mask[idx];
1069 if(warp_mask_aliases_lum) lum = NULL;
1097 gboolean top_enabled =
FALSE;
1098 gboolean raster_used =
FALSE;
1099 gboolean drawn_used =
FALSE;
1100 gboolean parametric_used =
FALSE;
1102 if(!top_enabled)
return 0;
1103 const unsigned int mask_mode =
d->mask_mode;
1107 const gboolean preview_mask_mode = top_enabled;
1110 const int xoffs = roi_out->
x - roi_in->
x;
1111 const int yoffs = roi_out->
y - roi_in->
y;
1112 const int iwidth = roi_in->
width;
1113 const int iheight = roi_in->
height;
1114 const int owidth = roi_out->
width;
1115 const int oheight = roi_out->
height;
1116 const size_t buffsize = (size_t)owidth * oheight;
1118 const float oscale = roi_out->
scale;
1119 const gboolean rois_equal = iwidth == owidth || iheight == oheight || xoffs == 0 || yoffs == 0;
1128 if(oscale !=
iscale || xoffs < 0 || yoffs < 0
1129 || ((xoffs > 0 || yoffs > 0) && (owidth + xoffs > iwidth || oheight + yoffs > iheight)))
1131 dt_control_log(_(
"skipped blending in module '%s': roi's do not match"), self->
op);
1141 && preview_mask_mode)
1154 const float opacity = fminf(fmaxf(
d->opacity / 100.0f, 0.0f), 1.0f);
1155 const gboolean use_masks = raster_used || drawn_used || parametric_used;
1156 const gboolean raster_only = raster_used && !drawn_used && !parametric_used;
1165 float *
const mask = _mask;
1197 const int devid = pipe->
devid;
1198 const int offs[2] = { xoffs, yoffs };
1202 cl_mem dev_blendif_params = NULL;
1203 cl_mem dev_boost_factors = NULL;
1204 cl_mem dev_mask_1 = NULL;
1205 cl_mem dev_mask_2 = NULL;
1206 cl_mem dev_tmp = NULL;
1207 cl_mem dev_guide = NULL;
1209 cl_mem dev_profile_info = NULL;
1210 cl_mem dev_profile_lut = NULL;
1212 cl_float *profile_lut_cl = NULL;
1214 cl_mem dev_work_profile_info = NULL;
1215 cl_mem dev_work_profile_lut = NULL;
1217 cl_float *work_profile_lut_cl = NULL;
1219 size_t origin[] = { 0, 0, 0 };
1220 size_t region[] = { owidth, oheight, 1 };
1237 &profile_lut_cl, &dev_profile_info, &dev_profile_lut);
1238 if(err != CL_SUCCESS)
goto error;
1250 if(err != CL_SUCCESS)
goto error;
1252 else if(raster_only)
1254 int raster_error = 0;
1256 if(raster_error)
goto error;
1260 if(err != CL_SUCCESS)
goto error;
1264 if(!raster_used && !drawn_used)
1272 else if(raster_used)
1274 int raster_error = 0;
1276 if(raster_error)
goto error;
1304 if(err != CL_SUCCESS)
goto error;
1307 const unsigned blendif =
d->blendif;
1308 const unsigned int mask_combine =
d->mask_combine;
1325 if(err != CL_SUCCESS)
1327 fprintf(stderr,
"[dt_develop_blend_process_cl] error %i enqueue kernel\n", err);
1335 for(
size_t index = 0; index < post_operations_size; ++index)
1340 int w = (int)(2 *
d->feathering_radius * roi_out->
scale + 0.5f);
1342 const float sqrt_eps = 1.0f;
1345 cl_mem guide = dev_in;
1351 size_t origin_1[] = { xoffs, yoffs, 0 };
1352 size_t origin_2[] = { 0, 0, 0 };
1354 if(err != CL_SUCCESS)
goto error;
1356 if(
guided_filter_cl(devid, guide, dev_mask_1, dev_mask_2, owidth, oheight,
ch, w, sqrt_eps, guide_weight,
1368 int w = (int)(2 *
d->feathering_radius * roi_out->
scale + 0.5f);
1370 const float sqrt_eps = 1.0f;
1373 if(
guided_filter_cl(devid, dev_out, dev_mask_1, dev_mask_2, owidth, oheight,
ch, w, sqrt_eps, guide_weight,
1380 const float sigma =
d->blur_radius * roi_out->
scale;
1381 const float mmax[] = { 1.0f };
1382 const float mmin[] = { 0.0f };
1388 if(err != CL_SUCCESS)
goto error;
1393 const float e = expf(3.f *
d->contrast);
1394 const float brightness =
d->brightness;
1403 if(err != CL_SUCCESS)
goto error;
1418 if(err != CL_SUCCESS)
goto error;
1424 d->blendif_boost_factors);
1430 const int use_work_profile = !
IS_NULL_PTR(work_profile);
1433 &dev_work_profile_info, &dev_work_profile_lut);
1434 if(err != CL_SUCCESS)
goto error;
1453 if(err != CL_SUCCESS)
1455 fprintf(stderr,
"[dt_develop_blend_process_cl] error %i enqueue kernel\n", err);
1462 const unsigned int blend_mode =
d->blend_mode;
1463 const float blend_parameter = exp2f(
d->blend_parameter);
1475 if(err != CL_SUCCESS)
goto error;
1492 if(err != CL_SUCCESS)
goto error;
1497 void *cache_data = NULL;
1500 "raster mask", pipe->
type,
TRUE, &cache_data, &mask_entry);
1519 memcpy(cache_data, _mask,
sizeof(
float) * buffsize);
1529 "[raster masks] %s mask id 0 for module %s (%s) for pipe %s"
1530 " with cache hash %" PRIu64
"\n",
1531 created ?
"published" :
"reused cached",
1532 piece->module->op, piece->module->multi_name,
1538 "[raster masks] discarding unpublished mask id 0 for module %s (%s) for pipe %s\n",
1539 piece->module->op, piece->module->multi_name,
1550 &dev_work_profile_lut);
1563 &dev_work_profile_lut);
1575 const int program = 3;
1588 const int program_rcd = 31;
1659 const char *data = (
const char *)params;
1661 for(
size_t k = 0;
k < length;
k++)
1662 if(data[
k])
return FALSE;
1670 gboolean blend_reverse =
FALSE;
1671 switch(blend_mode) {
1677 blend_reverse =
TRUE;
1685 blend_reverse =
TRUE;
1695 const int old_version,
void *new_params,
const int new_version,
1712 *
n = default_display_blend_params;
1716 if(old_version == 1 && new_version == 11)
1719 typedef struct dt_develop_blend_params1_t
1724 } dt_develop_blend_params1_t;
1726 if(length !=
sizeof(dt_develop_blend_params1_t))
return 1;
1728 dt_develop_blend_params1_t *o = (dt_develop_blend_params1_t *)old_params;
1731 *
n = default_display_blend_params;
1734 n->opacity = o->opacity;
1735 n->mask_id = o->mask_id;
1739 if(old_version == 2 && new_version == 11)
1742 typedef struct dt_develop_blend_params2_t
1753 float blendif_parameters[4 * 8];
1754 } dt_develop_blend_params2_t;
1756 if(length !=
sizeof(dt_develop_blend_params2_t))
return 1;
1758 dt_develop_blend_params2_t *o = (dt_develop_blend_params2_t *)old_params;
1761 *
n = default_display_blend_params;
1767 n->opacity = o->opacity;
1768 n->mask_id = o->mask_id;
1769 n->blendif = o->blendif & 0xff;
1772 for(
int i = 0;
i < (4 * 8);
i++)
n->blendif_parameters[
i] = o->blendif_parameters[
i];
1777 if(old_version == 3 && new_version == 11)
1780 typedef struct dt_develop_blend_params3_t
1792 } dt_develop_blend_params3_t;
1794 if(length !=
sizeof(dt_develop_blend_params3_t))
return 1;
1796 dt_develop_blend_params3_t *o = (dt_develop_blend_params3_t *)old_params;
1799 *
n = default_display_blend_params;
1805 n->opacity = o->opacity;
1806 n->mask_id = o->mask_id;
1813 if(old_version == 4 && new_version == 11)
1816 typedef struct dt_develop_blend_params4_t
1830 } dt_develop_blend_params4_t;
1832 if(length !=
sizeof(dt_develop_blend_params4_t))
return 1;
1834 dt_develop_blend_params4_t *o = (dt_develop_blend_params4_t *)old_params;
1837 *
n = default_display_blend_params;
1843 n->opacity = o->opacity;
1844 n->mask_id = o->mask_id;
1845 n->blur_radius = o->radius;
1852 if(old_version == 5 && new_version == 11)
1855 typedef struct dt_develop_blend_params5_t
1860 uint32_t blend_mode;
1864 uint32_t mask_combine;
1872 uint32_t reserved[4];
1875 } dt_develop_blend_params5_t;
1877 if(length !=
sizeof(dt_develop_blend_params5_t))
return 1;
1879 dt_develop_blend_params5_t *o = (dt_develop_blend_params5_t *)old_params;
1882 *
n = default_display_blend_params;
1885 n->opacity = o->opacity;
1886 n->mask_combine = o->mask_combine;
1887 n->mask_id = o->mask_id;
1888 n->blur_radius = o->radius;
1900 if(old_version == 6 && new_version == 11)
1903 typedef struct dt_develop_blend_params6_t
1908 uint32_t blend_mode;
1912 uint32_t mask_combine;
1920 uint32_t reserved[4];
1923 } dt_develop_blend_params6_t;
1925 if(length !=
sizeof(dt_develop_blend_params6_t))
return 1;
1927 dt_develop_blend_params6_t *o = (dt_develop_blend_params6_t *)old_params;
1930 *
n = default_display_blend_params;
1933 n->opacity = o->opacity;
1934 n->mask_combine = o->mask_combine;
1935 n->mask_id = o->mask_id;
1936 n->blur_radius = o->radius;
1937 n->blendif = o->blendif;
1942 if(old_version == 7 && new_version == 11)
1945 typedef struct dt_develop_blend_params7_t
1950 uint32_t blend_mode;
1954 uint32_t mask_combine;
1962 uint32_t reserved[4];
1965 } dt_develop_blend_params7_t;
1967 if(length !=
sizeof(dt_develop_blend_params7_t))
return 1;
1969 dt_develop_blend_params7_t *o = (dt_develop_blend_params7_t *)old_params;
1972 *
n = default_display_blend_params;
1975 n->opacity = o->opacity;
1976 n->mask_combine = o->mask_combine;
1977 n->mask_id = o->mask_id;
1978 n->blur_radius = o->radius;
1979 n->blendif = o->blendif;
1984 if(old_version == 8 && new_version == 11)
1987 typedef struct dt_develop_blend_params8_t
1992 uint32_t blend_mode;
1996 uint32_t mask_combine;
2002 float feathering_radius;
2004 uint32_t feathering_guide;
2012 uint32_t reserved[4];
2015 } dt_develop_blend_params8_t;
2017 if(length !=
sizeof(dt_develop_blend_params8_t))
return 1;
2019 dt_develop_blend_params8_t *o = (dt_develop_blend_params8_t *)old_params;
2022 *
n = default_display_blend_params;
2025 n->opacity = o->opacity;
2026 n->mask_combine = o->mask_combine;
2027 n->mask_id = o->mask_id;
2028 n->blendif = o->blendif;
2029 n->feathering_radius = o->feathering_radius;
2030 n->feathering_guide = o->feathering_guide;
2031 n->blur_radius = o->blur_radius;
2032 n->contrast = o->contrast;
2033 n->brightness = o->brightness;
2038 if(old_version == 9 && new_version == 11)
2041 typedef struct dt_develop_blend_params9_t
2047 uint32_t blend_mode;
2051 uint32_t mask_combine;
2057 float feathering_radius;
2059 uint32_t feathering_guide;
2067 uint32_t reserved[4];
2071 int raster_mask_instance;
2073 gboolean raster_mask_invert;
2074 } dt_develop_blend_params9_t;
2076 if(length !=
sizeof(dt_develop_blend_params9_t))
return 1;
2078 dt_develop_blend_params9_t *o = (dt_develop_blend_params9_t *)old_params;
2081 *
n = default_display_blend_params;
2084 n->opacity = o->opacity;
2085 n->mask_combine = o->mask_combine;
2086 n->mask_id = o->mask_id;
2087 n->blendif = o->blendif;
2088 n->feathering_radius = o->feathering_radius;
2089 n->feathering_guide = o->feathering_guide;
2090 n->blur_radius = o->blur_radius;
2091 n->contrast = o->contrast;
2092 n->brightness = o->brightness;
2094 memcpy(
n->raster_mask_source, o->raster_mask_source,
sizeof(
n->raster_mask_source));
2095 n->raster_mask_instance = o->raster_mask_instance;
2096 n->raster_mask_id = o->raster_mask_id;
2097 n->raster_mask_invert = o->raster_mask_invert;
2101 if(old_version == 10 && new_version == 11)
2104 typedef struct dt_develop_blend_params10_t
2112 uint32_t blend_mode;
2114 float blend_parameter;
2118 uint32_t mask_combine;
2124 float feathering_radius;
2126 uint32_t feathering_guide;
2134 uint32_t reserved[4];
2139 int raster_mask_instance;
2141 gboolean raster_mask_invert;
2142 } dt_develop_blend_params10_t;
2144 if(length !=
sizeof(dt_develop_blend_params10_t))
return 1;
2146 dt_develop_blend_params10_t *o = (dt_develop_blend_params10_t *)old_params;
2149 *
n = default_display_blend_params;
2151 n->blend_cst = o->blend_cst;
2153 n->blend_parameter = o->blend_parameter;
2154 n->opacity = o->opacity;
2155 n->mask_combine = o->mask_combine;
2156 n->mask_id = o->mask_id;
2157 n->blendif = o->blendif;
2158 n->feathering_radius = o->feathering_radius;
2159 n->feathering_guide = o->feathering_guide;
2160 n->blur_radius = o->blur_radius;
2161 n->contrast = o->contrast;
2162 n->brightness = o->brightness;
2164 memcpy(&
n->details, &o->reserved,
sizeof(
float));
2165 if(isnan(
n->details))
n->details = 0.0f;
2166 n->details = fminf(1.0f, fmaxf(-1.0f,
n->details));
2170 memcpy(
n->raster_mask_source, o->raster_mask_source,
sizeof(
n->raster_mask_source));
2171 n->raster_mask_instance = o->raster_mask_instance;
2172 n->raster_mask_id = o->raster_mask_id;
2173 n->raster_mask_invert = o->raster_mask_invert;
2181 const int old_version,
void *new_params,
const int new_version,
2185 dt_iop_module_t *
module = (dt_iop_module_t *)calloc(1, sizeof(dt_iop_module_t));
2192 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_iop_module_t::@31 raster_mask
struct dt_develop_t * dev
struct dt_iop_module_t::@31::@32 source
GModule *dt_dev_operation_t op
struct dt_iop_module_t::@31::@33 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