FFmpeg
vf_atadenoise.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Paul B Mahol
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * Adaptive Temporal Averaging Denoiser,
24  * based on paper "Video Denoising Based on Adaptive Temporal Averaging" by
25  * David Bartovčak and Miroslav Vrankić
26  */
27 
28 #include "libavutil/imgutils.h"
29 #include "libavutil/opt.h"
30 #include "libavutil/pixdesc.h"
31 #include "avfilter.h"
32 
33 #define FF_BUFQUEUE_SIZE 129
34 #include "bufferqueue.h"
35 
36 #include "atadenoise.h"
37 #include "filters.h"
38 #include "video.h"
39 
40 #define SIZE FF_BUFQUEUE_SIZE
41 
42 typedef struct ATADenoiseContext {
43  const AVClass *class;
44 
45  float fthra[4], fthrb[4];
46  float sigma[4];
47  int thra[4], thrb[4];
48  int algorithm;
49 
50  int planes;
51  int nb_planes;
52  int planewidth[4];
53  int planeheight[4];
54  int linesizes[4];
55 
56  struct FFBufQueue q;
57  void *data[4][SIZE];
58  int linesize[4][SIZE];
59  float weights[4][SIZE];
60  int size, mid, radius;
61  int available;
62 
63  int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
64 
67 
68 #define OFFSET(x) offsetof(ATADenoiseContext, x)
69 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
70 #define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
71 
72 static const AVOption atadenoise_options[] = {
73  { "0a", "set threshold A for 1st plane", OFFSET(fthra[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0, 0.3, FLAGS },
74  { "0b", "set threshold B for 1st plane", OFFSET(fthrb[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.04}, 0, 5.0, FLAGS },
75  { "1a", "set threshold A for 2nd plane", OFFSET(fthra[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0, 0.3, FLAGS },
76  { "1b", "set threshold B for 2nd plane", OFFSET(fthrb[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.04}, 0, 5.0, FLAGS },
77  { "2a", "set threshold A for 3rd plane", OFFSET(fthra[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0, 0.3, FLAGS },
78  { "2b", "set threshold B for 3rd plane", OFFSET(fthrb[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.04}, 0, 5.0, FLAGS },
79  { "s", "set how many frames to use", OFFSET(size), AV_OPT_TYPE_INT, {.i64=9}, 5, SIZE, VF },
80  { "p", "set what planes to filter", OFFSET(planes), AV_OPT_TYPE_FLAGS, {.i64=7}, 0, 15, FLAGS },
81  { "a", "set variant of algorithm", OFFSET(algorithm),AV_OPT_TYPE_INT, {.i64=PARALLEL}, 0, NB_ATAA-1, FLAGS, .unit = "a" },
82  { "p", "parallel", 0, AV_OPT_TYPE_CONST, {.i64=PARALLEL}, 0, 0, FLAGS, .unit = "a" },
83  { "s", "serial", 0, AV_OPT_TYPE_CONST, {.i64=SERIAL}, 0, 0, FLAGS, .unit = "a" },
84  { "0s", "set sigma for 1st plane", OFFSET(sigma[0]), AV_OPT_TYPE_FLOAT, {.dbl=INT16_MAX}, 0, INT16_MAX, FLAGS },
85  { "1s", "set sigma for 2nd plane", OFFSET(sigma[1]), AV_OPT_TYPE_FLOAT, {.dbl=INT16_MAX}, 0, INT16_MAX, FLAGS },
86  { "2s", "set sigma for 3rd plane", OFFSET(sigma[2]), AV_OPT_TYPE_FLOAT, {.dbl=INT16_MAX}, 0, INT16_MAX, FLAGS },
87  { NULL }
88 };
89 
90 AVFILTER_DEFINE_CLASS(atadenoise);
91 
92 static const enum AVPixelFormat pixel_fmts[] = {
120 };
121 
123 {
124  ATADenoiseContext *s = ctx->priv;
125 
126  if (!(s->size & 1)) {
127  av_log(ctx, AV_LOG_WARNING, "size %d is invalid. Must be an odd value, setting it to %d.\n", s->size, s->size|1);
128  s->size |= 1;
129  }
130  s->radius = s->size / 2;
131  s->mid = s->radius;
132 
133  return 0;
134 }
135 
136 typedef struct ThreadData {
137  AVFrame *in, *out;
138 } ThreadData;
139 
140 #define WFILTER_ROW(type, name) \
141 static void fweight_row##name(const uint8_t *ssrc, uint8_t *ddst, \
142  const uint8_t *ssrcf[SIZE], \
143  int w, int mid, int size, \
144  int thra, int thrb, const float *weights) \
145 { \
146  const type *src = (const type *)ssrc; \
147  const type **srcf = (const type **)ssrcf; \
148  type *dst = (type *)ddst; \
149  \
150  for (int x = 0; x < w; x++) { \
151  const int srcx = src[x]; \
152  unsigned lsumdiff = 0, rsumdiff = 0; \
153  unsigned ldiff, rdiff; \
154  float sum = srcx; \
155  float wsum = 1.f; \
156  int srcjx, srcix; \
157  \
158  for (int j = mid - 1, i = mid + 1; j >= 0 && i < size; j--, i++) { \
159  srcjx = srcf[j][x]; \
160  \
161  ldiff = FFABS(srcx - srcjx); \
162  lsumdiff += ldiff; \
163  if (ldiff > thra || \
164  lsumdiff > thrb) \
165  break; \
166  sum += srcjx * weights[j]; \
167  wsum += weights[j]; \
168  \
169  srcix = srcf[i][x]; \
170  \
171  rdiff = FFABS(srcx - srcix); \
172  rsumdiff += rdiff; \
173  if (rdiff > thra || \
174  rsumdiff > thrb) \
175  break; \
176  sum += srcix * weights[i]; \
177  wsum += weights[i]; \
178  } \
179  \
180  dst[x] = lrintf(sum / wsum); \
181  } \
182 }
183 
184 WFILTER_ROW(uint8_t, 8)
185 WFILTER_ROW(uint16_t, 16)
186 
187 #define WFILTER_ROW_SERIAL(type, name) \
188 static void fweight_row##name##_serial(const uint8_t *ssrc, uint8_t *ddst, \
189  const uint8_t *ssrcf[SIZE], \
190  int w, int mid, int size, \
191  int thra, int thrb, \
192  const float *weights) \
193 { \
194  const type *src = (const type *)ssrc; \
195  const type **srcf = (const type **)ssrcf; \
196  type *dst = (type *)ddst; \
197  \
198  for (int x = 0; x < w; x++) { \
199  const int srcx = src[x]; \
200  unsigned lsumdiff = 0, rsumdiff = 0; \
201  unsigned ldiff, rdiff; \
202  float sum = srcx; \
203  float wsum = 1.f; \
204  int srcjx, srcix; \
205  \
206  for (int j = mid - 1; j >= 0; j--) { \
207  srcjx = srcf[j][x]; \
208  \
209  ldiff = FFABS(srcx - srcjx); \
210  lsumdiff += ldiff; \
211  if (ldiff > thra || \
212  lsumdiff > thrb) \
213  break; \
214  sum += srcjx * weights[j]; \
215  wsum += weights[j]; \
216  } \
217  \
218  for (int i = mid + 1; i < size; i++) { \
219  srcix = srcf[i][x]; \
220  \
221  rdiff = FFABS(srcx - srcix); \
222  rsumdiff += rdiff; \
223  if (rdiff > thra || \
224  rsumdiff > thrb) \
225  break; \
226  sum += srcix * weights[i]; \
227  wsum += weights[i]; \
228  } \
229  \
230  dst[x] = lrintf(sum / wsum); \
231  } \
232 }
233 
234 WFILTER_ROW_SERIAL(uint8_t, 8)
235 WFILTER_ROW_SERIAL(uint16_t, 16)
236 
237 #define FILTER_ROW(type, name) \
238 static void filter_row##name(const uint8_t *ssrc, uint8_t *ddst, \
239  const uint8_t *ssrcf[SIZE], \
240  int w, int mid, int size, \
241  int thra, int thrb, const float *weights) \
242 { \
243  const type *src = (const type *)ssrc; \
244  const type **srcf = (const type **)ssrcf; \
245  type *dst = (type *)ddst; \
246  \
247  for (int x = 0; x < w; x++) { \
248  const int srcx = src[x]; \
249  unsigned lsumdiff = 0, rsumdiff = 0; \
250  unsigned ldiff, rdiff; \
251  unsigned sum = srcx; \
252  int l = 0, r = 0; \
253  int srcjx, srcix; \
254  \
255  for (int j = mid - 1, i = mid + 1; j >= 0 && i < size; j--, i++) { \
256  srcjx = srcf[j][x]; \
257  \
258  ldiff = FFABS(srcx - srcjx); \
259  lsumdiff += ldiff; \
260  if (ldiff > thra || \
261  lsumdiff > thrb) \
262  break; \
263  l++; \
264  sum += srcjx; \
265  \
266  srcix = srcf[i][x]; \
267  \
268  rdiff = FFABS(srcx - srcix); \
269  rsumdiff += rdiff; \
270  if (rdiff > thra || \
271  rsumdiff > thrb) \
272  break; \
273  r++; \
274  sum += srcix; \
275  } \
276  \
277  dst[x] = (sum + ((r + l + 1) >> 1)) / (r + l + 1); \
278  } \
279 }
280 
281 FILTER_ROW(uint8_t, 8)
282 FILTER_ROW(uint16_t, 16)
283 
284 #define FILTER_ROW_SERIAL(type, name) \
285 static void filter_row##name##_serial(const uint8_t *ssrc, uint8_t *ddst, \
286  const uint8_t *ssrcf[SIZE], \
287  int w, int mid, int size, \
288  int thra, int thrb, \
289  const float *weights) \
290 { \
291  const type *src = (const type *)ssrc; \
292  const type **srcf = (const type **)ssrcf; \
293  type *dst = (type *)ddst; \
294  \
295  for (int x = 0; x < w; x++) { \
296  const int srcx = src[x]; \
297  unsigned lsumdiff = 0, rsumdiff = 0; \
298  unsigned ldiff, rdiff; \
299  unsigned sum = srcx; \
300  int l = 0, r = 0; \
301  int srcjx, srcix; \
302  \
303  for (int j = mid - 1; j >= 0; j--) { \
304  srcjx = srcf[j][x]; \
305  \
306  ldiff = FFABS(srcx - srcjx); \
307  lsumdiff += ldiff; \
308  if (ldiff > thra || \
309  lsumdiff > thrb) \
310  break; \
311  l++; \
312  sum += srcjx; \
313  } \
314  \
315  for (int i = mid + 1; i < size; i++) { \
316  srcix = srcf[i][x]; \
317  \
318  rdiff = FFABS(srcx - srcix); \
319  rsumdiff += rdiff; \
320  if (rdiff > thra || \
321  rsumdiff > thrb) \
322  break; \
323  r++; \
324  sum += srcix; \
325  } \
326  \
327  dst[x] = (sum + ((r + l + 1) >> 1)) / (r + l + 1); \
328  } \
329 }
330 
331 FILTER_ROW_SERIAL(uint8_t, 8)
332 FILTER_ROW_SERIAL(uint16_t, 16)
333 
334 static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
335 {
336  ATADenoiseContext *s = ctx->priv;
337  ThreadData *td = arg;
338  AVFrame *in = td->in;
339  AVFrame *out = td->out;
340  const int size = s->size;
341  const int mid = s->mid;
342  int p, y, i;
343 
344  for (p = 0; p < s->nb_planes; p++) {
345  const float *weights = s->weights[p];
346  const int h = s->planeheight[p];
347  const int w = s->planewidth[p];
348  const int slice_start = (h * jobnr) / nb_jobs;
349  const int slice_end = (h * (jobnr+1)) / nb_jobs;
350  const uint8_t *src = in->data[p] + slice_start * in->linesize[p];
351  uint8_t *dst = out->data[p] + slice_start * out->linesize[p];
352  const int thra = s->thra[p];
353  const int thrb = s->thrb[p];
354  const uint8_t **data = (const uint8_t **)s->data[p];
355  const int *linesize = (const int *)s->linesize[p];
356  const uint8_t *srcf[SIZE];
357 
358  if (!((1 << p) & s->planes)) {
359  av_image_copy_plane(dst, out->linesize[p], src, in->linesize[p],
360  s->linesizes[p], slice_end - slice_start);
361  continue;
362  }
363 
364  for (i = 0; i < size; i++)
365  srcf[i] = data[i] + slice_start * linesize[i];
366 
367  for (y = slice_start; y < slice_end; y++) {
368  s->dsp.filter_row[p](src, dst, srcf, w, mid, size, thra, thrb, weights);
369 
370  dst += out->linesize[p];
371  src += in->linesize[p];
372 
373  for (i = 0; i < size; i++)
374  srcf[i] += linesize[i];
375  }
376  }
377 
378  return 0;
379 }
380 
382 {
384  AVFilterContext *ctx = inlink->dst;
385  ATADenoiseContext *s = ctx->priv;
386  int depth, ret;
387 
388  s->nb_planes = desc->nb_components;
389 
390  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
391  s->planeheight[0] = s->planeheight[3] = inlink->h;
392  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
393  s->planewidth[0] = s->planewidth[3] = inlink->w;
394 
395  depth = desc->comp[0].depth;
396  s->filter_slice = filter_slice;
397 
398  if ((ret = av_image_fill_linesizes(s->linesizes, inlink->format, inlink->w)) < 0)
399  return ret;
400 
401  for (int p = 0; p < s->nb_planes; p++) {
402  if (depth == 8 && s->sigma[p] == INT16_MAX)
403  s->dsp.filter_row[p] = s->algorithm == PARALLEL ? filter_row8 : filter_row8_serial;
404  else if (s->sigma[p] == INT16_MAX)
405  s->dsp.filter_row[p] = s->algorithm == PARALLEL ? filter_row16 : filter_row16_serial;
406  else if (depth == 8 && s->sigma[p] < INT16_MAX)
407  s->dsp.filter_row[p] = s->algorithm == PARALLEL ? fweight_row8 : fweight_row8_serial;
408  else if (s->sigma[p] < INT16_MAX)
409  s->dsp.filter_row[p] = s->algorithm == PARALLEL ? fweight_row16 : fweight_row16_serial;
410  }
411 
412  s->thra[0] = s->fthra[0] * (1 << depth) - 1;
413  s->thra[1] = s->fthra[1] * (1 << depth) - 1;
414  s->thra[2] = s->fthra[2] * (1 << depth) - 1;
415  s->thrb[0] = s->fthrb[0] * (1 << depth) - 1;
416  s->thrb[1] = s->fthrb[1] * (1 << depth) - 1;
417  s->thrb[2] = s->fthrb[2] * (1 << depth) - 1;
418 
419  for (int p = 0; p < s->nb_planes; p++) {
420  float sigma = s->radius * s->sigma[p];
421 
422  s->weights[p][s->radius] = 1.f;
423  for (int n = 1; n <= s->radius; n++) {
424  s->weights[p][s->radius + n] =
425  s->weights[p][s->radius - n] = expf(-0.5 * (n + 1) * (n + 1) / (sigma * sigma));
426  }
427  }
428 
429 #if ARCH_X86
430  ff_atadenoise_init_x86(&s->dsp, depth, s->algorithm, s->sigma);
431 #endif
432 
433  return 0;
434 }
435 
437 {
438  AVFilterContext *ctx = inlink->dst;
439  AVFilterLink *outlink = ctx->outputs[0];
440  ATADenoiseContext *s = ctx->priv;
441  AVFrame *out, *in;
442  int i;
443 
444  if (s->q.available != s->size) {
445  if (s->q.available < s->mid) {
446  for (i = 0; i < s->mid; i++) {
447  out = av_frame_clone(buf);
448  if (!out) {
449  av_frame_free(&buf);
450  return AVERROR(ENOMEM);
451  }
452  ff_bufqueue_add(ctx, &s->q, out);
453  }
454  }
455  if (s->q.available < s->size) {
456  ff_bufqueue_add(ctx, &s->q, buf);
457  s->available++;
458  }
459  return 0;
460  }
461 
462  in = ff_bufqueue_peek(&s->q, s->mid);
463 
464  if (!ctx->is_disabled) {
465  ThreadData td;
466 
467  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
468  if (!out) {
469  av_frame_free(&buf);
470  return AVERROR(ENOMEM);
471  }
472 
473  for (i = 0; i < s->size; i++) {
474  AVFrame *frame = ff_bufqueue_peek(&s->q, i);
475 
476  s->data[0][i] = frame->data[0];
477  s->data[1][i] = frame->data[1];
478  s->data[2][i] = frame->data[2];
479  s->linesize[0][i] = frame->linesize[0];
480  s->linesize[1][i] = frame->linesize[1];
481  s->linesize[2][i] = frame->linesize[2];
482  }
483 
484  td.in = in; td.out = out;
485  ff_filter_execute(ctx, s->filter_slice, &td, NULL,
486  FFMIN3(s->planeheight[1],
487  s->planeheight[2],
490  } else {
491  out = av_frame_clone(in);
492  if (!out) {
493  av_frame_free(&buf);
494  return AVERROR(ENOMEM);
495  }
496  }
497 
498  in = ff_bufqueue_get(&s->q);
499  av_frame_free(&in);
500  ff_bufqueue_add(ctx, &s->q, buf);
501 
502  return ff_filter_frame(outlink, out);
503 }
504 
505 static int request_frame(AVFilterLink *outlink)
506 {
507  AVFilterContext *ctx = outlink->src;
508  ATADenoiseContext *s = ctx->priv;
509  int ret = 0;
510 
511  ret = ff_request_frame(ctx->inputs[0]);
512 
513  if (ret == AVERROR_EOF && !ctx->is_disabled && s->available) {
514  AVFrame *buf = av_frame_clone(ff_bufqueue_peek(&s->q, s->available));
515  if (!buf)
516  return AVERROR(ENOMEM);
517 
518  ret = filter_frame(ctx->inputs[0], buf);
519  s->available--;
520  }
521 
522  return ret;
523 }
524 
526 {
527  ATADenoiseContext *s = ctx->priv;
528 
530 }
531 
533  const char *cmd,
534  const char *arg,
535  char *res,
536  int res_len,
537  int flags)
538 {
539  int ret = ff_filter_process_command(ctx, cmd, arg, res, res_len, flags);
540 
541  if (ret < 0)
542  return ret;
543 
544  return config_input(ctx->inputs[0]);
545 }
546 
547 static const AVFilterPad inputs[] = {
548  {
549  .name = "default",
550  .type = AVMEDIA_TYPE_VIDEO,
551  .filter_frame = filter_frame,
552  .config_props = config_input,
553  },
554 };
555 
556 static const AVFilterPad outputs[] = {
557  {
558  .name = "default",
559  .type = AVMEDIA_TYPE_VIDEO,
560  .request_frame = request_frame,
561  },
562 };
563 
565  .name = "atadenoise",
566  .description = NULL_IF_CONFIG_SMALL("Apply an Adaptive Temporal Averaging Denoiser."),
567  .priv_size = sizeof(ATADenoiseContext),
568  .priv_class = &atadenoise_class,
569  .init = init,
570  .uninit = uninit,
575  .process_command = process_command,
576 };
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:116
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:546
FILTER_ROW
#define FILTER_ROW(type, name)
Definition: vf_atadenoise.c:237
ATADenoiseContext::available
int available
Definition: vf_atadenoise.c:61
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:525
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:215
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
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
WFILTER_ROW
#define WFILTER_ROW(type, name)
Definition: vf_atadenoise.c:140
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
out
FILE * out
Definition: movenc.c:55
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1061
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3170
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
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:162
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Definition: vf_atadenoise.c:532
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:538
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
pixdesc.h
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:545
w
uint8_t w
Definition: llviddspenc.c:38
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(atadenoise)
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:540
AVOption
AVOption.
Definition: opt.h:429
data
const char data[16]
Definition: mxf.c:149
planes
static const struct @467 planes[]
ff_atadenoise_init_x86
void ff_atadenoise_init_x86(ATADenoiseDSPContext *dsp, int depth, int algorithm, const float *sigma)
Definition: vf_atadenoise_init.c:37
expf
#define expf(x)
Definition: libm.h:283
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:502
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:475
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:526
video.h
ThreadData::in
AVFrame * in
Definition: af_adecorrelate.c:155
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: vf_atadenoise.c:505
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:541
ATADenoiseContext::planes
int planes
Definition: vf_atadenoise.c:50
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:482
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:410
ff_bufqueue_get
static AVFrame * ff_bufqueue_get(struct FFBufQueue *queue)
Get the first buffer from the queue and remove it.
Definition: bufferqueue.h:98
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
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_atadenoise.c:122
FILTER_ROW_SERIAL
#define FILTER_ROW_SERIAL(type, name)
Definition: vf_atadenoise.c:284
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:537
SIZE
#define SIZE
Definition: vf_atadenoise.c:40
ATADenoiseContext::radius
int radius
Definition: vf_atadenoise.c:60
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:520
FLAGS
#define FLAGS
Definition: vf_atadenoise.c:69
atadenoise_options
static const AVOption atadenoise_options[]
Definition: vf_atadenoise.c:72
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
Definition: mpeg12dec.c:1720
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:518
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:547
NB_ATAA
@ NB_ATAA
Definition: atadenoise.h:30
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:500
ATADenoiseContext::thrb
int thrb[4]
Definition: vf_atadenoise.c:47
ATADenoiseContext::weights
float weights[4][SIZE]
Definition: vf_atadenoise.c:59
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:486
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:505
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:283
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: vf_atadenoise.c:436
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:514
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:86
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:522
ff_vf_atadenoise
const AVFilter ff_vf_atadenoise
Definition: vf_atadenoise.c:564
av_image_fill_linesizes
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:89
s
#define s(width, name)
Definition: cbs_vp9.c:198
ATADenoiseContext::thra
int thra[4]
Definition: vf_atadenoise.c:47
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:523
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:108
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:515
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
filters.h
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:544
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:499
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:513
ctx
AVFormatContext * ctx
Definition: movenc.c:49
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:485
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:609
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:73
WFILTER_ROW_SERIAL
#define WFILTER_ROW_SERIAL(type, name)
Definition: vf_atadenoise.c:187
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
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:87
arg
const char * arg
Definition: jacosubdec.c:67
ATADenoiseContext::algorithm
int algorithm
Definition: vf_atadenoise.c:48
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:483
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:521
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
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:725
ATADenoiseContext::q
struct FFBufQueue q
Definition: vf_atadenoise.c:56
SERIAL
@ SERIAL
Definition: atadenoise.h:29
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:85
ff_bufqueue_discard_all
static void ff_bufqueue_discard_all(struct FFBufQueue *queue)
Unref and remove all buffers from the queue.
Definition: bufferqueue.h:111
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:504
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:503
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_atadenoise.c:525
ATADenoiseContext::nb_planes
int nb_planes
Definition: vf_atadenoise.c:51
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:517
OFFSET
#define OFFSET(x)
Definition: vf_atadenoise.c:68
ATADenoiseContext::fthra
float fthra[4]
Definition: vf_atadenoise.c:45
ATADenoiseContext::data
void * data[4][SIZE]
Definition: vf_atadenoise.c:57
bufferqueue.h
ATADenoiseContext
Definition: vf_atadenoise.c:42
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:94
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:507
size
int size
Definition: twinvq_data.h:10344
atadenoise.h
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:509
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:900
PARALLEL
@ PARALLEL
Definition: atadenoise.h:28
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:174
ATADenoiseContext::linesizes
int linesizes[4]
Definition: vf_atadenoise.c:54
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:542
ff_bufqueue_add
static void ff_bufqueue_add(void *log, struct FFBufQueue *queue, AVFrame *buf)
Add a buffer to the queue.
Definition: bufferqueue.h:71
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
ATADenoiseContext::planewidth
int planewidth[4]
Definition: vf_atadenoise.c:52
ATADenoiseContext::sigma
float sigma[4]
Definition: vf_atadenoise.c:46
ATADenoiseContext::mid
int mid
Definition: vf_atadenoise.c:60
ff_bufqueue_peek
static AVFrame * ff_bufqueue_peek(struct FFBufQueue *queue, unsigned index)
Get a buffer from the queue without altering it.
Definition: bufferqueue.h:87
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
FFMIN3
#define FFMIN3(a, b, c)
Definition: macros.h:50
FFBufQueue
Structure holding the queue.
Definition: bufferqueue.h:49
ATADenoiseContext::dsp
ATADenoiseDSPContext dsp
Definition: vf_atadenoise.c:65
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:519
weights
static const int weights[]
Definition: hevc_pel.c:32
pixel_fmts
static enum AVPixelFormat pixel_fmts[]
Definition: vf_atadenoise.c:92
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:840
ThreadData
Used for passing data between threads.
Definition: dsddec.c:71
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:107
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:501
slice_start
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition: dec.c:736
AVFilter
Filter definition.
Definition: avfilter.h:201
ret
ret
Definition: filter_design.txt:187
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
VF
#define VF
Definition: vf_atadenoise.c:70
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:539
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_atadenoise.c:381
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:506
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:511
ff_filter_execute
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: avfilter.c:1666
ATADenoiseContext::filter_slice
int(* filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_atadenoise.c:63
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:543
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
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:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
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:152
desc
const char * desc
Definition: libsvtav1.c:79
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:77
ATADenoiseContext::fthrb
float fthrb[4]
Definition: vf_atadenoise.c:45
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
ATADenoiseContext::size
int size
Definition: vf_atadenoise.c:60
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:80
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
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:190
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:434
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:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:508
h
h
Definition: vp9dsp_template.c:2070
ATADenoiseContext::planeheight
int planeheight[4]
Definition: vf_atadenoise.c:53
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:512
ATADenoiseContext::linesize
int linesize[4][SIZE]
Definition: vf_atadenoise.c:58
inputs
static const AVFilterPad inputs[]
Definition: vf_atadenoise.c:547
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:484
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
ATADenoiseDSPContext
Definition: atadenoise.h:33
filter_slice
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_atadenoise.c:334
src
#define src
Definition: vp8dsp.c:248
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:173
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:510
outputs
static const AVFilterPad outputs[]
Definition: vf_atadenoise.c:556