| @@ -44,6 +44,12 @@ typedef struct { · 43 unmodified lines |
| 44 | 44 | |
| 45 | 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 | 53 | AVFilterBufferRef *cur; |
| 48 | 54 | AVFilterBufferRef *next; |
| 49 | 55 | AVFilterBufferRef *prev; |
| @@ -240,6 +246,14 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 190 unmodified lines |
| 240 | 246 | if (!yadif->cur) |
| 241 | 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 | 257 | if (!yadif->prev) |
| 244 | 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 | 273 | if (!yadif->out) |
| 260 | 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 | 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 | 320 | assert(yadif->next || !val); |
| 301 | 321 | |
| 322 | + if (yadif->auto_enable && yadif->next && !yadif->next->video->interlaced) |
| 323 | + return val; |
| 324 | + |
| 302 | 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 | 368 | yadif->mode = 0; |
| 346 | 369 | yadif->parity = -1; |
| 370 | + yadif->auto_enable = 0; |
| 347 | 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 | 375 | yadif->filter_line = filter_line_c; |
| 352 | 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 | 380 | else if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) |
| 357 | 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 | 385 | return 0; |
| 362 | 386 | } |