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
1737Deinterlace the input video ("yadif" means "yet another deinterlacing1737Deinterlace the input video ("yadif" means "yet another deinterlacing
1738filter").1738filter").
1739 1739
1740It accepts the optional parameters: @var{mode}:@var{parity}.1740It accepts the optional parameters: @var{mode}:@var{parity}:@var(auto).
1741 1741
1742@var{mode} specifies the interlacing mode to adopt, accepts one of the1742@var{mode} specifies the interlacing mode to adopt, accepts one of the
1743following values:1743following values:
@@ -1771,6 +1771,18 @@ Default value is -1. · 27 unmodified lines
1771If interlacing is unknown or decoder does not export this information,1771If interlacing is unknown or decoder does not export this information,
1772top field first will be assumed.1772top field first will be assumed.
1773 1773
1774@var{auto] specifies if deinterlacer should trust the interlaced flag
1775and only deinterlace frames marked as interlaced
1776
1777@table @option
1778@item 0
1779deinterlace all frames
1780@item 1
1781only deinterlace frames marked as interlaced
1782@end table
1783
1784Default value is 0.
1785
1774@c man end VIDEO FILTERS1786@c man end VIDEO FILTERS
1775 1787
1776@chapter Video Sources1788@chapter Video Sources
libavfilter/vf_yadif.c+26−2
@@ -44,6 +44,12 @@ typedef struct { · 43 unmodified lines
44 44
45 int frame_pending;45 int frame_pending;
46 46
47 /**
48 * 0: deinterlace all frames
49 * 1: only deinterlace frames marked as interlaced
50 */
51 int auto_enable;
52
47 AVFilterBufferRef *cur;53 AVFilterBufferRef *cur;
48 AVFilterBufferRef *next;54 AVFilterBufferRef *next;
49 AVFilterBufferRef *prev;55 AVFilterBufferRef *prev;
@@ -240,6 +246,14 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 190 unmodified lines
240 if (!yadif->cur)246 if (!yadif->cur)
241 return;247 return;
242 248
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
243 if (!yadif->prev)257 if (!yadif->prev)
244 yadif->prev = avfilter_ref_buffer(yadif->cur, AV_PERM_READ);258 yadif->prev = avfilter_ref_buffer(yadif->cur, AV_PERM_READ);
245 259
@@ -259,6 +273,12 @@ static void end_frame(AVFilterLink *link) · 13 unmodified lines
259 if (!yadif->out)273 if (!yadif->out)
260 return;274 return;
261 275
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
262 return_frame(ctx, 0);282 return_frame(ctx, 0);
263}283}
264 284
@@ -299,6 +319,9 @@ static int poll_frame(AVFilterLink *link) · 34 unmodified lines
299 }319 }
300 assert(yadif->next || !val);320 assert(yadif->next || !val);
301 321
322 if (yadif->auto_enable && yadif->next && !yadif->next->video->interlaced)
323 return val;
324
302 return val * ((yadif->mode&1)+1);325 return val * ((yadif->mode&1)+1);
303}326}
304 327
@@ -344,9 +367,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) · 39 unmodified lines
344 367
345 yadif->mode = 0;368 yadif->mode = 0;
346 yadif->parity = -1;369 yadif->parity = -1;
370 yadif->auto_enable = 0;
347 yadif->csp = NULL;371 yadif->csp = NULL;
348 372
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);
350 374
351 yadif->filter_line = filter_line_c;375 yadif->filter_line = filter_line_c;
352 if (HAVE_SSSE3 && cpu_flags & AV_CPU_FLAG_SSSE3)376 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
356 else if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX)380 else if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX)
357 yadif->filter_line = ff_yadif_filter_line_mmx;381 yadif->filter_line = ff_yadif_filter_line_mmx;
358 382
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);
360 384
361 return 0;385 return 0;
362}386}

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