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 "internal.h"
26 #include "libavcodec/avfft.h"
27 
28 #define MAX_THREADS 32
29 
35 };
36 
37 typedef struct PlaneContext {
39  int nox, noy;
40  int b;
41  int o;
42  float n;
43 
44  float *buffer[BSIZE];
48 } PlaneContext;
49 
50 typedef struct FFTdnoizContext {
51  const AVClass *class;
52 
53  float sigma;
54  float amount;
56  float overlap;
57  int nb_prev;
58  int nb_next;
59  int planesf;
60 
62 
63  int depth;
64  int nb_planes;
67 
69 
70  void (*import_row)(FFTComplex *dst, uint8_t *src, int rw);
71  void (*export_row)(FFTComplex *src, uint8_t *dst, int rw, float scale, int depth);
73 
74 #define OFFSET(x) offsetof(FFTdnoizContext, x)
75 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
76 #define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
77 static const AVOption fftdnoiz_options[] = {
78  { "sigma", "set denoise strength",
79  OFFSET(sigma), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 30, .flags = TFLAGS },
80  { "amount", "set amount of denoising",
81  OFFSET(amount), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0.01, 1, .flags = TFLAGS },
82  { "block", "set block log2(size)",
83  OFFSET(block_bits), AV_OPT_TYPE_INT, {.i64=4}, 3, 6, .flags = FLAGS },
84  { "overlap", "set block overlap",
85  OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0.2, 0.8, .flags = FLAGS },
86  { "prev", "set number of previous frames for temporal denoising",
87  OFFSET(nb_prev), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, .flags = FLAGS },
88  { "next", "set number of next frames for temporal denoising",
89  OFFSET(nb_next), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, .flags = FLAGS },
90  { "planes", "set planes to filter",
91  OFFSET(planesf), AV_OPT_TYPE_INT, {.i64=7}, 0, 15, .flags = TFLAGS },
92  { NULL }
93 };
94 
95 AVFILTER_DEFINE_CLASS(fftdnoiz);
96 
97 static const enum AVPixelFormat pix_fmts[] = {
122 };
123 
124 typedef struct ThreadData {
125  float *src, *dst;
126 } ThreadData;
127 
128 static void import_row8(FFTComplex *dst, uint8_t *src, int rw)
129 {
130  int j;
131 
132  for (j = 0; j < rw; j++) {
133  dst[j].re = src[j];
134  dst[j].im = 0;
135  }
136 }
137 
138 static void export_row8(FFTComplex *src, uint8_t *dst, int rw, float scale, int depth)
139 {
140  int j;
141 
142  for (j = 0; j < rw; j++)
143  dst[j] = av_clip_uint8(lrintf(src[j].re * scale));
144 }
145 
146 static void import_row16(FFTComplex *dst, uint8_t *srcp, int rw)
147 {
148  uint16_t *src = (uint16_t *)srcp;
149  int j;
150 
151  for (j = 0; j < rw; j++) {
152  dst[j].re = src[j];
153  dst[j].im = 0;
154  }
155 }
156 
157 static void export_row16(FFTComplex *src, uint8_t *dstp, int rw, float scale, int depth)
158 {
159  uint16_t *dst = (uint16_t *)dstp;
160  int j;
161 
162  for (j = 0; j < rw; j++)
163  dst[j] = av_clip_uintp2_c(src[j].re * scale + 0.5f, depth);
164 }
165 
167 {
168  AVFilterContext *ctx = inlink->dst;
169  const AVPixFmtDescriptor *desc;
170  FFTdnoizContext *s = ctx->priv;
171  int i;
172 
173  desc = av_pix_fmt_desc_get(inlink->format);
174  s->depth = desc->comp[0].depth;
175 
176  if (s->depth <= 8) {
177  s->import_row = import_row8;
178  s->export_row = export_row8;
179  } else {
180  s->import_row = import_row16;
181  s->export_row = export_row16;
182  s->sigma *= 1 << (s->depth - 8) * (1 + s->nb_prev + s->nb_next);
183  }
184 
185  s->planes[1].planewidth = s->planes[2].planewidth = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
186  s->planes[0].planewidth = s->planes[3].planewidth = inlink->w;
187  s->planes[1].planeheight = s->planes[2].planeheight = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
188  s->planes[0].planeheight = s->planes[3].planeheight = inlink->h;
189 
190  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
192 
193  for (int i = 0; i < s->nb_threads; i++) {
194  s->fft[i] = av_fft_init(s->block_bits, 0);
195  s->ifft[i] = av_fft_init(s->block_bits, 1);
196  if (!s->fft[i] || !s->ifft[i])
197  return AVERROR(ENOMEM);
198  }
199 
200  for (i = 0; i < s->nb_planes; i++) {
201  PlaneContext *p = &s->planes[i];
202  int size;
203 
204  p->b = 1 << s->block_bits;
205  p->n = 1.f / (p->b * p->b);
206  p->o = p->b * s->overlap;
207  size = p->b - p->o;
208  p->nox = (p->planewidth + (size - 1)) / size;
209  p->noy = (p->planeheight + (size - 1)) / size;
210 
211  av_log(ctx, AV_LOG_DEBUG, "nox:%d noy:%d size:%d\n", p->nox, p->noy, size);
212 
213  p->buffer_linesize = p->b * p->nox * sizeof(FFTComplex);
214  p->buffer[CURRENT] = av_calloc(p->b * p->noy, p->buffer_linesize);
215  if (!p->buffer[CURRENT])
216  return AVERROR(ENOMEM);
217  if (s->nb_prev > 0) {
218  p->buffer[PREV] = av_calloc(p->b * p->noy, p->buffer_linesize);
219  if (!p->buffer[PREV])
220  return AVERROR(ENOMEM);
221  }
222  if (s->nb_next > 0) {
223  p->buffer[NEXT] = av_calloc(p->b * p->noy, p->buffer_linesize);
224  if (!p->buffer[NEXT])
225  return AVERROR(ENOMEM);
226  }
227  p->data_linesize = 2 * p->b * sizeof(float);
228  for (int j = 0; j < s->nb_threads; j++) {
229  p->hdata[j] = av_calloc(p->b, p->data_linesize);
230  p->vdata[j] = av_calloc(p->b, p->data_linesize);
231  if (!p->hdata[j] || !p->vdata[j])
232  return AVERROR(ENOMEM);
233  }
234  }
235 
236  return 0;
237 }
238 
240  uint8_t *srcp, int src_linesize,
241  float *buffer, int buffer_linesize, int plane,
242  int jobnr, int nb_jobs)
243 {
244  PlaneContext *p = &s->planes[plane];
245  const int width = p->planewidth;
246  const int height = p->planeheight;
247  const int block = p->b;
248  const int overlap = p->o;
249  const int size = block - overlap;
250  const int nox = p->nox;
251  const int noy = p->noy;
252  const int bpp = (s->depth + 7) / 8;
253  const int data_linesize = p->data_linesize / sizeof(FFTComplex);
254  const int slice_start = (noy * jobnr) / nb_jobs;
255  const int slice_end = (noy * (jobnr+1)) / nb_jobs;
256  FFTComplex *hdata = p->hdata[jobnr];
257  FFTComplex *vdata = p->vdata[jobnr];
258  int x, y, i, j;
259 
260  buffer_linesize /= sizeof(float);
261  for (y = slice_start; y < slice_end; y++) {
262  for (x = 0; x < nox; x++) {
263  const int rh = FFMIN(block, height - y * size);
264  const int rw = FFMIN(block, width - x * size);
265  uint8_t *src = srcp + src_linesize * y * size + x * size * bpp;
266  float *bdst = buffer + buffer_linesize * y * block + x * block * 2;
267  FFTComplex *ssrc, *dst = hdata;
268 
269  for (i = 0; i < rh; i++) {
270  s->import_row(dst, src, rw);
271  for (j = rw; j < block; j++) {
272  dst[j].re = dst[block - j - 1].re;
273  dst[j].im = 0;
274  }
275  av_fft_permute(s->fft[jobnr], dst);
276  av_fft_calc(s->fft[jobnr], dst);
277 
278  src += src_linesize;
279  dst += data_linesize;
280  }
281 
282  dst = hdata;
283  for (; i < block; i++) {
284  for (j = 0; j < block; j++) {
285  dst[j].re = dst[(block - i - 1) * data_linesize + j].re;
286  dst[j].im = dst[(block - i - 1) * data_linesize + j].im;
287  }
288  }
289 
290  ssrc = hdata;
291  dst = vdata;
292  for (i = 0; i < block; i++) {
293  for (j = 0; j < block; j++)
294  dst[j] = ssrc[j * data_linesize + i];
295  av_fft_permute(s->fft[jobnr], dst);
296  av_fft_calc(s->fft[jobnr], dst);
297  memcpy(bdst, dst, block * sizeof(FFTComplex));
298 
299  dst += data_linesize;
300  bdst += buffer_linesize;
301  }
302  }
303  }
304 }
305 
307  uint8_t *dstp, int dst_linesize,
308  float *buffer, int buffer_linesize, int plane,
309  int jobnr, int nb_jobs)
310 {
311  PlaneContext *p = &s->planes[plane];
312  const int depth = s->depth;
313  const int bpp = (depth + 7) / 8;
314  const int width = p->planewidth;
315  const int height = p->planeheight;
316  const int block = p->b;
317  const int overlap = p->o;
318  const int hoverlap = overlap / 2;
319  const int size = block - overlap;
320  const int nox = p->nox;
321  const int noy = p->noy;
322  const int data_linesize = p->data_linesize / sizeof(FFTComplex);
323  const float scale = 1.f / (block * block);
324  const int slice_start = (noy * jobnr) / nb_jobs;
325  const int slice_end = (noy * (jobnr+1)) / nb_jobs;
326  FFTComplex *hdata = p->hdata[jobnr];
327  FFTComplex *vdata = p->vdata[jobnr];
328  int x, y, i, j;
329 
330  buffer_linesize /= sizeof(float);
331  for (y = slice_start; y < slice_end; y++) {
332  for (x = 0; x < nox; x++) {
333  const int woff = x == 0 ? 0 : hoverlap;
334  const int hoff = y == 0 ? 0 : hoverlap;
335  const int rw = x == 0 ? block : FFMIN(size, width - x * size - woff);
336  const int rh = y == 0 ? block : FFMIN(size, height - y * size - hoff);
337  float *bsrc = buffer + buffer_linesize * y * block + x * block * 2;
338  uint8_t *dst = dstp + dst_linesize * (y * size + hoff) + (x * size + woff) * bpp;
339  FFTComplex *hdst, *ddst = vdata;
340 
341  hdst = hdata;
342  for (i = 0; i < block; i++) {
343  memcpy(ddst, bsrc, block * sizeof(FFTComplex));
344  av_fft_permute(s->ifft[jobnr], ddst);
345  av_fft_calc(s->ifft[jobnr], ddst);
346  for (j = 0; j < block; j++) {
347  hdst[j * data_linesize + i] = ddst[j];
348  }
349 
350  ddst += data_linesize;
351  bsrc += buffer_linesize;
352  }
353 
354  hdst = hdata + hoff * data_linesize;
355  for (i = 0; i < rh; i++) {
356  av_fft_permute(s->ifft[jobnr], hdst);
357  av_fft_calc(s->ifft[jobnr], hdst);
358  s->export_row(hdst + woff, dst, rw, scale, depth);
359 
360  hdst += data_linesize;
361  dst += dst_linesize;
362  }
363  }
364  }
365 }
366 
367 static void filter_plane3d2(FFTdnoizContext *s, int plane, float *pbuffer, float *nbuffer,
368  int jobnr, int nb_jobs)
369 {
370  PlaneContext *p = &s->planes[plane];
371  const int block = p->b;
372  const int nox = p->nox;
373  const int noy = p->noy;
374  const int buffer_linesize = p->buffer_linesize / sizeof(float);
375  const float sigma = s->sigma * s->sigma * block * block;
376  const int slice_start = (noy * jobnr) / nb_jobs;
377  const int slice_end = (noy * (jobnr+1)) / nb_jobs;
378  const float limit = 1.f - s->amount;
379  float *cbuffer = p->buffer[CURRENT];
380  const float cfactor = sqrtf(3.f) * 0.5f;
381  const float scale = 1.f / 3.f;
382  int y, x, i, j;
383 
384  for (y = slice_start; y < slice_end; y++) {
385  for (x = 0; x < nox; x++) {
386  float *cbuff = cbuffer + buffer_linesize * y * block + x * block * 2;
387  float *pbuff = pbuffer + buffer_linesize * y * block + x * block * 2;
388  float *nbuff = nbuffer + buffer_linesize * y * block + x * block * 2;
389 
390  for (i = 0; i < block; i++) {
391  for (j = 0; j < block; j++) {
392  float sumr, sumi, difr, difi, mpr, mpi, mnr, mni;
393  float factor, power, sumpnr, sumpni;
394 
395  sumpnr = pbuff[2 * j ] + nbuff[2 * j ];
396  sumpni = pbuff[2 * j + 1] + nbuff[2 * j + 1];
397  sumr = cbuff[2 * j ] + sumpnr;
398  sumi = cbuff[2 * j + 1] + sumpni;
399  difr = cfactor * (nbuff[2 * j ] - pbuff[2 * j ]);
400  difi = cfactor * (pbuff[2 * j + 1] - nbuff[2 * j + 1]);
401  mpr = cbuff[2 * j ] - 0.5f * sumpnr + difi;
402  mnr = mpr - difi - difi;
403  mpi = cbuff[2 * j + 1] - 0.5f * sumpni + difr;
404  mni = mpi - difr - difr;
405  power = sumr * sumr + sumi * sumi + 1e-15f;
406  factor = FFMAX((power - sigma) / power, limit);
407  sumr *= factor;
408  sumi *= factor;
409  power = mpr * mpr + mpi * mpi + 1e-15f;
410  factor = FFMAX((power - sigma) / power, limit);
411  mpr *= factor;
412  mpi *= factor;
413  power = mnr * mnr + mni * mni + 1e-15f;
414  factor = FFMAX((power - sigma) / power, limit);
415  mnr *= factor;
416  mni *= factor;
417  cbuff[2 * j ] = (sumr + mpr + mnr) * scale;
418  cbuff[2 * j + 1] = (sumi + mpi + mni) * scale;
419 
420  }
421 
422  cbuff += buffer_linesize;
423  pbuff += buffer_linesize;
424  nbuff += buffer_linesize;
425  }
426  }
427  }
428 }
429 
430 static void filter_plane3d1(FFTdnoizContext *s, int plane, float *pbuffer,
431  int jobnr, int nb_jobs)
432 {
433  PlaneContext *p = &s->planes[plane];
434  const int block = p->b;
435  const int nox = p->nox;
436  const int noy = p->noy;
437  const int buffer_linesize = p->buffer_linesize / sizeof(float);
438  const float sigma = s->sigma * s->sigma * block * block;
439  const int slice_start = (noy * jobnr) / nb_jobs;
440  const int slice_end = (noy * (jobnr+1)) / nb_jobs;
441  const float limit = 1.f - s->amount;
442  float *cbuffer = p->buffer[CURRENT];
443  int y, x, i, j;
444 
445  for (y = slice_start; y < slice_end; y++) {
446  for (x = 0; x < nox; x++) {
447  float *cbuff = cbuffer + buffer_linesize * y * block + x * block * 2;
448  float *pbuff = pbuffer + buffer_linesize * y * block + x * block * 2;
449 
450  for (i = 0; i < block; i++) {
451  for (j = 0; j < block; j++) {
452  float factor, power, re, im, pre, pim;
453  float sumr, sumi, difr, difi;
454 
455  re = cbuff[j * 2 ];
456  pre = pbuff[j * 2 ];
457  im = cbuff[j * 2 + 1];
458  pim = pbuff[j * 2 + 1];
459 
460  sumr = re + pre;
461  sumi = im + pim;
462  difr = re - pre;
463  difi = im - pim;
464 
465  power = sumr * sumr + sumi * sumi + 1e-15f;
466  factor = FFMAX(limit, (power - sigma) / power);
467  sumr *= factor;
468  sumi *= factor;
469  power = difr * difr + difi * difi + 1e-15f;
470  factor = FFMAX(limit, (power - sigma) / power);
471  difr *= factor;
472  difi *= factor;
473 
474  cbuff[j * 2 ] = (sumr + difr) * 0.5f;
475  cbuff[j * 2 + 1] = (sumi + difi) * 0.5f;
476  }
477 
478  cbuff += buffer_linesize;
479  pbuff += buffer_linesize;
480  }
481  }
482  }
483 }
484 
485 static void filter_plane2d(FFTdnoizContext *s, int plane,
486  int jobnr, int nb_jobs)
487 {
488  PlaneContext *p = &s->planes[plane];
489  const int block = p->b;
490  const int nox = p->nox;
491  const int noy = p->noy;
492  const int buffer_linesize = p->buffer_linesize / 4;
493  const float sigma = s->sigma * s->sigma * block * block;
494  const float limit = 1.f - s->amount;
495  const int slice_start = (noy * jobnr) / nb_jobs;
496  const int slice_end = (noy * (jobnr+1)) / nb_jobs;
497  float *buffer = p->buffer[CURRENT];
498 
499  for (int y = slice_start; y < slice_end; y++) {
500  for (int x = 0; x < nox; x++) {
501  float *buff = buffer + buffer_linesize * y * block + x * block * 2;
502 
503  for (int i = 0; i < block; i++) {
504  for (int j = 0; j < block; j++) {
505  float factor, power, re, im;
506 
507  re = buff[j * 2 ];
508  im = buff[j * 2 + 1];
509  power = re * re + im * im + 1e-15f;
510  factor = FFMAX(limit, (power - sigma) / power);
511  buff[j * 2 ] *= factor;
512  buff[j * 2 + 1] *= factor;
513  }
514 
515  buff += buffer_linesize;
516  }
517  }
518  }
519 }
520 
521 static int import_pass(AVFilterContext *ctx, void *arg,
522  int jobnr, int nb_jobs)
523 {
524  FFTdnoizContext *s = ctx->priv;
525 
526  for (int plane = 0; plane < s->nb_planes; plane++) {
527  PlaneContext *p = &s->planes[plane];
528 
529  if (!((1 << plane) & s->planesf) || ctx->is_disabled)
530  continue;
531 
532  if (s->next) {
533  import_plane(s, s->next->data[plane], s->next->linesize[plane],
534  p->buffer[NEXT], p->buffer_linesize, plane,
535  jobnr, nb_jobs);
536  }
537 
538  if (s->prev) {
539  import_plane(s, s->prev->data[plane], s->prev->linesize[plane],
540  p->buffer[PREV], p->buffer_linesize, plane,
541  jobnr, nb_jobs);
542  }
543 
544  import_plane(s, s->cur->data[plane], s->cur->linesize[plane],
545  p->buffer[CURRENT], p->buffer_linesize, plane,
546  jobnr, nb_jobs);
547  }
548 
549  return 0;
550 }
551 
552 static int filter_pass(AVFilterContext *ctx, void *arg,
553  int jobnr, int nb_jobs)
554 {
555  FFTdnoizContext *s = ctx->priv;
556 
557  for (int plane = 0; plane < s->nb_planes; plane++) {
558  PlaneContext *p = &s->planes[plane];
559 
560  if (!((1 << plane) & s->planesf) || ctx->is_disabled)
561  continue;
562 
563  if (s->next && s->prev) {
564  filter_plane3d2(s, plane, p->buffer[PREV], p->buffer[NEXT], jobnr, nb_jobs);
565  } else if (s->next) {
566  filter_plane3d1(s, plane, p->buffer[NEXT], jobnr, nb_jobs);
567  } else if (s->prev) {
568  filter_plane3d1(s, plane, p->buffer[PREV], jobnr, nb_jobs);
569  } else {
570  filter_plane2d(s, plane, jobnr, nb_jobs);
571  }
572  }
573 
574  return 0;
575 }
576 
577 static int export_pass(AVFilterContext *ctx, void *arg,
578  int jobnr, int nb_jobs)
579 {
580  FFTdnoizContext *s = ctx->priv;
581  AVFrame *out = arg;
582 
583  for (int plane = 0; plane < s->nb_planes; plane++) {
584  PlaneContext *p = &s->planes[plane];
585 
586  if (!((1 << plane) & s->planesf) || ctx->is_disabled)
587  continue;
588 
589  export_plane(s, out->data[plane], out->linesize[plane],
590  p->buffer[CURRENT], p->buffer_linesize, plane,
591  jobnr, nb_jobs);
592  }
593 
594  return 0;
595 }
596 
598 {
599  AVFilterContext *ctx = inlink->dst;
600  FFTdnoizContext *s = ctx->priv;
601  AVFilterLink *outlink = ctx->outputs[0];
602  int direct, plane;
603  AVFrame *out;
604 
605  if (s->nb_next > 0 && s->nb_prev > 0) {
606  av_frame_free(&s->prev);
607  s->prev = s->cur;
608  s->cur = s->next;
609  s->next = in;
610 
611  if (!s->prev && s->cur) {
612  s->prev = av_frame_clone(s->cur);
613  if (!s->prev)
614  return AVERROR(ENOMEM);
615  }
616  if (!s->cur)
617  return 0;
618  } else if (s->nb_next > 0) {
619  av_frame_free(&s->cur);
620  s->cur = s->next;
621  s->next = in;
622 
623  if (!s->cur)
624  return 0;
625  } else if (s->nb_prev > 0) {
626  av_frame_free(&s->prev);
627  s->prev = s->cur;
628  s->cur = in;
629 
630  if (!s->prev)
631  s->prev = av_frame_clone(s->cur);
632  if (!s->prev)
633  return AVERROR(ENOMEM);
634  } else {
635  s->cur = in;
636  }
637 
638  if (av_frame_is_writable(in) && s->nb_next == 0 && s->nb_prev == 0) {
639  direct = 1;
640  out = in;
641  } else {
642  direct = 0;
643  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
644  if (!out)
645  return AVERROR(ENOMEM);
646  av_frame_copy_props(out, s->cur);
647  }
648 
650  FFMIN(s->planes[0].noy, s->nb_threads));
651 
653  FFMIN(s->planes[0].noy, s->nb_threads));
654 
656  FFMIN(s->planes[0].noy, s->nb_threads));
657 
658  for (plane = 0; plane < s->nb_planes; plane++) {
659  PlaneContext *p = &s->planes[plane];
660 
661  if (!((1 << plane) & s->planesf) || ctx->is_disabled) {
662  if (!direct)
663  av_image_copy_plane(out->data[plane], out->linesize[plane],
664  s->cur->data[plane], s->cur->linesize[plane],
665  p->planewidth, p->planeheight);
666  continue;
667  }
668  }
669 
670  if (s->nb_next == 0 && s->nb_prev == 0) {
671  if (direct) {
672  s->cur = NULL;
673  } else {
674  av_frame_free(&s->cur);
675  }
676  }
677  return ff_filter_frame(outlink, out);
678 }
679 
680 static int request_frame(AVFilterLink *outlink)
681 {
682  AVFilterContext *ctx = outlink->src;
683  FFTdnoizContext *s = ctx->priv;
684  int ret = 0;
685 
686  ret = ff_request_frame(ctx->inputs[0]);
687 
688  if (ret == AVERROR_EOF && (s->nb_next > 0)) {
689  AVFrame *buf;
690 
691  if (s->next && s->nb_next > 0)
692  buf = av_frame_clone(s->next);
693  else if (s->cur)
694  buf = av_frame_clone(s->cur);
695  else
696  buf = av_frame_clone(s->prev);
697  if (!buf)
698  return AVERROR(ENOMEM);
699 
700  ret = filter_frame(ctx->inputs[0], buf);
701  if (ret < 0)
702  return ret;
703  ret = AVERROR_EOF;
704  }
705 
706  return ret;
707 }
708 
710 {
711  FFTdnoizContext *s = ctx->priv;
712  int i;
713 
714  for (i = 0; i < 4; i++) {
715  PlaneContext *p = &s->planes[i];
716 
717  for (int j = 0; j < s->nb_threads; j++) {
718  av_freep(&p->hdata[j]);
719  av_freep(&p->vdata[j]);
720  }
721 
722  av_freep(&p->buffer[PREV]);
723  av_freep(&p->buffer[CURRENT]);
724  av_freep(&p->buffer[NEXT]);
725  }
726 
727  for (i = 0; i < s->nb_threads; i++) {
728  av_fft_end(s->fft[i]);
729  av_fft_end(s->ifft[i]);
730  }
731 
732  av_frame_free(&s->prev);
733  av_frame_free(&s->cur);
734  av_frame_free(&s->next);
735 }
736 
737 static const AVFilterPad fftdnoiz_inputs[] = {
738  {
739  .name = "default",
740  .type = AVMEDIA_TYPE_VIDEO,
741  .filter_frame = filter_frame,
742  .config_props = config_input,
743  },
744 };
745 
746 static const AVFilterPad fftdnoiz_outputs[] = {
747  {
748  .name = "default",
749  .type = AVMEDIA_TYPE_VIDEO,
750  .request_frame = request_frame,
751  },
752 };
753 
755  .name = "fftdnoiz",
756  .description = NULL_IF_CONFIG_SMALL("Denoise frames using 3D FFT."),
757  .priv_size = sizeof(FFTdnoizContext),
758  .uninit = uninit,
762  .priv_class = &fftdnoiz_class,
765  .process_command = ff_filter_process_command,
766 };
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:98
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:434
CURRENT
@ CURRENT
Definition: vf_fftdnoiz.c:31
av_fft_end
av_cold void av_fft_end(FFTContext *s)
Definition: avfft.c:48
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:413
direct
static void direct(const float *in, const FFTComplex *ir, int len, float *out)
Definition: af_afir.c:61
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
PlaneContext::buffer_linesize
int buffer_linesize
Definition: vf_fftdnoiz.c:47
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:680
MAX_THREADS
#define MAX_THREADS
Definition: vf_fftdnoiz.c:28
out
FILE * out
Definition: movenc.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
FFTdnoizContext::nb_next
int nb_next
Definition: vf_fftdnoiz.c:58
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2564
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
block_bits
static const uint8_t block_bits[]
Definition: imm4.c:103
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
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:112
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:426
im
float im
Definition: fft.c:78
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
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:276
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:433
export_plane
static void export_plane(FFTdnoizContext *s, uint8_t *dstp, int dst_linesize, float *buffer, int buffer_linesize, int plane, int jobnr, int nb_jobs)
Definition: vf_fftdnoiz.c:306
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:428
AVOption
AVOption.
Definition: opt.h:247
PlaneContext::b
int b
Definition: vf_fftdnoiz.c:40
fftdnoiz_outputs
static const AVFilterPad fftdnoiz_outputs[]
Definition: vf_fftdnoiz.c:746
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:391
FFTdnoizContext::sigma
float sigma
Definition: vf_fftdnoiz.c:53
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:420
av_fft_permute
void av_fft_permute(FFTContext *s, FFTComplex *z)
Do the permutation needed BEFORE calling ff_fft_calc().
Definition: avfft.c:38
float.h
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
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:153
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:429
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:371
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
FFTdnoizContext::cur
AVFrame * cur
Definition: vf_fftdnoiz.c:61
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2604
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:425
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:409
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:38
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:407
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:435
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:389
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1377
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:375
TFLAGS
#define TFLAGS
Definition: vf_fftdnoiz.c:76
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:394
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
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:403
filter_plane3d1
static void filter_plane3d1(FFTdnoizContext *s, int plane, float *pbuffer, int jobnr, int nb_jobs)
Definition: vf_fftdnoiz.c:430
FFTdnoizContext::overlap
float overlap
Definition: vf_fftdnoiz.c:56
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:411
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:412
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:404
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:51
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2041
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:432
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:388
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:402
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:374
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:424
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_fftdnoiz.c:97
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
f
#define f(width, name)
Definition: cbs_vp9.c:255
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
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:372
ThreadData::dst
AVFrame * dst
Definition: vf_blend.c:83
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:410
FFTdnoizContext::next
AVFrame * next
Definition: vf_fftdnoiz.c:61
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:537
PlaneContext::planewidth
int planewidth
Definition: vf_fftdnoiz.c:38
ThreadData::src
const uint8_t * src
Definition: vf_bm3d.c:55
FFTdnoizContext
Definition: vf_fftdnoiz.c:50
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:61
src
#define src
Definition: vp8dsp.c:255
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:393
PlaneContext
Definition: ffv1.h:66
PlaneContext::data_linesize
int data_linesize
Definition: vf_fftdnoiz.c:46
avfft.h
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:392
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:406
FFTdnoizContext::nb_threads
int nb_threads
Definition: vf_fftdnoiz.c:65
FFTdnoizContext::depth
int depth
Definition: vf_fftdnoiz.c:63
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_fftdnoiz.c:166
FFTComplex
void FFTComplex
Definition: tx_priv.h:43
filter_plane3d2
static void filter_plane3d2(FFTdnoizContext *s, int plane, float *pbuffer, float *nbuffer, int jobnr, int nb_jobs)
Definition: vf_fftdnoiz.c:367
FFTdnoizContext::ifft
FFTContext * ifft[MAX_THREADS]
Definition: vf_fftdnoiz.c:68
BSIZE
@ BSIZE
Definition: vf_fftdnoiz.c:34
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
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:396
size
int size
Definition: twinvq_data.h:10344
PlaneContext::o
int o
Definition: vf_fftdnoiz.c:41
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:398
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:473
FLAGS
#define FLAGS
Definition: vf_fftdnoiz.c:75
FFTComplex::im
FFTSample im
Definition: avfft.h:38
FFTComplex::re
FFTSample re
Definition: avfft.h:38
PREV
@ PREV
Definition: vf_fftdnoiz.c:32
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:882
FFTdnoizContext::import_row
void(* import_row)(FFTComplex *dst, uint8_t *src, int rw)
Definition: vf_fftdnoiz.c:70
PlaneContext::vdata
FFTComplex * vdata[MAX_THREADS]
Definition: vf_fftdnoiz.c:45
export_row16
static void export_row16(FFTComplex *src, uint8_t *dstp, int rw, float scale, int depth)
Definition: vf_fftdnoiz.c:157
height
#define height
FFTdnoizContext::block_bits
int block_bits
Definition: vf_fftdnoiz.c:55
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:430
internal.h
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
PlaneContext::buffer
float * buffer[BSIZE]
Definition: vf_fftdnoiz.c:44
FFTdnoizContext::amount
float amount
Definition: vf_fftdnoiz.c:54
FFTdnoizContext::nb_planes
int nb_planes
Definition: vf_fftdnoiz.c:64
FFTdnoizContext::planes
PlaneContext planes[4]
Definition: vf_fftdnoiz.c:66
FFTContext
Definition: fft.h:75
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
export_row8
static void export_row8(FFTComplex *src, uint8_t *dst, int rw, float scale, int depth)
Definition: vf_fftdnoiz.c:138
FFTdnoizContext::planesf
int planesf
Definition: vf_fftdnoiz.c:59
import_row8
static void import_row8(FFTComplex *dst, uint8_t *src, int rw)
Definition: vf_fftdnoiz.c:128
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:408
import_pass
static int import_pass(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_fftdnoiz.c:521
common.h
PlaneContext::nox
int nox
Definition: vf_fftdnoiz.c:39
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:803
ThreadData
Used for passing data between threads.
Definition: dsddec.c:67
import_row16
static void import_row16(FFTComplex *dst, uint8_t *srcp, int rw)
Definition: vf_fftdnoiz.c:146
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:56
OFFSET
#define OFFSET(x)
Definition: vf_fftdnoiz.c:74
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:390
filter_plane2d
static void filter_plane2d(FFTdnoizContext *s, int plane, int jobnr, int nb_jobs)
Definition: vf_fftdnoiz.c:485
limit
static double limit(double x)
Definition: vf_pseudocolor.c:128
NEXT
@ NEXT
Definition: vf_fftdnoiz.c:33
AVFilter
Filter definition.
Definition: avfilter.h:149
FFTdnoizContext::nb_prev
int nb_prev
Definition: vf_fftdnoiz.c:57
ret
ret
Definition: filter_design.txt:187
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_fftdnoiz.c:709
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:427
fftdnoiz_inputs
static const AVFilterPad fftdnoiz_inputs[]
Definition: vf_fftdnoiz.c:737
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:395
import_plane
static void import_plane(FFTdnoizContext *s, uint8_t *srcp, int src_linesize, float *buffer, int buffer_linesize, int plane, int jobnr, int nb_jobs)
Definition: vf_fftdnoiz.c:239
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:400
av_fft_init
FFTContext * av_fft_init(int nbits, int inverse)
Set up a complex FFT.
Definition: avfft.c:28
export_pass
static int export_pass(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_fftdnoiz.c:577
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:39
ff_vf_fftdnoiz
const AVFilter ff_vf_fftdnoiz
Definition: vf_fftdnoiz.c:754
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:431
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
FFTdnoizContext::fft
FFTContext * fft[MAX_THREADS]
Definition: vf_fftdnoiz.c:68
av_clip_uint8
#define av_clip_uint8
Definition: common.h:102
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:386
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:121
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
PlaneContext::hdata
FFTComplex * hdata[MAX_THREADS]
Definition: vf_fftdnoiz.c:45
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
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_fftdnoiz.c:597
PlaneContext::n
float n
Definition: vf_fftdnoiz.c:42
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
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:138
imgutils.h
filter_pass
static int filter_pass(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_fftdnoiz.c:552
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:28
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:397
FFTdnoizContext::export_row
void(* export_row)(FFTComplex *src, uint8_t *dst, int rw, float scale, int depth)
Definition: vf_fftdnoiz.c:71
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:401
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(fftdnoiz)
fftdnoiz_options
static const AVOption fftdnoiz_options[]
Definition: vf_fftdnoiz.c:77
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:373
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:143
av_fft_calc
void av_fft_calc(FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in av_fft_init().
Definition: avfft.c:43
BufferTypes
BufferTypes
Definition: vf_fftdnoiz.c:30
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:399
FFTComplex
Definition: avfft.h:37
re
float re
Definition: fft.c:78