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;
63 for(
int j = 0; j <
height; j++)
71 for(;
i <
width - st;
i += step)
73 gbuf(buf,
i, j) -= (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
74 / (tmp[
i - st] + tmp[
i]);
78 for(
ch = 0;
ch < 3;
ch++)
gbuf(buf, 0, j) +=
gbuf(buf, st, j) * 0.5f;
79 for(
i = step;
i <
width - st;
i += step)
81 gbuf(buf,
i, j) += (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
82 / (2.0 * (tmp[
i - st] + tmp[
i]));
97 for(
int j = 0; j <
height - st; j += st) tmp[j] =
gweight(
i, j,
i, j + st);
100 for(; j <
height - st; j += step)
102 gbuf(buf,
i, j) -= (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
103 / (tmp[j - st] + tmp[j]);
108 for(j = step; j <
height - st; j += step)
110 gbuf(buf,
i, j) += (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
111 / (2.0 * (tmp[j - st] + tmp[j]));
122 const int step = 1 << l;
123 const int st = step / 2;
124 const int wd = (int)(1 + (
width >> (l - 1)));
135 for(j = 0; j <
height - st; j += st) tmp[j] =
gweight(
i, j,
i, j + st);
138 for(j = step; j <
height - st; j += step)
139 for(
int ch = 0;
ch < 3;
ch++)
140 gbuf(buf,
i, j) -= (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
141 / (2.0 * (tmp[j - st] + tmp[j]));
143 for(
int ch = 0;
ch < 3;
ch++)
gbuf(buf,
i, j) -=
gbuf(buf,
i, j - st) * .5f;
145 for(j = st; j <
height - st; j += step)
146 for(
int ch = 0;
ch < 3;
ch++)
147 gbuf(buf,
i, j) += (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
148 / (tmp[j - st] + tmp[j]);
158 for(
int j = 0; j <
height; j++)
164 for(
int ch = 0;
ch < 3;
ch++)
gbuf(buf, 0, j) -=
gbuf(buf, st, j) * 0.5f;
166 for(
i = step;
i <
width - st;
i += step)
167 for(
int ch = 0;
ch < 3;
ch++)
168 gbuf(buf,
i, j) -= (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
169 / (2.0 * (tmp[
i - st] + tmp[
i]));
171 for(
int ch = 0;
ch < 3;
ch++)
gbuf(buf,
i, j) -=
gbuf(buf,
i - st, j) * 0.5f;
173 for(
i = st;
i <
width - st;
i += step)
174 for(
int ch = 0;
ch < 3;
ch++)
175 gbuf(buf,
i, j) += (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
176 / (tmp[
i - st] + tmp[
i]);
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
const float i
Definition colorspaces_inline_conversions.h:440
#define dt_pixelpipe_cache_free_align(mem)
Definition darktable.h:452
#define dt_get_perthread(buf, padsize)
Definition darktable.h:1035
#define __OMP_PARALLEL_FOR__(...)
Definition darktable.h:257
#define dt_pixelpipe_cache_alloc_perthread_float(n, padded_size)
Definition darktable.h:1030
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
Definition darktable.h:280
#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:120
float *const restrict const size_t const size_t ch
Definition luminance_mask.h:84