From 60796d22f9a74625bcb823c50b2406cd764726d5 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 30 Aug 2020 11:07:51 +0200 Subject: [PATCH] avfilter/vf_xfade: fix excessive number of queued frames Also do not abort in some cases too early when transition is over. Fixes #8823. --- libavfilter/vf_xfade.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libavfilter/vf_xfade.c b/libavfilter/vf_xfade.c index adfcd759a8..7412709587 100644 --- a/libavfilter/vf_xfade.c +++ b/libavfilter/vf_xfade.c @@ -1779,10 +1779,9 @@ static int xfade_activate(AVFilterContext *ctx) ff_outlink_set_status(outlink, status, s->pts); return 0; } else if (!ret) { - if (ff_outlink_frame_wanted(outlink)) { + if (ff_outlink_frame_wanted(outlink)) ff_inlink_request_frame(ctx->inputs[1]); - return 0; - } + return 0; } } @@ -1832,14 +1831,17 @@ static int xfade_activate(AVFilterContext *ctx) if (!s->eof[1] && ff_outlink_get_status(ctx->inputs[1])) { s->eof[1] = 1; } - if (!s->eof[0] && !s->xf[0]) + if (!s->eof[0] && !s->xf[0] && ff_inlink_queued_frames(ctx->inputs[0]) == 0) ff_inlink_request_frame(ctx->inputs[0]); - if (!s->eof[1] && (s->need_second || s->eof[0])) + if (!s->eof[1] && (s->need_second || s->eof[0]) && ff_inlink_queued_frames(ctx->inputs[1]) == 0) ff_inlink_request_frame(ctx->inputs[1]); if (s->eof[0] && s->eof[1] && ( - ff_inlink_queued_frames(ctx->inputs[0]) <= 0 || - ff_inlink_queued_frames(ctx->inputs[1]) <= 0)) + ff_inlink_queued_frames(ctx->inputs[0]) <= 0 && + ff_inlink_queued_frames(ctx->inputs[1]) <= 0)) { ff_outlink_set_status(outlink, AVERROR_EOF, AV_NOPTS_VALUE); + } else if (s->xfade_is_over) { + ff_filter_set_ready(ctx, 100); + } return 0; }