33#define gweight(i, j, ii, jj) \
34 1.0 / (fabsf(weight_a[l][(size_t)wd * ((j) >> (l - 1)) + ((i) >> (l - 1))] \
35 - weight_a[l][(size_t)wd * ((jj) >> (l - 1)) + ((ii) >> (l - 1))]) + 1.e-5)
40#define gbuf(BUF, A, B) ((BUF)[4 * ((size_t)width * ((B)) + ((A))) + ch])
45 const int wd = (int)(1 + (
width >> (l - 1))), ht = (
int)(1 + (
height >> (l - 1)));
48 for(
int j = 0; j < ht - 1; j++)
50 for(
int i = 0;
i < wd - 1;
i++) weight_a[l][(
size_t)j * wd +
i] =
gbuf(buf,
i << (l - 1), j << (l - 1));
51 weight_a[l][j * wd + (wd - 1)] = 0.0f;
53 for(
int i = 0;
i < wd;
i++)
54 weight_a[l][(ht-1) * wd +
i] = 0.0f;
56 const int step = 1 << l;
57 const int st = step / 2;
61 if(tmp_width_buf == NULL)
return 1;
64#pragma omp parallel for default(none) \
65 dt_omp_firstprivate(height, l, st, step, tmp_width_buf, scratch_size, wd, width) \
66 dt_omp_sharedconst(buf) \
71 for(
int j = 0; j <
height; j++)
79 for(;
i <
width - st;
i += step)
80 for(ch = 0; ch < 3; ch++)
81 gbuf(buf,
i, j) -= (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
82 / (tmp[
i - st] + tmp[
i]);
84 for(ch = 0; ch < 3; ch++)
gbuf(buf,
i, j) -=
gbuf(buf,
i - st, j);
86 for(ch = 0; ch < 3; ch++)
gbuf(buf, 0, j) +=
gbuf(buf, st, j) * 0.5f;
87 for(
i = step;
i <
width - st;
i += step)
88 for(ch = 0; ch < 3; ch++)
89 gbuf(buf,
i, j) += (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
90 / (2.0 * (tmp[
i - st] + tmp[
i]));
92 for(ch = 0; ch < 3; ch++)
gbuf(buf,
i, j) +=
gbuf(buf,
i - st, j) * .5f;
98 if(tmp_height_buf == NULL)
return 1;
101#pragma omp parallel for default(none) \
102 dt_omp_firstprivate(height, l, st, step, tmp_height_buf, scratch_size, wd, width) \
103 dt_omp_sharedconst(buf) \
113 for(
int j = 0; j <
height - st; j += st) tmp[j] =
gweight(
i, j,
i, j + st);
116 for(; j <
height - st; j += step)
117 for(ch = 0; ch < 3; ch++)
118 gbuf(buf,
i, j) -= (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
119 / (tmp[j - st] + tmp[j]);
121 for(ch = 0; ch < 3; ch++)
gbuf(buf,
i, j) -=
gbuf(buf,
i, j - st);
123 for(ch = 0; ch < 3; ch++)
gbuf(buf,
i, 0) +=
gbuf(buf,
i, st) * 0.5;
124 for(j = step; j <
height - st; j += step)
125 for(ch = 0; ch < 3; ch++)
126 gbuf(buf,
i, j) += (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
127 / (2.0 * (tmp[j - st] + tmp[j]));
129 for(ch = 0; ch < 3; ch++)
gbuf(buf,
i, j) +=
gbuf(buf,
i, j - st) * .5f;
138 const int step = 1 << l;
139 const int st = step / 2;
140 const int wd = (int)(1 + (
width >> (l - 1)));
144 if(tmp_height_buf == NULL)
return 1;
147#pragma omp parallel for default(none) \
148 dt_omp_firstprivate(height, l, st, step, tmp_height_buf, scratch_size, wd, width) \
149 shared(weight_a, buf) \
157 for(j = 0; j <
height - st; j += st) tmp[j] =
gweight(
i, j,
i, j + st);
159 for(
int ch = 0; ch < 3; ch++)
gbuf(buf,
i, 0) -=
gbuf(buf,
i, st) * 0.5f;
160 for(j = step; j <
height - st; j += step)
161 for(
int ch = 0; ch < 3; ch++)
162 gbuf(buf,
i, j) -= (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
163 / (2.0 * (tmp[j - st] + tmp[j]));
165 for(
int ch = 0; ch < 3; ch++)
gbuf(buf,
i, j) -=
gbuf(buf,
i, j - st) * .5f;
167 for(j = st; j <
height - st; j += step)
168 for(
int ch = 0; ch < 3; ch++)
169 gbuf(buf,
i, j) += (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
170 / (tmp[j - st] + tmp[j]);
172 for(
int ch = 0; ch < 3; ch++)
gbuf(buf,
i, j) +=
gbuf(buf,
i, j - st);
178 if(tmp_width_buf == NULL)
return 1;
181#pragma omp parallel for default(none) \
182 dt_omp_firstprivate(height, l, st, step, tmp_width_buf, scratch_size, wd, width) \
183 shared(weight_a, buf) \
186 for(
int j = 0; j <
height; j++)
192 for(
int ch = 0; ch < 3; ch++)
gbuf(buf, 0, j) -=
gbuf(buf, st, j) * 0.5f;
194 for(
i = step;
i <
width - st;
i += step)
195 for(
int ch = 0; ch < 3; ch++)
196 gbuf(buf,
i, j) -= (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
197 / (2.0 * (tmp[
i - st] + tmp[
i]));
199 for(
int ch = 0; ch < 3; ch++)
gbuf(buf,
i, j) -=
gbuf(buf,
i - st, j) * 0.5f;
201 for(
i = st;
i <
width - st;
i += step)
202 for(
int ch = 0; ch < 3; ch++)
203 gbuf(buf,
i, j) += (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
204 / (tmp[
i - st] + tmp[
i]);
206 for(
int ch = 0; ch < 3; ch++)
gbuf(buf,
i, j) +=
gbuf(buf,
i - st, j);
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
const float i
Definition colorspaces_inline_conversions.h:669
#define dt_pixelpipe_cache_free_align(mem)
Definition darktable.h:377
#define dt_get_perthread(buf, padsize)
Definition darktable.h:967
#define dt_pixelpipe_cache_alloc_perthread_float(n, padded_size)
Definition darktable.h:962
#define gweight(i, j, ii, jj)
Definition equalizer_eaw.h:33
static int dt_iop_equalizer_wtf(float *const buf, float **weight_a, const int l, const int width, const int height)
Definition equalizer_eaw.h:43
#define gbuf(BUF, A, B)
Definition equalizer_eaw.h:40
static int dt_iop_equalizer_iwtf(float *buf, float **weight_a, const int l, const int width, const int height)
Definition equalizer_eaw.h:136