History

avfilter/vf_w3fdif: add two more useful options

Paul B Mahol committed 5 years ago

Commit b112c861 parent fde55932 files · +44 −4Browse files

Unified · Split

2 files
  1. doc/filters.texi +29 −0
  2. libavfilter/vf_w3fdif.c +15 −4
doc/filters.texi+29−0
@@ -20931,6 +20931,35 @@ More-complex filter coefficient set. · 20930 unmodified lines
2093120931 @end table
2093220932 Default value is @samp{complex}.
2093320933
20934+@item mode
20935+The interlacing mode to adopt. It accepts one of the following values:
20936+
20937+@table @option
20938+@item frame
20939+Output one frame for each frame.
20940+@item field
20941+Output one frame for each field.
20942+@end table
20943+
20944+The default value is @code{field}.
20945+
20946+@item parity
20947+The picture field parity assumed for the input interlaced video. It accepts one
20948+of the following values:
20949+
20950+@table @option
20951+@item tff
20952+Assume the top field is first.
20953+@item bff
20954+Assume the bottom field is first.
20955+@item auto
20956+Enable automatic detection of field parity.
20957+@end table
20958+
20959+The default value is @code{auto}.
20960+If the interlacing is unknown or the decoder does not export this information,
20961+top field first will be assumed.
20962+
2093420963 @item deint
2093520964 Specify which frames to deinterlace. Accepts one of the following values:
2093620965
libavfilter/vf_w3fdif.c+15−4
@@ -34,6 +34,8 @@ · 33 unmodified lines
3434 typedef struct W3FDIFContext {
3535 const AVClass *class;
3636 int filter; ///< 0 is simple, 1 is more complex
37+ int mode; ///< 0 is frame, 1 is field
38+ int parity; ///< frame field parity
3739 int deint; ///< which frames to deinterlace
3840 int linesize[4]; ///< bytes of pixel data per line for each plane
3941 int planeheight[4]; ///< height of each plane
@@ -56,6 +58,13 @@ static const AVOption w3fdif_options[] = { · 16 unmodified lines
5658 { "filter", "specify the filter", OFFSET(filter), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "filter" },
5759 CONST("simple", NULL, 0, "filter"),
5860 CONST("complex", NULL, 1, "filter"),
61+ { "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "mode"},
62+ CONST("frame", "send one frame for each frame", 0, "mode"),
63+ CONST("field", "send one frame for each field", 1, "mode"),
64+ { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=-1}, -1, 1, FLAGS, "parity" },
65+ CONST("tff", "assume top field first", 0, "parity"),
66+ CONST("bff", "assume bottom field first", 1, "parity"),
67+ CONST("auto", "auto detect parity", -1, "parity"),
5968 { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" },
6069 CONST("all", "deinterlace all frames", 0, "deint"),
6170 CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"),
@@ -372,10 +381,11 @@ static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_ · 310 unmodified lines
372381 const int start = (height * jobnr) / nb_jobs;
373382 const int end = (height * (jobnr+1)) / nb_jobs;
374383 const int max = s->max;
384+ const int tff = s->field == (s->parity == -1 ? cur->top_field_first == 1 : s->parity == 0 ? 1 : 0);
375385 int j, y_in, y_out;
376386
377387 /* copy unchanged the lines of the field */
378− y_out = start + ((s->field == cur->top_field_first) ^ (start & 1));
388+ y_out = start + (tff ^ (start & 1));
379389
380390 in_line = cur_data + (y_out * cur_line_stride);
381391 out_line = dst_data + (y_out * dst_line_stride);
@@ -388,7 +398,7 @@ static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_ · 6 unmodified lines
388398 }
389399
390400 /* interpolate other lines of the field */
391− y_out = start + ((s->field != cur->top_field_first) ^ (start & 1));
401+ y_out = start + ((!tff) ^ (start & 1));
392402
393403 out_line = dst_data + (y_out * dst_line_stride);
394404
@@ -489,7 +499,8 @@ static int filter(AVFilterContext *ctx, int is_second) · 94 unmodified lines
489499 ctx->internal->execute(ctx, deinterlace_slice, &td, NULL, FFMIN(s->planeheight[plane], s->nb_threads));
490500 }
491501
492− s->field = !s->field;
502+ if (s->mode)
503+ s->field = !s->field;
493504
494505 return ff_filter_frame(outlink, out);
495506 }
@@ -526,7 +537,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 30 unmodified lines
526537 return 0;
527538
528539 ret = filter(ctx, 0);
529− if (ret < 0)
540+ if (ret < 0 || s->mode == 0)
530541 return ret;
531542
532543 return filter(ctx, 1);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t