FFmpeg  3.4.9
vf_yadif.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2011 Michael Niedermayer <michaelni@gmx.at>
3  * 2010 James Darnley <james.darnley@gmail.com>
4 
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/avassert.h"
23 #include "libavutil/cpu.h"
24 #include "libavutil/common.h"
25 #include "libavutil/opt.h"
26 #include "libavutil/pixdesc.h"
27 #include "libavutil/imgutils.h"
28 #include "avfilter.h"
29 #include "formats.h"
30 #include "internal.h"
31 #include "video.h"
32 #include "yadif.h"
33 
34 typedef struct ThreadData {
35  AVFrame *frame;
36  int plane;
37  int w, h;
38  int parity;
39  int tff;
40 } ThreadData;
41 
42 #define CHECK(j)\
43  { int score = FFABS(cur[mrefs - 1 + (j)] - cur[prefs - 1 - (j)])\
44  + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\
45  + FFABS(cur[mrefs + 1 + (j)] - cur[prefs + 1 - (j)]);\
46  if (score < spatial_score) {\
47  spatial_score= score;\
48  spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\
49 
50 /* The is_not_edge argument here controls when the code will enter a branch
51  * which reads up to and including x-3 and x+3. */
52 
53 #define FILTER(start, end, is_not_edge) \
54  for (x = start; x < end; x++) { \
55  int c = cur[mrefs]; \
56  int d = (prev2[0] + next2[0])>>1; \
57  int e = cur[prefs]; \
58  int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
59  int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
60  int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
61  int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
62  int spatial_pred = (c+e) >> 1; \
63  \
64  if (is_not_edge) {\
65  int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
66  + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
67  CHECK(-1) CHECK(-2) }} }} \
68  CHECK( 1) CHECK( 2) }} }} \
69  }\
70  \
71  if (!(mode&2)) { \
72  int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
73  int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
74  int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
75  int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
76  \
77  diff = FFMAX3(diff, min, -max); \
78  } \
79  \
80  if (spatial_pred > d + diff) \
81  spatial_pred = d + diff; \
82  else if (spatial_pred < d - diff) \
83  spatial_pred = d - diff; \
84  \
85  dst[0] = spatial_pred; \
86  \
87  dst++; \
88  cur++; \
89  prev++; \
90  next++; \
91  prev2++; \
92  next2++; \
93  }
94 
95 static void filter_line_c(void *dst1,
96  void *prev1, void *cur1, void *next1,
97  int w, int prefs, int mrefs, int parity, int mode)
98 {
99  uint8_t *dst = dst1;
100  uint8_t *prev = prev1;
101  uint8_t *cur = cur1;
102  uint8_t *next = next1;
103  int x;
104  uint8_t *prev2 = parity ? prev : cur ;
105  uint8_t *next2 = parity ? cur : next;
106 
107  /* The function is called with the pointers already pointing to data[3] and
108  * with 6 subtracted from the width. This allows the FILTER macro to be
109  * called so that it processes all the pixels normally. A constant value of
110  * true for is_not_edge lets the compiler ignore the if statement. */
111  FILTER(0, w, 1)
112 }
113 
114 #define MAX_ALIGN 8
115 static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1,
116  int w, int prefs, int mrefs, int parity, int mode)
117 {
118  uint8_t *dst = dst1;
119  uint8_t *prev = prev1;
120  uint8_t *cur = cur1;
121  uint8_t *next = next1;
122  int x;
123  uint8_t *prev2 = parity ? prev : cur ;
124  uint8_t *next2 = parity ? cur : next;
125  int offset = FFMAX(w - (MAX_ALIGN-1), 3);
126 
127  /* Only edge pixels need to be processed here. A constant value of false
128  * for is_not_edge should let the compiler ignore the whole branch. */
129  FILTER(0, FFMIN(3, w), 0)
130 
131  dst = (uint8_t*)dst1 + offset;
132  prev = (uint8_t*)prev1 + offset;
133  cur = (uint8_t*)cur1 + offset;
134  next = (uint8_t*)next1 + offset;
135  prev2 = (uint8_t*)(parity ? prev : cur);
136  next2 = (uint8_t*)(parity ? cur : next);
137 
138  FILTER(offset, w - 3, 1)
139  offset = FFMAX(offset, w - 3);
140  FILTER(offset, w, 0)
141 }
142 
143 
144 static void filter_line_c_16bit(void *dst1,
145  void *prev1, void *cur1, void *next1,
146  int w, int prefs, int mrefs, int parity,
147  int mode)
148 {
149  uint16_t *dst = dst1;
150  uint16_t *prev = prev1;
151  uint16_t *cur = cur1;
152  uint16_t *next = next1;
153  int x;
154  uint16_t *prev2 = parity ? prev : cur ;
155  uint16_t *next2 = parity ? cur : next;
156  mrefs /= 2;
157  prefs /= 2;
158 
159  FILTER(0, w, 1)
160 }
161 
162 static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void *next1,
163  int w, int prefs, int mrefs, int parity, int mode)
164 {
165  uint16_t *dst = dst1;
166  uint16_t *prev = prev1;
167  uint16_t *cur = cur1;
168  uint16_t *next = next1;
169  int x;
170  uint16_t *prev2 = parity ? prev : cur ;
171  uint16_t *next2 = parity ? cur : next;
172  int offset = FFMAX(w - (MAX_ALIGN/2-1), 3);
173  mrefs /= 2;
174  prefs /= 2;
175 
176  FILTER(0, FFMIN(3, w), 0)
177 
178  dst = (uint16_t*)dst1 + offset;
179  prev = (uint16_t*)prev1 + offset;
180  cur = (uint16_t*)cur1 + offset;
181  next = (uint16_t*)next1 + offset;
182  prev2 = (uint16_t*)(parity ? prev : cur);
183  next2 = (uint16_t*)(parity ? cur : next);
184 
185  FILTER(offset, w - 3, 1)
186  offset = FFMAX(offset, w - 3);
187  FILTER(offset, w, 0)
188 }
189 
190 static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
191 {
192  YADIFContext *s = ctx->priv;
193  ThreadData *td = arg;
194  int refs = s->cur->linesize[td->plane];
195  int df = (s->csp->comp[td->plane].depth + 7) / 8;
196  int pix_3 = 3 * df;
197  int slice_start = (td->h * jobnr ) / nb_jobs;
198  int slice_end = (td->h * (jobnr+1)) / nb_jobs;
199  int y;
200 
201  /* filtering reads 3 pixels to the left/right; to avoid invalid reads,
202  * we need to call the c variant which avoids this for border pixels
203  */
204  for (y = slice_start; y < slice_end; y++) {
205  if ((y ^ td->parity) & 1) {
206  uint8_t *prev = &s->prev->data[td->plane][y * refs];
207  uint8_t *cur = &s->cur ->data[td->plane][y * refs];
208  uint8_t *next = &s->next->data[td->plane][y * refs];
209  uint8_t *dst = &td->frame->data[td->plane][y * td->frame->linesize[td->plane]];
210  int mode = y == 1 || y + 2 == td->h ? 2 : s->mode;
211  s->filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
212  next + pix_3, td->w - (3 + MAX_ALIGN/df-1),
213  y + 1 < td->h ? refs : -refs,
214  y ? -refs : refs,
215  td->parity ^ td->tff, mode);
216  s->filter_edges(dst, prev, cur, next, td->w,
217  y + 1 < td->h ? refs : -refs,
218  y ? -refs : refs,
219  td->parity ^ td->tff, mode);
220  } else {
221  memcpy(&td->frame->data[td->plane][y * td->frame->linesize[td->plane]],
222  &s->cur->data[td->plane][y * refs], td->w * df);
223  }
224  }
225  return 0;
226 }
227 
228 static void filter(AVFilterContext *ctx, AVFrame *dstpic,
229  int parity, int tff)
230 {
231  YADIFContext *yadif = ctx->priv;
232  ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff };
233  int i;
234 
235  for (i = 0; i < yadif->csp->nb_components; i++) {
236  int w = dstpic->width;
237  int h = dstpic->height;
238 
239  if (i == 1 || i == 2) {
240  w = AV_CEIL_RSHIFT(w, yadif->csp->log2_chroma_w);
241  h = AV_CEIL_RSHIFT(h, yadif->csp->log2_chroma_h);
242  }
243 
244 
245  td.w = w;
246  td.h = h;
247  td.plane = i;
248 
249  ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ff_filter_get_nb_threads(ctx)));
250  }
251 
252  emms_c();
253 }
254 
255 static int return_frame(AVFilterContext *ctx, int is_second)
256 {
257  YADIFContext *yadif = ctx->priv;
258  AVFilterLink *link = ctx->outputs[0];
259  int tff, ret;
260 
261  if (yadif->parity == -1) {
262  tff = yadif->cur->interlaced_frame ?
263  yadif->cur->top_field_first : 1;
264  } else {
265  tff = yadif->parity ^ 1;
266  }
267 
268  if (is_second) {
269  yadif->out = ff_get_video_buffer(link, link->w, link->h);
270  if (!yadif->out)
271  return AVERROR(ENOMEM);
272 
273  av_frame_copy_props(yadif->out, yadif->cur);
274  yadif->out->interlaced_frame = 0;
275  }
276 
277  filter(ctx, yadif->out, tff ^ !is_second, tff);
278 
279  if (is_second) {
280  int64_t cur_pts = yadif->cur->pts;
281  int64_t next_pts = yadif->next->pts;
282 
283  if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
284  yadif->out->pts = cur_pts + next_pts;
285  } else {
286  yadif->out->pts = AV_NOPTS_VALUE;
287  }
288  }
289  ret = ff_filter_frame(ctx->outputs[0], yadif->out);
290 
291  yadif->frame_pending = (yadif->mode&1) && !is_second;
292  return ret;
293 }
294 
295 static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
296 {
297  int i;
298  for (i = 0; i < yadif->csp->nb_components; i++)
299  if (a->linesize[i] != b->linesize[i])
300  return 1;
301  return 0;
302 }
303 
304 static void fixstride(AVFilterLink *link, AVFrame *f)
305 {
307  if(!dst)
308  return;
309  av_frame_copy_props(dst, f);
310  av_image_copy(dst->data, dst->linesize,
311  (const uint8_t **)f->data, f->linesize,
312  dst->format, dst->width, dst->height);
313  av_frame_unref(f);
314  av_frame_move_ref(f, dst);
315  av_frame_free(&dst);
316 }
317 
319 {
320  AVFilterContext *ctx = link->dst;
321  YADIFContext *yadif = ctx->priv;
322 
323  av_assert0(frame);
324 
325  if (yadif->frame_pending)
326  return_frame(ctx, 1);
327 
328  if (yadif->prev)
329  av_frame_free(&yadif->prev);
330  yadif->prev = yadif->cur;
331  yadif->cur = yadif->next;
332  yadif->next = frame;
333 
334  if (!yadif->cur &&
335  !(yadif->cur = av_frame_clone(yadif->next)))
336  return AVERROR(ENOMEM);
337 
338  if (checkstride(yadif, yadif->next, yadif->cur)) {
339  av_log(ctx, AV_LOG_VERBOSE, "Reallocating frame due to differing stride\n");
340  fixstride(link, yadif->next);
341  }
342  if (checkstride(yadif, yadif->next, yadif->cur))
343  fixstride(link, yadif->cur);
344  if (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))
345  fixstride(link, yadif->prev);
346  if (checkstride(yadif, yadif->next, yadif->cur) || (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))) {
347  av_log(ctx, AV_LOG_ERROR, "Failed to reallocate frame\n");
348  return -1;
349  }
350 
351  if (!yadif->prev)
352  return 0;
353 
354  if ((yadif->deint && !yadif->cur->interlaced_frame) ||
355  ctx->is_disabled ||
356  (yadif->deint && !yadif->prev->interlaced_frame && yadif->prev->repeat_pict) ||
357  (yadif->deint && !yadif->next->interlaced_frame && yadif->next->repeat_pict)
358  ) {
359  yadif->out = av_frame_clone(yadif->cur);
360  if (!yadif->out)
361  return AVERROR(ENOMEM);
362 
363  av_frame_free(&yadif->prev);
364  if (yadif->out->pts != AV_NOPTS_VALUE)
365  yadif->out->pts *= 2;
366  return ff_filter_frame(ctx->outputs[0], yadif->out);
367  }
368 
369  yadif->out = ff_get_video_buffer(ctx->outputs[0], link->w, link->h);
370  if (!yadif->out)
371  return AVERROR(ENOMEM);
372 
373  av_frame_copy_props(yadif->out, yadif->cur);
374  yadif->out->interlaced_frame = 0;
375 
376  if (yadif->out->pts != AV_NOPTS_VALUE)
377  yadif->out->pts *= 2;
378 
379  return return_frame(ctx, 0);
380 }
381 
382 static int request_frame(AVFilterLink *link)
383 {
384  AVFilterContext *ctx = link->src;
385  YADIFContext *yadif = ctx->priv;
386  int ret;
387 
388  if (yadif->frame_pending) {
389  return_frame(ctx, 1);
390  return 0;
391  }
392 
393  if (yadif->eof)
394  return AVERROR_EOF;
395 
396  ret = ff_request_frame(ctx->inputs[0]);
397 
398  if (ret == AVERROR_EOF && yadif->cur) {
399  AVFrame *next = av_frame_clone(yadif->next);
400 
401  if (!next)
402  return AVERROR(ENOMEM);
403 
404  next->pts = yadif->next->pts * 2 - yadif->cur->pts;
405 
406  filter_frame(ctx->inputs[0], next);
407  yadif->eof = 1;
408  } else if (ret < 0) {
409  return ret;
410  }
411 
412  return 0;
413 }
414 
416 {
417  YADIFContext *yadif = ctx->priv;
418 
419  av_frame_free(&yadif->prev);
420  av_frame_free(&yadif->cur );
421  av_frame_free(&yadif->next);
422 }
423 
425 {
426  static const enum AVPixelFormat pix_fmts[] = {
465  };
466 
467  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
468  if (!fmts_list)
469  return AVERROR(ENOMEM);
470  return ff_set_common_formats(ctx, fmts_list);
471 }
472 
473 static int config_props(AVFilterLink *link)
474 {
475  AVFilterContext *ctx = link->src;
476  YADIFContext *s = ctx->priv;
477 
478  link->time_base.num = ctx->inputs[0]->time_base.num;
479  link->time_base.den = ctx->inputs[0]->time_base.den * 2;
480  link->w = ctx->inputs[0]->w;
481  link->h = ctx->inputs[0]->h;
482 
483  if(s->mode & 1)
484  link->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate,
485  (AVRational){2, 1});
486 
487  if (link->w < 3 || link->h < 3) {
488  av_log(ctx, AV_LOG_ERROR, "Video of less than 3 columns or lines is not supported\n");
489  return AVERROR(EINVAL);
490  }
491 
492  s->csp = av_pix_fmt_desc_get(link->format);
493  if (s->csp->comp[0].depth > 8) {
496  } else {
499  }
500 
501  if (ARCH_X86)
503 
504  return 0;
505 }
506 
507 
508 #define OFFSET(x) offsetof(YADIFContext, x)
509 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
510 
511 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
512 
513 static const AVOption yadif_options[] = {
514  { "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=YADIF_MODE_SEND_FRAME}, 0, 3, FLAGS, "mode"},
515  CONST("send_frame", "send one frame for each frame", YADIF_MODE_SEND_FRAME, "mode"),
516  CONST("send_field", "send one frame for each field", YADIF_MODE_SEND_FIELD, "mode"),
517  CONST("send_frame_nospatial", "send one frame for each frame, but skip spatial interlacing check", YADIF_MODE_SEND_FRAME_NOSPATIAL, "mode"),
518  CONST("send_field_nospatial", "send one frame for each field, but skip spatial interlacing check", YADIF_MODE_SEND_FIELD_NOSPATIAL, "mode"),
519 
520  { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=YADIF_PARITY_AUTO}, -1, 1, FLAGS, "parity" },
521  CONST("tff", "assume top field first", YADIF_PARITY_TFF, "parity"),
522  CONST("bff", "assume bottom field first", YADIF_PARITY_BFF, "parity"),
523  CONST("auto", "auto detect parity", YADIF_PARITY_AUTO, "parity"),
524 
525  { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=YADIF_DEINT_ALL}, 0, 1, FLAGS, "deint" },
526  CONST("all", "deinterlace all frames", YADIF_DEINT_ALL, "deint"),
527  CONST("interlaced", "only deinterlace frames marked as interlaced", YADIF_DEINT_INTERLACED, "deint"),
528 
529  { NULL }
530 };
531 
532 AVFILTER_DEFINE_CLASS(yadif);
533 
535  {
536  .name = "default",
537  .type = AVMEDIA_TYPE_VIDEO,
538  .filter_frame = filter_frame,
539  },
540  { NULL }
541 };
542 
544  {
545  .name = "default",
546  .type = AVMEDIA_TYPE_VIDEO,
547  .request_frame = request_frame,
548  .config_props = config_props,
549  },
550  { NULL }
551 };
552 
554  .name = "yadif",
555  .description = NULL_IF_CONFIG_SMALL("Deinterlace the input image."),
556  .priv_size = sizeof(YADIFContext),
557  .priv_class = &yadif_class,
558  .uninit = uninit,
560  .inputs = avfilter_vf_yadif_inputs,
561  .outputs = avfilter_vf_yadif_outputs,
563 };
#define NULL
Definition: coverity.c:32
static const AVFilterPad avfilter_vf_yadif_inputs[]
Definition: vf_yadif.c:534
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2419
This structure describes decoded (raw) audio or video data.
Definition: frame.h:201
AVOption.
Definition: opt.h:246
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:393
#define MAX_ALIGN
Definition: vf_yadif.c:114
int tff
Definition: vf_bwdif.c:57
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
misc image utilities
AVFrame * frame
Definition: vf_bwdif.c:53
Main libavfilter public API header.
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:184
int num
Numerator.
Definition: rational.h:59
int repeat_pict
When decoding, this signals how much the picture must be delayed.
Definition: frame.h:343
const char * b
Definition: vf_curves.c:113
send 1 frame for each frame but skips spatial interlacing check
Definition: yadif.h:28
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:399
int frame_pending
Definition: yadif.h:50
static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
Definition: vf_yadif.c:295
static void fixstride(AVFilterLink *link, AVFrame *f)
Definition: vf_yadif.c:304
static void filter_line_c(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
Definition: vf_yadif.c:95
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:387
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition: frame.c:531
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:92
int is_disabled
the enabled state from the last expression evaluation
Definition: avfilter.h:385
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
const char * name
Pad name.
Definition: internal.h:60
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:346
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1151
static int request_frame(AVFilterLink *link)
Definition: vf_yadif.c:382
AVFrame * cur
Definition: yadif.h:52
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:106
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
#define av_cold
Definition: attributes.h:82
AVOptions.
#define emms_c()
Definition: internal.h:54
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:294
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:398
AVFrame * next
Definition: yadif.h:53
bottom field first
Definition: yadif.h:34
int plane
Definition: vf_blend.c:57
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:105
static int flags
Definition: log.c:57
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
#define AVERROR_EOF
End of file.
Definition: error.h:55
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
static void filter(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
Definition: vf_yadif.c:228
static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
Definition: vf_yadif.c:115
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:396
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:348
send 1 frame for each field
Definition: yadif.h:27
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:388
AVFrame * prev
Definition: yadif.h:54
#define av_log(a,...)
A filter pad used for either input or output.
Definition: internal.h:54
auto detection
Definition: yadif.h:35
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:192
int width
Definition: frame.h:259
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:568
#define td
Definition: regdef.h:70
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
int deint
YADIFDeint.
Definition: yadif.h:48
#define ARCH_X86
Definition: config.h:38
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:163
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:181
void * priv
private data for use by the filter
Definition: avfilter.h:353
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
int parity
Definition: vf_bwdif.c:56
const char * arg
Definition: jacosubdec.c:66
simple assert() macros that are a bit more flexible than ISO C assert().
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:386
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_yadif.c:190
static const uint8_t offset[127][2]
Definition: vf_spp.c:92
static int query_formats(AVFilterContext *ctx)
Definition: vf_yadif.c:424
#define OFFSET(x)
Definition: vf_yadif.c:508
#define FFMAX(a, b)
Definition: common.h:94
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
Definition: imgutils.c:385
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
void(* filter_edges)(void *dst, void *prev, void *cur, void *next, int w, int prefs, int mrefs, int parity, int mode)
Definition: yadif.h:63
static const AVFilterPad avfilter_vf_yadif_outputs[]
Definition: vf_yadif.c:543
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:381
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:83
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:402
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:857
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:367
#define FFMIN(a, b)
Definition: common.h:96
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
AVFormatContext * ctx
Definition: movenc.c:48
static int config_props(AVFilterLink *link)
Definition: vf_yadif.c:473
AVFilter ff_vf_yadif
Definition: vf_yadif.c:553
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:389
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:382
int eof
Definition: yadif.h:67
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:401
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:492
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:394
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:274
AVFrame * dst
Definition: vf_blend.c:55
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:379
static const AVOption yadif_options[]
Definition: vf_yadif.c:513
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:391
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:232
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:193
AVFrame * out
Definition: yadif.h:55
AVFrame * cur
Definition: vf_w3fdif.c:339
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:383
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
Filter definition.
Definition: avfilter.h:144
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: vf_yadif.c:318
Rational number (pair of numerator and denominator).
Definition: rational.h:58
int parity
YADIFParity.
Definition: yadif.h:47
send 1 frame for each field but skips spatial interlacing check
Definition: yadif.h:29
const char * name
Filter name.
Definition: avfilter.h:148
AVFILTER_DEFINE_CLASS(yadif)
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:380
#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:133
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:392
void(* filter_line)(void *dst, void *prev, void *cur, void *next, int w, int prefs, int mrefs, int parity, int mode)
Required alignment for filter_line.
Definition: yadif.h:60
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:400
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:505
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:378
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:384
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:390
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:215
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:44
const AVPixFmtDescriptor * csp
Definition: yadif.h:66
#define FILTER(start, end, is_not_edge)
Definition: vf_yadif.c:53
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
Y , 8bpp.
Definition: pixfmt.h:74
common internal and external API header
#define FLAGS
Definition: vf_yadif.c:509
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:233
static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
Definition: vf_yadif.c:162
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
int den
Denominator.
Definition: rational.h:60
avfilter_execute_func * execute
Definition: internal.h:155
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2051
deinterlace all frames
Definition: yadif.h:39
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_yadif.c:415
int top_field_first
If the content is interlaced, is top field displayed first.
Definition: frame.h:353
av_cold void ff_yadif_init_x86(YADIFContext *yadif)
Definition: vf_yadif_init.c:60
send 1 frame for each frame
Definition: yadif.h:26
A list of supported formats for one end of a filter link.
Definition: formats.h:64
#define CONST(name, help, val, unit)
Definition: vf_yadif.c:511
An instance of a filter.
Definition: avfilter.h:338
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
int height
Definition: frame.h:259
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:104
static int return_frame(AVFilterContext *ctx, int is_second)
Definition: vf_yadif.c:255
#define df(A, B)
Definition: vf_xbr.c:90
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:405
internal API functions
int depth
Number of bits in the component.
Definition: pixdesc.h:58
only deinterlace frames marked as interlaced
Definition: yadif.h:40
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
top field first
Definition: yadif.h:33
mode
Use these values in ebur128_init (or&#39;ed).
Definition: ebur128.h:83
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:395
int mode
YADIFMode.
Definition: yadif.h:46
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:603
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
static void filter_line_c_16bit(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
Definition: vf_yadif.c:144
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58