From patchwork Sat Feb 19 16:01:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 34412 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp1921743nkx; Sat, 19 Feb 2022 08:01:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzA/+DnX5lAzQD/phWOxdoWO4ro5xS7h0Bk9ntXK4W5EcQnOA89nowvVtdEJifUYaPjuXqj X-Received: by 2002:a17:906:1188:b0:6ce:f315:21df with SMTP id n8-20020a170906118800b006cef31521dfmr10472230eja.591.1645286513344; Sat, 19 Feb 2022 08:01:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645286513; cv=none; d=google.com; s=arc-20160816; b=0xSWyQ/HMVoIJO+EiXR6aU9afqb2HrzLnB2bf8lSms0auzLtkNQaRwbh6Mp/pkv2PB lTZqZEOPeuRxf1GQ/uPIAXKnmuQPYmdQDqgmB7yHOTvjIugYYzB4mDrt8rlBk0XgIVmh +mfmMtvSF9qQrscXto7vn9suNAe8PNSsdgQJipOMaFx4/7IBgmIUTJCU6JdYRa6k5OuX Q2a+SiYFnc06EZNK+C0LCoQkp+QupXLkLylW2gnGQfztwMCjkCDHleo1Wmjs6JTYLayI U5sF0Icfqx7A7KvNBDjC3dcPsiH0Uc2W+p4QFMV9/4gyiGZkEGGkQ9qh8gQy0om8562f g+tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=2U1pYCGFzoqEzEesyVxGCSsZ/rW517Nk3K9rdzg9ocI=; b=tIQj+EJHllYBO/zVUKS/tBmlXCt0gZX6i6/YTeRKcOx+/4YOkE7EIDwsNBj1RMq30x /MBJEuC7xAODuT0OP/wbITF8pDaIUkisqM5ZqA79uhEI2d7vHczg50xPB05rW5yFlatq Dxz9F5A489TjajVZV42a6Y44PbSZUWFoXwDCcIYqDtJVuTtR8I8vgM1jSZp/TcMSwk9Z MdGijm7VdCnWY6fuFmpJBAAFlUIRD5eCoO9Zbm5FCmRQ8IU9QJvLw2dyCO/SyUSyjYnd OxTqvJ5G2AQ6e1Z6vvkmFxWRZMic5fCa8Xi8jp1dhKEYUBhHF7GFgWqUUmlZHLHBlEHM D62w== 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 a16si3905529ejt.416.2022.02.19.08.01.48; Sat, 19 Feb 2022 08:01:53 -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 A77B168B16F; Sat, 19 Feb 2022 18:01:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C0D4668AFDD for ; Sat, 19 Feb 2022 18:01:39 +0200 (EET) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 21JG1coT006055 for ; Sat, 19 Feb 2022 17:01:39 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id D1953EB5BC; Sat, 19 Feb 2022 17:01:38 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Sat, 19 Feb 2022 17:01:36 +0100 Message-Id: <20220219160137.2806285-1-george@nsup.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Sat, 19 Feb 2022 17:01:39 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 1/2] lavfi: add ff_inoutlink_check_flow() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: kzDLwueethGz Signed-off-by: Nicolas George --- libavfilter/avfilter.c | 8 ++++++++ libavfilter/filters.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 7362bcdab5..1f37a70179 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -1559,6 +1559,14 @@ int ff_outlink_get_status(AVFilterLink *link) return link->status_in; } +int ff_inoutlink_check_flow(AVFilterLink *inlink, AVFilterLink *outlink) +{ + return ff_outlink_frame_wanted(outlink) || + ff_inlink_check_available_frame(inlink) || + inlink->status_out; +} + + const AVClass *avfilter_get_class(void) { return &avfilter_class; diff --git a/libavfilter/filters.h b/libavfilter/filters.h index 1157755403..86bc49d459 100644 --- a/libavfilter/filters.h +++ b/libavfilter/filters.h @@ -258,4 +258,12 @@ static inline void ff_outlink_set_status(AVFilterLink *link, int status, int64_t } \ } while (0) +/** + * Check for flow control between input and output. + * This is necessary for filters that may produce several output frames for + * a single input event, otherwise they may produce them all at once, + * causing excessive memory consumption. + */ +int ff_inoutlink_check_flow(AVFilterLink *inlink, AVFilterLink *outlink); + #endif /* AVFILTER_FILTERS_H */