FFmpeg
vf_tinterlace.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Thomas Mundt <tmundt75@gmail.com>
3  * Copyright (c) 2011 Stefano Sabatini
4  * Copyright (c) 2010 Baptiste Coudurier
5  * Copyright (c) 2003 Michael Zucchi <notzed@ximian.com>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with FFmpeg if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 /**
25  * @file
26  * temporal field interlace filter, ported from MPlayer/libmpcodecs
27  */
28 
29 #include "libavutil/mem.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/imgutils.h"
32 #include "libavutil/avassert.h"
33 #include "avfilter.h"
34 #include "filters.h"
35 #include "tinterlace.h"
36 #include "video.h"
37 
38 #define OFFSET(x) offsetof(TInterlaceContext, x)
39 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
40 
41 static const AVOption tinterlace_options[] = {
42  {"mode", "select interlace mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_MERGE}, 0, MODE_NB-1, FLAGS, .unit = "mode"},
43  {"merge", "merge fields", 0, AV_OPT_TYPE_CONST, {.i64=MODE_MERGE}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
44  {"drop_even", "drop even fields", 0, AV_OPT_TYPE_CONST, {.i64=MODE_DROP_EVEN}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
45  {"drop_odd", "drop odd fields", 0, AV_OPT_TYPE_CONST, {.i64=MODE_DROP_ODD}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
46  {"pad", "pad alternate lines with black", 0, AV_OPT_TYPE_CONST, {.i64=MODE_PAD}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
47  {"interleave_top", "interleave top and bottom fields", 0, AV_OPT_TYPE_CONST, {.i64=MODE_INTERLEAVE_TOP}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
48  {"interleave_bottom", "interleave bottom and top fields", 0, AV_OPT_TYPE_CONST, {.i64=MODE_INTERLEAVE_BOTTOM}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
49  {"interlacex2", "interlace fields from two consecutive frames", 0, AV_OPT_TYPE_CONST, {.i64=MODE_INTERLACEX2}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
50  {"mergex2", "merge fields keeping same frame rate", 0, AV_OPT_TYPE_CONST, {.i64=MODE_MERGEX2}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
51 
52  {"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, INT_MAX, 0, .unit = "flags" },
53  {"low_pass_filter", "enable vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_VLPF}, INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
54  {"vlpf", "enable vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_VLPF}, INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
55  {"complex_filter", "enable complex vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_CVLPF},INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
56  {"cvlpf", "enable complex vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_CVLPF},INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
57  {"exact_tb", "force a timebase which can represent timestamps exactly", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_EXACT_TB}, INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
58  {"bypass_il", "bypass already interlaced frames", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_BYPASS_IL}, INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
59 
60  {NULL}
61 };
62 
63 AVFILTER_DEFINE_CLASS(tinterlace);
64 
65 static const AVOption interlace_options[] = {
66  { "scan", "scanning mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = MODE_TFF}, 0, 1, FLAGS, .unit = "mode"},
67  { "tff", "top field first", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_TFF}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
68  { "bff", "bottom field first", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_BFF}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
69  { "lowpass", "set vertical low-pass filter", OFFSET(lowpass), AV_OPT_TYPE_INT, {.i64 = VLPF_LIN}, 0, 2, FLAGS, .unit = "lowpass" },
70  { "off", "disable vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = VLPF_OFF}, INT_MIN, INT_MAX, FLAGS, .unit = "lowpass" },
71  { "linear", "linear vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = VLPF_LIN}, INT_MIN, INT_MAX, FLAGS, .unit = "lowpass" },
72  { "complex", "complex vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = VLPF_CMP}, INT_MIN, INT_MAX, FLAGS, .unit = "lowpass" },
73 
74  { NULL }
75 };
76 
77 AVFILTER_DEFINE_CLASS(interlace);
78 
79 #define FULL_SCALE_YUVJ_FORMATS \
80  AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P
81 
82 static const enum AVPixelFormat full_scale_yuvj_pix_fmts[] = {
84 };
85 
86 static const AVRational standard_tbs[] = {
87  {1, 25},
88  {1, 30},
89  {1001, 30000},
90 };
91 
92 static const enum AVPixelFormat pix_fmts[] = {
104 };
105 
106 static void lowpass_line_c(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp,
107  ptrdiff_t mref, ptrdiff_t pref, int clip_max)
108 {
109  const uint8_t *srcp_above = srcp + mref;
110  const uint8_t *srcp_below = srcp + pref;
111  int i;
112  for (i = 0; i < width; i++) {
113  // this calculation is an integer representation of
114  // '0.5 * current + 0.25 * above + 0.25 * below'
115  // '1 +' is for rounding.
116  dstp[i] = (1 + srcp[i] + srcp[i] + srcp_above[i] + srcp_below[i]) >> 2;
117  }
118 }
119 
120 static void lowpass_line_c_16(uint8_t *dst8, ptrdiff_t width, const uint8_t *src8,
121  ptrdiff_t mref, ptrdiff_t pref, int clip_max)
122 {
123  uint16_t *dstp = (uint16_t *)dst8;
124  const uint16_t *srcp = (const uint16_t *)src8;
125  const uint16_t *srcp_above = srcp + mref / 2;
126  const uint16_t *srcp_below = srcp + pref / 2;
127  int i, src_x;
128  for (i = 0; i < width; i++) {
129  // this calculation is an integer representation of
130  // '0.5 * current + 0.25 * above + 0.25 * below'
131  // '1 +' is for rounding.
132  src_x = av_le2ne16(srcp[i]) << 1;
133  dstp[i] = av_le2ne16((1 + src_x + av_le2ne16(srcp_above[i])
134  + av_le2ne16(srcp_below[i])) >> 2);
135  }
136 }
137 
138 static void lowpass_line_complex_c(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp,
139  ptrdiff_t mref, ptrdiff_t pref, int clip_max)
140 {
141  const uint8_t *srcp_above = srcp + mref;
142  const uint8_t *srcp_below = srcp + pref;
143  const uint8_t *srcp_above2 = srcp + mref * 2;
144  const uint8_t *srcp_below2 = srcp + pref * 2;
145  int i, src_x, src_ab;
146  for (i = 0; i < width; i++) {
147  // this calculation is an integer representation of
148  // '0.75 * current + 0.25 * above + 0.25 * below - 0.125 * above2 - 0.125 * below2'
149  // '4 +' is for rounding.
150  src_x = srcp[i] << 1;
151  src_ab = srcp_above[i] + srcp_below[i];
152  dstp[i] = av_clip_uint8((4 + ((srcp[i] + src_x + src_ab) << 1)
153  - srcp_above2[i] - srcp_below2[i]) >> 3);
154  // Prevent over-sharpening:
155  // dst must not exceed src when the average of above and below
156  // is less than src. And the other way around.
157  if (src_ab > src_x) {
158  if (dstp[i] < srcp[i])
159  dstp[i] = srcp[i];
160  } else if (dstp[i] > srcp[i])
161  dstp[i] = srcp[i];
162  }
163 }
164 
165 static void lowpass_line_complex_c_16(uint8_t *dst8, ptrdiff_t width, const uint8_t *src8,
166  ptrdiff_t mref, ptrdiff_t pref, int clip_max)
167 {
168  uint16_t *dstp = (uint16_t *)dst8;
169  const uint16_t *srcp = (const uint16_t *)src8;
170  const uint16_t *srcp_above = srcp + mref / 2;
171  const uint16_t *srcp_below = srcp + pref / 2;
172  const uint16_t *srcp_above2 = srcp + mref;
173  const uint16_t *srcp_below2 = srcp + pref;
174  int i, dst_le, src_le, src_x, src_ab;
175  for (i = 0; i < width; i++) {
176  // this calculation is an integer representation of
177  // '0.75 * current + 0.25 * above + 0.25 * below - 0.125 * above2 - 0.125 * below2'
178  // '4 +' is for rounding.
179  src_le = av_le2ne16(srcp[i]);
180  src_x = src_le << 1;
181  src_ab = av_le2ne16(srcp_above[i]) + av_le2ne16(srcp_below[i]);
182  dst_le = av_clip((4 + ((src_le + src_x + src_ab) << 1)
183  - av_le2ne16(srcp_above2[i])
184  - av_le2ne16(srcp_below2[i])) >> 3, 0, clip_max);
185  // Prevent over-sharpening:
186  // dst must not exceed src when the average of above and below
187  // is less than src. And the other way around.
188  if (src_ab > src_x) {
189  if (dst_le < src_le)
190  dstp[i] = av_le2ne16(src_le);
191  else
192  dstp[i] = av_le2ne16(dst_le);
193  } else if (dst_le > src_le) {
194  dstp[i] = av_le2ne16(src_le);
195  } else
196  dstp[i] = av_le2ne16(dst_le);
197  }
198 }
199 
201 {
202  TInterlaceContext *tinterlace = ctx->priv;
203 
204  av_frame_free(&tinterlace->cur );
205  av_frame_free(&tinterlace->next);
206  av_freep(&tinterlace->black_data[0][0]);
207  av_freep(&tinterlace->black_data[1][0]);
208  ff_ccfifo_uninit(&tinterlace->cc_fifo);
209 }
210 
211 static int config_out_props(AVFilterLink *outlink)
212 {
213  AVFilterContext *ctx = outlink->src;
214  AVFilterLink *inlink = outlink->src->inputs[0];
216  FilterLink *ol = ff_filter_link(outlink);
218  TInterlaceContext *tinterlace = ctx->priv;
219  int ret, i;
220 
221  tinterlace->vsub = desc->log2_chroma_h;
222  outlink->w = inlink->w;
223  outlink->h = tinterlace->mode == MODE_MERGE || tinterlace->mode == MODE_PAD || tinterlace->mode == MODE_MERGEX2?
224  inlink->h*2 : inlink->h;
225  if (tinterlace->mode == MODE_MERGE || tinterlace->mode == MODE_PAD || tinterlace->mode == MODE_MERGEX2)
226  outlink->sample_aspect_ratio = av_mul_q(inlink->sample_aspect_ratio,
227  av_make_q(2, 1));
228 
229  if (tinterlace->mode == MODE_PAD) {
230  uint8_t black[4] = { 0, 0, 0, 16 };
231  ff_draw_init2(&tinterlace->draw, outlink->format, outlink->colorspace, outlink->color_range, 0);
232  ff_draw_color(&tinterlace->draw, &tinterlace->color, black);
233  /* limited range */
234  if (!ff_fmt_is_in(outlink->format, full_scale_yuvj_pix_fmts)) {
235  ret = av_image_alloc(tinterlace->black_data[0], tinterlace->black_linesize,
236  outlink->w, outlink->h, outlink->format, 16);
237  if (ret < 0)
238  return ret;
239  ff_fill_rectangle(&tinterlace->draw, &tinterlace->color, tinterlace->black_data[0],
240  tinterlace->black_linesize, 0, 0, outlink->w, outlink->h);
241  }
242  /* full range */
243  tinterlace->color.comp[0].u8[0] = 0;
244  ret = av_image_alloc(tinterlace->black_data[1], tinterlace->black_linesize,
245  outlink->w, outlink->h, outlink->format, 16);
246  if (ret < 0)
247  return ret;
248  ff_fill_rectangle(&tinterlace->draw, &tinterlace->color, tinterlace->black_data[1],
249  tinterlace->black_linesize, 0, 0, outlink->w, outlink->h);
250  }
251  if (tinterlace->flags & (TINTERLACE_FLAG_VLPF | TINTERLACE_FLAG_CVLPF)
252  && !(tinterlace->mode == MODE_INTERLEAVE_TOP
253  || tinterlace->mode == MODE_INTERLEAVE_BOTTOM)) {
254  av_log(ctx, AV_LOG_WARNING, "low_pass_filter flags ignored with mode %d\n",
255  tinterlace->mode);
257  }
258  tinterlace->preout_time_base = inlink->time_base;
259  if (tinterlace->mode == MODE_INTERLACEX2) {
260  tinterlace->preout_time_base.den *= 2;
261  ol->frame_rate = av_mul_q(il->frame_rate, (AVRational){2,1});
262  outlink->time_base = av_mul_q(inlink->time_base , (AVRational){1,2});
263  } else if (tinterlace->mode == MODE_MERGEX2) {
264  ol->frame_rate = il->frame_rate;
265  outlink->time_base = inlink->time_base;
266  } else if (tinterlace->mode != MODE_PAD) {
267  ol->frame_rate = av_mul_q(il->frame_rate, (AVRational){1,2});
268  outlink->time_base = av_mul_q(inlink->time_base , (AVRational){2,1});
269  }
270 
271  for (i = 0; i<FF_ARRAY_ELEMS(standard_tbs); i++){
272  if (!av_cmp_q(standard_tbs[i], outlink->time_base))
273  break;
274  }
275  if (i == FF_ARRAY_ELEMS(standard_tbs) ||
276  (tinterlace->flags & TINTERLACE_FLAG_EXACT_TB))
277  outlink->time_base = tinterlace->preout_time_base;
278 
279  tinterlace->csp = av_pix_fmt_desc_get(outlink->format);
280  if (tinterlace->flags & TINTERLACE_FLAG_CVLPF) {
281  if (tinterlace->csp->comp[0].depth > 8)
283  else
284  tinterlace->lowpass_line = lowpass_line_complex_c;
285 #if ARCH_X86
286  ff_tinterlace_init_x86(tinterlace);
287 #endif
288  } else if (tinterlace->flags & TINTERLACE_FLAG_VLPF) {
289  if (tinterlace->csp->comp[0].depth > 8)
290  tinterlace->lowpass_line = lowpass_line_c_16;
291  else
292  tinterlace->lowpass_line = lowpass_line_c;
293 #if ARCH_X86
294  ff_tinterlace_init_x86(tinterlace);
295 #endif
296  }
297 
298  ret = ff_ccfifo_init(&tinterlace->cc_fifo, ol->frame_rate, ctx);
299  if (ret < 0) {
300  av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n");
301  return ret;
302  }
303 
304  av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode,
305  (tinterlace->flags & TINTERLACE_FLAG_CVLPF) ? "complex" :
306  (tinterlace->flags & TINTERLACE_FLAG_VLPF) ? "linear" : "off",
307  inlink->h, outlink->h);
308 
309  return 0;
310 }
311 
312 #define FIELD_UPPER 0
313 #define FIELD_LOWER 1
314 #define FIELD_UPPER_AND_LOWER 2
315 
316 /**
317  * Copy picture field from src to dst.
318  *
319  * @param src_field copy from upper, lower field or both
320  * @param interleave leave a padding line between each copied line
321  * @param dst_field copy to upper or lower field,
322  * only meaningful when interleave is selected
323  * @param flags context flags
324  */
325 static inline
327  uint8_t *dst[4], int dst_linesize[4],
328  const uint8_t *src[4], int src_linesize[4],
329  enum AVPixelFormat format, int w, int src_h,
330  int src_field, int interleave, int dst_field,
331  int flags)
332 {
334  int hsub = desc->log2_chroma_w;
335  int plane, vsub = desc->log2_chroma_h;
336  int k = src_field == FIELD_UPPER_AND_LOWER ? 1 : 2;
337  int h;
338 
339  for (plane = 0; plane < desc->nb_components; plane++) {
340  int lines = plane == 1 || plane == 2 ? AV_CEIL_RSHIFT(src_h, vsub) : src_h;
341  int cols = plane == 1 || plane == 2 ? AV_CEIL_RSHIFT( w, hsub) : w;
342  uint8_t *dstp = dst[plane];
343  const uint8_t *srcp = src[plane];
344  int srcp_linesize = src_linesize[plane] * k;
345  int dstp_linesize = dst_linesize[plane] * (interleave ? 2 : 1);
346  int clip_max = (1 << tinterlace->csp->comp[plane].depth) - 1;
347 
348  lines = (lines + (src_field == FIELD_UPPER)) / k;
349  if (src_field == FIELD_LOWER)
350  srcp += src_linesize[plane];
351  if (interleave && dst_field == FIELD_LOWER)
352  dstp += dst_linesize[plane];
353  // Low-pass filtering is required when creating an interlaced destination from
354  // a progressive source which contains high-frequency vertical detail.
355  // Filtering will reduce interlace 'twitter' and Moire patterning.
357  int x = !!(flags & TINTERLACE_FLAG_CVLPF);
358  for (h = lines; h > 0; h--) {
359  ptrdiff_t pref = src_linesize[plane];
360  ptrdiff_t mref = -pref;
361  if (h >= (lines - x)) mref = 0; // there is no line above
362  else if (h <= (1 + x)) pref = 0; // there is no line below
363 
364  tinterlace->lowpass_line(dstp, cols, srcp, mref, pref, clip_max);
365  dstp += dstp_linesize;
366  srcp += srcp_linesize;
367  }
368  } else {
369  if (tinterlace->csp->comp[plane].depth > 8)
370  cols *= 2;
371  av_image_copy_plane(dstp, dstp_linesize, srcp, srcp_linesize, cols, lines);
372  }
373  }
374 }
375 
377 {
379  AVFilterContext *ctx = inlink->dst;
380  AVFilterLink *outlink = ctx->outputs[0];
381  FilterLink *l = ff_filter_link(outlink);
382  TInterlaceContext *tinterlace = ctx->priv;
383  AVFrame *cur, *next, *out;
384  int field, tff, full, ret;
385 
386  av_frame_free(&tinterlace->cur);
387  tinterlace->cur = tinterlace->next;
388  tinterlace->next = picref;
389 
390  ff_ccfifo_extract(&tinterlace->cc_fifo, picref);
391 
392  cur = tinterlace->cur;
393  next = tinterlace->next;
394  /* we need at least two frames */
395  if (!tinterlace->cur)
396  return 0;
397 
398  switch (tinterlace->mode) {
399  case MODE_MERGEX2: /* move the odd frame into the upper field of the new image, even into
400  * the lower field, generating a double-height video at same framerate */
401  case MODE_MERGE: /* move the odd frame into the upper field of the new image, even into
402  * the lower field, generating a double-height video at half framerate */
403  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
404  if (!out)
405  return AVERROR(ENOMEM);
406  av_frame_copy_props(out, cur);
407  out->height = outlink->h;
408 #if FF_API_INTERLACED_FRAME
410  out->interlaced_frame = 1;
411  out->top_field_first = 1;
413 #endif
415  out->sample_aspect_ratio = av_mul_q(cur->sample_aspect_ratio, av_make_q(2, 1));
416 
417  /* write odd frame lines into the upper field of the new frame */
418  copy_picture_field(tinterlace, out->data, out->linesize,
419  (const uint8_t **)cur->data, cur->linesize,
420  inlink->format, inlink->w, inlink->h,
421  FIELD_UPPER_AND_LOWER, 1, tinterlace->mode == MODE_MERGEX2 ? (1 + inl->frame_count_out) & 1 ? FIELD_LOWER : FIELD_UPPER : FIELD_UPPER, tinterlace->flags);
422  /* write even frame lines into the lower field of the new frame */
423  copy_picture_field(tinterlace, out->data, out->linesize,
424  (const uint8_t **)next->data, next->linesize,
425  inlink->format, inlink->w, inlink->h,
426  FIELD_UPPER_AND_LOWER, 1, tinterlace->mode == MODE_MERGEX2 ? (1 + inl->frame_count_out) & 1 ? FIELD_UPPER : FIELD_LOWER : FIELD_LOWER, tinterlace->flags);
427  if (tinterlace->mode != MODE_MERGEX2)
428  av_frame_free(&tinterlace->next);
429  break;
430 
431  case MODE_DROP_ODD: /* only output even frames, odd frames are dropped; height unchanged, half framerate */
432  case MODE_DROP_EVEN: /* only output odd frames, even frames are dropped; height unchanged, half framerate */
433  out = av_frame_clone(tinterlace->mode == MODE_DROP_EVEN ? cur : next);
434  if (!out)
435  return AVERROR(ENOMEM);
436  av_frame_free(&tinterlace->next);
437  break;
438 
439  case MODE_PAD: /* expand each frame to double height, but pad alternate
440  * lines with black; framerate unchanged */
441  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
442  if (!out)
443  return AVERROR(ENOMEM);
444  av_frame_copy_props(out, cur);
445  out->height = outlink->h;
446  out->sample_aspect_ratio = av_mul_q(cur->sample_aspect_ratio, av_make_q(2, 1));
447 
448  field = (1 + l->frame_count_in) & 1 ? FIELD_UPPER : FIELD_LOWER;
449  full = out->color_range == AVCOL_RANGE_JPEG || ff_fmt_is_in(out->format, full_scale_yuvj_pix_fmts);
450  /* copy upper and lower fields */
451  copy_picture_field(tinterlace, out->data, out->linesize,
452  (const uint8_t **)cur->data, cur->linesize,
453  inlink->format, inlink->w, inlink->h,
454  FIELD_UPPER_AND_LOWER, 1, field, tinterlace->flags);
455  /* pad with black the other field */
456  copy_picture_field(tinterlace, out->data, out->linesize,
457  (const uint8_t **)tinterlace->black_data[full], tinterlace->black_linesize,
458  inlink->format, inlink->w, inlink->h,
459  FIELD_UPPER_AND_LOWER, 1, !field, tinterlace->flags);
460  break;
461 
462  /* interleave upper/lower lines from odd frames with lower/upper lines from even frames,
463  * halving the frame rate and preserving image height */
464  case MODE_INTERLEAVE_TOP: /* top field first */
465  case MODE_INTERLEAVE_BOTTOM: /* bottom field first */
466  if ((tinterlace->flags & TINTERLACE_FLAG_BYPASS_IL) && (cur->flags & AV_FRAME_FLAG_INTERLACED)) {
468  "video is already interlaced, adjusting framerate only\n");
469  out = av_frame_clone(cur);
470  if (!out)
471  return AVERROR(ENOMEM);
472  out->pts /= 2; // adjust pts to new framerate
473  ff_ccfifo_inject(&tinterlace->cc_fifo, out);
474  ret = ff_filter_frame(outlink, out);
475  return ret;
476  }
477  tff = tinterlace->mode == MODE_INTERLEAVE_TOP;
478  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
479  if (!out)
480  return AVERROR(ENOMEM);
481  av_frame_copy_props(out, cur);
482 #if FF_API_INTERLACED_FRAME
484  out->interlaced_frame = 1;
485  out->top_field_first = tff;
487 #endif
488  out->flags |= AV_FRAME_FLAG_INTERLACED;
489  if (tff)
491  else
493 
494  /* copy upper/lower field from cur */
495  copy_picture_field(tinterlace, out->data, out->linesize,
496  (const uint8_t **)cur->data, cur->linesize,
497  inlink->format, inlink->w, inlink->h,
498  tff ? FIELD_UPPER : FIELD_LOWER, 1, tff ? FIELD_UPPER : FIELD_LOWER,
499  tinterlace->flags);
500  /* copy lower/upper field from next */
501  copy_picture_field(tinterlace, out->data, out->linesize,
502  (const uint8_t **)next->data, next->linesize,
503  inlink->format, inlink->w, inlink->h,
504  tff ? FIELD_LOWER : FIELD_UPPER, 1, tff ? FIELD_LOWER : FIELD_UPPER,
505  tinterlace->flags);
506  av_frame_free(&tinterlace->next);
507  break;
508  case MODE_INTERLACEX2: /* re-interlace preserving image height, double frame rate */
509  /* output current frame first */
510  out = av_frame_clone(cur);
511  if (!out)
512  return AVERROR(ENOMEM);
513 #if FF_API_INTERLACED_FRAME
515  out->interlaced_frame = 1;
517 #endif
518  out->flags |= AV_FRAME_FLAG_INTERLACED;
519  if (cur->pts != AV_NOPTS_VALUE)
520  out->pts = cur->pts*2;
521 
522  out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base);
523  ff_ccfifo_inject(&tinterlace->cc_fifo, out);
524  if ((ret = ff_filter_frame(outlink, out)) < 0)
525  return ret;
526 
527  /* output mix of current and next frame */
528  tff = !!(next->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
529  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
530  if (!out)
531  return AVERROR(ENOMEM);
532  av_frame_copy_props(out, next);
533 #if FF_API_INTERLACED_FRAME
535  out->interlaced_frame = 1;
536  out->top_field_first = !tff;
538 #endif
539  out->flags |= AV_FRAME_FLAG_INTERLACED;
540  if (tff)
542  else
544 
545  if (next->pts != AV_NOPTS_VALUE && cur->pts != AV_NOPTS_VALUE)
546  out->pts = cur->pts + next->pts;
547  else
548  out->pts = AV_NOPTS_VALUE;
549  /* write current frame second field lines into the second field of the new frame */
550  copy_picture_field(tinterlace, out->data, out->linesize,
551  (const uint8_t **)cur->data, cur->linesize,
552  inlink->format, inlink->w, inlink->h,
553  tff ? FIELD_LOWER : FIELD_UPPER, 1, tff ? FIELD_LOWER : FIELD_UPPER,
554  tinterlace->flags);
555  /* write next frame first field lines into the first field of the new frame */
556  copy_picture_field(tinterlace, out->data, out->linesize,
557  (const uint8_t **)next->data, next->linesize,
558  inlink->format, inlink->w, inlink->h,
559  tff ? FIELD_UPPER : FIELD_LOWER, 1, tff ? FIELD_UPPER : FIELD_LOWER,
560  tinterlace->flags);
561  break;
562  default:
563  av_assert0(0);
564  }
565 
566  out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base);
567  out->duration = av_rescale_q(1, av_inv_q(l->frame_rate), outlink->time_base);
568  ff_ccfifo_inject(&tinterlace->cc_fifo, out);
569  ret = ff_filter_frame(outlink, out);
570 
571  return ret;
572 }
573 
575 {
576  TInterlaceContext *tinterlace = ctx->priv;
577 
578  if (tinterlace->mode <= MODE_BFF)
579  tinterlace->mode += MODE_INTERLEAVE_TOP;
580 
581  tinterlace->flags |= TINTERLACE_FLAG_BYPASS_IL;
582  if (tinterlace->lowpass == VLPF_LIN)
583  tinterlace->flags |= TINTERLACE_FLAG_VLPF;
584  if (tinterlace->lowpass == VLPF_CMP)
585  tinterlace->flags |= TINTERLACE_FLAG_CVLPF;
586 
587  return 0;
588 }
589 
590 static const AVFilterPad tinterlace_inputs[] = {
591  {
592  .name = "default",
593  .type = AVMEDIA_TYPE_VIDEO,
594  .filter_frame = filter_frame,
595  },
596 };
597 
598 static const AVFilterPad tinterlace_outputs[] = {
599  {
600  .name = "default",
601  .type = AVMEDIA_TYPE_VIDEO,
602  .config_props = config_out_props,
603  },
604 };
605 
607  .name = "tinterlace",
608  .description = NULL_IF_CONFIG_SMALL("Perform temporal field interlacing."),
609  .priv_size = sizeof(TInterlaceContext),
610  .uninit = uninit,
614  .priv_class = &tinterlace_class,
615 };
616 
617 
619  .name = "interlace",
620  .description = NULL_IF_CONFIG_SMALL("Convert progressive video into interlaced."),
621  .priv_size = sizeof(TInterlaceContext),
622  .init = init_interlace,
623  .uninit = uninit,
627  .priv_class = &interlace_class,
628 };
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:116
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
Definition: vf_tinterlace.c:376
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
MODE_MERGE
@ MODE_MERGE
Definition: tinterlace.h:49
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:215
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
av_clip
#define av_clip
Definition: common.h:100
init_interlace
static int init_interlace(AVFilterContext *ctx)
Definition: vf_tinterlace.c:574
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
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
out
FILE * out
Definition: movenc.c:55
TINTERLACE_FLAG_BYPASS_IL
#define TINTERLACE_FLAG_BYPASS_IL
Definition: tinterlace.h:40
standard_tbs
static const AVRational standard_tbs[]
Definition: vf_tinterlace.c:86
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1062
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3170
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
TInterlaceContext::lowpass_line
void(* lowpass_line)(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, ptrdiff_t mref, ptrdiff_t pref, int clip_max)
Definition: tinterlace.h:79
lowpass_line_complex_c
static void lowpass_line_complex_c(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, ptrdiff_t mref, ptrdiff_t pref, int clip_max)
Definition: vf_tinterlace.c:138
FIELD_UPPER_AND_LOWER
#define FIELD_UPPER_AND_LOWER
Definition: vf_tinterlace.c:314
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:162
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:501
w
uint8_t w
Definition: llviddspenc.c:38
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:717
TInterlaceContext
Definition: tinterlace.h:65
AVComponentDescriptor::depth
int depth
Number of bits in the component.
Definition: pixdesc.h:57
TInterlaceContext::color
FFDrawColor color
Definition: tinterlace.h:77
AVOption
AVOption.
Definition: opt.h:429
TInterlaceContext::black_linesize
int black_linesize[4]
Definition: tinterlace.h:75
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:225
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
AVFrame::flags
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:661
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
video.h
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:410
av_image_copy_plane
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:374
hsub
static void hsub(htype *dst, const htype *src, int bins)
Definition: vf_median.c:74
VLPF_LIN
@ VLPF_LIN
Definition: tinterlace.h:44
AV_FRAME_FLAG_TOP_FIELD_FIRST
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
Definition: frame.h:653
MODE_INTERLEAVE_TOP
@ MODE_INTERLEAVE_TOP
Definition: tinterlace.h:53
TInterlaceContext::vsub
int vsub
chroma vertical subsampling
Definition: tinterlace.h:71
TInterlaceContext::preout_time_base
AVRational preout_time_base
Definition: tinterlace.h:68
AV_PIX_FMT_YUV420P12LE
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:268
OFFSET
#define OFFSET(x)
Definition: vf_tinterlace.c:38
config_out_props
static int config_out_props(AVFilterLink *outlink)
Definition: vf_tinterlace.c:211
FIELD_LOWER
#define FIELD_LOWER
Definition: vf_tinterlace.c:313
ff_ccfifo_uninit
void ff_ccfifo_uninit(CCFifo *ccf)
Free all memory allocated in a CCFifo and clear the context.
Definition: ccfifo.c:46
tinterlace_inputs
static const AVFilterPad tinterlace_inputs[]
Definition: vf_tinterlace.c:590
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
AV_PIX_FMT_YUV420P10LE
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:156
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_tinterlace.c:200
AV_PIX_FMT_YUV444P12LE
@ AV_PIX_FMT_YUV444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:276
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
MODE_MERGEX2
@ MODE_MERGEX2
Definition: tinterlace.h:56
ff_ccfifo_inject
int ff_ccfifo_inject(CCFifo *ccf, AVFrame *frame)
Insert CC data from the FIFO into an AVFrame (as side data)
Definition: ccfifo.c:133
TInterlaceContext::flags
int flags
flags affecting interlacing algorithm
Definition: tinterlace.h:69
TInterlaceContext::csp
const AVPixFmtDescriptor * csp
Definition: tinterlace.h:78
TInterlaceContext::cur
AVFrame * cur
Definition: tinterlace.h:72
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
format
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 format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
VLPF_CMP
@ VLPF_CMP
Definition: tinterlace.h:45
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
filters.h
TInterlaceContext::next
AVFrame * next
Definition: tinterlace.h:73
ctx
AVFormatContext * ctx
Definition: movenc.c:49
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:609
av_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:142
field
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this field
Definition: writing_filters.txt:78
ff_fmt_is_in
int ff_fmt_is_in(int fmt, const int *fmts)
Tell if an integer is contained in the provided -1-terminated list of integers.
Definition: formats.c:406
TInterlaceContext::black_data
uint8_t * black_data[2][4]
buffer used to fill padded lines (limited/full)
Definition: tinterlace.h:74
ff_tinterlace_init_x86
void ff_tinterlace_init_x86(TInterlaceContext *interlace)
Definition: vf_tinterlace_init.c:57
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
ff_vf_tinterlace
const AVFilter ff_vf_tinterlace
Definition: vf_tinterlace.c:606
TInterlaceContext::cc_fifo
CCFifo cc_fifo
Definition: tinterlace.h:81
AV_PIX_FMT_YUV444P10LE
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:162
AV_PIX_FMT_YUVA422P10LE
@ AV_PIX_FMT_YUVA422P10LE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:184
TINTERLACE_FLAG_EXACT_TB
#define TINTERLACE_FLAG_EXACT_TB
Definition: tinterlace.h:39
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:725
tinterlace_options
static const AVOption tinterlace_options[]
Definition: vf_tinterlace.c:41
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
ff_vf_interlace
const AVFilter ff_vf_interlace
Definition: vf_tinterlace.c:618
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:465
TInterlaceContext::mode
int mode
TInterlaceMode, interlace mode selected.
Definition: tinterlace.h:67
ff_ccfifo_extract
int ff_ccfifo_extract(CCFifo *ccf, AVFrame *frame)
Extract CC data from an AVFrame.
Definition: ccfifo.c:183
MODE_DROP_EVEN
@ MODE_DROP_EVEN
Definition: tinterlace.h:50
FFDrawColor::u8
uint8_t u8[16]
Definition: drawutils.h:56
AV_PIX_FMT_YUV440P10LE
@ AV_PIX_FMT_YUV440P10LE
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:298
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:197
FFDrawColor::comp
union FFDrawColor::@314 comp[MAX_PLANES]
av_image_alloc
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
Definition: imgutils.c:218
interleave
static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dst_linesize, int src_linesize, enum FilterMode mode, int swap)
Definition: vf_il.c:113
lowpass
@ lowpass
Definition: af_biquads.c:86
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_PIX_FMT_YUV440P12LE
@ AV_PIX_FMT_YUV440P12LE
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:300
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_tinterlace.c:92
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
AV_PIX_FMT_YUV422P10LE
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:158
ff_draw_init2
int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSpace csp, enum AVColorRange range, unsigned flags)
Init a draw context.
Definition: drawutils.c:95
TINTERLACE_FLAG_CVLPF
#define TINTERLACE_FLAG_CVLPF
Definition: tinterlace.h:38
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
ff_fill_rectangle
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
Definition: drawutils.c:246
av_le2ne16
#define av_le2ne16(x)
Definition: bswap.h:91
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
FULL_SCALE_YUVJ_FORMATS
#define FULL_SCALE_YUVJ_FORMATS
Definition: vf_tinterlace.c:79
copy_picture_field
static void copy_picture_field(TInterlaceContext *tinterlace, uint8_t *dst[4], int dst_linesize[4], const uint8_t *src[4], int src_linesize[4], enum AVPixelFormat format, int w, int src_h, int src_field, int interleave, int dst_field, int flags)
Copy picture field from src to dst.
Definition: vf_tinterlace.c:326
AV_PIX_FMT_YUVA420P10LE
@ AV_PIX_FMT_YUVA420P10LE
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:182
MODE_NB
@ MODE_NB
Definition: avf_avectorscope.c:40
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
MODE_INTERLEAVE_BOTTOM
@ MODE_INTERLEAVE_BOTTOM
Definition: tinterlace.h:54
FIELD_UPPER
#define FIELD_UPPER
Definition: vf_tinterlace.c:312
MODE_BFF
@ MODE_BFF
Definition: tinterlace.h:62
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: filters.h:44
AV_FRAME_FLAG_INTERLACED
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
Definition: frame.h:648
ff_draw_color
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
Definition: drawutils.c:171
av_cmp_q
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:89
AVFilter
Filter definition.
Definition: avfilter.h:201
ff_ccfifo_init
int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx)
Initialize a CCFifo.
Definition: ccfifo.c:53
TInterlaceContext::lowpass
int lowpass
legacy interlace filter lowpass mode
Definition: tinterlace.h:70
ret
ret
Definition: filter_design.txt:187
AVFrame::sample_aspect_ratio
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:496
tinterlace.h
AVRational::den
int den
Denominator.
Definition: rational.h:60
mode
mode
Definition: ebur128.h:83
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
MODE_PAD
@ MODE_PAD
Definition: tinterlace.h:52
avfilter.h
TInterlaceContext::draw
FFDrawContext draw
Definition: tinterlace.h:76
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
av_clip_uint8
#define av_clip_uint8
Definition: common.h:106
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
MODE_INTERLACEX2
@ MODE_INTERLACEX2
Definition: tinterlace.h:55
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
lowpass_line_c
static void lowpass_line_c(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, ptrdiff_t mref, ptrdiff_t pref, int clip_max)
Definition: vf_tinterlace.c:106
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
VLPF_OFF
@ VLPF_OFF
Definition: tinterlace.h:43
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
mem.h
full_scale_yuvj_pix_fmts
static enum AVPixelFormat full_scale_yuvj_pix_fmts[]
Definition: vf_tinterlace.c:82
AV_PIX_FMT_YUVA444P10LE
@ AV_PIX_FMT_YUVA444P10LE
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:186
lowpass_line_complex_c_16
static void lowpass_line_complex_c_16(uint8_t *dst8, ptrdiff_t width, const uint8_t *src8, ptrdiff_t mref, ptrdiff_t pref, int clip_max)
Definition: vf_tinterlace.c:165
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
MODE_TFF
@ MODE_TFF
Definition: tinterlace.h:61
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
TINTERLACE_FLAG_VLPF
#define TINTERLACE_FLAG_VLPF
Definition: tinterlace.h:37
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
imgutils.h
interlace_options
static const AVOption interlace_options[]
Definition: vf_tinterlace.c:65
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
lowpass_line_c_16
static void lowpass_line_c_16(uint8_t *dst8, ptrdiff_t width, const uint8_t *src8, ptrdiff_t mref, ptrdiff_t pref, int clip_max)
Definition: vf_tinterlace.c:120
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:434
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
h
h
Definition: vp9dsp_template.c:2070
FLAGS
#define FLAGS
Definition: vf_tinterlace.c:39
width
#define width
Definition: dsp.h:85
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
AV_PIX_FMT_YUV422P12LE
@ AV_PIX_FMT_YUV422P12LE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:272
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(tinterlace)
src
#define src
Definition: vp8dsp.c:248
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:173
MODE_DROP_ODD
@ MODE_DROP_ODD
Definition: tinterlace.h:51
tinterlace_outputs
static const AVFilterPad tinterlace_outputs[]
Definition: vf_tinterlace.c:598