From patchwork Sat Dec 24 17:41:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 1921 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp383954vsb; Sat, 24 Dec 2016 09:44:10 -0800 (PST) X-Received: by 10.194.80.162 with SMTP id s2mr17373060wjx.52.1482601450174; Sat, 24 Dec 2016 09:44:10 -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 an4si40003660wjc.19.2016.12.24.09.44.09; Sat, 24 Dec 2016 09:44:10 -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 9DD58689CFA; Sat, 24 Dec 2016 19:42:18 +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 18C3B6899BE for ; Sat, 24 Dec 2016 19:42:06 +0200 (EET) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef2.ens.fr (8.13.6/1.01.28121999) with ESMTP id uBOHg7ce095801 for ; Sat, 24 Dec 2016 18:42:07 +0100 (CET) Received: by phare.normalesup.org (Postfix, from userid 1001) id 11209E0087; Sat, 24 Dec 2016 18:42:07 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Dec 2016 18:41:41 +0100 Message-Id: <20161224174149.8995-10-george@nsup.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161224174149.8995-1-george@nsup.org> References: <20161224174149.8995-1-george@nsup.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 18:42:07 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 09/17] lavfi: use the consume helpers in ff_filter_frame_to_filter(). 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" Signed-off-by: Nicolas George --- libavfilter/avfilter.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index e2eb2980be..1df1157f02 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -1252,24 +1252,25 @@ static int take_samples(AVFilterLink *link, unsigned min, unsigned max, int ff_filter_frame_to_filter(AVFilterLink *link) { - AVFrame *frame; + AVFrame *frame = NULL; AVFilterContext *dst = link->dst; int ret; av_assert1(ff_framequeue_queued_frames(&link->fifo)); - if (link->min_samples) { - int min = link->min_samples; - if (link->status_in) - min = FFMIN(min, ff_framequeue_queued_samples(&link->fifo)); - ret = take_samples(link, min, link->max_samples, &frame); - if (ret < 0) - return ret; - } else { - frame = ff_framequeue_take(&link->fifo); + ret = link->min_samples ? + ff_link_consume_samples_sure(link, link->min_samples, link->max_samples, &frame) : + ff_link_consume_frame_sure(link, &frame); + av_assert1(ret); + if (ret < 0) { + av_assert1(!frame); + return ret; } /* The filter will soon have received a new frame, that may allow it to produce one or more: unblock its outputs. */ filter_unblock(dst); + /* AVFilterPad.filter_frame() expect frame_count_out to have the value + before the frame; ff_filter_frame_framed() will re-increment it. */ + link->frame_count_out--; ret = ff_filter_frame_framed(link, frame); if (ret < 0 && ret != link->status_out) { ff_avfilter_link_set_out_status(link, ret, AV_NOPTS_VALUE);