History

avfilter/vf_w3fdif: add two more useful options

Paul B Mahol committed 5 years ago

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

Showing the changes to libavfilter (1 of 2 files). Show all

Unified · Split

libavfilter/vf_w3fdif.c+15−4
@@ -34,6 +34,8 @@ · 33 unmodified lines
34typedef struct W3FDIFContext {34typedef struct W3FDIFContext {
35 const AVClass *class;35 const AVClass *class;
36 int filter; ///< 0 is simple, 1 is more complex36 int filter; ///< 0 is simple, 1 is more complex
37 int mode; ///< 0 is frame, 1 is field
38 int parity; ///< frame field parity
37 int deint; ///< which frames to deinterlace39 int deint; ///< which frames to deinterlace
38 int linesize[4]; ///< bytes of pixel data per line for each plane40 int linesize[4]; ///< bytes of pixel data per line for each plane
39 int planeheight[4]; ///< height of each plane41 int planeheight[4]; ///< height of each plane
@@ -56,6 +58,13 @@ static const AVOption w3fdif_options[] = { · 16 unmodified lines
56 { "filter", "specify the filter", OFFSET(filter), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "filter" },58 { "filter", "specify the filter", OFFSET(filter), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "filter" },
57 CONST("simple", NULL, 0, "filter"),59 CONST("simple", NULL, 0, "filter"),
58 CONST("complex", NULL, 1, "filter"),60 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"),
59 { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" },68 { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" },
60 CONST("all", "deinterlace all frames", 0, "deint"),69 CONST("all", "deinterlace all frames", 0, "deint"),
61 CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"),70 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
372 const int start = (height * jobnr) / nb_jobs;381 const int start = (height * jobnr) / nb_jobs;
373 const int end = (height * (jobnr+1)) / nb_jobs;382 const int end = (height * (jobnr+1)) / nb_jobs;
374 const int max = s->max;383 const int max = s->max;
384 const int tff = s->field == (s->parity == -1 ? cur->top_field_first == 1 : s->parity == 0 ? 1 : 0);
375 int j, y_in, y_out;385 int j, y_in, y_out;
376 386
377 /* copy unchanged the lines of the field */387 /* 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));
379 389
380 in_line = cur_data + (y_out * cur_line_stride);390 in_line = cur_data + (y_out * cur_line_stride);
381 out_line = dst_data + (y_out * dst_line_stride);391 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
388 }398 }
389 399
390 /* interpolate other lines of the field */400 /* 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));
392 402
393 out_line = dst_data + (y_out * dst_line_stride);403 out_line = dst_data + (y_out * dst_line_stride);
394 404
@@ -489,7 +499,8 @@ static int filter(AVFilterContext *ctx, int is_second) · 94 unmodified lines
489 ctx->internal->execute(ctx, deinterlace_slice, &td, NULL, FFMIN(s->planeheight[plane], s->nb_threads));499 ctx->internal->execute(ctx, deinterlace_slice, &td, NULL, FFMIN(s->planeheight[plane], s->nb_threads));
490 }500 }
491 501
492 s->field = !s->field;502 if (s->mode)
503 s->field = !s->field;
493 504
494 return ff_filter_frame(outlink, out);505 return ff_filter_frame(outlink, out);
495}506}
@@ -526,7 +537,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 30 unmodified lines
526 return 0;537 return 0;
527 538
528 ret = filter(ctx, 0);539 ret = filter(ctx, 0);
529 if (ret < 0)540 if (ret < 0 || s->mode == 0)
530 return ret;541 return ret;
531 542
532 return filter(ctx, 1);543 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