FFmpeg
vf_fftdnoiz.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <float.h>
20 
21 #include "libavutil/common.h"
22 #include "libavutil/imgutils.h"
23 #include "libavutil/opt.h"
24 #include "libavutil/pixdesc.h"
25 #include "libavutil/tx.h"
26 #include "internal.h"
27 #include "window_func.h"
28 
29 #define MAX_BLOCK 256
30 #define MAX_THREADS 32
31 
37 };
38 
39 typedef struct PlaneContext {
41  int nox, noy;
42  int b;
43  int o;
44  float n;
45 
51 } PlaneContext;
52 
53 typedef struct FFTdnoizContext {
54  const AVClass *class;
55 
56  float sigma;
57  float amount;
59  float overlap;
60  int method;
61  int window;
62  int nb_prev;
63  int nb_next;
64  int planesf;
65 
67 
68  int depth;
69  int nb_planes;
73 
76 
79 
80  void (*import_row)(AVComplexFloat *dst, uint8_t *src, int rw, float scale, float *win, int off);
81  void (*export_row)(AVComplexFloat *src, uint8_t *dst, int rw, int depth, float *win);
83 
84 #define OFFSET(x) offsetof(FFTdnoizContext, x)
85 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
86 #define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
87 static const AVOption fftdnoiz_options[] = {
88  { "sigma", "set denoise strength",
89  OFFSET(sigma), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 100, .flags = TFLAGS },
90  { "amount", "set amount of denoising",
91  OFFSET(amount), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0.01, 1, .flags = TFLAGS },
92  { "block", "set block size",
93  OFFSET(block_size), AV_OPT_TYPE_INT, {.i64=32}, 8, MAX_BLOCK, .flags = FLAGS },
94  { "overlap", "set block overlap",
95  OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0.2, 0.8, .flags = FLAGS },
96  { "method", "set method of denoising",
97  OFFSET(method), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, .flags = TFLAGS, "method" },
98  { "wiener", "wiener method",
99  0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, .flags = TFLAGS, "method" },
100  { "hard", "hard thresholding",
101  0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, .flags = TFLAGS, "method" },
102  { "prev", "set number of previous frames for temporal denoising",
103  OFFSET(nb_prev), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, .flags = FLAGS },
104  { "next", "set number of next frames for temporal denoising",
105  OFFSET(nb_next), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, .flags = FLAGS },
106  { "planes", "set planes to filter",
107  OFFSET(planesf), AV_OPT_TYPE_INT, {.i64=7}, 0, 15, .flags = TFLAGS },
109  { NULL }
110 };
111 
112 AVFILTER_DEFINE_CLASS(fftdnoiz);
113 
114 static const enum AVPixelFormat pix_fmts[] = {
139 };
140 
141 typedef struct ThreadData {
142  float *src, *dst;
143 } ThreadData;
144 
145 static void import_row8(AVComplexFloat *dst, uint8_t *src, int rw,
146  float scale, float *win, int off)
147 {
148  for (int j = 0; j < rw; j++) {
149  const int i = abs(j + off);
150  dst[j].re = src[i] * scale * win[j];
151  dst[j].im = 0.f;
152  }
153 }
154 
155 static void export_row8(AVComplexFloat *src, uint8_t *dst, int rw, int depth, float *win)
156 {
157  for (int j = 0; j < rw; j++)
158  dst[j] = av_clip_uint8(lrintf(src[j].re / win[j]));
159 }
160 
161 static void import_row16(AVComplexFloat *dst, uint8_t *srcp, int rw,
162  float scale, float *win, int off)
163 {
164  uint16_t *src = (uint16_t *)srcp;
165 
166  for (int j = 0; j < rw; j++) {
167  const int i = abs(j + off);
168  dst[j].re = src[i] * scale * win[j];
169  dst[j].im = 0;
170  }
171 }
172 
173 static void export_row16(AVComplexFloat *src, uint8_t *dstp, int rw, int depth, float *win)
174 {
175  uint16_t *dst = (uint16_t *)dstp;
176 
177  for (int j = 0; j < rw; j++)
178  dst[j] = av_clip_uintp2_c(lrintf(src[j].re / win[j]), depth);
179 }
180 
182 {
183  AVFilterContext *ctx = inlink->dst;
184  const AVPixFmtDescriptor *desc;
185  FFTdnoizContext *s = ctx->priv;
186  float lut[MAX_BLOCK + 1];
187  float overlap;
188  int i;
189 
190  desc = av_pix_fmt_desc_get(inlink->format);
191  s->depth = desc->comp[0].depth;
192 
193  if (s->depth <= 8) {
194  s->import_row = import_row8;
195  s->export_row = export_row8;
196  } else {
197  s->import_row = import_row16;
198  s->export_row = export_row16;
199  }
200 
201  s->planes[1].planewidth = s->planes[2].planewidth = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
202  s->planes[0].planewidth = s->planes[3].planewidth = inlink->w;
203  s->planes[1].planeheight = s->planes[2].planeheight = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
204  s->planes[0].planeheight = s->planes[3].planeheight = inlink->h;
205 
206  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
208 
209  for (int i = 0; i < s->nb_threads; i++) {
210  float scale = 1.f, iscale = 1.f;
211 
212  av_tx_init(&s->fft[i], &s->tx_fn, AV_TX_FLOAT_FFT, 0, s->block_size, &scale, 0);
213  av_tx_init(&s->ifft[i], &s->itx_fn, AV_TX_FLOAT_FFT, 1, s->block_size, &iscale, 0);
214  av_tx_init(&s->fft_r[i], &s->tx_r_fn, AV_TX_FLOAT_FFT, 0, 1 + s->nb_prev + s->nb_next, &scale, 0);
215  av_tx_init(&s->ifft_r[i], &s->itx_r_fn, AV_TX_FLOAT_FFT, 1, 1 + s->nb_prev + s->nb_next, &iscale, 0);
216  if (!s->fft[i] || !s->ifft[i] || !s->fft_r[i] || !s->ifft_r[i])
217  return AVERROR(ENOMEM);
218  }
219 
220  for (i = 0; i < s->nb_planes; i++) {
221  PlaneContext *p = &s->planes[i];
222  int size;
223 
224  p->b = s->block_size;
225  p->n = 1.f / (p->b * p->b);
226  p->o = lrintf(p->b * s->overlap);
227  size = p->b - p->o;
228  p->nox = (p->planewidth + (size - 1)) / size;
229  p->noy = (p->planeheight + (size - 1)) / size;
230 
231  av_log(ctx, AV_LOG_DEBUG, "nox:%d noy:%d size:%d\n", p->nox, p->noy, size);
232 
233  p->buffer_linesize = p->b * sizeof(AVComplexFloat);
234  p->data_linesize = 2 * p->b * sizeof(float);
235  for (int j = 0; j < s->nb_threads; j++) {
236  p->hdata[j] = av_calloc(p->b, p->data_linesize);
237  p->hdata_out[j] = av_calloc(p->b, p->data_linesize);
238  p->vdata[j] = av_calloc(p->b, p->data_linesize);
239  p->vdata_out[j] = av_calloc(p->b, p->data_linesize);
240  p->buffer[j][CURRENT] = av_calloc(p->b, p->buffer_linesize);
241  if (!p->buffer[j][CURRENT])
242  return AVERROR(ENOMEM);
243  if (s->nb_prev > 0) {
244  p->buffer[j][PREV] = av_calloc(p->b, p->buffer_linesize);
245  if (!p->buffer[j][PREV])
246  return AVERROR(ENOMEM);
247  }
248  if (s->nb_next > 0) {
249  p->buffer[j][NEXT] = av_calloc(p->b, p->buffer_linesize);
250  if (!p->buffer[j][NEXT])
251  return AVERROR(ENOMEM);
252  }
253  if (!p->hdata[j] || !p->vdata[j] ||
254  !p->hdata_out[j] || !p->vdata_out[j])
255  return AVERROR(ENOMEM);
256  }
257  }
258 
259  generate_window_func(lut, s->block_size + 1, s->window, &overlap);
260 
261  for (int y = 0; y < s->block_size; y++) {
262  for (int x = 0; x < s->block_size; x++)
263  s->win[y][x] = lut[y] * lut[x];
264  }
265 
266  return 0;
267 }
268 
270  uint8_t *srcp, int src_linesize,
271  float *buffer, int buffer_linesize, int plane,
272  int jobnr, int y, int x)
273 {
274  PlaneContext *p = &s->planes[plane];
275  const int width = p->planewidth;
276  const int height = p->planeheight;
277  const int block = p->b;
278  const int overlap = p->o;
279  const int hoverlap = overlap / 2;
280  const int size = block - overlap;
281  const int bpp = (s->depth + 7) / 8;
282  const int data_linesize = p->data_linesize / sizeof(AVComplexFloat);
283  const float scale = 1.f / ((1.f + s->nb_prev + s->nb_next) * s->block_size * s->block_size);
284  AVComplexFloat *hdata = p->hdata[jobnr];
285  AVComplexFloat *hdata_out = p->hdata_out[jobnr];
286  AVComplexFloat *vdata_out = p->vdata_out[jobnr];
287  const int woff = -hoverlap;
288  const int hoff = -hoverlap;
289  const int rh = FFMIN(block, height - y * size + hoverlap);
290  const int rw = FFMIN(block, width - x * size + hoverlap);
291  AVComplexFloat *ssrc, *ddst, *dst = hdata, *dst_out = hdata_out;
292  float *bdst = buffer;
293 
294  buffer_linesize /= sizeof(float);
295 
296  for (int i = 0; i < rh; i++) {
297  uint8_t *src = srcp + src_linesize * abs(y * size + i + hoff) + x * size * bpp;
298 
299  s->import_row(dst, src, rw, scale, s->win[i], woff);
300  for (int j = rw; j < block; j++) {
301  dst[j].re = dst[rw - 1].re;
302  dst[j].im = 0.f;
303  }
304  s->tx_fn(s->fft[jobnr], dst_out, dst, sizeof(float));
305 
306  ddst = dst_out;
307  dst += data_linesize;
308  dst_out += data_linesize;
309  }
310 
311  for (int i = rh; i < block; i++) {
312  for (int j = 0; j < block; j++) {
313  dst[j].re = ddst[j].re;
314  dst[j].im = ddst[j].im;
315  }
316 
317  dst += data_linesize;
318  }
319 
320  ssrc = hdata_out;
321  dst = vdata_out;
322  for (int i = 0; i < block; i++) {
323  for (int j = 0; j < block; j++)
324  dst[j] = ssrc[j * data_linesize + i];
325  s->tx_fn(s->fft[jobnr], bdst, dst, sizeof(float));
326 
327  dst += data_linesize;
328  bdst += buffer_linesize;
329  }
330 }
331 
333  uint8_t *dstp, int dst_linesize,
334  float *buffer, int buffer_linesize, int plane,
335  int jobnr, int y, int x)
336 {
337  PlaneContext *p = &s->planes[plane];
338  const int depth = s->depth;
339  const int bpp = (depth + 7) / 8;
340  const int width = p->planewidth;
341  const int height = p->planeheight;
342  const int block = p->b;
343  const int overlap = p->o;
344  const int hoverlap = overlap / 2;
345  const int size = block - overlap;
346  const int data_linesize = p->data_linesize / sizeof(AVComplexFloat);
347  AVComplexFloat *hdata = p->hdata[jobnr];
348  AVComplexFloat *hdata_out = p->hdata_out[jobnr];
349  AVComplexFloat *vdata_out = p->vdata_out[jobnr];
350  const int rw = FFMIN(size, width - x * size + hoverlap);
351  const int rh = FFMIN(size, height - y * size + hoverlap);
352  AVComplexFloat *hdst, *vdst = vdata_out, *hdst_out = hdata_out;
353  float *bsrc = buffer;
354 
355  hdst = hdata;
356  buffer_linesize /= sizeof(float);
357 
358  for (int i = 0; i < block; i++) {
359  s->itx_fn(s->ifft[jobnr], vdst, bsrc, sizeof(float));
360  for (int j = 0; j < block; j++)
361  hdst[j * data_linesize + i] = vdst[j];
362 
363  vdst += data_linesize;
364  bsrc += buffer_linesize;
365  }
366 
367  hdst = hdata + hoverlap * data_linesize;
368  for (int i = 0; i < rh && (y * size + i) < height; i++) {
369  uint8_t *dst = dstp + dst_linesize * (y * size + i) + x * size * bpp;
370 
371  s->itx_fn(s->ifft[jobnr], hdst_out, hdst, sizeof(float));
372  s->export_row(hdst_out + hoverlap, dst, rw, depth, s->win[i + hoverlap] + hoverlap);
373 
374  hdst += data_linesize;
375  hdst_out += data_linesize;
376  }
377 }
378 
379 static void filter_block3d2(FFTdnoizContext *s, int plane, float *pbuffer, float *nbuffer,
380  int jobnr)
381 {
382  PlaneContext *p = &s->planes[plane];
383  const int block = p->b;
384  const int buffer_linesize = p->buffer_linesize / sizeof(float);
385  const float depthx = (1 << (s->depth - 8)) * (1 << (s->depth - 8));
386  const float sigma = s->sigma * depthx / (3.f * s->block_size * s->block_size);
387  const float limit = 1.f - s->amount;
388  float *cbuffer = p->buffer[jobnr][CURRENT];
389  const int method = s->method;
390  float *cbuff = cbuffer;
391  float *pbuff = pbuffer;
392  float *nbuff = nbuffer;
393 
394  for (int i = 0; i < block; i++) {
395  for (int j = 0; j < block; j++) {
397  AVComplexFloat outbuffer[BSIZE];
398 
399  buffer[0].re = pbuff[2 * j ];
400  buffer[0].im = pbuff[2 * j + 1];
401 
402  buffer[1].re = cbuff[2 * j ];
403  buffer[1].im = cbuff[2 * j + 1];
404 
405  buffer[2].re = nbuff[2 * j ];
406  buffer[2].im = nbuff[2 * j + 1];
407 
408  s->tx_r_fn(s->fft_r[jobnr], outbuffer, buffer, sizeof(float));
409 
410  for (int z = 0; z < 3; z++) {
411  const float re = outbuffer[z].re;
412  const float im = outbuffer[z].im;
413  const float power = re * re + im * im;
414  float factor;
415 
416  switch (method) {
417  case 0:
418  factor = fmaxf(limit, (power - sigma) / (power + 1e-15f));
419  break;
420  case 1:
421  factor = power < sigma ? limit : 1.f;
422  break;
423  }
424 
425  outbuffer[z].re *= factor;
426  outbuffer[z].im *= factor;
427  }
428 
429  s->itx_r_fn(s->ifft_r[jobnr], buffer, outbuffer, sizeof(float));
430 
431  cbuff[2 * j + 0] = buffer[1].re;
432  cbuff[2 * j + 1] = buffer[1].im;
433  }
434 
435  cbuff += buffer_linesize;
436  pbuff += buffer_linesize;
437  nbuff += buffer_linesize;
438  }
439 }
440 
441 static void filter_block3d1(FFTdnoizContext *s, int plane, float *pbuffer,
442  int jobnr)
443 {
444  PlaneContext *p = &s->planes[plane];
445  const int block = p->b;
446  const int buffer_linesize = p->buffer_linesize / sizeof(float);
447  const float depthx = (1 << (s->depth - 8)) * (1 << (s->depth - 8));
448  const float sigma = s->sigma * depthx / (2.f * s->block_size * s->block_size);
449  const float limit = 1.f - s->amount;
450  float *cbuffer = p->buffer[jobnr][CURRENT];
451  const int method = s->method;
452  float *cbuff = cbuffer;
453  float *pbuff = pbuffer;
454 
455  for (int i = 0; i < block; i++) {
456  for (int j = 0; j < block; j++) {
458  AVComplexFloat outbuffer[BSIZE];
459 
460  buffer[0].re = pbuff[2 * j ];
461  buffer[0].im = pbuff[2 * j + 1];
462 
463  buffer[1].re = cbuff[2 * j ];
464  buffer[1].im = cbuff[2 * j + 1];
465 
466  s->tx_r_fn(s->fft_r[jobnr], outbuffer, buffer, sizeof(float));
467 
468  for (int z = 0; z < 2; z++) {
469  const float re = outbuffer[z].re;
470  const float im = outbuffer[z].im;
471  const float power = re * re + im * im;
472  float factor;
473 
474  switch (method) {
475  case 0:
476  factor = fmaxf(limit, (power - sigma) / (power + 1e-15f));
477  break;
478  case 1:
479  factor = power < sigma ? limit : 1.f;
480  break;
481  }
482 
483  outbuffer[z].re *= factor;
484  outbuffer[z].im *= factor;
485  }
486 
487  s->itx_r_fn(s->ifft_r[jobnr], buffer, outbuffer, sizeof(float));
488 
489  cbuff[2 * j + 0] = buffer[1].re;
490  cbuff[2 * j + 1] = buffer[1].im;
491  }
492 
493  cbuff += buffer_linesize;
494  pbuff += buffer_linesize;
495  }
496 }
497 
498 static void filter_block2d(FFTdnoizContext *s, int plane,
499  int jobnr)
500 {
501  PlaneContext *p = &s->planes[plane];
502  const int block = p->b;
503  const int method = s->method;
504  const int buffer_linesize = p->buffer_linesize / sizeof(float);
505  const float depthx = (1 << (s->depth - 8)) * (1 << (s->depth - 8));
506  const float sigma = s->sigma * depthx / (s->block_size * s->block_size);
507  const float limit = 1.f - s->amount;
508  float *buff = p->buffer[jobnr][CURRENT];
509 
510  for (int i = 0; i < block; i++) {
511  for (int j = 0; j < block; j++) {
512  float factor, power, re, im;
513 
514  re = buff[j * 2 ];
515  im = buff[j * 2 + 1];
516  power = re * re + im * im;
517  switch (method) {
518  case 0:
519  factor = fmaxf(limit, (power - sigma) / (power + 1e-15f));
520  break;
521  case 1:
522  factor = power < sigma ? limit : 1.f;
523  break;
524  }
525 
526  buff[j * 2 ] *= factor;
527  buff[j * 2 + 1] *= factor;
528  }
529 
530  buff += buffer_linesize;
531  }
532 }
533 
534 static int denoise(AVFilterContext *ctx, void *arg,
535  int jobnr, int nb_jobs)
536 {
537  FFTdnoizContext *s = ctx->priv;
538  AVFrame *out = arg;
539 
540  for (int plane = 0; plane < s->nb_planes; plane++) {
541  PlaneContext *p = &s->planes[plane];
542  const int nox = p->nox;
543  const int noy = p->noy;
544  const int slice_start = (noy * jobnr) / nb_jobs;
545  const int slice_end = (noy * (jobnr+1)) / nb_jobs;
546 
547  if (!((1 << plane) & s->planesf) || ctx->is_disabled)
548  continue;
549 
550  for (int y = slice_start; y < slice_end; y++) {
551  for (int x = 0; x < nox; x++) {
552  if (s->next) {
553  import_block(s, s->next->data[plane], s->next->linesize[plane],
554  p->buffer[jobnr][NEXT], p->buffer_linesize, plane,
555  jobnr, y, x);
556  }
557 
558  if (s->prev) {
559  import_block(s, s->prev->data[plane], s->prev->linesize[plane],
560  p->buffer[jobnr][PREV], p->buffer_linesize, plane,
561  jobnr, y, x);
562  }
563 
564  import_block(s, s->cur->data[plane], s->cur->linesize[plane],
565  p->buffer[jobnr][CURRENT], p->buffer_linesize, plane,
566  jobnr, y, x);
567 
568  if (s->next && s->prev) {
569  filter_block3d2(s, plane, p->buffer[jobnr][PREV], p->buffer[jobnr][NEXT], jobnr);
570  } else if (s->next) {
571  filter_block3d1(s, plane, p->buffer[jobnr][NEXT], jobnr);
572  } else if (s->prev) {
573  filter_block3d1(s, plane, p->buffer[jobnr][PREV], jobnr);
574  } else {
575  filter_block2d(s, plane, jobnr);
576  }
577 
578  export_block(s, out->data[plane], out->linesize[plane],
579  p->buffer[jobnr][CURRENT], p->buffer_linesize, plane,
580  jobnr, y, x);
581  }
582  }
583  }
584 
585  return 0;
586 }
587 
589 {
590  AVFilterContext *ctx = inlink->dst;
591  FFTdnoizContext *s = ctx->priv;
592  AVFilterLink *outlink = ctx->outputs[0];
593  int direct, plane;
594  AVFrame *out;
595 
596  if (s->nb_next > 0 && s->nb_prev > 0) {
597  av_frame_free(&s->prev);
598  s->prev = s->cur;
599  s->cur = s->next;
600  s->next = in;
601 
602  if (!s->prev && s->cur) {
603  s->prev = av_frame_clone(s->cur);
604  if (!s->prev)
605  return AVERROR(ENOMEM);
606  }
607  if (!s->cur)
608  return 0;
609  } else if (s->nb_next > 0) {
610  av_frame_free(&s->cur);
611  s->cur = s->next;
612  s->next = in;
613 
614  if (!s->cur)
615  return 0;
616  } else if (s->nb_prev > 0) {
617  av_frame_free(&s->prev);
618  s->prev = s->cur;
619  s->cur = in;
620 
621  if (!s->prev)
622  s->prev = av_frame_clone(s->cur);
623  if (!s->prev)
624  return AVERROR(ENOMEM);
625  } else {
626  s->cur = in;
627  }
628 
629  if (av_frame_is_writable(in) && s->nb_next == 0 && s->nb_prev == 0) {
630  direct = 1;
631  out = in;
632  } else {
633  direct = 0;
634  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
635  if (!out)
636  return AVERROR(ENOMEM);
637  av_frame_copy_props(out, s->cur);
638  }
639 
641  FFMIN(s->planes[0].noy, s->nb_threads));
642 
643  for (plane = 0; plane < s->nb_planes; plane++) {
644  PlaneContext *p = &s->planes[plane];
645 
646  if (!((1 << plane) & s->planesf) || ctx->is_disabled) {
647  if (!direct)
648  av_image_copy_plane(out->data[plane], out->linesize[plane],
649  s->cur->data[plane], s->cur->linesize[plane],
650  p->planewidth * (1 + (s->depth > 8)), p->planeheight);
651  continue;
652  }
653  }
654 
655  if (s->nb_next == 0 && s->nb_prev == 0) {
656  if (direct) {
657  s->cur = NULL;
658  } else {
659  av_frame_free(&s->cur);
660  }
661  }
662  return ff_filter_frame(outlink, out);
663 }
664 
665 static int request_frame(AVFilterLink *outlink)
666 {
667  AVFilterContext *ctx = outlink->src;
668  FFTdnoizContext *s = ctx->priv;
669  int ret = 0;
670 
671  ret = ff_request_frame(ctx->inputs[0]);
672 
673  if (ret == AVERROR_EOF && (s->nb_next > 0)) {
674  AVFrame *buf;
675 
676  if (s->next && s->nb_next > 0)
677  buf = av_frame_clone(s->next);
678  else if (s->cur)
679  buf = av_frame_clone(s->cur);
680  else
681  buf = av_frame_clone(s->prev);
682  if (!buf)
683  return AVERROR(ENOMEM);
684 
685  ret = filter_frame(ctx->inputs[0], buf);
686  if (ret < 0)
687  return ret;
688  ret = AVERROR_EOF;
689  }
690 
691  return ret;
692 }
693 
695 {
696  FFTdnoizContext *s = ctx->priv;
697  int i;
698 
699  for (i = 0; i < 4; i++) {
700  PlaneContext *p = &s->planes[i];
701 
702  for (int j = 0; j < s->nb_threads; j++) {
703  av_freep(&p->hdata[j]);
704  av_freep(&p->vdata[j]);
705  av_freep(&p->hdata_out[j]);
706  av_freep(&p->vdata_out[j]);
707  av_freep(&p->buffer[j][PREV]);
708  av_freep(&p->buffer[j][CURRENT]);
709  av_freep(&p->buffer[j][NEXT]);
710  }
711  }
712 
713  for (i = 0; i < s->nb_threads; i++) {
714  av_tx_uninit(&s->fft[i]);
715  av_tx_uninit(&s->ifft[i]);
716  av_tx_uninit(&s->fft_r[i]);
717  av_tx_uninit(&s->ifft_r[i]);
718  }
719 
720  av_frame_free(&s->prev);
721  av_frame_free(&s->cur);
722  av_frame_free(&s->next);
723 }
724 
725 static const AVFilterPad fftdnoiz_inputs[] = {
726  {
727  .name = "default",
728  .type = AVMEDIA_TYPE_VIDEO,
729  .filter_frame = filter_frame,
730  .config_props = config_input,
731  },
732 };
733 
734 static const AVFilterPad fftdnoiz_outputs[] = {
735  {
736  .name = "default",
737  .type = AVMEDIA_TYPE_VIDEO,
738  .request_frame = request_frame,
739  },
740 };
741 
743  .name = "fftdnoiz",
744  .description = NULL_IF_CONFIG_SMALL("Denoise frames using 3D FFT."),
745  .priv_size = sizeof(FFTdnoizContext),
746  .uninit = uninit,
750  .priv_class = &fftdnoiz_class,
753  .process_command = ff_filter_process_command,
754 };
filter_block2d
static void filter_block2d(FFTdnoizContext *s, int plane, int jobnr)
Definition: vf_fftdnoiz.c:498
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:101
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:449
CURRENT
@ CURRENT
Definition: vf_fftdnoiz.c:33
denoise
static int denoise(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_fftdnoiz.c:534
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:428
FFTdnoizContext::import_row
void(* import_row)(AVComplexFloat *dst, uint8_t *src, int rw, float scale, float *win, int off)
Definition: vf_fftdnoiz.c:80
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
PlaneContext::buffer_linesize
int buffer_linesize
Definition: vf_fftdnoiz.c:50
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: vf_fftdnoiz.c:665
MAX_THREADS
#define MAX_THREADS
Definition: vf_fftdnoiz.c:30
out
FILE * out
Definition: movenc.c:54
FFTdnoizContext::window
int window
Definition: vf_fftdnoiz.c:61
FFTdnoizContext::export_row
void(* export_row)(AVComplexFloat *src, uint8_t *dst, int rw, int depth, float *win)
Definition: vf_fftdnoiz.c:81
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:999
FFTdnoizContext::nb_next
int nb_next
Definition: vf_fftdnoiz.c:63
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2662
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
PlaneContext::buffer
float * buffer[MAX_THREADS][BSIZE]
Definition: vf_fftdnoiz.c:46
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:170
AVTXContext
Definition: tx_priv.h:201
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
import_row16
static void import_row16(AVComplexFloat *dst, uint8_t *srcp, int rw, float scale, float *win, int off)
Definition: vf_fftdnoiz.c:161
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:111
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:441
im
float im
Definition: fft.c:79
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
pixdesc.h
av_clip_uintp2_c
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
Clip a signed integer to an unsigned power of two range.
Definition: common.h:275
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:448
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:443
AVOption
AVOption.
Definition: opt.h:251
PlaneContext::b
int b
Definition: vf_fftdnoiz.c:42
fftdnoiz_outputs
static const AVFilterPad fftdnoiz_outputs[]
Definition: vf_fftdnoiz.c:734
FFTdnoizContext::ifft
AVTXContext * ifft[MAX_THREADS]
Definition: vf_fftdnoiz.c:74
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:406
FFTdnoizContext::sigma
float sigma
Definition: vf_fftdnoiz.c:56
ff_request_frame
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:400
float.h
AVComplexFloat
Definition: tx.h:27
WIN_FUNC_OPTION
#define WIN_FUNC_OPTION(win_func_opt_name, win_func_offset, flag, default_window_func)
Definition: window_func.h:37
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:175
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:444
av_tx_init
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
Definition: tx.c:649
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:386
av_image_copy_plane
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:374
win
static float win(SuperEqualizerContext *s, float n, int N)
Definition: af_superequalizer.c:119
FFTdnoizContext::cur
AVFrame * cur
Definition: vf_fftdnoiz.c:66
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2702
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:440
AVComplexFloat::im
float im
Definition: tx.h:28
window
static SDL_Window * window
Definition: ffplay.c:365
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:424
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
PlaneContext::planeheight
int planeheight
Definition: vf_fftdnoiz.c:40
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:422
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:450
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:404
import_block
static void import_block(FFTdnoizContext *s, uint8_t *srcp, int src_linesize, float *buffer, int buffer_linesize, int plane, int jobnr, int y, int x)
Definition: vf_fftdnoiz.c:269
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1389
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:390
TFLAGS
#define TFLAGS
Definition: vf_fftdnoiz.c:86
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:49
MAX_BLOCK
#define MAX_BLOCK
Definition: vf_fftdnoiz.c:29
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:409
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:248
PlaneContext::vdata
AVComplexFloat * vdata[MAX_THREADS]
Definition: vf_fftdnoiz.c:47
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:418
av_tx_fn
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition: tx.h:111
FFTdnoizContext::overlap
float overlap
Definition: vf_fftdnoiz.c:59
FFTdnoizContext::itx_r_fn
av_tx_fn itx_r_fn
Definition: vf_fftdnoiz.c:78
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:426
float
float
Definition: af_crystalizer.c:122
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:256
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:427
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:419
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:50
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2013
direct
static void fn() direct(const ftype *in, const ctype *ir, int len, ftype *out)
Definition: afir_template.c:248
AV_TX_FLOAT_FFT
@ AV_TX_FLOAT_FFT
Standard complex to complex FFT with sample data type of AVComplexFloat, AVComplexDouble or AVComplex...
Definition: tx.h:47
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:447
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:403
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
FFTdnoizContext::win
float win[MAX_BLOCK][MAX_BLOCK]
Definition: vf_fftdnoiz.c:72
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:417
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:389
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:464
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_fftdnoiz.c:114
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
arg
const char * arg
Definition: jacosubdec.c:67
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:387
ThreadData::dst
AVFrame * dst
Definition: vf_blend.c:56
PlaneContext::hdata
AVComplexFloat * hdata[MAX_THREADS]
Definition: vf_fftdnoiz.c:47
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:425
FFTdnoizContext::next
AVFrame * next
Definition: vf_fftdnoiz.c:66
FFTdnoizContext::tx_fn
av_tx_fn tx_fn
Definition: vf_fftdnoiz.c:77
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:596
PlaneContext::planewidth
int planewidth
Definition: vf_fftdnoiz.c:40
ThreadData::src
const uint8_t * src
Definition: vf_bm3d.c:55
FFTdnoizContext::fft_r
AVTXContext * fft_r[MAX_THREADS]
Definition: vf_fftdnoiz.c:75
FFTdnoizContext
Definition: vf_fftdnoiz.c:53
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
FFTdnoizContext::prev
AVFrame * prev
Definition: vf_fftdnoiz.c:66
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:408
PlaneContext
Definition: ffv1.h:62
generate_window_func
static void generate_window_func(float *lut, int N, int win_func, float *overlap)
Definition: window_func.h:61
PlaneContext::data_linesize
int data_linesize
Definition: vf_fftdnoiz.c:49
abs
#define abs(x)
Definition: cuda_runtime.h:35
WFUNC_HANNING
@ WFUNC_HANNING
Definition: window_func.h:29
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:407
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:421
FFTdnoizContext::nb_threads
int nb_threads
Definition: vf_fftdnoiz.c:70
FFTdnoizContext::depth
int depth
Definition: vf_fftdnoiz.c:68
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_fftdnoiz.c:181
filter_block3d2
static void filter_block3d2(FFTdnoizContext *s, int plane, float *pbuffer, float *nbuffer, int jobnr)
Definition: vf_fftdnoiz.c:379
f
f
Definition: af_crystalizer.c:122
BSIZE
@ BSIZE
Definition: vf_fftdnoiz.c:36
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
fmaxf
float fmaxf(float, float)
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:411
size
int size
Definition: twinvq_data.h:10344
AVComplexFloat::re
float re
Definition: tx.h:28
PlaneContext::o
int o
Definition: vf_fftdnoiz.c:43
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:413
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:523
FLAGS
#define FLAGS
Definition: vf_fftdnoiz.c:85
FFTdnoizContext::tx_r_fn
av_tx_fn tx_r_fn
Definition: vf_fftdnoiz.c:78
PREV
@ PREV
Definition: vf_fftdnoiz.c:34
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:863
height
#define height
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:445
av_tx_uninit
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
Definition: tx.c:251
filter_block3d1
static void filter_block3d1(FFTdnoizContext *s, int plane, float *pbuffer, int jobnr)
Definition: vf_fftdnoiz.c:441
internal.h
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
FFTdnoizContext::amount
float amount
Definition: vf_fftdnoiz.c:57
FFTdnoizContext::nb_planes
int nb_planes
Definition: vf_fftdnoiz.c:69
FFTdnoizContext::planes
PlaneContext planes[4]
Definition: vf_fftdnoiz.c:71
PlaneContext::vdata_out
AVComplexFloat * vdata_out[MAX_THREADS]
Definition: vf_fftdnoiz.c:48
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
FFTdnoizContext::planesf
int planesf
Definition: vf_fftdnoiz.c:64
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:423
common.h
PlaneContext::nox
int nox
Definition: vf_fftdnoiz.c:41
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:783
ThreadData
Used for passing data between threads.
Definition: dsddec.c:68
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:100
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:55
OFFSET
#define OFFSET(x)
Definition: vf_fftdnoiz.c:84
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:272
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:405
limit
static double limit(double x)
Definition: vf_pseudocolor.c:128
NEXT
@ NEXT
Definition: vf_fftdnoiz.c:35
FFTdnoizContext::itx_fn
av_tx_fn itx_fn
Definition: vf_fftdnoiz.c:77
AVFilter
Filter definition.
Definition: avfilter.h:171
FFTdnoizContext::nb_prev
int nb_prev
Definition: vf_fftdnoiz.c:62
ret
ret
Definition: filter_design.txt:187
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_fftdnoiz.c:694
export_block
static void export_block(FFTdnoizContext *s, uint8_t *dstp, int dst_linesize, float *buffer, int buffer_linesize, int plane, int jobnr, int y, int x)
Definition: vf_fftdnoiz.c:332
FFTdnoizContext::ifft_r
AVTXContext * ifft_r[MAX_THREADS]
Definition: vf_fftdnoiz.c:75
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:442
fftdnoiz_inputs
static const AVFilterPad fftdnoiz_inputs[]
Definition: vf_fftdnoiz.c:725
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:410
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:415
window_func.h
PlaneContext::hdata_out
AVComplexFloat * hdata_out[MAX_THREADS]
Definition: vf_fftdnoiz.c:48
power
static float power(float r, float g, float b, float max)
Definition: preserve_color.h:45
PlaneContext::noy
int noy
Definition: vf_fftdnoiz.c:41
ff_vf_fftdnoiz
const AVFilter ff_vf_fftdnoiz
Definition: vf_fftdnoiz.c:742
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:446
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
export_row16
static void export_row16(AVComplexFloat *src, uint8_t *dstp, int rw, int depth, float *win)
Definition: vf_fftdnoiz.c:173
av_clip_uint8
#define av_clip_uint8
Definition: common.h:101
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVFilterContext
An instance of a filter.
Definition: avfilter.h:408
factor
static const int factor[16]
Definition: vf_pp7.c:76
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:127
desc
const char * desc
Definition: libsvtav1.c:83
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
import_row8
static void import_row8(AVComplexFloat *dst, uint8_t *src, int rw, float scale, float *win, int off)
Definition: vf_fftdnoiz.c:145
FFTdnoizContext::block_size
int block_size
Definition: vf_fftdnoiz.c:58
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
FFTdnoizContext::fft
AVTXContext * fft[MAX_THREADS]
Definition: vf_fftdnoiz.c:74
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_fftdnoiz.c:588
PlaneContext::n
float n
Definition: vf_fftdnoiz.c:44
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:160
imgutils.h
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
export_row8
static void export_row8(AVComplexFloat *src, uint8_t *dst, int rw, int depth, float *win)
Definition: vf_fftdnoiz.c:155
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:412
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:416
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(fftdnoiz)
fftdnoiz_options
static const AVOption fftdnoiz_options[]
Definition: vf_fftdnoiz.c:87
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:388
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:142
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
BufferTypes
BufferTypes
Definition: vf_fftdnoiz.c:32
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:414
tx.h
re
float re
Definition: fft.c:79
FFTdnoizContext::method
int method
Definition: vf_fftdnoiz.c:60