From patchwork Sat Dec 24 09:41:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 1904 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp228776vsb; Sat, 24 Dec 2016 01:41:14 -0800 (PST) X-Received: by 10.28.113.76 with SMTP id m73mr16003505wmc.114.1482572474026; Sat, 24 Dec 2016 01:41:14 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e70si35058775wma.135.2016.12.24.01.41.13; Sat, 24 Dec 2016 01:41:13 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BE1A4689ACB; Sat, 24 Dec 2016 11:41:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef2.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 36B06680501 for ; Sat, 24 Dec 2016 11:41:04 +0200 (EET) Received: from phare.normalesup.org (archicubes.ens.fr [129.199.129.80]) by nef2.ens.fr (8.13.6/1.01.28121999) with ESMTP id uBO9f5Aq008350 for ; Sat, 24 Dec 2016 10:41:05 +0100 (CET) Received: by phare.normalesup.org (Postfix, from userid 1001) id 0B4E2E0087; Sat, 24 Dec 2016 10:41:05 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Dec 2016 10:41:00 +0100 Message-Id: <20161224094101.27898-1-george@nsup.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161224093958.GA2111506@phare.normalesup.org> References: <20161224093958.GA2111506@phare.normalesup.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Sat, 24 Dec 2016 10:41:05 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 1/2] lavf/framesync: detect EOF immediately. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fix an infinite loop in forward_status_change(). Signed-off-by: Nicolas George --- libavfilter/framesync.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c index 7920cdb379..eb05d66a86 100644 --- a/libavfilter/framesync.c +++ b/libavfilter/framesync.c @@ -18,6 +18,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#define FF_INTERNAL_FIELDS 1 +#include "framequeue.h" + #include "libavutil/avassert.h" #include "avfilter.h" #include "bufferqueue.h" @@ -314,7 +317,7 @@ int ff_framesync_filter_frame(FFFrameSync *fs, AVFilterLink *inlink, int ff_framesync_request_frame(FFFrameSync *fs, AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; - int input, ret; + int input, ret, i; if ((ret = ff_framesync_process_frame(fs, 0)) < 0) return ret; @@ -323,6 +326,11 @@ int ff_framesync_request_frame(FFFrameSync *fs, AVFilterLink *outlink) if (fs->eof) return AVERROR_EOF; input = fs->in_request; + /* Detect status change early */ + for (i = 0; i < fs->nb_in; i++) + if (!ff_framequeue_queued_frames(&ctx->inputs[i]->fifo) && + ctx->inputs[i]->status_in && !ctx->inputs[i]->status_out) + input = i; ret = ff_request_frame(ctx->inputs[input]); if (ret == AVERROR_EOF) { if ((ret = ff_framesync_add_frame(fs, input, NULL)) < 0)