From patchwork Thu Sep 7 08:59:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 5029 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp1673477jao; Thu, 7 Sep 2017 02:00:33 -0700 (PDT) X-Google-Smtp-Source: ADKCNb44KH7mkbIvCca9R4/GGyiHocn73wmQYJxvXNKCAA07cfVyY4Cc8soLkTGs3mrDdFSnW5Dm X-Received: by 10.28.72.87 with SMTP id v84mr121927wma.138.1504774833282; Thu, 07 Sep 2017 02:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504774833; cv=none; d=google.com; s=arc-20160816; b=oVjAHfZ5LB7+PTS6CWdXT/0XUxpPnS9cr2+FU+C1sUXuOdK/Lk1EhkJX9WHLX6VoWo ted2jzFMHG4/kXrDO6uhdTdPydaZwrwnWP390HlRJGjqm/uCDqN8cyDt6yvI1t9SqmPr /YDbpw/mC6xurI+xnKmr7AIfzzDGHctcBDJv+Swa5vEZ65fQgEfHF4cKhFpKSKxCeQR3 ikvfwiCMkQqJC9gVUfeoanQQHxOmoOCvh6HVAB+Bg7AG/4Nauyz3aWO+BCWfUsDTReZC 7K5b+fy+5TTRPiAVO3e3ydt+3Nk9GjxUTtHrzkx+EejsQaQybX1T3Nv+/KxUv4TB+/3c hiEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=tATfC2WKg2Lx6YLuyU0KzkmRLZSXP4kqcSymNEoUrPg=; b=OQX9VbOT2jYHTVNC5LUbz3fV5bf5k/Khkdkt/wMa73CSH88WqIXGMEA9Hj9tEMNdcB ekrddF1d44CLSTjnkKv57LulBeXCu8GgM6+dacP0hfh7dxyLquahjycRl5JTR2wa+SrJ aXIBRWbFMvvW14V23AZFVfAaiuyICdb1pye3NZOToK2YjaFBe9mxHf1ZDgIsRhNM2qcx 8f+dCuZdYmyoWImpFgNi9gNU2I0zFGL/VeR6W4GAj/adEKEYLUyXXDi16taPVvUSUsXm EmQHVR1Ygky0TKJACffKhkEQFwtG6DTEaNyoOU9d0Nu3GB+WkjyvLL6lmfwZSJo/nphy VGwA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u34si1735950wrf.325.2017.09.07.02.00.32; Thu, 07 Sep 2017 02:00:33 -0700 (PDT) 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 EB284689E4B; Thu, 7 Sep 2017 11:59:52 +0300 (EEST) 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 BF756689E31 for ; Thu, 7 Sep 2017 11:59:44 +0300 (EEST) 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 v878xfC3089843 for ; Thu, 7 Sep 2017 10:59:42 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id C0F3BE00AB; Thu, 7 Sep 2017 10:59:41 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Sep 2017 10:59:38 +0200 Message-Id: <20170907085939.21770-4-george@nsup.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170907085939.21770-1-george@nsup.org> References: <20170907085939.21770-1-george@nsup.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Thu, 07 Sep 2017 10:59:42 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 4/5] lavfi/buffersrc: add av_buffersrc_close(). 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" TODO APIChanges and minor bump. Signed-off-by: Nicolas George --- libavfilter/buffersrc.c | 22 ++++++++++++---------- libavfilter/buffersrc.h | 8 ++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index e8f59c2de7..ad5aedd5f7 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -196,16 +196,9 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx, s->nb_failed_requests = 0; - if (!frame) { - s->eof = 1; - ff_avfilter_link_set_in_status(ctx->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE); - if ((flags & AV_BUFFERSRC_FLAG_PUSH)) { - ret = push_frame(ctx->graph); - if (ret < 0) - return ret; - } - return 0; - } else if (s->eof) + if (!frame) + return av_buffersrc_close(ctx, AV_NOPTS_VALUE, flags); + if (s->eof) return AVERROR(EINVAL); refcounted = !!frame->buf[0]; @@ -267,6 +260,15 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx, return 0; } +int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags) +{ + BufferSourceContext *s = ctx->priv; + + s->eof = 1; + ff_avfilter_link_set_in_status(ctx->outputs[0], AVERROR_EOF, pts); + return (flags & AV_BUFFERSRC_FLAG_PUSH) ? push_frame(ctx->graph) : 0; +} + static av_cold int init_video(AVFilterContext *ctx) { BufferSourceContext *c = ctx->priv; diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h index e42c78196b..0652113f2b 100644 --- a/libavfilter/buffersrc.h +++ b/libavfilter/buffersrc.h @@ -193,6 +193,14 @@ av_warn_unused_result int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src, AVFrame *frame, int flags); +/** + * Close the buffer source after EOF. + * + * This is similar to passing NULL to av_buffersrc_add_frame_flags() + * except it takes the timestamp of the EOF, i.e. the timestamp of the end + * of the last frame. + */ +int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags); /** * @}