FFmpeg
vf_estdif.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 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 #include "libavutil/common.h"
22 #include "libavutil/imgutils.h"
23 #include "libavutil/opt.h"
24 #include "libavutil/pixdesc.h"
25 #include "avfilter.h"
26 #include "formats.h"
27 #include "internal.h"
28 #include "video.h"
29 
30 typedef struct ESTDIFContext {
31  const AVClass *class;
32 
33  int mode; ///< 0 is frame, 1 is field
34  int parity; ///< frame field parity
35  int deint; ///< which frames to deinterlace
36  int rslope; ///< best edge slope search radius
37  int redge; ///< best edge match search radius
38  int interp; ///< type of interpolation
39  int linesize[4]; ///< bytes of pixel data per line for each plane
40  int planewidth[4]; ///< width of each plane
41  int planeheight[4]; ///< height of each plane
42  int field; ///< which field are we on, 0 or 1
43  int eof;
44  int depth;
45  int half;
46  int nb_planes;
48  int64_t pts;
50 
51  void (*interpolate)(struct ESTDIFContext *s, uint8_t *dst,
52  const uint8_t *prev_line, const uint8_t *next_line,
53  const uint8_t *prev2_line, const uint8_t *next2_line,
54  const uint8_t *prev3_line, const uint8_t *next3_line,
55  int x, int width, int rslope, int redge, unsigned half,
56  int depth, int *K);
57 
58  unsigned (*mid_8[3])(const uint8_t *const prev,
59  const uint8_t *const next,
60  const uint8_t *const prev2,
61  const uint8_t *const next2,
62  const uint8_t *const prev3,
63  const uint8_t *const next3,
64  int end, int x, int k, int depth);
65 
66  unsigned (*mid_16[3])(const uint16_t *const prev,
67  const uint16_t *const next,
68  const uint16_t *const prev2,
69  const uint16_t *const next2,
70  const uint16_t *const prev3,
71  const uint16_t *const next3,
72  int end, int x, int k, int depth);
74 
75 #define MAX_R 15
76 #define S (MAX_R * 2 + 1)
77 
78 #define OFFSET(x) offsetof(ESTDIFContext, x)
79 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
80 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
81 
82 static const AVOption estdif_options[] = {
83  { "mode", "specify the mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "mode" },
84  CONST("frame", "send one frame for each frame", 0, "mode"),
85  CONST("field", "send one frame for each field", 1, "mode"),
86  { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=-1}, -1, 1, FLAGS, "parity" },
87  CONST("tff", "assume top field first", 0, "parity"),
88  CONST("bff", "assume bottom field first", 1, "parity"),
89  CONST("auto", "auto detect parity", -1, "parity"),
90  { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" },
91  CONST("all", "deinterlace all frames", 0, "deint"),
92  CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"),
93  { "rslope", "specify the search radius for edge slope tracing", OFFSET(rslope), AV_OPT_TYPE_INT, {.i64=1}, 1, MAX_R, FLAGS, },
94  { "redge", "specify the search radius for best edge matching", OFFSET(redge), AV_OPT_TYPE_INT, {.i64=2}, 0, MAX_R, FLAGS, },
95  { "interp", "specify the type of interpolation", OFFSET(interp), AV_OPT_TYPE_INT, {.i64=1}, 0, 2, FLAGS, "interp" },
96  CONST("2p", "two-point interpolation", 0, "interp"),
97  CONST("4p", "four-point interpolation", 1, "interp"),
98  CONST("6p", "six-point interpolation", 2, "interp"),
99  { NULL }
100 };
101 
102 AVFILTER_DEFINE_CLASS(estdif);
103 
104 static const enum AVPixelFormat pix_fmts[] = {
128 };
129 
130 static int config_output(AVFilterLink *outlink)
131 {
132  AVFilterContext *ctx = outlink->src;
133  AVFilterLink *inlink = ctx->inputs[0];
134 
135  outlink->time_base = av_mul_q(inlink->time_base, (AVRational){1, 2});
136  outlink->frame_rate = av_mul_q(inlink->frame_rate, (AVRational){2, 1});
137 
138  return 0;
139 }
140 
141 typedef struct ThreadData {
142  AVFrame *out, *in;
143 } ThreadData;
144 
145 #define MIDL(type, ss) \
146 static unsigned midl_##ss(const type *const prev, \
147  const type *const next, \
148  int end, int x, int k) \
149 { \
150  return (prev[av_clip(x + k, 0, end)] + \
151  next[av_clip(x - k, 0, end)] + 1) >> 1; \
152 }
153 
154 MIDL(uint8_t, 8)
155 MIDL(uint16_t, 16)
156 
157 #define MID2(type, ss) \
158 static unsigned mid2_##ss(const type *const prev, \
159  const type *const next, \
160  const type *const prev2, \
161  const type *const next2, \
162  const type *const prev3, \
163  const type *const next3, \
164  int end, int x, int k, int depth) \
165 { \
166  return (prev[av_clip(x + k, 0, end)] + \
167  next[av_clip(x - k, 0, end)] + 1) >> 1; \
168 }
169 
170 MID2(uint8_t, 8)
171 MID2(uint16_t, 16)
172 
173 #define MID4(type, ss) \
174 static unsigned mid4_##ss(const type *const prev, \
175  const type *const next, \
176  const type *const prev2, \
177  const type *const next2, \
178  const type *const prev3, \
179  const type *const next3, \
180  int end, int x, int k, int depth) \
181 { \
182  return av_clip_uintp2_c(( \
183  9 * (prev[av_clip(x + k, 0, end)] + \
184  next[av_clip(x - k, 0, end)]) - \
185  1 * (prev2[av_clip(x + k*3, 0, end)] + \
186  next2[av_clip(x - k*3, 0, end)]) + 8) >> 4, \
187  depth); \
188 }
189 
190 MID4(uint8_t, 8)
191 MID4(uint16_t, 16)
192 
193 #define MID6(type, ss) \
194 static unsigned mid6_##ss(const type *const prev, \
195  const type *const next, \
196  const type *const prev2, \
197  const type *const next2, \
198  const type *const prev3, \
199  const type *const next3, \
200  int end, int x, int k, int depth) \
201 { \
202  return av_clip_uintp2_c(( \
203  20 * (prev[av_clip(x + k, 0, end)] + \
204  next[av_clip(x - k, 0, end)]) - \
205  5 * (prev2[av_clip(x + k*3, 0, end)] + \
206  next2[av_clip(x - k*3, 0, end)]) + \
207  1 * (prev3[av_clip(x + k*5, 0, end)] + \
208  next3[av_clip(x - k*5, 0, end)]) + 16) >> 5, \
209  depth); \
210 }
211 
212 MID6(uint8_t, 8)
213 MID6(uint16_t, 16)
214 
215 #define DIFF(type, ss) \
216 static unsigned diff_##ss(const type *const prev, \
217  const type *const next, \
218  int end, int x, int k, int j) \
219 { \
220  return FFABS(prev[av_clip(x + k + j, 0, end)] - \
221  next[av_clip(x - k + j, 0, end)]); \
222 }
223 
224 DIFF(uint8_t, 8)
225 DIFF(uint16_t, 16)
226 
227 #define COST(type, ss) \
228 static unsigned cost_##ss(const type *const prev, \
229  const type *const next, \
230  int end, int x, int k) \
231 { \
232  const int m = midl_##ss(prev, next, end, x, k); \
233  const int p = prev[x]; \
234  const int n = next[x]; \
235  \
236  return FFABS(p - m) + FFABS(n - m); \
237 }
238 
239 COST(uint8_t, 8)
240 COST(uint16_t, 16)
241 
242 #define INTERPOLATE(type, atype, max, ss) \
243 static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \
244  const uint8_t *const pprev_line, \
245  const uint8_t *const nnext_line, \
246  const uint8_t *const pprev2_line, \
247  const uint8_t *const nnext2_line, \
248  const uint8_t *const pprev3_line, \
249  const uint8_t *const nnext3_line, \
250  int x, int width, int rslope, \
251  int redge, unsigned h, int depth, \
252  int *K) \
253 { \
254  type *dst = (type *)ddst; \
255  const type *const prev_line = (const type *const)pprev_line; \
256  const type *const prev2_line = (const type *const)pprev2_line; \
257  const type *const prev3_line = (const type *const)pprev3_line; \
258  const type *const next_line = (const type *const)nnext_line; \
259  const type *const next2_line = (const type *const)nnext2_line; \
260  const type *const next3_line = (const type *const)nnext3_line; \
261  const int interp = s->interp; \
262  const int end = width - 1; \
263  const atype f = redge + 2; \
264  atype sd[S], sD[S], di = 0; \
265  atype dmin = max; \
266  int k = *K; \
267  \
268  for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) { \
269  atype sum = 0; \
270  \
271  for (int j = -redge; j <= redge; j++) { \
272  sum += diff_##ss(prev_line, next_line, end, x, i, j); \
273  sum += diff_##ss(prev2_line, prev_line, end, x, i, j); \
274  sum += diff_##ss(next_line, next2_line, end, x, i, j); \
275  } \
276  \
277  sD[i + rslope] = sum; \
278  sD[i + rslope] += f * cost_##ss(prev_line, next_line, end, x, i); \
279  sD[i + rslope] += h * abs(i); \
280  \
281  dmin = FFMIN(sD[i + rslope], dmin); \
282  } \
283  \
284  for (int i = -rslope; i <= rslope; i++) { \
285  atype sum = 0; \
286  \
287  for (int j = -redge; j <= redge; j++) { \
288  sum += diff_##ss(prev_line, next_line, end, x, k + i, j); \
289  sum += diff_##ss(prev2_line, prev_line, end, x, k + i, j); \
290  sum += diff_##ss(next_line, next2_line, end, x, k + i, j); \
291  } \
292  \
293  sd[i + rslope] = sum; \
294  sd[i + rslope] += f * cost_##ss(prev_line, next_line, end, x, k + i); \
295  sd[i + rslope] += h * abs(k + i); \
296  \
297  dmin = FFMIN(sd[i + rslope], dmin); \
298  } \
299  \
300  for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) { \
301  if (dmin == sD[i + rslope]) { \
302  di = 1; \
303  k = i; \
304  break; \
305  } \
306  } \
307  \
308  for (int i = -rslope; i <= rslope && !di; i++) { \
309  if (dmin == sd[i + rslope]) { \
310  k += i; \
311  break; \
312  } \
313  } \
314  \
315  dst[x] = s->mid_##ss[interp](prev_line, next_line, \
316  prev2_line, next2_line, \
317  prev3_line, next3_line, \
318  end, x, k, depth); \
319  \
320  *K = k; \
321 }
322 
323 INTERPOLATE(uint8_t, unsigned, UINT_MAX, 8)
324 INTERPOLATE(uint16_t, uint64_t, UINT64_MAX, 16)
325 
327  int jobnr, int nb_jobs)
328 {
329  ESTDIFContext *s = ctx->priv;
330  ThreadData *td = arg;
331  AVFrame *out = td->out;
332  AVFrame *in = td->in;
333  const int rslope = s->rslope;
334  const int redge = s->redge;
335  const int half = s->half;
336  const int depth = s->depth;
337  const int interlaced = in->interlaced_frame;
338  const int tff = (s->field == (s->parity == -1 ? interlaced ? in->top_field_first : 1 :
339  s->parity ^ 1));
340 
341  for (int plane = 0; plane < s->nb_planes; plane++) {
342  const uint8_t *src_data = in->data[plane];
343  uint8_t *dst_data = out->data[plane];
344  const int linesize = s->linesize[plane];
345  const int width = s->planewidth[plane];
346  const int height = s->planeheight[plane];
347  const int src_linesize = in->linesize[plane];
348  const int dst_linesize = out->linesize[plane];
349  const int start = (height * jobnr) / nb_jobs;
350  const int end = (height * (jobnr+1)) / nb_jobs;
351  const uint8_t *prev_line, *prev2_line, *next_line, *next2_line, *in_line;
352  const uint8_t *prev3_line, *next3_line;
353  uint8_t *out_line;
354  int y_out;
355 
356  y_out = start + (tff ^ (start & 1));
357 
358  in_line = src_data + (y_out * src_linesize);
359  out_line = dst_data + (y_out * dst_linesize);
360 
361  while (y_out < end) {
362  memcpy(out_line, in_line, linesize);
363  y_out += 2;
364  in_line += src_linesize * 2;
365  out_line += dst_linesize * 2;
366  }
367 
368  y_out = start + ((!tff) ^ (start & 1));
369  out_line = dst_data + (y_out * dst_linesize);
370 
371  for (int y = y_out; y < end; y += 2) {
372  int y_prev3_in = y - 5;
373  int y_next3_in = y + 5;
374  int y_prev2_in = y - 3;
375  int y_next2_in = y + 3;
376  int y_prev_in = y - 1;
377  int y_next_in = y + 1;
378  int k;
379 
380  while (y_prev3_in < 0)
381  y_prev3_in += 2;
382 
383  while (y_next3_in >= height)
384  y_next3_in -= 2;
385 
386  while (y_prev2_in < 0)
387  y_prev2_in += 2;
388 
389  while (y_next2_in >= height)
390  y_next2_in -= 2;
391 
392  while (y_prev_in < 0)
393  y_prev_in += 2;
394 
395  while (y_next_in >= height)
396  y_next_in -= 2;
397 
398  prev3_line = src_data + (y_prev3_in * src_linesize);
399  next3_line = src_data + (y_next3_in * src_linesize);
400 
401  prev2_line = src_data + (y_prev2_in * src_linesize);
402  next2_line = src_data + (y_next2_in * src_linesize);
403 
404  prev_line = src_data + (y_prev_in * src_linesize);
405  next_line = src_data + (y_next_in * src_linesize);
406 
407  k = 0;
408 
409  for (int x = 0; x < width; x++) {
410  s->interpolate(s, out_line,
411  prev_line, next_line,
412  prev2_line, next2_line,
413  prev3_line, next3_line,
414  x, width, rslope, redge, half, depth, &k);
415  }
416 
417  out_line += 2 * dst_linesize;
418  }
419  }
420 
421  return 0;
422 }
423 
424 static int filter(AVFilterContext *ctx, int is_second, AVFrame *in)
425 {
426  ESTDIFContext *s = ctx->priv;
427  AVFilterLink *outlink = ctx->outputs[0];
428  AVFrame *out;
429  ThreadData td;
430 
431  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
432  if (!out)
433  return AVERROR(ENOMEM);
435  out->interlaced_frame = 0;
436  out->pts = s->pts;
437 
438  td.out = out; td.in = in;
440  FFMIN(s->planeheight[1] / 2, s->nb_threads));
441 
442  if (s->mode)
443  s->field = !s->field;
444 
445  return ff_filter_frame(outlink, out);
446 }
447 
449 {
450  AVFilterContext *ctx = inlink->dst;
451  ESTDIFContext *s = ctx->priv;
453  int ret;
454 
455  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
456  return ret;
457 
458  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
459  s->planeheight[0] = s->planeheight[3] = inlink->h;
460  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
461  s->planewidth[0] = s->planewidth[3] = inlink->w;
462 
463  if (inlink->h < 3) {
464  av_log(ctx, AV_LOG_ERROR, "Video of less than 3 lines is not supported\n");
465  return AVERROR(EINVAL);
466  }
467 
468  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
469  s->nb_threads = ff_filter_get_nb_threads(ctx);
470  s->depth = desc->comp[0].depth;
471  s->interpolate = s->depth <= 8 ? interpolate_8 : interpolate_16;
472  s->mid_8[0] = mid2_8;
473  s->mid_8[1] = mid4_8;
474  s->mid_8[2] = mid6_8;
475  s->mid_16[0] = mid2_16;
476  s->mid_16[1] = mid4_16;
477  s->mid_16[2] = mid6_16;
478  s->half = 1 << (s->depth - 1);
479 
480  return 0;
481 }
483 {
484  AVFilterContext *ctx = inlink->dst;
485  ESTDIFContext *s = ctx->priv;
486  int ret;
487 
488  if (!s->prev) {
489  s->prev = in;
490  return 0;
491  }
492 
493  if ((s->deint && !s->prev->interlaced_frame) || ctx->is_disabled) {
494  s->prev->pts *= 2;
495  ret = ff_filter_frame(ctx->outputs[0], s->prev);
496  s->prev = in;
497  return ret;
498  }
499 
500  s->pts = s->prev->pts * 2;
501  ret = filter(ctx, 0, s->prev);
502  if (ret < 0 || s->mode == 0) {
503  av_frame_free(&s->prev);
504  s->prev = in;
505  return ret;
506  }
507 
508  s->pts = s->prev->pts + in->pts;
509  ret = filter(ctx, 1, s->prev);
510  av_frame_free(&s->prev);
511  s->prev = in;
512  return ret;
513 }
514 
516 {
517  AVFilterContext *ctx = link->src;
518  ESTDIFContext *s = ctx->priv;
519  int ret;
520 
521  if (s->eof)
522  return AVERROR_EOF;
523 
524  ret = ff_request_frame(ctx->inputs[0]);
525 
526  if (ret == AVERROR_EOF && s->prev) {
527  AVFrame *next = av_frame_clone(s->prev);
528 
529  if (!next)
530  return AVERROR(ENOMEM);
531 
532  next->pts = s->prev->pts + av_rescale_q(1, av_inv_q(ctx->outputs[0]->frame_rate),
533  ctx->outputs[0]->time_base);
534  s->eof = 1;
535  ret = filter_frame(ctx->inputs[0], next);
536  } else if (ret < 0) {
537  return ret;
538  }
539 
540  return ret;
541 }
542 
544 {
545  ESTDIFContext *s = ctx->priv;
546 
547  av_frame_free(&s->prev);
548 }
549 
550 static const AVFilterPad estdif_inputs[] = {
551  {
552  .name = "default",
553  .type = AVMEDIA_TYPE_VIDEO,
554  .filter_frame = filter_frame,
555  .config_props = config_input,
556  },
557 };
558 
559 static const AVFilterPad estdif_outputs[] = {
560  {
561  .name = "default",
562  .type = AVMEDIA_TYPE_VIDEO,
563  .config_props = config_output,
564  .request_frame = request_frame,
565  },
566 };
567 
569  .name = "estdif",
570  .description = NULL_IF_CONFIG_SMALL("Apply Edge Slope Tracing deinterlace."),
571  .priv_size = sizeof(ESTDIFContext),
572  .priv_class = &estdif_class,
573  .uninit = uninit,
578  .process_command = ff_filter_process_command,
579 };
ESTDIFContext::nb_planes
int nb_planes
Definition: vf_estdif.c:46
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
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:413
td
#define td
Definition: regdef.h:70
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
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
MID6
#define MID6(type, ss)
Definition: vf_estdif.c:193
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
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
deinterlace_slice
static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_estdif.c:326
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
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
estdif_inputs
static const AVFilterPad estdif_inputs[]
Definition: vf_estdif.c:550
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
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
ESTDIFContext::parity
int parity
frame field parity
Definition: vf_estdif.c:34
pixdesc.h
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:396
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:433
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:428
AVFrame::top_field_first
int top_field_first
If the content is interlaced, is top field displayed first.
Definition: frame.h:438
AVOption
AVOption.
Definition: opt.h:247
ESTDIFContext::mid_16
unsigned(* mid_16[3])(const uint16_t *const prev, const uint16_t *const next, const uint16_t *const prev2, const uint16_t *const next2, const uint16_t *const prev3, const uint16_t *const next3, int end, int x, int k, int depth)
Definition: vf_estdif.c:66
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_estdif.c:482
half
static uint8_t half(int a, int b)
Definition: mobiclip.c:541
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:391
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
MIDL
#define MIDL(type, ss)
Definition: vf_estdif.c:145
DIFF
#define DIFF(type, ss)
Definition: vf_estdif.c:215
ESTDIFContext::deint
int deint
which frames to deinterlace
Definition: vf_estdif.c:35
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:153
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:473
video.h
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
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:317
formats.h
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
MID4
#define MID4(type, ss)
Definition: vf_estdif.c:173
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:409
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_estdif.c:104
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:407
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_estdif.c:130
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
ESTDIFContext::interpolate
void(* interpolate)(struct ESTDIFContext *s, uint8_t *dst, const uint8_t *prev_line, const uint8_t *next_line, const uint8_t *prev2_line, const uint8_t *next2_line, const uint8_t *prev3_line, const uint8_t *next3_line, int x, int width, int rslope, int redge, unsigned half, int depth, int *K)
Definition: vf_estdif.c:51
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:375
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_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:403
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
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: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
ESTDIFContext::field
int field
which field are we on, 0 or 1
Definition: vf_estdif.c:42
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_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
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:141
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:191
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_estdif.c:448
link
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 link
Definition: filter_design.txt:23
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
ESTDIFContext::mode
int mode
0 is frame, 1 is field
Definition: vf_estdif.c:33
arg
const char * arg
Definition: jacosubdec.c:67
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:372
ESTDIFContext::interp
int interp
type of interpolation
Definition: vf_estdif.c:38
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:410
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
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
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
ESTDIFContext::eof
int eof
Definition: vf_estdif.c:43
MID2
#define MID2(type, ss)
Definition: vf_estdif.c:157
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:393
COST
#define COST(type, ss)
Definition: vf_estdif.c:227
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_estdif.c:543
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
estdif_outputs
static const AVFilterPad estdif_outputs[]
Definition: vf_estdif.c:559
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:406
ESTDIFContext::linesize
int linesize[4]
bytes of pixel data per line for each plane
Definition: vf_estdif.c:39
FLAGS
#define FLAGS
Definition: vf_estdif.c:79
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
ESTDIFContext::mid_8
unsigned(* mid_8[3])(const uint8_t *const prev, const uint8_t *const next, const uint8_t *const prev2, const uint8_t *const next2, const uint8_t *const prev3, const uint8_t *const next3, int end, int x, int k, int depth)
Definition: vf_estdif.c:58
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:396
parity
mcdeint parity
Definition: vf_mcdeint.c:266
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:398
ESTDIFContext
Definition: vf_estdif.c:30
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
ESTDIFContext::depth
int depth
Definition: vf_estdif.c:44
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:430
OFFSET
#define OFFSET(x)
Definition: vf_estdif.c:78
internal.h
AVFrame::interlaced_frame
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:433
interlaced
uint8_t interlaced
Definition: mxfenc.c:2207
ff_vf_estdif
const AVFilter ff_vf_estdif
Definition: vf_estdif.c:568
ESTDIFContext::planeheight
int planeheight[4]
height of each plane
Definition: vf_estdif.c:41
MAX_R
#define MAX_R
Definition: vf_estdif.c:75
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:408
common.h
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
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
CONST
#define CONST(name, help, val, unit)
Definition: vf_estdif.c:80
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
ESTDIFContext::half
int half
Definition: vf_estdif.c:45
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:390
AVFilter
Filter definition.
Definition: avfilter.h:149
estdif_options
static const AVOption estdif_options[]
Definition: vf_estdif.c:82
ret
ret
Definition: filter_design.txt:187
ESTDIFContext::nb_threads
int nb_threads
Definition: vf_estdif.c:47
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:427
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:395
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:400
request_frame
static int request_frame(AVFilterLink *link)
Definition: vf_estdif.c:515
mode
mode
Definition: ebur128.h:83
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
avfilter.h
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
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
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
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
INTERPOLATE
#define INTERPOLATE(type, atype, max, ss)
Definition: vf_estdif.c:242
ThreadData::in
AVFrame * in
Definition: af_adecorrelate.c:154
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
ESTDIFContext::prev
AVFrame * prev
Definition: vf_estdif.c:49
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
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
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(estdif)
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:334
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
filter
static int filter(AVFilterContext *ctx, int is_second, AVFrame *in)
Definition: vf_estdif.c:424
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
ESTDIFContext::redge
int redge
best edge match search radius
Definition: vf_estdif.c:37
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:397
ESTDIFContext::planewidth
int planewidth[4]
width of each plane
Definition: vf_estdif.c:40
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:401
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
ESTDIFContext::pts
int64_t pts
Definition: vf_estdif.c:48
ESTDIFContext::rslope
int rslope
best edge slope search radius
Definition: vf_estdif.c:36
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