From patchwork Sun May 28 09:14:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41873 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp988712pzb; Sun, 28 May 2023 02:18:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ48ORl3z6sq2IYKeV4bI/zWXRC10o047KGIpLAOLd3bvpQ63s2SLcV20EiveFLYg88AzsLk X-Received: by 2002:aa7:d44f:0:b0:50d:b92e:d1dc with SMTP id q15-20020aa7d44f000000b0050db92ed1dcmr5427672edr.14.1685265514918; Sun, 28 May 2023 02:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685265514; cv=none; d=google.com; s=arc-20160816; b=kW9t4JqpjDXPDFaxUrkVpUy+c0ytBaIUfiw8fhilsZ07HNlVT+rChptM7HncyEMyEv x+4QwHyDOtDiPRuoqFGGD9P8MH0k21yItp8RbwbpByFZ5N5tvzQfDK4hmLyV33R/dpAF 371R2xZvbNnmfzylO5Po5Bfp8++4dlGaKxKFsOSkEY4e7NpzQ/bCi1RJ5cfYzhvHNcYa j81iGLf+FzeZllYRxn21CFUYPe0/SINHFeYe7hJBaRq8YPLSo8FG4d7ZoAoLYZqU+Sma EIkyPKOlfGb+rYtnI84unjczTcS3IUNai6nXrWkEPlLnkPN6oF+KqT+xtix/gdwgY6mQ x/3A== 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=UMaFpI0qev8wW2byvTueyaQOutBq2VFtDOT/YpR4sPo=; b=cuDwPWZaiHPJHPF82Eub323O7ARBsZ08Zs1IKwXdj6Ypx9BZi6s6JQc+znuHH1F9UM aWflCZ/ol3Tlt9Q9fLTzi+a68HWt68q4bAIw5CAgTPtx+nu8tUv901SICAKFlTokKmdu ahDIKHEgIFzGWjbKxR9TBfl1ufXfV8qOj3bZFzixVtnPhqlqWG7wu4y8+buHvCemEO+r 5Nd5oJgtN7d6RqAehHWnxAAkj4zLzXvh+zpJzcIDGHACZ9PlXRbzS9iv7u/JCNtpQSQc YUMu6yGFH5L3bHSiiTnfssch48TizhDhwxy9O9fs6eo8BRizF/jhlQYjk1+opcc1AWZI plww== 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 o6-20020a056402038600b0051478d4ec4csi3155982edv.342.2023.05.28.02.18.34; Sun, 28 May 2023 02:18:34 -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 AA5BC68C294; Sun, 28 May 2023 12:15:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A6DE68C229 for ; Sun, 28 May 2023 12:15:01 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id CD26E240177 for ; Sun, 28 May 2023 11:15:00 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id LFnVowO0CvIC for ; Sun, 28 May 2023 11:14:57 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id D0357240D03 for ; Sun, 28 May 2023 11:14:47 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 833173A082C for ; Sun, 28 May 2023 11:14:41 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 May 2023 11:14:03 +0200 Message-Id: <20230528091416.17927-11-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230528091416.17927-1-anton@khirnov.net> References: <20230528091416.17927-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/24] fftools/ffmpeg_filter: try to configure filtergraphs earlier 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: j2DqLjOycksg When the filtergraph has no inputs, it can be configured immediately when all its outputs are bound to output streams. This will simplify treating some corner cases. --- fftools/ffmpeg_filter.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 3f6b906468..3bf1862ab6 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -504,6 +504,7 @@ static void set_channel_layout(OutputFilter *f, OutputStream *ost) void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) { + FilterGraph *fg = ofilter->graph; const AVCodec *c = ost->enc_ctx->codec; ofilter->ost = ost; @@ -538,6 +539,23 @@ void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) } break; } + + // if we have all input parameters and all outputs are bound, + // the graph can now be configured + if (ifilter_has_all_input_formats(fg)) { + int ret; + + for (int i = 0; i < fg->nb_outputs; i++) + if (!fg->outputs[i]->ost) + return; + + ret = configure_filtergraph(fg); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error configuring filter graph: %s\n", + av_err2str(ret)); + exit_program(1); + } + } } static InputFilter *ifilter_alloc(FilterGraph *fg)