Libav
vf_yadif.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2010 Michael Niedermayer <michaelni@gmx.at>
3  * 2010 James Darnley <james.darnley@gmail.com>
4  *
5  * This file is part of Libav.
6  *
7  * Libav 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  * Libav 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 Libav; 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/cpu.h"
23 #include "libavutil/common.h"
24 #include "libavutil/opt.h"
25 #include "libavutil/pixdesc.h"
26 #include "avfilter.h"
27 #include "formats.h"
28 #include "internal.h"
29 #include "video.h"
30 #include "yadif.h"
31 
32 #undef NDEBUG
33 #include <assert.h>
34 
35 typedef struct ThreadData {
37  int plane;
38  int w, h;
39  int parity;
40  int tff;
41 } ThreadData;
42 
43 #define CHECK(j)\
44  { int score = FFABS(cur[mrefs - 1 + (j)] - cur[prefs - 1 - (j)])\
45  + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\
46  + FFABS(cur[mrefs + 1 + (j)] - cur[prefs + 1 - (j)]);\
47  if (score < spatial_score) {\
48  spatial_score= score;\
49  spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\
50 
51 /* The is_not_edge argument here controls when the code will enter a branch
52  * which reads up to and including x-3 and x+3. */
53 
54 #define FILTER(start, end, is_not_edge) \
55  for (x = start; x < end; x++) { \
56  int c = cur[mrefs]; \
57  int d = (prev2[0] + next2[0])>>1; \
58  int e = cur[prefs]; \
59  int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
60  int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
61  int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
62  int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
63  int spatial_pred = (c+e) >> 1; \
64  \
65  if (is_not_edge) {\
66  int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
67  + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
68  CHECK(-1) CHECK(-2) }} }} \
69  CHECK( 1) CHECK( 2) }} }} \
70  }\
71  \
72  if (mode < 2) { \
73  int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
74  int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
75  int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
76  int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
77  \
78  diff = FFMAX3(diff, min, -max); \
79  } \
80  \
81  if (spatial_pred > d + diff) \
82  spatial_pred = d + diff; \
83  else if (spatial_pred < d - diff) \
84  spatial_pred = d - diff; \
85  \
86  dst[0] = spatial_pred; \
87  \
88  dst++; \
89  cur++; \
90  prev++; \
91  next++; \
92  prev2++; \
93  next2++; \
94  }
95 
96 static void filter_line_c(void *dst1,
97  void *prev1, void *cur1, void *next1,
98  int w, int prefs, int mrefs, int parity, int mode)
99 {
100  uint8_t *dst = dst1;
101  uint8_t *prev = prev1;
102  uint8_t *cur = cur1;
103  uint8_t *next = next1;
104  int x;
105  uint8_t *prev2 = parity ? prev : cur ;
106  uint8_t *next2 = parity ? cur : next;
107 
108  /* The function is called with the pointers already pointing to data[3] and
109  * with 6 subtracted from the width. This allows the FILTER macro to be
110  * called so that it processes all the pixels normally. A constant value of
111  * true for is_not_edge lets the compiler ignore the if statement. */
112  FILTER(0, w, 1)
113 }
114 
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 
126  /* Only edge pixels need to be processed here. A constant value of false
127  * for is_not_edge should let the compiler ignore the whole branch. */
128  FILTER(0, 3, 0)
129 
130  dst = (uint8_t*)dst1 + w - 3;
131  prev = (uint8_t*)prev1 + w - 3;
132  cur = (uint8_t*)cur1 + w - 3;
133  next = (uint8_t*)next1 + w - 3;
134  prev2 = (uint8_t*)(parity ? prev : cur);
135  next2 = (uint8_t*)(parity ? cur : next);
136 
137  FILTER(w - 3, w, 0)
138 }
139 
140 
141 static void filter_line_c_16bit(void *dst1,
142  void *prev1, void *cur1, void *next1,
143  int w, int prefs, int mrefs, int parity,
144  int mode)
145 {
146  uint16_t *dst = dst1;
147  uint16_t *prev = prev1;
148  uint16_t *cur = cur1;
149  uint16_t *next = next1;
150  int x;
151  uint16_t *prev2 = parity ? prev : cur ;
152  uint16_t *next2 = parity ? cur : next;
153  mrefs /= 2;
154  prefs /= 2;
155 
156  FILTER(0, w, 1)
157 }
158 
159 static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void *next1,
160  int w, int prefs, int mrefs, int parity, int mode)
161 {
162  uint16_t *dst = dst1;
163  uint16_t *prev = prev1;
164  uint16_t *cur = cur1;
165  uint16_t *next = next1;
166  int x;
167  uint16_t *prev2 = parity ? prev : cur ;
168  uint16_t *next2 = parity ? cur : next;
169  mrefs /= 2;
170  prefs /= 2;
171 
172  FILTER(0, 3, 0)
173 
174  dst = (uint16_t*)dst1 + w - 3;
175  prev = (uint16_t*)prev1 + w - 3;
176  cur = (uint16_t*)cur1 + w - 3;
177  next = (uint16_t*)next1 + w - 3;
178  prev2 = (uint16_t*)(parity ? prev : cur);
179  next2 = (uint16_t*)(parity ? cur : next);
180 
181  FILTER(w - 3, w, 0)
182 }
183 
184 static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
185 {
186  YADIFContext *s = ctx->priv;
187  ThreadData *td = arg;
188  int refs = s->cur->linesize[td->plane];
189  int df = (s->csp->comp[td->plane].depth_minus1 + 8) / 8;
190  int pix_3 = 3 * df;
191  int slice_h = td->h / nb_jobs;
192  int slice_start = jobnr * slice_h;
193  int slice_end = (jobnr == nb_jobs - 1) ? td->h : (jobnr + 1) * slice_h;
194  int y;
195 
196  /* filtering reads 3 pixels to the left/right; to avoid invalid reads,
197  * we need to call the c variant which avoids this for border pixels
198  */
199  for (y = slice_start; y < slice_end; y++) {
200  if ((y ^ td->parity) & 1) {
201  uint8_t *prev = &s->prev->data[td->plane][y * refs];
202  uint8_t *cur = &s->cur ->data[td->plane][y * refs];
203  uint8_t *next = &s->next->data[td->plane][y * refs];
204  uint8_t *dst = &td->frame->data[td->plane][y * td->frame->linesize[td->plane]];
205  int mode = y == 1 || y + 2 == td->h ? 2 : s->mode;
206  s->filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
207  next + pix_3, td->w - 6,
208  y + 1 < td->h ? refs : -refs,
209  y ? -refs : refs,
210  td->parity ^ td->tff, mode);
211  s->filter_edges(dst, prev, cur, next, td->w,
212  y + 1 < td->h ? refs : -refs,
213  y ? -refs : refs,
214  td->parity ^ td->tff, mode);
215  } else {
216  memcpy(&td->frame->data[td->plane][y * td->frame->linesize[td->plane]],
217  &s->cur->data[td->plane][y * refs], td->w * df);
218  }
219  }
220  return 0;
221 }
222 
223 static void filter(AVFilterContext *ctx, AVFrame *dstpic,
224  int parity, int tff)
225 {
226  YADIFContext *yadif = ctx->priv;
227  ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff };
228  int i;
229 
230  for (i = 0; i < yadif->csp->nb_components; i++) {
231  int w = dstpic->width;
232  int h = dstpic->height;
233 
234  if (i == 1 || i == 2) {
235  w >>= yadif->csp->log2_chroma_w;
236  h >>= yadif->csp->log2_chroma_h;
237  }
238 
239 
240  td.w = w;
241  td.h = h;
242  td.plane = i;
243 
244  ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ctx->graph->nb_threads));
245  }
246 
247  emms_c();
248 }
249 
250 static AVFrame *get_video_buffer(AVFilterLink *link, int w, int h)
251 {
252  AVFrame *frame;
253  int width = FFALIGN(w, 32);
254  int height = FFALIGN(h + 2, 32);
255  int i;
256 
257  frame = ff_default_get_video_buffer(link, width, height);
258 
259  frame->width = w;
260  frame->height = h;
261 
262  for (i = 0; i < 3; i++)
263  frame->data[i] += frame->linesize[i];
264 
265  return frame;
266 }
267 
268 static int return_frame(AVFilterContext *ctx, int is_second)
269 {
270  YADIFContext *yadif = ctx->priv;
271  AVFilterLink *link = ctx->outputs[0];
272  int tff, ret;
273 
274  if (yadif->parity == -1) {
275  tff = yadif->cur->interlaced_frame ?
276  yadif->cur->top_field_first : 1;
277  } else {
278  tff = yadif->parity ^ 1;
279  }
280 
281  if (is_second) {
282  yadif->out = ff_get_video_buffer(link, link->w, link->h);
283  if (!yadif->out)
284  return AVERROR(ENOMEM);
285 
286  av_frame_copy_props(yadif->out, yadif->cur);
287  yadif->out->interlaced_frame = 0;
288  }
289 
290  filter(ctx, yadif->out, tff ^ !is_second, tff);
291 
292  if (is_second) {
293  int64_t cur_pts = yadif->cur->pts;
294  int64_t next_pts = yadif->next->pts;
295 
296  if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
297  yadif->out->pts = cur_pts + next_pts;
298  } else {
299  yadif->out->pts = AV_NOPTS_VALUE;
300  }
301  }
302  ret = ff_filter_frame(ctx->outputs[0], yadif->out);
303 
304  yadif->frame_pending = (yadif->mode&1) && !is_second;
305  return ret;
306 }
307 
308 static int filter_frame(AVFilterLink *link, AVFrame *frame)
309 {
310  AVFilterContext *ctx = link->dst;
311  YADIFContext *yadif = ctx->priv;
312 
313  if (yadif->frame_pending)
314  return_frame(ctx, 1);
315 
316  if (yadif->prev)
317  av_frame_free(&yadif->prev);
318  yadif->prev = yadif->cur;
319  yadif->cur = yadif->next;
320  yadif->next = frame;
321 
322  if (!yadif->cur)
323  return 0;
324 
325  if (yadif->auto_enable && !yadif->cur->interlaced_frame) {
326  yadif->out = av_frame_clone(yadif->cur);
327  if (!yadif->out)
328  return AVERROR(ENOMEM);
329 
330  av_frame_free(&yadif->prev);
331  if (yadif->out->pts != AV_NOPTS_VALUE)
332  yadif->out->pts *= 2;
333  return ff_filter_frame(ctx->outputs[0], yadif->out);
334  }
335 
336  if (!yadif->prev &&
337  !(yadif->prev = av_frame_clone(yadif->cur)))
338  return AVERROR(ENOMEM);
339 
340  yadif->out = ff_get_video_buffer(ctx->outputs[0], link->w, link->h);
341  if (!yadif->out)
342  return AVERROR(ENOMEM);
343 
344  av_frame_copy_props(yadif->out, yadif->cur);
345  yadif->out->interlaced_frame = 0;
346 
347  if (yadif->out->pts != AV_NOPTS_VALUE)
348  yadif->out->pts *= 2;
349 
350  return return_frame(ctx, 0);
351 }
352 
353 static int request_frame(AVFilterLink *link)
354 {
355  AVFilterContext *ctx = link->src;
356  YADIFContext *yadif = ctx->priv;
357 
358  if (yadif->frame_pending) {
359  return_frame(ctx, 1);
360  return 0;
361  }
362 
363  do {
364  int ret;
365 
366  if (yadif->eof)
367  return AVERROR_EOF;
368 
369  ret = ff_request_frame(link->src->inputs[0]);
370 
371  if (ret == AVERROR_EOF && yadif->next) {
372  AVFrame *next = av_frame_clone(yadif->next);
373 
374  if (!next)
375  return AVERROR(ENOMEM);
376 
377  next->pts = yadif->next->pts * 2 - yadif->cur->pts;
378 
379  filter_frame(link->src->inputs[0], next);
380  yadif->eof = 1;
381  } else if (ret < 0) {
382  return ret;
383  }
384  } while (!yadif->cur);
385 
386  return 0;
387 }
388 
389 static int poll_frame(AVFilterLink *link)
390 {
391  YADIFContext *yadif = link->src->priv;
392  int ret, val;
393 
394  if (yadif->frame_pending)
395  return 1;
396 
397  val = ff_poll_frame(link->src->inputs[0]);
398  if (val <= 0)
399  return val;
400 
401  //FIXME change API to not requre this red tape
402  if (val == 1 && !yadif->next) {
403  if ((ret = ff_request_frame(link->src->inputs[0])) < 0)
404  return ret;
405  val = ff_poll_frame(link->src->inputs[0]);
406  if (val <= 0)
407  return val;
408  }
409  assert(yadif->next || !val);
410 
411  if (yadif->auto_enable && yadif->next && !yadif->next->interlaced_frame)
412  return val;
413 
414  return val * ((yadif->mode&1)+1);
415 }
416 
417 static av_cold void uninit(AVFilterContext *ctx)
418 {
419  YADIFContext *yadif = ctx->priv;
420 
421  if (yadif->prev) av_frame_free(&yadif->prev);
422  if (yadif->cur ) av_frame_free(&yadif->cur );
423  if (yadif->next) av_frame_free(&yadif->next);
424 }
425 
427 {
428  static const enum AVPixelFormat pix_fmts[] = {
449  };
450 
452 
453  return 0;
454 }
455 
456 static int config_props(AVFilterLink *link)
457 {
458  YADIFContext *s = link->src->priv;
459 
460  link->time_base.num = link->src->inputs[0]->time_base.num;
461  link->time_base.den = link->src->inputs[0]->time_base.den * 2;
462  link->w = link->src->inputs[0]->w;
463  link->h = link->src->inputs[0]->h;
464 
465  s->csp = av_pix_fmt_desc_get(link->format);
466  if (s->csp->comp[0].depth_minus1 / 8 == 1) {
469  } else {
472 
473  if (ARCH_X86)
475  }
476 
477  return 0;
478 }
479 
480 #define OFFSET(x) offsetof(YADIFContext, x)
481 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
482 static const AVOption options[] = {
483  { "mode", NULL, OFFSET(mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, FLAGS },
484  { "parity", NULL, OFFSET(parity), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, FLAGS, "parity" },
485  { "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, .unit = "parity" },
486  { "tff", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .unit = "parity" },
487  { "bff", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .unit = "parity" },
488  { "auto", NULL, OFFSET(auto_enable), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
489  { NULL },
490 };
491 
492 static const AVClass yadif_class = {
493  .class_name = "yadif",
494  .item_name = av_default_item_name,
495  .option = options,
496  .version = LIBAVUTIL_VERSION_INT,
497 };
498 
500  {
501  .name = "default",
502  .type = AVMEDIA_TYPE_VIDEO,
503  .get_video_buffer = get_video_buffer,
504  .filter_frame = filter_frame,
505  },
506  { NULL }
507 };
508 
510  {
511  .name = "default",
512  .type = AVMEDIA_TYPE_VIDEO,
513  .poll_frame = poll_frame,
514  .request_frame = request_frame,
515  .config_props = config_props,
516  },
517  { NULL }
518 };
519 
521  .name = "yadif",
522  .description = NULL_IF_CONFIG_SMALL("Deinterlace the input image"),
523 
524  .priv_size = sizeof(YADIFContext),
525  .priv_class = &yadif_class,
526  .uninit = uninit,
528 
529  .inputs = avfilter_vf_yadif_inputs,
530 
531  .outputs = avfilter_vf_yadif_outputs,
532 
534 };
void(* filter_edges)(void *dst, void *prev, void *cur, void *next, int w, int prefs, int mrefs, int parity, int mode)
Definition: yadif.h:61
static const AVFilterPad avfilter_vf_yadif_inputs[]
Definition: vf_yadif.c:499
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1507
This structure describes decoded (raw) audio or video data.
Definition: frame.h:107
AVOption.
Definition: opt.h:233
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:150
int tff
Definition: vf_yadif.c:40
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:70
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:122
Main libavfilter public API header.
int num
numerator
Definition: rational.h:44
int frame_pending
Definition: yadif.h:42
static const AVOption options[]
Definition: vf_yadif.c:482
#define ARCH_X86
Definition: config.h:33
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:96
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:104
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:129
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:68
#define FFALIGN(x, a)
Definition: common.h:62
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:165
struct AVFilterGraph * graph
filtergraph this filter belongs to
Definition: avfilter.h:586
const char * name
Pad name.
Definition: internal.h:42
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:38
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:571
static const AVClass yadif_class
Definition: vf_yadif.c:492
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:728
static int request_frame(AVFilterLink *link)
Definition: vf_yadif.c:353
AVFrame * cur
Definition: yadif.h:50
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:104
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:85
uint8_t
#define av_cold
Definition: attributes.h:66
AVOptions.
#define AV_NE(be, le)
Definition: common.h:45
#define emms_c()
Definition: internal.h:46
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:183
AVFrame * next
Definition: yadif.h:51
int plane
Definition: vf_yadif.c:37
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
Definition: pixfmt.h:103
int nb_threads
Maximum number of threads used by filters in this graph.
Definition: avfilter.h:976
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:58
static int flags
Definition: log.c:44
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
Definition: pixfmt.h:78
#define AVERROR_EOF
End of file.
Definition: error.h:51
static void filter(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
Definition: vf_yadif.c:223
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
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:292
void 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:375
AVFrame * prev
Definition: yadif.h:52
A filter pad used for either input or output.
Definition: internal.h:36
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:156
uint16_t depth_minus1
number of bits in the component minus 1
Definition: pixdesc.h:45
int width
width and height of the video frame
Definition: frame.h:146
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:77
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:134
#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:55
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:142
void * priv
private data for use by the filter
Definition: avfilter.h:584
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:415
int parity
Definition: vf_yadif.c:39
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:152
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:132
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_yadif.c:184
static int query_formats(AVFilterContext *ctx)
Definition: vf_yadif.c:426
#define OFFSET(x)
Definition: vf_yadif.c:480
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:69
static const AVFilterPad avfilter_vf_yadif_outputs[]
Definition: vf_yadif.c:509
int auto_enable
0: deinterlace all frames 1: only deinterlace frames marked as interlaced
Definition: yadif.h:48
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:59
#define FFMIN(a, b)
Definition: common.h:57
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
Definition: pixfmt.h:77
AVFrame * frame
Definition: vf_yadif.c:36
static int config_props(AVFilterLink *link)
Definition: vf_yadif.c:456
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:149
AVFilter ff_vf_yadif
Definition: vf_yadif.c:520
int eof
Definition: yadif.h:65
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:260
static int poll_frame(AVFilterLink *link)
Definition: vf_yadif.c:389
NULL
Definition: eval.c:55
static int width
Definition: utils.c:156
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:130
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:125
av_default_item_name
Definition: dnxhdenc.c:45
AVFrame * out
Definition: yadif.h:53
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:71
Describe the class of an AVClass context structure.
Definition: log.h:33
Filter definition.
Definition: avfilter.h:421
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: vf_yadif.c:308
Y , 16bpp, big-endian.
Definition: pixfmt.h:100
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:111
int parity
0: top field first 1: bottom field first -1: auto-detection
Definition: yadif.h:40
const char * name
Filter name.
Definition: avfilter.h:425
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:578
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:609
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:113
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:133
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:38
const AVPixFmtDescriptor * csp
Definition: yadif.h:64
int height
Definition: gxfenc.c:72
#define FILTER(start, end, is_not_edge)
Definition: vf_yadif.c:54
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:65
Y , 8bpp.
Definition: pixfmt.h:73
common internal and external API header
#define FLAGS
Definition: vf_yadif.c:481
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:159
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:131
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
Definition: pixfmt.h:79
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:72
int den
denominator
Definition: rational.h:45
avfilter_execute_func * execute
Definition: internal.h:137
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:1986
static AVFrame * get_video_buffer(AVFilterLink *link, int w, int h)
Definition: vf_yadif.c:250
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_yadif.c:417
int top_field_first
If the content is interlaced, is top field displayed first.
Definition: frame.h:297
av_cold void ff_yadif_init_x86(YADIFContext *yadif)
Definition: vf_yadif_init.c:39
Y , 16bpp, little-endian.
Definition: pixfmt.h:101
An instance of a filter.
Definition: avfilter.h:563
int height
Definition: frame.h:146
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:102
static int return_frame(AVFilterContext *ctx, int is_second)
Definition: vf_yadif.c:268
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:244
internal API functions
int ff_poll_frame(AVFilterLink *link)
Poll a frame from the filter chain.
Definition: avfilter.c:255
AVPixelFormat
Pixel format.
Definition: pixfmt.h:63
int mode
0: send 1 frame for each frame 1: send 1 frame for each field 2: like 0 but skips spatial interlacing...
Definition: yadif.h:33
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:155
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:362
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:228
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:141
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:151