History

Add mode to yadif to enable/disable deinterlacing based on src frame "interlaced" flag

Joakim Plate committed 15 years ago

Commit 2a375bb1 parent cbfdfbe2 files · +39 −3Browse files

Unified · Split

2 files
  1. doc/filters.texi +13 −1
  2. libavfilter/vf_yadif.c +26 −2
doc/filters.texi+13−1
@@ -1737,7 +1737,7 @@ Flip the input video vertically. · 1736 unmodified lines
17371737 Deinterlace the input video ("yadif" means "yet another deinterlacing
17381738 filter").
17391739
1740−It accepts the optional parameters: @var{mode}:@var{parity}.
1740+It accepts the optional parameters: @var{mode}:@var{parity}:@var(auto).
17411741
17421742 @var{mode} specifies the interlacing mode to adopt, accepts one of the
17431743 following values:
@@ -1771,6 +1771,18 @@ Default value is -1. · 27 unmodified lines
17711771 If interlacing is unknown or decoder does not export this information,
17721772 top field first will be assumed.
17731773
1774+@var{auto] specifies if deinterlacer should trust the interlaced flag
1775+and only deinterlace frames marked as interlaced
1776+
1777+@table @option
1778+@item 0
1779+deinterlace all frames
1780+@item 1
1781+only deinterlace frames marked as interlaced
1782+@end table
1783+
1784+Default value is 0.
1785+
17741786 @c man end VIDEO FILTERS
17751787
17761788 @chapter Video Sources
libavfilter/vf_yadif.c+26−2
@@ -44,6 +44,12 @@ typedef struct { · 43 unmodified lines
4444
4545 int frame_pending;
4646
47+ /**
48+ * 0: deinterlace all frames
49+ * 1: only deinterlace frames marked as interlaced
50+ */
51+ int auto_enable;
52+
4753 AVFilterBufferRef *cur;
4854 AVFilterBufferRef *next;
4955 AVFilterBufferRef *prev;
@@ -240,6 +246,14 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 190 unmodified lines
240246 if (!yadif->cur)
241247 return;
242248
249+ if (yadif->auto_enable && !yadif->cur->video->interlaced) {
250+ yadif->out = avfilter_ref_buffer(yadif->cur, AV_PERM_READ);
251+ avfilter_unref_buffer(yadif->prev);
252+ yadif->prev = NULL;
253+ avfilter_start_frame(ctx->outputs[0], yadif->out);
254+ return;
255+ }
256+
243257 if (!yadif->prev)
244258 yadif->prev = avfilter_ref_buffer(yadif->cur, AV_PERM_READ);
245259
@@ -259,6 +273,12 @@ static void end_frame(AVFilterLink *link) · 13 unmodified lines
259273 if (!yadif->out)
260274 return;
261275
276+ if (yadif->auto_enable && !yadif->cur->video->interlaced) {
277+ avfilter_draw_slice(ctx->outputs[0], 0, link->h, 1);
278+ avfilter_end_frame(ctx->outputs[0]);
279+ return;
280+ }
281+
262282 return_frame(ctx, 0);
263283 }
264284
@@ -299,6 +319,9 @@ static int poll_frame(AVFilterLink *link) · 34 unmodified lines
299319 }
300320 assert(yadif->next || !val);
301321
322+ if (yadif->auto_enable && yadif->next && !yadif->next->video->interlaced)
323+ return val;
324+
302325 return val * ((yadif->mode&1)+1);
303326 }
304327
@@ -344,9 +367,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) · 39 unmodified lines
344367
345368 yadif->mode = 0;
346369 yadif->parity = -1;
370+ yadif->auto_enable = 0;
347371 yadif->csp = NULL;
348372
349− if (args) sscanf(args, "%d:%d", &yadif->mode, &yadif->parity);
373+ if (args) sscanf(args, "%d:%d:%d", &yadif->mode, &yadif->parity, &yadif->auto_enable);
350374
351375 yadif->filter_line = filter_line_c;
352376 if (HAVE_SSSE3 && cpu_flags & AV_CPU_FLAG_SSSE3)
@@ -356,7 +380,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) · 3 unmodified lines
356380 else if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX)
357381 yadif->filter_line = ff_yadif_filter_line_mmx;
358382
359− av_log(ctx, AV_LOG_INFO, "mode:%d parity:%d\n", yadif->mode, yadif->parity);
383+ av_log(ctx, AV_LOG_INFO, "mode:%d parity:%d auto_enable:%d\n", yadif->mode, yadif->parity, yadif->auto_enable);
360384
361385 return 0;
362386 }

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