From patchwork Wed Nov 1 20:39:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 5821 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp1217585jah; Wed, 1 Nov 2017 13:40:03 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Twv3seNZ8Z8VIjgmjaBTtRmaVXA4lj2lppQ0pQNmtYqhTMghURB0KHRHPK2nHGZ75z0s47 X-Received: by 10.28.58.145 with SMTP id h139mr1066650wma.56.1509568803098; Wed, 01 Nov 2017 13:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509568803; cv=none; d=google.com; s=arc-20160816; b=OPSUyicNa9VyClWnizL064eqPzHTlhVokeWzESiVkjgnGkdPQTfn0QbwiAre/lEZSB abFgls5AQPQXjFXIpD1gKHYhKB70KgPbSrQJCnxXCTRqCmioEQl9i/R6WABuIbB/vJA7 rf7ZXJ6lB4CrHoQe9mWLggMURK1mg1+JC0dJeUHoMSs5K7jwGYo3NUdMQVfg62zRoScW DmF40DCFek8dDyMVV+MT+HGRUQ8kdrWW92ijr11j1sfF8V9800KwyF/6fXYVa+ttJTDP 3RArv2aFA50cNAKVNt1uEAxiZlo+RKpOGEyriFS+iscrXj/zBzMcVtGiFbidSwDqWD7X xFuA== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=mEcPsuWkxn3IRpXgPPT+KMAxHwcTMSDuKxbBjhY/2Ts=; b=iSNoB6x3TbZfX4QesnYkOcMpdAOeA/tWmroTCZb2eGiOv/Zg9Z8eaJODgSLVlTke4F X6mpn0KXIK1P3bs/dkSuWO9GbKvZF0jUOlYi3A2gBWJ4TdgRnGQ5sXdBu7Xr23U2M40y K8usVUgQQLtTtXiEseKEUcHmwDCVlvd93pjSpIFA4D6JLW2SA4mDvDnPvsqwU/G3x9Sm RiBiONJwIxMyDzzpo7kSwE2So1S3w23PGHtGmDvkPTFLjJ1Sz62NBnv/H8GuCnWd3Ymp R1sOU4vUDgSTNUXNEJnzvYldZb0f82oKTwk5YcLoeZalCtSGKOm+CeucDOaG6PROmpfX z7jg== 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 r28si1411297wrr.64.2017.11.01.13.40.02; Wed, 01 Nov 2017 13:40:03 -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 81C4A68A218; Wed, 1 Nov 2017 22:39:51 +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 1703468A12E for ; Wed, 1 Nov 2017 22:39:45 +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 vA1KdsXj069866 for ; Wed, 1 Nov 2017 21:39:55 +0100 (CET) Received: by phare.normalesup.org (Postfix, from userid 1001) id E6548E0095; Wed, 1 Nov 2017 21:39:54 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 1 Nov 2017 21:39:52 +0100 Message-Id: <20171101203953.11309-1-george@nsup.org> X-Mailer: git-send-email 2.14.2 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Wed, 01 Nov 2017 21:39:55 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 1/2] lavfi: check links properties after configuring them. 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" For now, check the image size. Inspired by a patch from Paul B Mahol. Invalid sizes would be detected later by allocation failures, detecting problems earlier is cleaner. Signed-off-by: Nicolas George --- libavfilter/avfiltergraph.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 69cf26896d..a009e0a760 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -28,6 +28,7 @@ #include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "libavutil/channel_layout.h" +#include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" @@ -263,6 +264,27 @@ static int graph_config_links(AVFilterGraph *graph, AVClass *log_ctx) return 0; } +static int graph_check_links(AVFilterGraph *graph, AVClass *log_ctx) +{ + AVFilterContext *f; + AVFilterLink *l; + unsigned i, j; + int ret; + + for (i = 0; i < graph->nb_filters; i++) { + f = graph->filters[i]; + for (j = 0; j < f->nb_outputs; j++) { + l = f->outputs[j]; + if (l->type == AVMEDIA_TYPE_VIDEO) { + ret = av_image_check_size2(l->w, l->h, INT64_MAX, l->format, 0, f); + if (ret < 0) + return ret; + } + } + } + return 0; +} + AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, const char *name) { int i; @@ -1256,6 +1278,8 @@ int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx) return ret; if ((ret = graph_config_links(graphctx, log_ctx))) return ret; + if ((ret = graph_check_links(graphctx, log_ctx))) + return ret; if ((ret = graph_config_pointers(graphctx, log_ctx))) return ret;