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 */ From patchwork Sat Feb 19 16:01:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 34413 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp1921937nkx; Sat, 19 Feb 2022 08:02:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxylBq9HzwNqy1hXjwJyCvD54qghy/wsmSgowpGvM7CjMhkHD/LshBawkKyP7hZXLTypcnE X-Received: by 2002:a17:906:5a94:b0:6c5:5aa4:da87 with SMTP id l20-20020a1709065a9400b006c55aa4da87mr10691614ejq.381.1645286525709; Sat, 19 Feb 2022 08:02:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645286525; cv=none; d=google.com; s=arc-20160816; b=j2FC8bo//Om5IkYiFiLpqLzrQofXRCLKnr4z9XbuQOa2X4KeD+xJJ1eSBqWXUVZgxy 9G9AU+TtyYPAG7EAshu5Fn/2vvd0tkCF6Q362fJcon+MnXg5frAqmeX47NPMIuBSAoj2 l/9KEfUxMeTgbkZ71J4YtJFCLP3NVCoZnbW2xOyQXbxdLWXRYli3AHpbvcKdezt84ynb NuTmw4UQ+9SW175s1/UG2i0JS7dzXWi1jkoOI8wQzUdewiaS3mrJuBdwj+UP9QCsqjdN abHiQKgF4Z9jS1ihUZEiN16vCScbOds0Ly5NUTuq2FDXI2CFFIL/HM+oQqzJwFO+udLV tcWw== 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:references:in-reply-to:message-id :date:to:from:delivered-to; bh=FkipDacBYHSYzzHaI3OhqhejnmyOPJ9bw3xKZMlWhs0=; b=0MZEcf4tSsS/i9vukzienrvXN+TCDPe4Su+8P1qFjENyaccKokvyB8XjPmzNOLsKiU WZdILcoZt9Qo7bKHikA7EHeyjlzOwRCSKqiUOuLXajRYtdgT/A/IBPW/LgyQpQomgR4y QRn1Au8fIyqrRMCgcIrV9/2SGrMWEslhpxxtZq4EVm5KgVEj66kzPGCV8E3mIB9R3bwa H+Wcawb/mh2ciZ0GJofN2TwQ7jAB9EpypbrtP7Yl4S59uyPS5tDYuu/+fQ7Xfwe+/GEn 2yriuuZMwdfL+uVBISwyRn9qH/kp9iW1eLi13kGQAObtQ+RTkADviJ5LyyEwVPBUVtCM pIuA== 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 di17si5617829ejc.956.2022.02.19.08.01.58; Sat, 19 Feb 2022 08:02:05 -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 A6FAA68B19F; Sat, 19 Feb 2022 18:01:46 +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 D20A368B021 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 21JG1df3006056 for ; Sat, 19 Feb 2022 17:01:39 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id 106C8EB5BD; Sat, 19 Feb 2022 17:01:39 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Sat, 19 Feb 2022 17:01:37 +0100 Message-Id: <20220219160137.2806285-2-george@nsup.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220219160137.2806285-1-george@nsup.org> References: <20220219160137.2806285-1-george@nsup.org> 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 2/2] lavfi/vf_fps: check flow before sending more frames 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: II8bwBMElRsK Analyzed by Paul B Mahol . Fixes OOM in #9081. Signed-off-by: Nicolas George --- libavfilter/vf_fps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index 99e679441e..0e5a1fec35 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -351,7 +351,7 @@ static int activate(AVFilterContext *ctx) if (s->frames_count > 0) { ret = write_frame(ctx, s, outlink, &again); /* Couldn't generate a frame, so schedule us to perform another step */ - if (again) + if (again && ff_inoutlink_check_flow(inlink, outlink)) ff_filter_set_ready(ctx, 100); return ret; }