30#ifndef DT_IOP_EQUALIZER_EAW_H
31#define DT_IOP_EQUALIZER_EAW_H
34#define gweight(i, j, ii, jj) \
35 1.0 / (fabsf(weight_a[l][(size_t)wd * ((j) >> (l - 1)) + ((i) >> (l - 1))] \
36 - weight_a[l][(size_t)wd * ((jj) >> (l - 1)) + ((ii) >> (l - 1))]) + 1.e-5)
41#define gbuf(BUF, A, B) ((BUF)[4 * ((size_t)width * ((B)) + ((A))) + ch])
46 const int wd = (int)(1 + (
width >> (l - 1))), ht = (
int)(1 + (
height >> (l - 1)));
49 for(
int j = 0; j < ht - 1; j++)
51 for(
int i = 0;
i < wd - 1;
i++) weight_a[l][(
size_t)j * wd +
i] =
gbuf(buf,
i << (l - 1), j << (l - 1));
52 weight_a[l][j * wd + (wd - 1)] = 0.0f;
54 for(
int i = 0;
i < wd;
i++)
55 weight_a[l][(ht-1) * wd +
i] = 0.0f;
57 const int step = 1 << l;
58 const int st = step / 2;
64 for(
int j = 0; j <
height; j++)
72 for(;
i <
width - st;
i += step)
74 gbuf(buf,
i, j) -= (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
75 / (tmp[
i - st] + tmp[
i]);
79 for(
ch = 0;
ch < 3;
ch++)
gbuf(buf, 0, j) +=
gbuf(buf, st, j) * 0.5f;
80 for(
i = step;
i <
width - st;
i += step)
82 gbuf(buf,
i, j) += (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
83 / (2.0 * (tmp[
i - st] + tmp[
i]));
98 for(
int j = 0; j <
height - st; j += st) tmp[j] =
gweight(
i, j,
i, j + st);
101 for(; j <
height - st; j += step)
103 gbuf(buf,
i, j) -= (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
104 / (tmp[j - st] + tmp[j]);
109 for(j = step; j <
height - st; j += step)
111 gbuf(buf,
i, j) += (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
112 / (2.0 * (tmp[j - st] + tmp[j]));
123 const int step = 1 << l;
124 const int st = step / 2;
125 const int wd = (int)(1 + (
width >> (l - 1)));
136 for(j = 0; j <
height - st; j += st) tmp[j] =
gweight(
i, j,
i, j + st);
139 for(j = step; j <
height - st; j += step)
140 for(
int ch = 0;
ch < 3;
ch++)
141 gbuf(buf,
i, j) -= (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
142 / (2.0 * (tmp[j - st] + tmp[j]));
144 for(
int ch = 0;
ch < 3;
ch++)
gbuf(buf,
i, j) -=
gbuf(buf,
i, j - st) * .5f;
146 for(j = st; j <
height - st; j += step)
147 for(
int ch = 0;
ch < 3;
ch++)
148 gbuf(buf,
i, j) += (tmp[j - st] *
gbuf(buf,
i, j - st) + tmp[j] *
gbuf(buf,
i, j + st))
149 / (tmp[j - st] + tmp[j]);
159 for(
int j = 0; j <
height; j++)
165 for(
int ch = 0;
ch < 3;
ch++)
gbuf(buf, 0, j) -=
gbuf(buf, st, j) * 0.5f;
167 for(
i = step;
i <
width - st;
i += step)
168 for(
int ch = 0;
ch < 3;
ch++)
169 gbuf(buf,
i, j) -= (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
170 / (2.0 * (tmp[
i - st] + tmp[
i]));
172 for(
int ch = 0;
ch < 3;
ch++)
gbuf(buf,
i, j) -=
gbuf(buf,
i - st, j) * 0.5f;
174 for(
i = st;
i <
width - st;
i += step)
175 for(
int ch = 0;
ch < 3;
ch++)
176 gbuf(buf,
i, j) += (tmp[
i - st] *
gbuf(buf,
i - st, j) + tmp[
i] *
gbuf(buf,
i + st, j))
177 / (tmp[
i - st] + tmp[
i]);
#define gweight(i, j, ii, jj)
static int dt_iop_equalizer_wtf(float *const buf, float **weight_a, const int l, const int width, const int height)
static int dt_iop_equalizer_iwtf(float *buf, float **weight_a, const int l, const int width, const int height)
float *const restrict const size_t const size_t ch
#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 __OMP_PARALLEL_FOR__(...)
#define dt_pixelpipe_cache_free_align(mem)
#define dt_get_perthread(buf, padsize)
#define dt_pixelpipe_cache_alloc_perthread_float(n, padded_size)