FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_w3fdif.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 British Broadcasting Corporation, All Rights Reserved
3  * Author of de-interlace algorithm: Jim Easterbrook for BBC R&D
4  * Based on the process described by Martin Weston for BBC R&D
5  * Author of FFmpeg filter: Mark Himsley for BBC Broadcast Systems Development
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (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 GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include "libavutil/common.h"
25 #include "libavutil/imgutils.h"
26 #include "libavutil/opt.h"
27 #include "libavutil/pixdesc.h"
28 #include "avfilter.h"
29 #include "formats.h"
30 #include "internal.h"
31 #include "video.h"
32 #include "w3fdif.h"
33 
34 typedef struct W3FDIFContext {
35  const AVClass *class;
36  int filter; ///< 0 is simple, 1 is more complex
37  int deint; ///< which frames to deinterlace
38  int linesize[4]; ///< bytes of pixel data per line for each plane
39  int planeheight[4]; ///< height of each plane
40  int field; ///< which field are we on, 0 or 1
41  int eof;
42  int nb_planes;
43  AVFrame *prev, *cur, *next; ///< previous, current, next frames
44  int32_t **work_line; ///< lines we are calculating
46 
49 
50 #define OFFSET(x) offsetof(W3FDIFContext, x)
51 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
52 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
53 
54 static const AVOption w3fdif_options[] = {
55  { "filter", "specify the filter", OFFSET(filter), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "filter" },
56  CONST("simple", NULL, 0, "filter"),
57  CONST("complex", NULL, 1, "filter"),
58  { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" },
59  CONST("all", "deinterlace all frames", 0, "deint"),
60  CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"),
61  { NULL }
62 };
63 
64 AVFILTER_DEFINE_CLASS(w3fdif);
65 
67 {
68  static const enum AVPixelFormat pix_fmts[] = {
79  };
80 
81  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
82  if (!fmts_list)
83  return AVERROR(ENOMEM);
84  return ff_set_common_formats(ctx, fmts_list);
85 }
86 
87 static void filter_simple_low(int32_t *work_line,
88  uint8_t *in_lines_cur[2],
89  const int16_t *coef, int linesize)
90 {
91  int i;
92 
93  for (i = 0; i < linesize; i++) {
94  *work_line = *in_lines_cur[0]++ * coef[0];
95  *work_line++ += *in_lines_cur[1]++ * coef[1];
96  }
97 }
98 
99 static void filter_complex_low(int32_t *work_line,
100  uint8_t *in_lines_cur[4],
101  const int16_t *coef, int linesize)
102 {
103  int i;
104 
105  for (i = 0; i < linesize; i++) {
106  *work_line = *in_lines_cur[0]++ * coef[0];
107  *work_line += *in_lines_cur[1]++ * coef[1];
108  *work_line += *in_lines_cur[2]++ * coef[2];
109  *work_line++ += *in_lines_cur[3]++ * coef[3];
110  }
111 }
112 
113 static void filter_simple_high(int32_t *work_line,
114  uint8_t *in_lines_cur[3],
115  uint8_t *in_lines_adj[3],
116  const int16_t *coef, int linesize)
117 {
118  int i;
119 
120  for (i = 0; i < linesize; i++) {
121  *work_line += *in_lines_cur[0]++ * coef[0];
122  *work_line += *in_lines_adj[0]++ * coef[0];
123  *work_line += *in_lines_cur[1]++ * coef[1];
124  *work_line += *in_lines_adj[1]++ * coef[1];
125  *work_line += *in_lines_cur[2]++ * coef[2];
126  *work_line++ += *in_lines_adj[2]++ * coef[2];
127  }
128 }
129 
130 static void filter_complex_high(int32_t *work_line,
131  uint8_t *in_lines_cur[5],
132  uint8_t *in_lines_adj[5],
133  const int16_t *coef, int linesize)
134 {
135  int i;
136 
137  for (i = 0; i < linesize; i++) {
138  *work_line += *in_lines_cur[0]++ * coef[0];
139  *work_line += *in_lines_adj[0]++ * coef[0];
140  *work_line += *in_lines_cur[1]++ * coef[1];
141  *work_line += *in_lines_adj[1]++ * coef[1];
142  *work_line += *in_lines_cur[2]++ * coef[2];
143  *work_line += *in_lines_adj[2]++ * coef[2];
144  *work_line += *in_lines_cur[3]++ * coef[3];
145  *work_line += *in_lines_adj[3]++ * coef[3];
146  *work_line += *in_lines_cur[4]++ * coef[4];
147  *work_line++ += *in_lines_adj[4]++ * coef[4];
148  }
149 }
150 
151 static void filter_scale(uint8_t *out_pixel, const int32_t *work_pixel, int linesize)
152 {
153  int j;
154 
155  for (j = 0; j < linesize; j++, out_pixel++, work_pixel++)
156  *out_pixel = av_clip(*work_pixel, 0, 255 * 256 * 128) >> 15;
157 }
158 
159 static int config_input(AVFilterLink *inlink)
160 {
161  AVFilterContext *ctx = inlink->dst;
162  W3FDIFContext *s = ctx->priv;
164  int ret, i;
165 
166  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
167  return ret;
168 
169  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
170  s->planeheight[0] = s->planeheight[3] = inlink->h;
171 
173  s->nb_threads = ctx->graph->nb_threads;
174  s->work_line = av_calloc(s->nb_threads, sizeof(*s->work_line));
175  if (!s->work_line)
176  return AVERROR(ENOMEM);
177 
178  for (i = 0; i < s->nb_threads; i++) {
179  s->work_line[i] = av_calloc(FFALIGN(s->linesize[0], 32), sizeof(*s->work_line[0]));
180  if (!s->work_line[i])
181  return AVERROR(ENOMEM);
182  }
183 
189 
190  if (ARCH_X86)
191  ff_w3fdif_init_x86(&s->dsp);
192 
193  return 0;
194 }
195 
196 static int config_output(AVFilterLink *outlink)
197 {
198  AVFilterLink *inlink = outlink->src->inputs[0];
199 
200  outlink->time_base.num = inlink->time_base.num;
201  outlink->time_base.den = inlink->time_base.den * 2;
202  outlink->frame_rate.num = inlink->frame_rate.num * 2;
203  outlink->frame_rate.den = inlink->frame_rate.den;
204 
205  return 0;
206 }
207 
208 /*
209  * Filter coefficients from PH-2071, scaled by 256 * 128.
210  * Each set of coefficients has a set for low-frequencies and high-frequencies.
211  * n_coef_lf[] and n_coef_hf[] are the number of coefs for simple and more-complex.
212  * It is important for later that n_coef_lf[] is even and n_coef_hf[] is odd.
213  * coef_lf[][] and coef_hf[][] are the coefficients for low-frequencies
214  * and high-frequencies for simple and more-complex mode.
215  */
216 static const int8_t n_coef_lf[2] = { 2, 4 };
217 static const int16_t coef_lf[2][4] = {{ 16384, 16384, 0, 0},
218  { -852, 17236, 17236, -852}};
219 static const int8_t n_coef_hf[2] = { 3, 5 };
220 static const int16_t coef_hf[2][5] = {{ -2048, 4096, -2048, 0, 0},
221  { 1016, -3801, 5570, -3801, 1016}};
222 
223 typedef struct ThreadData {
225  int plane;
226 } ThreadData;
227 
228 static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
229 {
230  W3FDIFContext *s = ctx->priv;
231  ThreadData *td = arg;
232  AVFrame *out = td->out;
233  AVFrame *cur = td->cur;
234  AVFrame *adj = td->adj;
235  const int plane = td->plane;
236  const int filter = s->filter;
237  uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5];
238  uint8_t *out_line, *out_pixel;
239  int32_t *work_line, *work_pixel;
240  uint8_t *cur_data = cur->data[plane];
241  uint8_t *adj_data = adj->data[plane];
242  uint8_t *dst_data = out->data[plane];
243  const int linesize = s->linesize[plane];
244  const int height = s->planeheight[plane];
245  const int cur_line_stride = cur->linesize[plane];
246  const int adj_line_stride = adj->linesize[plane];
247  const int dst_line_stride = out->linesize[plane];
248  const int start = (height * jobnr) / nb_jobs;
249  const int end = (height * (jobnr+1)) / nb_jobs;
250  int j, y_in, y_out;
251 
252  /* copy unchanged the lines of the field */
253  y_out = start + (s->field == cur->top_field_first) - (start & 1);
254 
255  in_line = cur_data + (y_out * cur_line_stride);
256  out_line = dst_data + (y_out * dst_line_stride);
257 
258  while (y_out < end) {
259  memcpy(out_line, in_line, linesize);
260  y_out += 2;
261  in_line += cur_line_stride * 2;
262  out_line += dst_line_stride * 2;
263  }
264 
265  /* interpolate other lines of the field */
266  y_out = start + (s->field != cur->top_field_first) - (start & 1);
267 
268  out_line = dst_data + (y_out * dst_line_stride);
269 
270  while (y_out < end) {
271  /* get low vertical frequencies from current field */
272  for (j = 0; j < n_coef_lf[filter]; j++) {
273  y_in = (y_out + 1) + (j * 2) - n_coef_lf[filter];
274 
275  while (y_in < 0)
276  y_in += 2;
277  while (y_in >= height)
278  y_in -= 2;
279 
280  in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
281  }
282 
283  work_line = s->work_line[jobnr];
284  switch (n_coef_lf[filter]) {
285  case 2:
286  s->dsp.filter_simple_low(work_line, in_lines_cur,
287  coef_lf[filter], linesize);
288  break;
289  case 4:
290  s->dsp.filter_complex_low(work_line, in_lines_cur,
291  coef_lf[filter], linesize);
292  }
293 
294  /* get high vertical frequencies from adjacent fields */
295  for (j = 0; j < n_coef_hf[filter]; j++) {
296  y_in = (y_out + 1) + (j * 2) - n_coef_hf[filter];
297 
298  while (y_in < 0)
299  y_in += 2;
300  while (y_in >= height)
301  y_in -= 2;
302 
303  in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
304  in_lines_adj[j] = adj_data + (y_in * adj_line_stride);
305  }
306 
307  work_line = s->work_line[jobnr];
308  switch (n_coef_hf[filter]) {
309  case 3:
310  s->dsp.filter_simple_high(work_line, in_lines_cur, in_lines_adj,
311  coef_hf[filter], linesize);
312  break;
313  case 5:
314  s->dsp.filter_complex_high(work_line, in_lines_cur, in_lines_adj,
315  coef_hf[filter], linesize);
316  }
317 
318  /* save scaled result to the output frame, scaling down by 256 * 128 */
319  work_pixel = s->work_line[jobnr];
320  out_pixel = out_line;
321 
322  s->dsp.filter_scale(out_pixel, work_pixel, linesize);
323 
324  /* move on to next line */
325  y_out += 2;
326  out_line += dst_line_stride * 2;
327  }
328 
329  return 0;
330 }
331 
332 static int filter(AVFilterContext *ctx, int is_second)
333 {
334  W3FDIFContext *s = ctx->priv;
335  AVFilterLink *outlink = ctx->outputs[0];
336  AVFrame *out, *adj;
337  ThreadData td;
338  int plane;
339 
340  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
341  if (!out)
342  return AVERROR(ENOMEM);
343  av_frame_copy_props(out, s->cur);
344  out->interlaced_frame = 0;
345 
346  if (!is_second) {
347  if (out->pts != AV_NOPTS_VALUE)
348  out->pts *= 2;
349  } else {
350  int64_t cur_pts = s->cur->pts;
351  int64_t next_pts = s->next->pts;
352 
353  if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
354  out->pts = cur_pts + next_pts;
355  } else {
356  out->pts = AV_NOPTS_VALUE;
357  }
358  }
359 
360  adj = s->field ? s->next : s->prev;
361  td.out = out; td.cur = s->cur; td.adj = adj;
362  for (plane = 0; plane < s->nb_planes; plane++) {
363  td.plane = plane;
364  ctx->internal->execute(ctx, deinterlace_slice, &td, NULL, FFMIN(s->planeheight[plane], s->nb_threads));
365  }
366 
367  s->field = !s->field;
368 
369  return ff_filter_frame(outlink, out);
370 }
371 
372 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
373 {
374  AVFilterContext *ctx = inlink->dst;
375  W3FDIFContext *s = ctx->priv;
376  int ret;
377 
378  av_frame_free(&s->prev);
379  s->prev = s->cur;
380  s->cur = s->next;
381  s->next = frame;
382 
383  if (!s->cur) {
384  s->cur = av_frame_clone(s->next);
385  if (!s->cur)
386  return AVERROR(ENOMEM);
387  }
388 
389  if ((s->deint && !s->cur->interlaced_frame) || ctx->is_disabled) {
390  AVFrame *out = av_frame_clone(s->cur);
391  if (!out)
392  return AVERROR(ENOMEM);
393 
394  av_frame_free(&s->prev);
395  if (out->pts != AV_NOPTS_VALUE)
396  out->pts *= 2;
397  return ff_filter_frame(ctx->outputs[0], out);
398  }
399 
400  if (!s->prev)
401  return 0;
402 
403  ret = filter(ctx, 0);
404  if (ret < 0)
405  return ret;
406 
407  return filter(ctx, 1);
408 }
409 
410 static int request_frame(AVFilterLink *outlink)
411 {
412  AVFilterContext *ctx = outlink->src;
413  W3FDIFContext *s = ctx->priv;
414  int ret;
415 
416  if (s->eof)
417  return AVERROR_EOF;
418 
419  ret = ff_request_frame(ctx->inputs[0]);
420 
421  if (ret == AVERROR_EOF && s->cur) {
422  AVFrame *next = av_frame_clone(s->next);
423  if (!next)
424  return AVERROR(ENOMEM);
425  next->pts = s->next->pts * 2 - s->cur->pts;
426  filter_frame(ctx->inputs[0], next);
427  s->eof = 1;
428  } else if (ret < 0) {
429  return ret;
430  }
431 
432  return 0;
433 }
434 
436 {
437  W3FDIFContext *s = ctx->priv;
438  int i;
439 
440  av_frame_free(&s->prev);
441  av_frame_free(&s->cur );
442  av_frame_free(&s->next);
443 
444  for (i = 0; i < s->nb_threads; i++)
445  av_freep(&s->work_line[i]);
446 
447  av_freep(&s->work_line);
448 }
449 
450 static const AVFilterPad w3fdif_inputs[] = {
451  {
452  .name = "default",
453  .type = AVMEDIA_TYPE_VIDEO,
454  .filter_frame = filter_frame,
455  .config_props = config_input,
456  },
457  { NULL }
458 };
459 
460 static const AVFilterPad w3fdif_outputs[] = {
461  {
462  .name = "default",
463  .type = AVMEDIA_TYPE_VIDEO,
464  .config_props = config_output,
465  .request_frame = request_frame,
466  },
467  { NULL }
468 };
469 
471  .name = "w3fdif",
472  .description = NULL_IF_CONFIG_SMALL("Apply Martin Weston three field deinterlace."),
473  .priv_size = sizeof(W3FDIFContext),
474  .priv_class = &w3fdif_class,
475  .uninit = uninit,
477  .inputs = w3fdif_inputs,
478  .outputs = w3fdif_outputs,
480 };
int plane
Definition: avisynth_c.h:291
#define NULL
Definition: coverity.c:32
void(* filter_scale)(uint8_t *out_pixel, const int32_t *work_pixel, int linesize)
Definition: w3fdif.h:42
const char * s
Definition: avisynth_c.h:631
AVFrame * out
Definition: af_sofalizer.c:585
static int filter(AVFilterContext *ctx, int is_second)
Definition: vf_w3fdif.c:332
AVFrame * prev
Definition: vf_w3fdif.c:43
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2222
This structure describes decoded (raw) audio or video data.
Definition: frame.h:184
AVOption.
Definition: opt.h:245
AVFrame * cur
Definition: vf_w3fdif.c:43
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
misc image utilities
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2262
Main libavfilter public API header.
const char * desc
Definition: nvenc.c:89
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:180
int num
numerator
Definition: rational.h:44
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:76
void ff_w3fdif_init_x86(W3FDIFDSPContext *dsp)
int is_disabled
the enabled state from the last expression evaluation
Definition: avfilter.h:361
static void filter_complex_low(int32_t *work_line, uint8_t *in_lines_cur[4], const int16_t *coef, int linesize)
Definition: vf_w3fdif.c:99
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:322
const char * name
Pad name.
Definition: internal.h:59
static const AVOption w3fdif_options[]
Definition: vf_w3fdif.c:54
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:313
static int config_input(AVFilterLink *inlink)
Definition: vf_w3fdif.c:159
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1180
#define FLAGS
Definition: vf_w3fdif.c:51
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:102
uint8_t
void(* filter_simple_high)(int32_t *work_line, uint8_t *in_lines_cur[3], uint8_t *in_lines_adj[3], const int16_t *coef, int linesize)
Definition: w3fdif.h:34
#define av_cold
Definition: attributes.h:82
AVOptions.
AVFILTER_DEFINE_CLASS(w3fdif)
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
void(* filter_complex_high)(int32_t *work_line, uint8_t *in_lines_cur[5], uint8_t *in_lines_adj[5], const int16_t *coef, int linesize)
Definition: w3fdif.h:38
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:268
static AVFrame * frame
#define height
int plane
Definition: vf_blend.c:57
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:101
int nb_threads
Maximum number of threads used by filters in this graph.
Definition: avfilter.h:804
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:75
static void filter_complex_high(int32_t *work_line, uint8_t *in_lines_cur[5], uint8_t *in_lines_adj[5], const int16_t *coef, int linesize)
Definition: vf_w3fdif.c:130
#define AVERROR_EOF
End of file.
Definition: error.h:55
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:318
#define FFALIGN(x, a)
Definition: macros.h:48
A filter pad used for either input or output.
Definition: internal.h:53
int linesize[4]
bytes of pixel data per line for each plane
Definition: vf_w3fdif.c:38
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:187
AVFrame * next
previous, current, next frames
Definition: vf_w3fdif.c:43
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:568
#define td
Definition: regdef.h:70
static int query_formats(AVFilterContext *ctx)
Definition: vf_w3fdif.c:66
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
#define AVERROR(e)
Definition: error.h:43
static const int16_t coef_hf[2][5]
Definition: vf_w3fdif.c:220
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:153
void(* filter_complex_low)(int32_t *work_line, uint8_t *in_lines_cur[4], const int16_t *coef, int linesize)
Definition: w3fdif.h:31
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
void * priv
private data for use by the filter
Definition: avfilter.h:320
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:114
#define OFFSET(x)
Definition: vf_w3fdif.c:50
const char * arg
Definition: jacosubdec.c:66
int planeheight[4]
height of each plane
Definition: vf_w3fdif.c:39
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
void(* filter_simple_low)(int32_t *work_line, uint8_t *in_lines_cur[2], const int16_t *coef, int linesize)
Definition: w3fdif.h:28
#define FFMIN(a, b)
Definition: common.h:96
int field
which field are we on, 0 or 1
Definition: vf_w3fdif.c:40
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:74
int32_t
AVFormatContext * ctx
Definition: movenc.c:48
static const int16_t coef_lf[2][4]
Definition: vf_w3fdif.c:217
static const int8_t n_coef_hf[2]
Definition: vf_w3fdif.c:219
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:386
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:471
AVFilter ff_vf_w3fdif
Definition: vf_w3fdif.c:470
static int config_output(AVFilterLink *outlink)
Definition: vf_w3fdif.c:196
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:376
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:215
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:188
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
AVFrame * adj
Definition: vf_w3fdif.c:224
static const int8_t n_coef_lf[2]
Definition: vf_w3fdif.c:216
AVFrame * cur
Definition: vf_w3fdif.c:224
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:142
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:88
const char * name
Filter name.
Definition: avfilter.h:146
#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:131
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:317
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
Definition: mem.c:260
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:345
static void filter_scale(uint8_t *out_pixel, const int32_t *work_pixel, int linesize)
Definition: vf_w3fdif.c:151
static int flags
Definition: cpu.c:47
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:198
#define CONST(name, help, val, unit)
Definition: vf_w3fdif.c:52
static const AVFilterPad w3fdif_inputs[]
Definition: vf_w3fdif.c:450
W3FDIFDSPContext dsp
Definition: vf_w3fdif.c:47
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
Y , 8bpp.
Definition: pixfmt.h:70
common internal and external API header
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_w3fdif.c:372
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:228
int deint
which frames to deinterlace
Definition: vf_w3fdif.c:37
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:76
static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_w3fdif.c:228
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:69
int den
denominator
Definition: rational.h:45
avfilter_execute_func * execute
Definition: internal.h:153
int top_field_first
If the content is interlaced, is top field displayed first.
Definition: frame.h:323
static const AVFilterPad w3fdif_outputs[]
Definition: vf_w3fdif.c:460
A list of supported formats for one end of a filter link.
Definition: formats.h:64
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:271
An instance of a filter.
Definition: avfilter.h:305
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_w3fdif.c:435
FILE * out
Definition: movenc.c:54
#define av_freep(p)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:100
void INT64 start
Definition: avisynth_c.h:553
static void filter_simple_low(int32_t *work_line, uint8_t *in_lines_cur[2], const int16_t *coef, int linesize)
Definition: vf_w3fdif.c:87
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:369
int32_t ** work_line
lines we are calculating
Definition: vf_w3fdif.c:44
static int request_frame(AVFilterLink *outlink)
Definition: vf_w3fdif.c:410
internal API functions
int nb_threads
Definition: vf_w3fdif.c:45
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
int filter
0 is simple, 1 is more complex
Definition: vf_w3fdif.c:36
static void filter_simple_high(int32_t *work_line, uint8_t *in_lines_cur[3], uint8_t *in_lines_adj[3], const int16_t *coef, int linesize)
Definition: vf_w3fdif.c:113
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:580
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:240
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58