42 float *plane[16+1][4];
47 #define OFFSET(x) offsetof(OWDenoiseContext, x)
48 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
61 { 0, 48, 12, 60, 3, 51, 15, 63 },
62 { 32, 16, 44, 28, 35, 19, 47, 31 },
63 { 8, 56, 4, 52, 11, 59, 7, 55 },
64 { 40, 24, 36, 20, 43, 27, 39, 23 },
65 { 2, 50, 14, 62, 1, 49, 13, 61 },
66 { 34, 18, 46, 30, 33, 17, 45, 29 },
67 { 10, 58, 6, 54, 9, 57, 5, 53 },
68 { 42, 26, 38, 22, 41, 25, 37, 21 },
71 static const double coeff[2][5] = {
102 static inline void decompose(
float *dst_l,
float *dst_h,
const float *
src,
106 for (x = 0; x < w; x++) {
107 double sum_l = src[x * linesize] *
coeff[0][0];
108 double sum_h = src[x * linesize] * coeff[1][0];
109 for (i = 1; i <= 4; i++) {
113 sum_l += coeff[0][i] *
s;
114 sum_h += coeff[1][i] *
s;
116 dst_l[x * linesize] = sum_l;
117 dst_h[x * linesize] = sum_h;
121 static inline void compose(
float *dst,
const float *src_l,
const float *src_h,
125 for (x = 0; x < w; x++) {
126 double sum_l = src_l[x * linesize] *
icoeff[0][0];
127 double sum_h = src_h[x * linesize] * icoeff[1][0];
128 for (i = 1; i <= 4; i++) {
132 sum_l += icoeff[0][i] * (src_l[x0] + src_l[x1]);
133 sum_h += icoeff[1][i] * (src_h[x0] + src_h[x1]);
135 dst[x * linesize] = (sum_l + sum_h) * 0.5;
140 int xlinesize,
int ylinesize,
141 int step,
int w,
int h)
144 for (y = 0; y < h; y++)
145 for (x = 0; x < step; x++)
146 decompose(dst_l + ylinesize*y + xlinesize*x,
147 dst_h + ylinesize*y + xlinesize*x,
148 src + ylinesize*y + xlinesize*x,
149 step * xlinesize, (w - x + step - 1) / step);
152 static inline void compose2D(
float *dst,
const float *src_l,
const float *src_h,
153 int xlinesize,
int ylinesize,
154 int step,
int w,
int h)
157 for (y = 0; y < h; y++)
158 for (x = 0; x < step; x++)
159 compose(dst + ylinesize*y + xlinesize*x,
160 src_l + ylinesize*y + xlinesize*x,
161 src_h + ylinesize*y + xlinesize*x,
162 step * xlinesize, (w - x + step - 1) / step);
166 int linesize,
int step,
int w,
int h)
168 decompose2D(temp[0], temp[1], src, 1, linesize, step, w, h);
169 decompose2D( dst[0], dst[1], temp[0], linesize, 1, step, h, w);
170 decompose2D( dst[2], dst[3], temp[1], linesize, 1, step, h, w);
174 int linesize,
int step,
int w,
int h)
176 compose2D(temp[0], src[0], src[1], linesize, 1, step, h, w);
177 compose2D(temp[1], src[2], src[3], linesize, 1, step, h, w);
178 compose2D(dst, temp[0], temp[1], 1, linesize, step, w, h);
182 uint8_t *dst,
int dst_linesize,
188 while (1<<depth > width || 1<<depth > height)
191 for (y = 0; y <
height; y++)
192 for(x = 0; x <
width; x++)
198 for (i = 0; i <
depth; i++) {
199 for (j = 1; j < 4; j++) {
200 for (y = 0; y <
height; y++) {
201 for (x = 0; x <
width; x++) {
203 if (v > strength) v -= strength;
204 else if (v < -strength) v += strength;
211 for (i = depth-1; i >= 0; i--)
214 for (y = 0; y <
height; y++) {
215 for (x = 0; x <
width; x++) {
217 if ((
unsigned)i > 255
U) i = ~(i >> 31);
218 dst[y*dst_linesize + x] = i;
253 inlink->
w, inlink->
h);
279 const int h =
FFALIGN(inlink->
h, 16);
285 for (j = 0; j < 4; j++) {
286 for (i = 0; i <= s->
depth; i++) {
300 for (j = 0; j < 4; j++)
301 for (i = 0; i <= s->
depth; i++)
329 .
inputs = owdenoise_inputs,
331 .priv_class = &owdenoise_class,