34#define DT_BLENDIF_LAB_CH 4
35#define DT_BLENDIF_LAB_BCH 3
39 float *
const restrict
out,
const float *
const restrict mask,
const size_t stride,
44static inline
float _CLAMP(const
float x, const
float min, const
float max)
46 return fminf(fmaxf(
x,
min),
max);
57 const
float *const restrict parameters)
60 if(
value <= parameters[0])
65 else if(
value < parameters[1])
70 else if(
value <= parameters[2])
75 else if(
value < parameters[3])
78 factor = 1.0f - (
value - parameters[2]) * parameters[5];
89static inline
void _blendif_lab_l(const float *const restrict pixels, float *const restrict mask,
90 const size_t stride, const float *const restrict parameters,
91 const unsigned int invert_mask)
100static inline
void _blendif_lab_a(const float *const restrict pixels, float *const restrict
mask,
101 const size_t stride, const float *const restrict parameters,
102 const unsigned int invert_mask)
111static inline
void _blendif_lab_b(const float *const restrict pixels, float *const restrict
mask,
112 const size_t stride, const float *const restrict parameters,
113 const unsigned int invert_mask)
122static inline
void _blendif_lch(const float *const restrict pixels, float *const restrict mask,
123 const size_t stride, const float *const restrict parameters,
124 const unsigned int *const restrict invert_mask)
126 const float c_scale = 1.0f / (128.0f * sqrtf(2.0f));
130 dt_Lab_2_LCH(pixels + j,
LCH);
139static
void _blendif_combine_channels(const float *const restrict pixels, float *const restrict mask,
140 const size_t stride, const unsigned int blendif,
141 const float *const restrict parameters)
176 const float *
const restrict b,
float *
const restrict mask)
184 const int xoffs = roi_out->
x - roi_in->
x;
185 const int yoffs = roi_out->
y - roi_in->
y;
186 const int iwidth = roi_in->
width;
187 const int owidth = roi_out->
width;
188 const int oheight = roi_out->
height;
200 const size_t buffsize = (size_t)owidth * oheight;
203 const float global_opacity =
clamp_simd(
d->opacity / 100.0f);
211 for(
size_t x = 0;
x < buffsize;
x++) mask[
x] = global_opacity * (1.0f - mask[
x]);
218 else if(canceling_channel || !any_channel_active)
223 if((mask_inversed == 0) ^ (mask_inclusive == 0))
250 for(
size_t x = 0;
x < buffsize;
x++) temp_mask[
x] = 1.0f;
254 for(
size_t y = 0; y < oheight; y++)
257 _blendif_combine_channels(a + start, temp_mask + (y * owidth), owidth, blendif, parameters);
260 for(
size_t y = 0; y < oheight; y++)
263 _blendif_combine_channels(b + start, temp_mask + (y * owidth), owidth, blendif >>
DEVELOP_BLENDIF_L_out,
273 for(
size_t x = 0;
x < buffsize;
x++) mask[
x] = global_opacity * (1.0f - mask[
x]) * temp_mask[
x];
278 for(
size_t x = 0;
x < buffsize;
x++) mask[
x] = global_opacity * (1.0f - (1.0f - mask[
x]) * temp_mask[
x]);
286 for(
size_t x = 0;
x < buffsize;
x++) mask[
x] = global_opacity * (1.0f - mask[
x] * temp_mask[
x]);
291 for(
size_t x = 0;
x < buffsize;
x++) mask[
x] = global_opacity * mask[
x] * temp_mask[
x];
306 o[c] =
i[c] * scale[c];
314 o[c] =
i[c] * scale[c];
320static
void _blend_normal_bounded(const float *const restrict a, const float *const restrict b,
321 float *const restrict
out, const float *const restrict mask, const size_t stride,
324 for(
size_t i = 0;
i < stride;
i++)
327 const float local_opacity = mask[
i];
334 tb[
x] =
_CLAMP(ta[
x] * (1.0f - local_opacity) + tb[
x] * local_opacity,
min[
x],
max[
x]);
343static
void _blend_normal_unbounded(const float *const restrict
a, const float *const restrict
b,
344 float *const restrict
out,
345 const float *const restrict
mask, const size_t stride,
348 for(
size_t i = 0;
i < stride;
i++)
351 const float local_opacity =
mask[
i];
358 tb[
x] = ta[
x] * (1.0f - local_opacity) + tb[
x] * local_opacity;
367static
void _blend_lighten(const float *const restrict
a, const float *const restrict
b,
368 float *const restrict
out, const float *const restrict
mask, const size_t stride,
373 const float local_opacity =
mask[
i];
379 tb[0] =
_CLAMP(ta[0] * (1.0f - local_opacity) + (ta[0] > tb[0] ? ta[0] : tb[0]) * local_opacity,
381 tb[1] =
_CLAMP(ta[1] * (1.0f - fabsf(tb[0] - ta[0])) + 0.5f * (ta[1] + tb[1]) * fabsf(tb[0] - ta[0]),
383 tb[2] =
_CLAMP(ta[2] * (1.0f - fabsf(tb[0] - ta[0])) + 0.5f * (ta[2] + tb[2]) * fabsf(tb[0] - ta[0]),
393static
void _blend_darken(const float *const restrict
a, const float *const restrict
b,
394 float *const restrict
out, const float *const restrict
mask, const size_t stride,
399 const float local_opacity =
mask[
i];
405 tb[0] =
_CLAMP(ta[0] * (1.0f - local_opacity) + (ta[0] < tb[0] ? ta[0] : tb[0]) * local_opacity,
407 tb[1] =
_CLAMP(ta[1] * (1.0f - fabsf(tb[0] - ta[0])) + 0.5f * (ta[1] + tb[1]) * fabsf(tb[0] - ta[0]),
409 tb[2] =
_CLAMP(ta[2] * (1.0f - fabsf(tb[0] - ta[0])) + 0.5f * (ta[2] + tb[2]) * fabsf(tb[0] - ta[0]),
419static
void _blend_multiply(const float *const restrict
a, const float *const restrict
b,
420 float *const restrict
out, const float *const restrict
mask, const size_t stride,
425 const float local_opacity =
mask[
i];
431 tb[0] =
_CLAMP(ta[0] * (1.0f - local_opacity) + (ta[0] * tb[0]) * local_opacity,
min[0],
max[0]);
433 const float f = fmaxf(ta[0], 0.01f);
434 tb[1] =
_CLAMP(ta[1] * (1.0f - local_opacity) + (ta[1] + tb[1]) * tb[0] /
f * local_opacity,
min[1],
max[1]);
435 tb[2] =
_CLAMP(ta[2] * (1.0f - local_opacity) + (ta[2] + tb[2]) * tb[0] /
f * local_opacity,
min[2],
max[2]);
444static
void _blend_average(const float *const restrict
a, const float *const restrict
b,
445 float *const restrict
out, const float *const restrict
mask, const size_t stride,
448 for(
size_t i = 0;
i < stride;
i++)
451 const float local_opacity =
mask[
i];
458 tb[
x] =
_CLAMP(ta[
x] * (1.0f - local_opacity) + (ta[
x] + tb[
x]) / 2.0f * local_opacity,
min[
x],
max[
x]);
467static
void _blend_add(const float *const restrict
a, const float *const restrict
b,
468 float *const restrict
out, const float *const restrict
mask, const size_t stride,
471 for(
size_t i = 0;
i < stride;
i++)
474 const float local_opacity =
mask[
i];
481 tb[
x] =
_CLAMP(ta[
x] * (1.0f - local_opacity) + (ta[
x] + tb[
x]) * local_opacity,
min[
x],
max[
x]);
490static
void _blend_subtract(const float *const restrict
a, const float *const restrict
b,
491 float *const restrict
out, const float *const restrict
mask, const size_t stride,
494 for(
size_t i = 0;
i < stride;
i++)
497 float local_opacity =
mask[
i];
504 tb[
x] =
_CLAMP(ta[
x] * (1.0f - local_opacity) + ((tb[
x] + ta[
x]) - (fabsf(
min[
x] +
max[
x]))) * local_opacity,
514static
void _blend_difference(const float *const restrict
a, const float *const restrict
b,
515 float *const restrict
out, const float *const restrict
mask, const size_t stride,
520 const float local_opacity =
mask[
i];
526 const float lmin = 0.0f;
527 for(
size_t x = 0;
x < 3;
x++)
529 float lmax =
max[
x] + fabsf(
min[
x]);
530 float la =
_CLAMP(ta[
x] + fabsf(
min[
x]), lmin, lmax);
531 float lb =
_CLAMP(tb[
x] + fabsf(
min[
x]), lmin, lmax);
532 tb[
x] =
_CLAMP(la * (1.0f - local_opacity) + fabsf(la - lb) * local_opacity, lmin, lmax) - fabsf(
min[
x]);
542static
void _blend_difference2(const float *const restrict
a, const float *const restrict
b,
543 float *const restrict
out, const float *const restrict
mask, const size_t stride,
548 const float local_opacity =
mask[
i];
555 tb[
x] = fabsf(ta[
x] - tb[
x]) / fabsf(
max[
x] -
min[
x]);
556 tb[0] = fmaxf(tb[0], fmaxf(tb[1], tb[2]));
558 tb[0] =
_CLAMP(ta[0] * (1.0f - local_opacity) + tb[0] * local_opacity,
min[0],
max[0]);
569static
void _blend_screen(const float *const restrict
a, const float *const restrict
b,
570 float *const restrict
out, const float *const restrict
mask, const size_t stride,
575 const float local_opacity =
mask[
i];
581 const float lmin = 0.0f;
582 const float lmax =
max[0] + fabsf(
min[0]);
583 const float la =
_CLAMP(ta[0] + fabsf(
min[0]), lmin, lmax);
584 const float lb =
_CLAMP(tb[0] + fabsf(
min[0]), lmin, lmax);
586 tb[0] =
_CLAMP(la * (1.0f - local_opacity) + ((lmax - (lmax - la) * (lmax - lb))) * local_opacity, lmin, lmax)
589 const float f = fmaxf(ta[0], 0.01f);
590 tb[1] =
_CLAMP(ta[1] * (1.0f - local_opacity) + 0.5f * (ta[1] + tb[1]) * tb[0] /
f * local_opacity,
592 tb[2] =
_CLAMP(ta[2] * (1.0f - local_opacity) + 0.5f * (ta[2] + tb[2]) * tb[0] /
f * local_opacity,
602static
void _blend_overlay(const float *const restrict
a, const float *const restrict
b,
603 float *const restrict
out, const float *const restrict
mask, const size_t stride,
608 const float local_opacity =
mask[
i];
609 const float local_opacity2 = local_opacity * local_opacity;
615 const float lmin = 0.0f;
616 const float lmax =
max[0] + fabsf(
min[0]);
617 const float la =
_CLAMP(ta[0] + fabsf(
min[0]), lmin, lmax);
618 const float lb =
_CLAMP(tb[0] + fabsf(
min[0]), lmin, lmax);
619 const float halfmax = lmax / 2.0f;
620 const float doublemax = lmax * 2.0f;
622 tb[0] =
_CLAMP(la * (1.0f - local_opacity2)
623 + (la > halfmax ? lmax - (lmax - doublemax * (la - halfmax)) * (lmax - lb)
624 : (doublemax * la) * lb)
625 * local_opacity2, lmin, lmax)
628 const float f = fmaxf(ta[0], 0.01f);
629 tb[1] =
_CLAMP(ta[1] * (1.0f - local_opacity2) + (ta[1] + tb[1]) * tb[0] /
f * local_opacity2,
min[1],
max[1]);
630 tb[2] =
_CLAMP(ta[2] * (1.0f - local_opacity2) + (ta[2] + tb[2]) * tb[0] /
f * local_opacity2,
min[2],
max[2]);
639static
void _blend_softlight(const float *const restrict
a, const float *const restrict
b,
640 float *const restrict
out, const float *const restrict
mask, const size_t stride,
645 const float local_opacity =
mask[
i];
646 const float local_opacity2 = local_opacity * local_opacity;
652 const float lmin = 0.0f;
653 const float lmax =
max[0] + fabsf(
min[0]);
654 const float la =
_CLAMP(ta[0] + fabsf(
min[0]), lmin, lmax);
655 const float lb =
_CLAMP(tb[0] + fabsf(
min[0]), lmin, lmax);
656 const float halfmax = lmax / 2.0f;
658 tb[0] =
_CLAMP(la * (1.0f - local_opacity2)
659 + (lb > halfmax ? lmax - (lmax - la) * (lmax - (lb - halfmax))
660 : la * (lb + halfmax))
661 * local_opacity2, lmin, lmax)
664 const float f = fmaxf(ta[0], 0.01f);
665 tb[1] =
_CLAMP(ta[1] * (1.0f - local_opacity2) + (ta[1] + tb[1]) * tb[0] /
f * local_opacity2,
min[1],
max[1]);
666 tb[2] =
_CLAMP(ta[2] * (1.0f - local_opacity2) + (ta[2] + tb[2]) * tb[0] /
f * local_opacity2,
min[2],
max[2]);
675static
void _blend_hardlight(const float *const restrict
a, const float *const restrict
b,
676 float *const restrict
out, const float *const restrict
mask, const size_t stride,
681 const float local_opacity =
mask[
i];
682 const float local_opacity2 = local_opacity * local_opacity;
688 const float lmin = 0.0f;
689 const float lmax =
max[0] + fabsf(
min[0]);
690 const float la =
_CLAMP(ta[0] + fabsf(
min[0]), lmin, lmax);
691 const float lb =
_CLAMP(tb[0] + fabsf(
min[0]), lmin, lmax);
692 const float halfmax = lmax / 2.0f;
693 const float doublemax = lmax * 2.0f;
695 tb[0] =
_CLAMP(la * (1.0f - local_opacity2)
696 + (lb > halfmax ? lmax - (lmax - doublemax * (la - halfmax)) * (lmax - lb)
697 : doublemax * la * lb)
698 * local_opacity2, lmin, lmax)
701 const float f = fmaxf(ta[0], 0.01f);
702 tb[1] =
_CLAMP(ta[1] * (1.0f - local_opacity2) + (ta[1] + tb[1]) * tb[0] /
f * local_opacity2,
min[1],
max[1]);
703 tb[2] =
_CLAMP(ta[2] * (1.0f - local_opacity2) + (ta[2] + tb[2]) * tb[0] /
f * local_opacity2,
min[2],
max[2]);
712static
void _blend_vividlight(const float *const restrict
a, const float *const restrict
b,
713 float *const restrict
out, const float *const restrict
mask, const size_t stride,
718 const float local_opacity =
mask[
i];
719 const float local_opacity2 = local_opacity * local_opacity;
725 const float lmin = 0.0f;
726 const float lmax =
max[0] + fabsf(
min[0]);
727 const float la =
_CLAMP(ta[0] + fabsf(
min[0]), lmin, lmax);
728 const float lb =
_CLAMP(tb[0] + fabsf(
min[0]), lmin, lmax);
729 const float halfmax = lmax / 2.0f;
730 const float doublemax = lmax * 2.0f;
732 tb[0] =
_CLAMP(la * (1.0f - local_opacity2)
733 + (lb > halfmax ? (lb >= lmax ? lmax : la / (doublemax * (lmax - lb)))
734 : (lb <= lmin ? lmin : lmax - (lmax - la) / (doublemax * lb)))
735 * local_opacity2, lmin, lmax)
738 const float f = fmaxf(ta[0], 0.01f);
739 tb[1] =
_CLAMP(ta[1] * (1.0f - local_opacity2) + (ta[1] + tb[1]) * tb[0] /
f * local_opacity2,
min[1],
max[1]);
740 tb[2] =
_CLAMP(ta[2] * (1.0f - local_opacity2) + (ta[2] + tb[2]) * tb[0] /
f * local_opacity2,
min[2],
max[2]);
749static
void _blend_linearlight(const float *const restrict
a, const float *const restrict
b,
750 float *const restrict
out, const float *const restrict
mask, const size_t stride,
755 const float local_opacity =
mask[
i];
756 const float local_opacity2 = local_opacity * local_opacity;
762 const float lmin = 0.0f;
763 const float lmax =
max[0] + fabsf(
min[0]);
764 const float la =
_CLAMP(ta[0] + fabsf(
min[0]), lmin, lmax);
765 const float lb =
_CLAMP(tb[0] + fabsf(
min[0]), lmin, lmax);
766 const float doublemax = lmax * 2.0f;
768 tb[0] =
_CLAMP(la * (1.0f - local_opacity2) + (la + doublemax * lb - lmax) * local_opacity2, lmin, lmax)
771 const float f = fmaxf(ta[0], 0.01f);
772 tb[1] =
_CLAMP(ta[1] * (1.0f - local_opacity2) + (ta[1] + tb[1]) * tb[0] /
f * local_opacity2,
min[1],
max[1]);
773 tb[2] =
_CLAMP(ta[2] * (1.0f - local_opacity2) + (ta[2] + tb[2]) * tb[0] /
f * local_opacity2,
min[2],
max[2]);
782static
void _blend_pinlight(const float *const restrict
a, const float *const restrict
b,
783 float *const restrict
out, const float *const restrict
mask, const size_t stride,
788 const float local_opacity =
mask[
i];
789 const float local_opacity2 = local_opacity * local_opacity;
795 const float lmin = 0.0f;
796 const float lmax =
max[0] + fabsf(
min[0]);
797 const float la =
_CLAMP(ta[0] + fabsf(
min[0]), lmin, lmax);
798 const float lb =
_CLAMP(tb[0] + fabsf(
min[0]), lmin, lmax);
799 const float halfmax = lmax / 2.0f;
800 const float doublemax = lmax * 2.0f;
802 tb[0] =
_CLAMP(la * (1.0f - local_opacity2)
803 + (lb > halfmax ? fmaxf(la, doublemax * (lb - halfmax))
804 : fminf(la, doublemax * lb))
805 * local_opacity2, lmin, lmax)
818static
void _blend_lightness(const float *const restrict
a, const float *const restrict
b,
819 float *const restrict
out, const float *const restrict
mask, const size_t stride,
824 const float local_opacity =
mask[
i];
832 tb[0] =
_CLAMP(ta[0] * (1.0f - local_opacity) + tb[0] * local_opacity,
min[0],
max[0]);
843static
void _blend_chromaticity(const float *const restrict
a, const float *const restrict
b,
844 float *const restrict
out, const float *const restrict
mask, const size_t stride,
849 const float local_opacity =
mask[
i];
855 dt_Lab_2_LCH(ta, tta);
859 dt_Lab_2_LCH(tb, ttb);
862 ttb[1] = (tta[1] * (1.0f - local_opacity)) + ttb[1] * local_opacity;
865 dt_LCH_2_Lab(ttb, tb);
874static
void _blend_hue(const float *const restrict
a, const float *const restrict
b,
875 float *const restrict
out, const float *const restrict
mask, const size_t stride,
880 const float local_opacity =
mask[
i];
886 dt_Lab_2_LCH(ta, tta);
890 dt_Lab_2_LCH(tb, ttb);
895 const float d = fabsf(tta[2] - ttb[2]);
896 const float s =
d > 0.5f ? -local_opacity * (1.0f -
d) /
d : local_opacity;
897 ttb[2] = fmodf((tta[2] * (1.0f - s)) + ttb[2] * s + 1.0f, 1.0f);
899 dt_LCH_2_Lab(ttb, tb);
908static
void _blend_color(const float *const restrict
a, const float *const restrict
b,
909 float *const restrict
out, const float *const restrict
mask, const size_t stride,
914 const float local_opacity =
mask[
i];
920 dt_Lab_2_LCH(ta, tta);
924 dt_Lab_2_LCH(tb, ttb);
927 ttb[1] = (tta[1] * (1.0f - local_opacity)) + ttb[1] * local_opacity;
930 const float d = fabsf(tta[2] - ttb[2]);
931 const float s =
d > 0.5f ? -local_opacity * (1.0f -
d) /
d : local_opacity;
932 ttb[2] = fmodf((tta[2] * (1.0f - s)) + ttb[2] * s + 1.0f, 1.0f);
934 dt_LCH_2_Lab(ttb, tb);
943static
void _blend_coloradjust(const float *const restrict
a, const float *const restrict
b,
944 float *const restrict
out, const float *const restrict
mask, const size_t stride,
949 const float local_opacity =
mask[
i];
955 dt_Lab_2_LCH(ta, tta);
959 dt_Lab_2_LCH(tb, ttb);
962 ttb[1] = (tta[1] * (1.0f - local_opacity)) + ttb[1] * local_opacity;
965 const float d = fabsf(tta[2] - ttb[2]);
966 const float s =
d > 0.5f ? -local_opacity * (1.0f -
d) /
d : local_opacity;
967 ttb[2] = fmodf((tta[2] * (1.0f - s)) + ttb[2] * s + 1.0f, 1.0f);
969 dt_LCH_2_Lab(ttb, tb);
978static
void _blend_Lab_lightness(const float *const restrict
a, const float *const restrict
b,
979 float *const restrict
out, const float *const restrict
mask, const size_t stride,
984 const float local_opacity =
mask[
i];
990 tb[0] = ta[0] * (1.0f - local_opacity) + tb[0] * local_opacity;
1001static
void _blend_Lab_a(const float *const restrict
a, const float *const restrict
b,
1002 float *const restrict
out, const float *const restrict
mask, const size_t stride,
1007 const float local_opacity =
mask[
i];
1014 tb[1] = ta[1] * (1.0f - local_opacity) + tb[1] * local_opacity;
1024static
void _blend_Lab_b(const float *const restrict
a, const float *const restrict
b,
1025 float *const restrict
out, const float *const restrict
mask, const size_t stride,
1030 const float local_opacity =
mask[
i];
1038 tb[2] = ta[2] * (1.0f - local_opacity) + tb[2] * local_opacity;
1048static
void _blend_Lab_color(const float *const restrict
a, const float *const restrict
b,
1049 float *const restrict
out, const float *const restrict
mask, const size_t stride,
1054 float local_opacity =
mask[
i];
1061 tb[1] = ta[1] * (1.0f - local_opacity) + tb[1] * local_opacity;
1062 tb[2] = ta[2] * (1.0f - local_opacity) + tb[2] * local_opacity;
1078 blend = _blend_lighten;
1081 blend = _blend_darken;
1084 blend = _blend_multiply;
1087 blend = _blend_average;
1093 blend = _blend_subtract;
1096 blend = _blend_difference;
1099 blend = _blend_difference2;
1102 blend = _blend_screen;
1105 blend = _blend_overlay;
1108 blend = _blend_softlight;
1111 blend = _blend_hardlight;
1114 blend = _blend_vividlight;
1117 blend = _blend_linearlight;
1120 blend = _blend_pinlight;
1123 blend = _blend_lightness;
1126 blend = _blend_chromaticity;
1132 blend = _blend_color;
1135 blend = _blend_normal_bounded;
1138 blend = _blend_coloradjust;
1142 blend = _blend_Lab_lightness;
1145 blend = _blend_Lab_a;
1148 blend = _blend_Lab_b;
1151 blend = _blend_Lab_color;
1157 blend = _blend_normal_unbounded;
1175static
void _display_channel(const float *const restrict a, float *const restrict b,
1176 const float *const restrict mask, const size_t stride, const int channel,
1177 const float *const restrict boost_factors)
1247 dt_Lab_2_LCH(a + j,
LCH);
1259 dt_Lab_2_LCH(b + j,
LCH);
1270 dt_Lab_2_LCH(a + j,
LCH);
1280 dt_Lab_2_LCH(b + j,
LCH);
1296static inline
void _copy_mask(const float *const restrict a, float *const restrict b, const size_t stride)
1304 const float *
const a,
float *
const b,
1305 const float *
const restrict mask,
1314 const int xoffs = roi_out->
x - roi_in->
x;
1315 const int yoffs = roi_out->
y - roi_in->
y;
1316 const int iwidth = roi_in->
width;
1317 const int owidth = roi_out->
width;
1318 const int oheight = roi_out->
height;
1326 const float *
const restrict boost_factors =
d->blendif_boost_factors;
1330 for(
size_t y = 0; y < oheight; y++)
1334 const size_t m_start = y * owidth;
1335 _display_channel(a + a_start, b + b_start, mask + m_start, owidth, channel, boost_factors);
1351 const float yellow_mask = b[j+3];
1354 b[j+3] = yellow_mask;
1363 const float yellow_mask = b[j+3];
1366 b[j+3] = yellow_mask;
1384 for(
size_t y = 0; y < oheight; y++)
1388 const size_t m_start = y * owidth;
1389 blend(tmp_buffer + b_start, a + a_start, b + b_start, mask + m_start, owidth,
min,
max);
1395 for(
size_t y = 0; y < oheight; y++)
1399 const size_t m_start = y * owidth;
1400 blend(a + a_start, tmp_buffer + b_start, b + b_start, mask + m_start, owidth,
min,
max);
1411 for(
size_t y = 0; y < oheight; y++)
1414 const size_t b_start = y * stride;
1415 _copy_mask(a + a_start, b + b_start, stride);
void dt_develop_blendif_process_parameters(float *const restrict parameters, const dt_develop_blend_params_t *const params)
@ DEVELOP_BLENDIF_Lab_MASK
#define DEVELOP_BLENDIF_PARAMETER_ITEMS
@ DEVELOP_BLEND_CHROMATICITY
@ DEVELOP_BLEND_DIFFERENCE
@ DEVELOP_BLEND_LIGHTNESS
@ DEVELOP_BLEND_MODE_MASK
@ DEVELOP_BLEND_HARDLIGHT
@ DEVELOP_BLEND_LAB_COLOR
@ DEVELOP_BLEND_LINEARLIGHT
@ DEVELOP_BLEND_VIVIDLIGHT
@ DEVELOP_BLEND_SOFTLIGHT
@ DEVELOP_BLEND_COLORADJUST
@ DEVELOP_BLEND_LAB_LIGHTNESS
@ DEVELOP_BLEND_DIFFERENCE2
@ DEVELOP_MASK_PARAMETRIC
#define DT_BLENDIF_LAB_BCH
static _blend_row_func * _choose_blend_func(const unsigned int blend_mode)
static float _blendif_compute_factor(const float value, const unsigned int invert_mask, const float *const restrict parameters)
#define DT_BLENDIF_LAB_CH
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 restrict mask, const dt_dev_pixelpipe_display_mask_t request_mask_display)
void() _blend_row_func(const float *const restrict a, const float *const restrict b, float *const restrict out, const float *const restrict mask, const size_t stride, const dt_aligned_pixel_t min, const dt_aligned_pixel_t max)
static void _CLAMP_XYZ(dt_aligned_pixel_t XYZ, const dt_aligned_pixel_t min, const dt_aligned_pixel_t max)
static float _CLAMP(const float x, const float min, const float max)
void dt_develop_blendif_lab_make_mask(const struct dt_dev_pixelpipe_iop_t *piece, const float *const restrict a, const float *const restrict b, float *const restrict mask)
static void _display_channel_value(dt_aligned_pixel_t out, const float value, const float mask)
static void _blend_Lab_rescale(const float *i, float *o)
static void _blend_Lab_scale(const float *i, float *o)
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
static dt_aligned_pixel_t LCH
static const float const float const float min
static dt_aligned_pixel_t XYZ
const dt_colormatrix_t dt_aligned_pixel_t out
dt_Rec709_to_XYZ_D50(rgb, XYZ)
dt_iop_order_iccprofile_info_t * dt_ioppr_get_pipe_work_profile_info(const struct dt_dev_pixelpipe_t *pipe)
dt_dev_pixelpipe_display_mask_t
@ DT_DEV_PIXELPIPE_DISPLAY_a
@ DT_DEV_PIXELPIPE_DISPLAY_OUTPUT
@ DT_DEV_PIXELPIPE_DISPLAY_L
@ DT_DEV_PIXELPIPE_DISPLAY_ANY
@ DT_DEV_PIXELPIPE_DISPLAY_LCH_h
@ DT_DEV_PIXELPIPE_DISPLAY_LCH_C
@ DT_DEV_PIXELPIPE_DISPLAY_b
@ DT_DEV_PIXELPIPE_DISPLAY_MASK
__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_copy(float *const __restrict__ out, const float *const __restrict__ in, const size_t nfloats)
__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)
#define DEVELOP_BLENDIF_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...
#define DT_ALIGNED_PIXEL
Align a 4-float pixel on 16 bytes, enough for SSE. Same struct-member caveat as DT_ALIGNED_ARRAY,...
#define DT_ALIGNED_ARRAY
Align an object on a cacheline boundary, so AVX2 can load it whole.
#define __OMP_SIMD__(...)
#define __OMP_DECLARE_SIMD__(...)
#define __OMP_PARALLEL__(...)
#define __OMP_PARALLEL_FOR__(...)
#define __OMP_FOR_SIMD__(...)
#define __OMP_PARALLEL_FOR_SIMD__(...)
static float clamp_simd(const float x)
#define dt_pixelpipe_cache_alloc_align_float_cache(pixels, id)
#define dt_pixelpipe_cache_free_align(mem)
DT_ALIGNED_PIXEL float dt_aligned_pixel_t[4]
#define for_each_channel(_var,...)
static const dt_aligned_pixel_simd_t value
dt_iop_buffer_dsc_t dsc_in
A profile reduced to the arithmetic the pixel loop can run: two matrices and six tone-curve LUTs,...
int nonlinearlut
Non-zero when the profile has tone curves at all; tested as a boolean everywhere, but it is really th...
int lutsize
Entry count of each of the six LUTs. Always 65536 in practice: both callers of dt_ioppr_init_profile_...
float * lut_in[3]
Per-channel encoded -> linear tone curve, lutsize entries each, sampled over [0,1]....
dt_colormatrix_t matrix_in_transposed
Region of interest passed through the pixelpipe.