From patchwork Wed May 17 10:20:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41677 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:ba91:b0:105:feb:71f2 with SMTP id fb17csp1079455pzb; Wed, 17 May 2023 03:24:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7AOe9lPl8Xnuqr6xjVN1iYkHz6B5z922we17/7x4oJQgeR+ZrVlRbDLwtfnOMbKg2inmrW X-Received: by 2002:a17:907:80e:b0:94e:9a73:1637 with SMTP id wv14-20020a170907080e00b0094e9a731637mr33960971ejb.75.1684319050347; Wed, 17 May 2023 03:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684319050; cv=none; d=google.com; s=arc-20160816; b=zk95KdV9aN3bZnhVGIRWEgcwhlA/5SaqVp6m+PduHp+AvT6exdFr2kXIvM9UffiY2e ol/RtU5WeYs88/IabUGy/KjozdPu5e+xSzkzkEM+BpqHcuIxWzIU3CBpDrm+rRH+Lumo mFYZdIhy++1kTj3TSQ2T8UKeZi8aFtLklJQOMkCQuHbihNuNqYa/zsxPgy+Y5KVs2BhD vVqo15qp0gOMB8G4OkeEqWc/dkb7AtRea7iw+A9hp86nTMRV7HTRKaJns+aEYpB7UBjc AP86vXOEF5Vws8YrNer+5xOoWerUPnARsFiGQhM7RJBOLftd5W6rjjOa2DS2QzDyDpjE wuaQ== 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=OLMHgWkN7NTt5ZjNhX8c1364wRPBKfrXYheLGmpuJp8=; b=IclkSPlg7FRbvoBZV+NRW5G+4ucwgvCRFpTt2MpVSGZsKSqPD/B6RNoWNzpQJVHSc0 DseUcaLQoqDemtBnoaCsPBywp1MsDsJClAdSFlsixtZsVNIOP+WJDkSReQPViVZixp+Q iJ3NpkRcfYPqNhpkLd0FXXPBkeINrbLgEmb/yDqKZzcptBpSuhPMizKjXDU+RAWYam7b fYZcxbY+ozPMNtfOGGJZ63XdGmW5C11YWiV/hGkmgRjNxdDvNtTMd6qfQRXxZsENjsNQ UXvth9CiS1Ehs/7kEQWEET28SQEb2CaEoQgBxTAMRbZFLpfmrQYMLDcjqebGcjcYExQR +cNw== 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 rh7-20020a17090720e700b00953842dab75si14229415ejb.818.2023.05.17.03.24.09; Wed, 17 May 2023 03:24:10 -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 8745F68C1B7; Wed, 17 May 2023 13:21:14 +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 090B768C14B for ; Wed, 17 May 2023 13:20:53 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7BDBA2404F8 for ; Wed, 17 May 2023 12:20:51 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id dtC_5PSPOHEz for ; Wed, 17 May 2023 12:20:50 +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 001C22405F9 for ; Wed, 17 May 2023 12:20:46 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id DFDB73A168E for ; Wed, 17 May 2023 12:20:39 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 May 2023 12:20:05 +0200 Message-Id: <20230517102029.541-12-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230517102029.541-1-anton@khirnov.net> References: <20230517102029.541-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/36] fftools/ffmpeg_filter: only use fallback parameters when necessary 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: 3ChCKvIT75c/ With complex filtergraphs it can happen that the filtergraph is unconfigured because some other filter than the one we just got EOF on is missing parameters. Make sure that the fallback parametes for a given input are only used when that input is unconfigured. --- fftools/ffmpeg_filter.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 2c3e2a96f7..8eca0f2cae 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1521,17 +1521,19 @@ int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb) if (ret < 0) return ret; } else { - // the filtergraph was never configured, use the fallback parameters - ifilter->format = ifp->fallback.format; - ifilter->sample_rate = ifp->fallback.sample_rate; - ifilter->width = ifp->fallback.width; - ifilter->height = ifp->fallback.height; - ifilter->sample_aspect_ratio = ifp->fallback.sample_aspect_ratio; - - ret = av_channel_layout_copy(&ifilter->ch_layout, - &ifp->fallback.ch_layout); - if (ret < 0) - return ret; + if (ifilter->format < 0) { + // the filtergraph was never configured, use the fallback parameters + ifilter->format = ifp->fallback.format; + ifilter->sample_rate = ifp->fallback.sample_rate; + ifilter->width = ifp->fallback.width; + ifilter->height = ifp->fallback.height; + ifilter->sample_aspect_ratio = ifp->fallback.sample_aspect_ratio; + + ret = av_channel_layout_copy(&ifilter->ch_layout, + &ifp->fallback.ch_layout); + if (ret < 0) + return ret; + } if (ifilter->format < 0 && (ifilter->type == AVMEDIA_TYPE_AUDIO || ifilter->type == AVMEDIA_TYPE_VIDEO)) { av_log(NULL, AV_LOG_ERROR, "Cannot determine format of input stream %d:%d after EOF\n", ifilter->ist->file_index, ifilter->ist->st->index);