64 const float *
src,
int src_linesize,
65 float *dst,
int dst_linesize,
68 const uint8_t **
src,
int src_linesize,
71 float **
src,
int src_linesize,
77 #define DEFAULT_NBITS 3
79 #define OFFSET(x) offsetof(DCTdnoizContext, x)
80 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
94 int dst_stridea,
int dst_strideb,
95 int src_stridea,
int src_strideb)
99 for (
i = 0;
i < 8;
i++) {
100 const float x00 =
src[0*src_stridea] +
src[7*src_stridea];
101 const float x01 =
src[1*src_stridea] +
src[6*src_stridea];
102 const float x02 =
src[2*src_stridea] +
src[5*src_stridea];
103 const float x03 =
src[3*src_stridea] +
src[4*src_stridea];
104 const float x04 =
src[0*src_stridea] -
src[7*src_stridea];
105 const float x05 =
src[1*src_stridea] -
src[6*src_stridea];
106 const float x06 =
src[2*src_stridea] -
src[5*src_stridea];
107 const float x07 =
src[3*src_stridea] -
src[4*src_stridea];
108 const float x08 = x00 + x03;
109 const float x09 = x01 + x02;
110 const float x0a = x00 - x03;
111 const float x0b = x01 - x02;
112 const float x0c = 1.38703984532215f*x04 + 0.275899379282943f*x07;
113 const float x0d = 1.17587560241936f*x05 + 0.785694958387102f*x06;
114 const float x0e = -0.785694958387102f*x05 + 1.17587560241936f*x06;
115 const float x0f = 0.275899379282943f*x04 - 1.38703984532215f*x07;
116 const float x10 = 0.353553390593274f * (x0c - x0d);
117 const float x11 = 0.353553390593274f * (x0e - x0f);
118 dst[0*dst_stridea] = 0.353553390593274f * (x08 + x09);
119 dst[1*dst_stridea] = 0.353553390593274f * (x0c + x0d);
120 dst[2*dst_stridea] = 0.461939766255643f*x0a + 0.191341716182545f*x0b;
121 dst[3*dst_stridea] = 0.707106781186547f * (x10 - x11);
122 dst[4*dst_stridea] = 0.353553390593274f * (x08 - x09);
123 dst[5*dst_stridea] = 0.707106781186547f * (x10 + x11);
124 dst[6*dst_stridea] = 0.191341716182545f*x0a - 0.461939766255643f*x0b;
125 dst[7*dst_stridea] = 0.353553390593274f * (x0e + x0f);
132 int dst_stridea,
int dst_strideb,
133 int src_stridea,
int src_strideb,
138 for (
i = 0;
i < 8;
i++) {
139 const float x00 = 1.4142135623731f *
src[0*src_stridea];
140 const float x01 = 1.38703984532215f *
src[1*src_stridea] + 0.275899379282943f*
src[7*src_stridea];
141 const float x02 = 1.30656296487638f *
src[2*src_stridea] + 0.541196100146197f*
src[6*src_stridea];
142 const float x03 = 1.17587560241936f *
src[3*src_stridea] + 0.785694958387102f*
src[5*src_stridea];
143 const float x04 = 1.4142135623731f *
src[4*src_stridea];
144 const float x05 = -0.785694958387102f*
src[3*src_stridea] + 1.17587560241936f*
src[5*src_stridea];
145 const float x06 = 0.541196100146197f*
src[2*src_stridea] - 1.30656296487638f*
src[6*src_stridea];
146 const float x07 = -0.275899379282943f*
src[1*src_stridea] + 1.38703984532215f*
src[7*src_stridea];
147 const float x09 = x00 + x04;
148 const float x0a = x01 + x03;
149 const float x0b = 1.4142135623731f*x02;
150 const float x0c = x00 - x04;
151 const float x0d = x01 - x03;
152 const float x0e = 0.353553390593274f * (x09 - x0b);
153 const float x0f = 0.353553390593274f * (x0c + x0d);
154 const float x10 = 0.353553390593274f * (x0c - x0d);
155 const float x11 = 1.4142135623731f*x06;
156 const float x12 = x05 + x07;
157 const float x13 = x05 - x07;
158 const float x14 = 0.353553390593274f * (x11 + x12);
159 const float x15 = 0.353553390593274f * (x11 - x12);
160 const float x16 = 0.5f*x13;
161 dst[0*dst_stridea] = (add ? dst[ 0*dst_stridea] : 0) + 0.25
f * (x09 + x0b) + 0.353553390593274f*x0a;
162 dst[1*dst_stridea] = (add ? dst[ 1*dst_stridea] : 0) + 0.707106781186547
f * (x0f + x15);
163 dst[2*dst_stridea] = (add ? dst[ 2*dst_stridea] : 0) + 0.707106781186547
f * (x0f - x15);
164 dst[3*dst_stridea] = (add ? dst[ 3*dst_stridea] : 0) + 0.707106781186547
f * (x0e + x16);
165 dst[4*dst_stridea] = (add ? dst[ 4*dst_stridea] : 0) + 0.707106781186547
f * (x0e - x16);
166 dst[5*dst_stridea] = (add ? dst[ 5*dst_stridea] : 0) + 0.707106781186547
f * (x10 - x14);
167 dst[6*dst_stridea] = (add ? dst[ 6*dst_stridea] : 0) + 0.707106781186547
f * (x10 + x14);
168 dst[7*dst_stridea] = (add ? dst[ 7*dst_stridea] : 0) + 0.25
f * (x09 + x0b) - 0.353553390593274f*x0a;
176 int dst_stridea,
int dst_strideb,
177 int src_stridea,
int src_strideb)
181 for (
i = 0;
i < 16;
i++) {
182 const float x00 =
src[ 0*src_stridea] +
src[15*src_stridea];
183 const float x01 =
src[ 1*src_stridea] +
src[14*src_stridea];
184 const float x02 =
src[ 2*src_stridea] +
src[13*src_stridea];
185 const float x03 =
src[ 3*src_stridea] +
src[12*src_stridea];
186 const float x04 =
src[ 4*src_stridea] +
src[11*src_stridea];
187 const float x05 =
src[ 5*src_stridea] +
src[10*src_stridea];
188 const float x06 =
src[ 6*src_stridea] +
src[ 9*src_stridea];
189 const float x07 =
src[ 7*src_stridea] +
src[ 8*src_stridea];
190 const float x08 =
src[ 0*src_stridea] -
src[15*src_stridea];
191 const float x09 =
src[ 1*src_stridea] -
src[14*src_stridea];
192 const float x0a =
src[ 2*src_stridea] -
src[13*src_stridea];
193 const float x0b =
src[ 3*src_stridea] -
src[12*src_stridea];
194 const float x0c =
src[ 4*src_stridea] -
src[11*src_stridea];
195 const float x0d =
src[ 5*src_stridea] -
src[10*src_stridea];
196 const float x0e =
src[ 6*src_stridea] -
src[ 9*src_stridea];
197 const float x0f =
src[ 7*src_stridea] -
src[ 8*src_stridea];
198 const float x10 = x00 + x07;
199 const float x11 = x01 + x06;
200 const float x12 = x02 + x05;
201 const float x13 = x03 + x04;
202 const float x14 = x00 - x07;
203 const float x15 = x01 - x06;
204 const float x16 = x02 - x05;
205 const float x17 = x03 - x04;
206 const float x18 = x10 + x13;
207 const float x19 = x11 + x12;
208 const float x1a = x10 - x13;
209 const float x1b = x11 - x12;
210 const float x1c = 1.38703984532215f*x14 + 0.275899379282943f*x17;
211 const float x1d = 1.17587560241936f*x15 + 0.785694958387102f*x16;
212 const float x1e = -0.785694958387102f*x15 + 1.17587560241936f *x16;
213 const float x1f = 0.275899379282943f*x14 - 1.38703984532215f *x17;
214 const float x20 = 0.25f * (x1c - x1d);
215 const float x21 = 0.25f * (x1e - x1f);
216 const float x22 = 1.40740373752638f *x08 + 0.138617169199091f*x0f;
217 const float x23 = 1.35331800117435f *x09 + 0.410524527522357f*x0e;
218 const float x24 = 1.24722501298667f *x0a + 0.666655658477747f*x0d;
219 const float x25 = 1.09320186700176f *x0b + 0.897167586342636f*x0c;
220 const float x26 = -0.897167586342636f*x0b + 1.09320186700176f *x0c;
221 const float x27 = 0.666655658477747f*x0a - 1.24722501298667f *x0d;
222 const float x28 = -0.410524527522357f*x09 + 1.35331800117435f *x0e;
223 const float x29 = 0.138617169199091f*x08 - 1.40740373752638f *x0f;
224 const float x2a = x22 + x25;
225 const float x2b = x23 + x24;
226 const float x2c = x22 - x25;
227 const float x2d = x23 - x24;
228 const float x2e = 0.25f * (x2a - x2b);
229 const float x2f = 0.326640741219094f*x2c + 0.135299025036549f*x2d;
230 const float x30 = 0.135299025036549f*x2c - 0.326640741219094f*x2d;
231 const float x31 = x26 + x29;
232 const float x32 = x27 + x28;
233 const float x33 = x26 - x29;
234 const float x34 = x27 - x28;
235 const float x35 = 0.25f * (x31 - x32);
236 const float x36 = 0.326640741219094f*x33 + 0.135299025036549f*x34;
237 const float x37 = 0.135299025036549f*x33 - 0.326640741219094f*x34;
238 dst[ 0*dst_stridea] = 0.25f * (x18 + x19);
239 dst[ 1*dst_stridea] = 0.25f * (x2a + x2b);
240 dst[ 2*dst_stridea] = 0.25f * (x1c + x1d);
241 dst[ 3*dst_stridea] = 0.707106781186547f * (x2f - x37);
242 dst[ 4*dst_stridea] = 0.326640741219094f*x1a + 0.135299025036549f*x1b;
243 dst[ 5*dst_stridea] = 0.707106781186547f * (x2f + x37);
244 dst[ 6*dst_stridea] = 0.707106781186547f * (x20 - x21);
245 dst[ 7*dst_stridea] = 0.707106781186547f * (x2e + x35);
246 dst[ 8*dst_stridea] = 0.25f * (x18 - x19);
247 dst[ 9*dst_stridea] = 0.707106781186547f * (x2e - x35);
248 dst[10*dst_stridea] = 0.707106781186547f * (x20 + x21);
249 dst[11*dst_stridea] = 0.707106781186547f * (x30 - x36);
250 dst[12*dst_stridea] = 0.135299025036549f*x1a - 0.326640741219094f*x1b;
251 dst[13*dst_stridea] = 0.707106781186547f * (x30 + x36);
252 dst[14*dst_stridea] = 0.25f * (x1e + x1f);
253 dst[15*dst_stridea] = 0.25f * (x31 + x32);
260 int dst_stridea,
int dst_strideb,
261 int src_stridea,
int src_strideb,
266 for (
i = 0;
i < 16;
i++) {
267 const float x00 = 1.4142135623731f *
src[ 0*src_stridea];
268 const float x01 = 1.40740373752638f *
src[ 1*src_stridea] + 0.138617169199091f*
src[15*src_stridea];
269 const float x02 = 1.38703984532215f *
src[ 2*src_stridea] + 0.275899379282943f*
src[14*src_stridea];
270 const float x03 = 1.35331800117435f *
src[ 3*src_stridea] + 0.410524527522357f*
src[13*src_stridea];
271 const float x04 = 1.30656296487638f *
src[ 4*src_stridea] + 0.541196100146197f*
src[12*src_stridea];
272 const float x05 = 1.24722501298667f *
src[ 5*src_stridea] + 0.666655658477747f*
src[11*src_stridea];
273 const float x06 = 1.17587560241936f *
src[ 6*src_stridea] + 0.785694958387102f*
src[10*src_stridea];
274 const float x07 = 1.09320186700176f *
src[ 7*src_stridea] + 0.897167586342636f*
src[ 9*src_stridea];
275 const float x08 = 1.4142135623731f *
src[ 8*src_stridea];
276 const float x09 = -0.897167586342636f*
src[ 7*src_stridea] + 1.09320186700176f*
src[ 9*src_stridea];
277 const float x0a = 0.785694958387102f*
src[ 6*src_stridea] - 1.17587560241936f*
src[10*src_stridea];
278 const float x0b = -0.666655658477747f*
src[ 5*src_stridea] + 1.24722501298667f*
src[11*src_stridea];
279 const float x0c = 0.541196100146197f*
src[ 4*src_stridea] - 1.30656296487638f*
src[12*src_stridea];
280 const float x0d = -0.410524527522357f*
src[ 3*src_stridea] + 1.35331800117435f*
src[13*src_stridea];
281 const float x0e = 0.275899379282943f*
src[ 2*src_stridea] - 1.38703984532215f*
src[14*src_stridea];
282 const float x0f = -0.138617169199091f*
src[ 1*src_stridea] + 1.40740373752638f*
src[15*src_stridea];
283 const float x12 = x00 + x08;
284 const float x13 = x01 + x07;
285 const float x14 = x02 + x06;
286 const float x15 = x03 + x05;
287 const float x16 = 1.4142135623731f*x04;
288 const float x17 = x00 - x08;
289 const float x18 = x01 - x07;
290 const float x19 = x02 - x06;
291 const float x1a = x03 - x05;
292 const float x1d = x12 + x16;
293 const float x1e = x13 + x15;
294 const float x1f = 1.4142135623731f*x14;
295 const float x20 = x12 - x16;
296 const float x21 = x13 - x15;
297 const float x22 = 0.25f * (x1d - x1f);
298 const float x23 = 0.25f * (x20 + x21);
299 const float x24 = 0.25f * (x20 - x21);
300 const float x25 = 1.4142135623731f*x17;
301 const float x26 = 1.30656296487638f*x18 + 0.541196100146197f*x1a;
302 const float x27 = 1.4142135623731f*x19;
303 const float x28 = -0.541196100146197f*x18 + 1.30656296487638f*x1a;
304 const float x29 = 0.176776695296637f * (x25 + x27) + 0.25
f*x26;
305 const float x2a = 0.25f * (x25 - x27);
306 const float x2b = 0.176776695296637f * (x25 + x27) - 0.25
f*x26;
307 const float x2c = 0.353553390593274f*x28;
308 const float x1b = 0.707106781186547f * (x2a - x2c);
309 const float x1c = 0.707106781186547f * (x2a + x2c);
310 const float x2d = 1.4142135623731f*x0c;
311 const float x2e = x0b + x0d;
312 const float x2f = x0a + x0e;
313 const float x30 = x09 + x0f;
314 const float x31 = x09 - x0f;
315 const float x32 = x0a - x0e;
316 const float x33 = x0b - x0d;
317 const float x37 = 1.4142135623731f*x2d;
318 const float x38 = 1.30656296487638f*x2e + 0.541196100146197f*x30;
319 const float x39 = 1.4142135623731f*x2f;
320 const float x3a = -0.541196100146197f*x2e + 1.30656296487638f*x30;
321 const float x3b = 0.176776695296637f * (x37 + x39) + 0.25
f*x38;
322 const float x3c = 0.25f * (x37 - x39);
323 const float x3d = 0.176776695296637f * (x37 + x39) - 0.25
f*x38;
324 const float x3e = 0.353553390593274f*x3a;
325 const float x34 = 0.707106781186547f * (x3c - x3e);
326 const float x35 = 0.707106781186547f * (x3c + x3e);
327 const float x3f = 1.4142135623731f*x32;
328 const float x40 = x31 + x33;
329 const float x41 = x31 - x33;
330 const float x42 = 0.25f * (x3f + x40);
331 const float x43 = 0.25f * (x3f - x40);
332 const float x44 = 0.353553390593274f*x41;
333 dst[ 0*dst_stridea] = (add ? dst[ 0*dst_stridea] : 0) + 0.176776695296637
f * (x1d + x1f) + 0.25f*x1e;
334 dst[ 1*dst_stridea] = (add ? dst[ 1*dst_stridea] : 0) + 0.707106781186547
f * (x29 + x3d);
335 dst[ 2*dst_stridea] = (add ? dst[ 2*dst_stridea] : 0) + 0.707106781186547
f * (x29 - x3d);
336 dst[ 3*dst_stridea] = (add ? dst[ 3*dst_stridea] : 0) + 0.707106781186547
f * (x23 - x43);
337 dst[ 4*dst_stridea] = (add ? dst[ 4*dst_stridea] : 0) + 0.707106781186547
f * (x23 + x43);
338 dst[ 5*dst_stridea] = (add ? dst[ 5*dst_stridea] : 0) + 0.707106781186547
f * (x1b - x35);
339 dst[ 6*dst_stridea] = (add ? dst[ 6*dst_stridea] : 0) + 0.707106781186547
f * (x1b + x35);
340 dst[ 7*dst_stridea] = (add ? dst[ 7*dst_stridea] : 0) + 0.707106781186547
f * (x22 + x44);
341 dst[ 8*dst_stridea] = (add ? dst[ 8*dst_stridea] : 0) + 0.707106781186547
f * (x22 - x44);
342 dst[ 9*dst_stridea] = (add ? dst[ 9*dst_stridea] : 0) + 0.707106781186547
f * (x1c + x34);
343 dst[10*dst_stridea] = (add ? dst[10*dst_stridea] : 0) + 0.707106781186547
f * (x1c - x34);
344 dst[11*dst_stridea] = (add ? dst[11*dst_stridea] : 0) + 0.707106781186547
f * (x24 + x42);
345 dst[12*dst_stridea] = (add ? dst[12*dst_stridea] : 0) + 0.707106781186547
f * (x24 - x42);
346 dst[13*dst_stridea] = (add ? dst[13*dst_stridea] : 0) + 0.707106781186547
f * (x2b - x3b);
347 dst[14*dst_stridea] = (add ? dst[14*dst_stridea] : 0) + 0.707106781186547
f * (x2b + x3b);
348 dst[15*dst_stridea] = (add ? dst[15*dst_stridea] : 0) + 0.176776695296637
f * (x1d + x1f) - 0.25f*x1e;
354 #define DEF_FILTER_FREQ_FUNCS(bsize) \
355 static av_always_inline void filter_freq_##bsize(const float *src, int src_linesize, \
356 float *dst, int dst_linesize, \
357 AVExpr *expr, double *var_values, \
361 DECLARE_ALIGNED(32, float, tmp_block1)[bsize * bsize]; \
362 DECLARE_ALIGNED(32, float, tmp_block2)[bsize * bsize]; \
365 fdct##bsize##_1d(tmp_block1, src, 1, bsize, 1, src_linesize); \
366 fdct##bsize##_1d(tmp_block2, tmp_block1, bsize, 1, bsize, 1); \
368 for (i = 0; i < bsize*bsize; i++) { \
369 float *b = &tmp_block2[i]; \
372 var_values[VAR_C] = fabsf(*b); \
373 *b *= av_expr_eval(expr, var_values, NULL); \
375 if (fabsf(*b) < sigma_th) \
381 idct##bsize##_1d(tmp_block1, tmp_block2, 1, bsize, 1, bsize, 0); \
382 idct##bsize##_1d(dst, tmp_block1, dst_linesize, 1, bsize, 1, 1); \
385 static void filter_freq_sigma_##bsize(DCTdnoizContext *s, \
386 const float *src, int src_linesize, \
387 float *dst, int dst_linesize, int thread_id) \
389 filter_freq_##bsize(src, src_linesize, dst, dst_linesize, NULL, NULL, s->th); \
392 static void filter_freq_expr_##bsize(DCTdnoizContext *s, \
393 const float *src, int src_linesize, \
394 float *dst, int dst_linesize, int thread_id) \
396 filter_freq_##bsize(src, src_linesize, dst, dst_linesize, \
397 s->expr[thread_id], s->var_values[thread_id], 0); \
403 #define DCT3X3_0_0 0.5773502691896258f
404 #define DCT3X3_0_1 0.5773502691896258f
405 #define DCT3X3_0_2 0.5773502691896258f
406 #define DCT3X3_1_0 0.7071067811865475f
407 #define DCT3X3_1_2 -0.7071067811865475f
408 #define DCT3X3_2_0 0.4082482904638631f
409 #define DCT3X3_2_1 -0.8164965809277261f
410 #define DCT3X3_2_2 0.4082482904638631f
413 const uint8_t **
src,
int src_linesize,
418 float *dstp_r = dst[0];
419 float *dstp_g = dst[1];
420 float *dstp_b = dst[2];
421 const uint8_t *srcp =
src[0];
423 for (y = 0; y <
h; y++) {
424 for (x = 0; x <
w; x++) {
430 srcp += src_linesize -
w * 3;
431 dstp_r += dst_linesize;
432 dstp_g += dst_linesize;
433 dstp_b += dst_linesize;
438 float **
src,
int src_linesize,
443 const float *src_r =
src[0];
444 const float *src_g =
src[1];
445 const float *src_b =
src[2];
446 uint8_t *dstp = dst[0];
448 for (y = 0; y <
h; y++) {
449 for (x = 0; x <
w; x++) {
455 dstp += dst_linesize -
w * 3;
456 src_r += src_linesize;
457 src_g += src_linesize;
458 src_b += src_linesize;
462 #define DECLARE_COLOR_FUNCS(name, r, g, b) \
463 static void color_decorrelation_##name(float **dst, int dst_linesize, \
464 const uint8_t **src, int src_linesize, \
467 color_decorrelation(dst, dst_linesize, src, src_linesize, w, h, r, g, b); \
470 static void color_correlation_##name(uint8_t **dst, int dst_linesize, \
471 float **src, int src_linesize, \
474 color_correlation(dst, dst_linesize, src, src_linesize, w, h, r, g, b); \
481 const uint8_t **
src,
int src_linesize,
485 float *dstp_r = dst[0];
486 float *dstp_g = dst[1];
487 float *dstp_b = dst[2];
488 const uint8_t *srcp_r =
src[2];
489 const uint8_t *srcp_g =
src[0];
490 const uint8_t *srcp_b =
src[1];
492 for (y = 0; y <
h; y++) {
493 for (x = 0; x <
w; x++) {
498 srcp_r += src_linesize;
499 srcp_g += src_linesize;
500 srcp_b += src_linesize;
501 dstp_r += dst_linesize;
502 dstp_g += dst_linesize;
503 dstp_b += dst_linesize;
508 float **
src,
int src_linesize,
512 const float *src_r =
src[0];
513 const float *src_g =
src[1];
514 const float *src_b =
src[2];
515 uint8_t *dstp_r = dst[2];
516 uint8_t *dstp_g = dst[0];
517 uint8_t *dstp_b = dst[1];
519 for (y = 0; y <
h; y++) {
520 for (x = 0; x <
w; x++) {
525 dstp_r += dst_linesize;
526 dstp_g += dst_linesize;
527 dstp_b += dst_linesize;
528 src_r += src_linesize;
529 src_g += src_linesize;
530 src_b += src_linesize;
538 int i, x, y, bx, by, linesize, *iweights, max_slice_h, slice_h;
539 const int bsize = 1 <<
s->n;
543 s->color_decorrelation = color_decorrelation_bgr;
544 s->color_correlation = color_correlation_bgr;
547 s->color_decorrelation = color_decorrelation_rgb;
548 s->color_correlation = color_correlation_rgb;
567 max_slice_h =
s->pr_height / ((
s->bsize - 1) * 2);
568 if (max_slice_h == 0)
575 s->p_linesize = linesize =
FFALIGN(
s->pr_width, 32);
576 for (
i = 0;
i < 2;
i++) {
580 if (!
s->cbuf[
i][0] || !
s->cbuf[
i][1] || !
s->cbuf[
i][2])
587 for (
i = 0;
i <
s->nb_threads;
i++) {
598 slice_h = (
int)
ceilf(
s->pr_height / (
float)
s->nb_threads) + (
s->bsize - 1) * 2;
599 for (
i = 0;
i <
s->nb_threads;
i++) {
605 s->weights =
av_malloc(
s->pr_height * linesize *
sizeof(*
s->weights));
608 iweights =
av_calloc(
s->pr_height, linesize *
sizeof(*iweights));
611 for (y = 0; y <
s->pr_height -
bsize + 1; y +=
s->step)
612 for (x = 0; x <
s->pr_width -
bsize + 1; x +=
s->step)
613 for (by = 0; by <
bsize; by++)
614 for (bx = 0; bx <
bsize; bx++)
615 iweights[(y + by)*linesize + x + bx]++;
616 for (y = 0; y <
s->pr_height; y++)
617 for (x = 0; x <
s->pr_width; x++)
618 s->weights[y*linesize + x] = 1. / iweights[y*linesize + x];
628 s->bsize = 1 <<
s->n;
629 if (
s->overlap == -1)
630 s->overlap =
s->bsize - 1;
632 if (
s->overlap >
s->bsize - 1) {
634 "with a block size of %dx%d\n",
635 s->bsize - 1,
s->bsize,
s->bsize);
641 case 3:
s->filter_freq_func = filter_freq_expr_8;
break;
642 case 4:
s->filter_freq_func = filter_freq_expr_16;
break;
647 case 3:
s->filter_freq_func = filter_freq_sigma_8;
break;
648 case 4:
s->filter_freq_func = filter_freq_sigma_16;
break;
653 s->th =
s->sigma * 3.;
654 s->step =
s->bsize -
s->overlap;
669 void *
arg,
int jobnr,
int nb_jobs)
674 const int w =
s->pr_width;
675 const int h =
s->pr_height;
676 const int slice_start = (
h * jobnr ) / nb_jobs;
677 const int slice_end = (
h * (jobnr+1)) / nb_jobs;
678 const int slice_start_ctx =
FFMAX(slice_start -
s->bsize + 1, 0);
680 const int slice_h = slice_end_ctx - slice_start_ctx;
681 const int src_linesize =
s->p_linesize;
682 const int dst_linesize =
s->p_linesize;
683 const int slice_linesize =
s->p_linesize;
685 const float *
src =
td->src + slice_start_ctx * src_linesize;
686 const float *
weights =
s->weights + slice_start * dst_linesize;
687 float *slice =
s->slices[jobnr];
690 memset(slice, 0, (slice_h +
s->bsize - 1) * dst_linesize *
sizeof(*slice));
693 for (y = 0; y < slice_h; y +=
s->step) {
694 for (x = 0; x <
w -
s->bsize + 1; x +=
s->step)
695 s->filter_freq_func(
s,
src + x, src_linesize,
696 slice + x, slice_linesize,
698 src +=
s->step * src_linesize;
699 slice +=
s->step * slice_linesize;
703 slice =
s->slices[jobnr] + (slice_start - slice_start_ctx) * slice_linesize;
704 dst =
td->dst + slice_start * dst_linesize;
705 for (y = slice_start; y <
slice_end; y++) {
706 for (x = 0; x <
w; x++)
707 dst[x] = slice[x] *
weights[x];
708 slice += slice_linesize;
737 s->color_decorrelation(
s->cbuf[0],
s->p_linesize,
739 s->pr_width,
s->pr_height);
740 for (plane = 0; plane < 3; plane++) {
742 .src =
s->cbuf[0][plane],
743 .dst =
s->cbuf[1][plane],
747 s->color_correlation(
out->data,
out->linesize[0],
748 s->cbuf[1],
s->p_linesize,
749 s->pr_width,
s->pr_height);
753 uint8_t *dst =
out->data[0];
754 const uint8_t *
src = in->
data[0];
755 const int dst_linesize =
out->linesize[0];
756 const int src_linesize = in->
linesize[0];
757 const int hpad = (
inlink->w -
s->pr_width) * 3;
758 const int vpad = (
inlink->h -
s->pr_height);
761 uint8_t *dstp = dst +
s->pr_width * 3;
762 const uint8_t *srcp =
src +
s->pr_width * 3;
764 for (y = 0; y <
s->pr_height; y++) {
765 memcpy(dstp, srcp, hpad);
766 dstp += dst_linesize;
767 srcp += src_linesize;
771 uint8_t *dstp = dst +
s->pr_height * dst_linesize;
772 const uint8_t *srcp =
src +
s->pr_height * src_linesize;
774 for (y = 0; y < vpad; y++) {
775 memcpy(dstp, srcp,
inlink->w * 3);
776 dstp += dst_linesize;
777 srcp += src_linesize;
793 for (
i = 0;
i < 2;
i++) {
798 for (
i = 0;
i <
s->nb_threads;
i++) {
822 .priv_class = &dctdnoiz_class,