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