Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -34,6 +34,8 @@ · 33 unmodified lines | ||
| 34 | 34 | typedef struct W3FDIFContext { |
| 35 | 35 | const AVClass *class; |
| 36 | 36 | 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 | 39 | int deint; ///< which frames to deinterlace |
| 38 | 40 | int linesize[4]; ///< bytes of pixel data per line for each plane |
| 39 | 41 | int planeheight[4]; ///< height of each plane |
| @@ -56,6 +58,13 @@ static const AVOption w3fdif_options[] = { · 16 unmodified lines | ||
| 56 | 58 | { "filter", "specify the filter", OFFSET(filter), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "filter" }, |
| 57 | 59 | CONST("simple", NULL, 0, "filter"), |
| 58 | 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 | 68 | { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" }, |
| 60 | 69 | CONST("all", "deinterlace all frames", 0, "deint"), |
| 61 | 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 | 381 | const int start = (height * jobnr) / nb_jobs; |
| 373 | 382 | const int end = (height * (jobnr+1)) / nb_jobs; |
| 374 | 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 | 385 | int j, y_in, y_out; |
| 376 | 386 | |
| 377 | 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 | 390 | in_line = cur_data + (y_out * cur_line_stride); |
| 381 | 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 | 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 | 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 | 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 | 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 | 537 | return 0; |
| 527 | 538 | |
| 528 | 539 | ret = filter(ctx, 0); |
| 529 | − if (ret < 0) | |
| 540 | + if (ret < 0 || s->mode == 0) | |
| 530 | 541 | return ret; |
| 531 | 542 | |
| 532 | 543 | return filter(ctx, 1); |