From patchwork Mon Oct 7 10:50:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 52087 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:938f:0:b0:48e:c0f8:d0de with SMTP id z15csp1832195vqg; Mon, 7 Oct 2024 03:51:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUEnNro6/iI3KVDE8vaWi3duOaxPVWglu5Q54dpDmN/3D8X3HU6tiGWgm1kXC86DNnoZGAlbZSI+e6pgu1yjLmB@gmail.com X-Google-Smtp-Source: AGHT+IFTc19lNkf7mQEHvPxa6JEHABapFXUrefvZdP/Q7JIA/O5QB8O3e1rdkdB4i6SZz5WTniWJ X-Received: by 2002:a05:6512:3e01:b0:530:aea3:4659 with SMTP id 2adb3069b0e04-539ab84a2f2mr5684569e87.9.1728298291528; Mon, 07 Oct 2024 03:51:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728298291; cv=none; d=google.com; s=arc-20240605; b=HtZsMJpYEk0XqYWIgWhoO0SfqFtGU2Sm6M3iSoPJtkPQ5saQTyT0ZMabxfn6FhF+tk mKOWKK6wr+qo0AKPPctaQvdR+koF79a678RQbYuCMZPlx0/2eTkBQVn+TuqUp4MK1dd4 gp0CeQnSgNtpVxoOVmqsLa2hWFekZH+CBIkpWlv6j1nNCs3ps99LRH7ImLGAZv8xvv3G bff8kpmzw65yywu4gy9GebIKpA1FAj3GQCXu8QCtwx50iFa1XWhhdHsY+LCYV4gWF9Pr q8iUZ5uNT49IaeyR+LhSQundat1En5C9Kgx/+KHchzKgWsEYkWRnrATdJ15ed7p7OFNc kEUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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 :dkim-signature:delivered-to; bh=FNaYM5UjXoA7IKRyd5mnK6PK5Zg5U97QsorijV/Ckcs=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=IwgsF2f4O2Ux4173zksjcsfHmGtzx1qLR38ipjXozZko+HkWRFoDj2crBFwfEQz66o dSXyaHVOJGv2fjzcCTAQrOm1wef1XA9iXqdavaePF3miYgSgO6NubtHRvwvPlUfe4pEy Yc+bIiR/FwVOmF8lLyFTp/0xiv4JTfllSV2iCeaJzChI9cFntPoda7Pkl0M2JGNb5+5f cZuHUcWB/ztnWEt82t2EZWlSlr/6dMbZEf9VZF69SuIUZYOvphAs3zZfrG+Ux+YR9me0 4kp/BtPqqFnvHjDRH10C9fe9pKxR8vrAzWSbJ6imaKm9BWvN3tYSFP6qFr3OBvNCR8sf d2/Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=bM11mVEn; 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 2adb3069b0e04-539afec2b1asi1617061e87.58.2024.10.07.03.51.30; Mon, 07 Oct 2024 03:51:31 -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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=bM11mVEn; 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 E36E468DB31; Mon, 7 Oct 2024 13:50:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0164468DA36 for ; Mon, 7 Oct 2024 13:50:38 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=bM11mVEn; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 9BB7CEFF for ; Mon, 7 Oct 2024 12:50:38 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id EbvYRMqLpCFz for ; Mon, 7 Oct 2024 12:50:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1728298236; bh=Z4buApuPtV9ZnpzT+h8kBzX3/4b0BeIeqdZRGNpcD2U=; h=From:To:Subject:Date:From; b=bM11mVEnamKixPZvWIV/5gdsWz+1TTaqiatXlVmdejhfNdGtfG77unvD0gSb+EzCO sFX2YARGiU2oKfywn9YH49iEIo/iykhLousQM1DejJuF7pNyPRY5/qbgpEtU1NART2 Pq0t9UF4/PKd1at+WePcNDMYFoAyej9qTYmTFo+lDVjo3/7dxOGK9heBB0BsK4HSoY Gzf6JMRs/gymaJ6vNIHgGN58J6h+z0Wbvn0pUFkzbuxb2RCLhZnflJ5Ekyv0N1ltyd UDL0QN2rcXlGAoFzUl/fwQjVtyL6HKuNGixtOqugYtxkxdJ1laztUqQPDLnhnG8eTT fP7GBdZLzA00g== 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 mail1.khirnov.net (Postfix) with ESMTPS id C7F444DF5 for ; Mon, 7 Oct 2024 12:50:36 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5D6D63A02AF for ; Mon, 07 Oct 2024 12:50:30 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Oct 2024 12:50:12 +0200 Message-ID: <20241007105016.1597-1-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] fftools/cmdutils: group related calls together 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: vALwD0HY6ocd For readability only, should have no functional effect. --- fftools/cmdutils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 9beed94ead..9eb49dbf20 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -551,11 +551,12 @@ static void check_options(const OptionDef *po) void parse_loglevel(int argc, char **argv, const OptionDef *options) { - int idx = locate_option(argc, argv, options, "loglevel"); + int idx; char *env; check_options(options); + idx = locate_option(argc, argv, options, "loglevel"); if (!idx) idx = locate_option(argc, argv, options, "v"); if (idx && argv[idx + 1]) From patchwork Mon Oct 7 10:50:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 52089 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:938f:0:b0:48e:c0f8:d0de with SMTP id z15csp1845841vqg; Mon, 7 Oct 2024 04:16:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWd9OiRhia9R9ENG92GU06+MG6/M00M2MMbasRb2a9JfF6mfZgnbJ2SxeBoi2OGMoI/TGNG2g2ip2eWc3d25uN0@gmail.com X-Google-Smtp-Source: AGHT+IFg5nrRv5VekrJ4txIWg1nYD87RDLriQdazlMOqIxwDnrEv9/oXFWouPi+5tCpVpvT6Lxso X-Received: by 2002:a05:6512:12c3:b0:530:ab86:3 with SMTP id 2adb3069b0e04-539ab84a49bmr4753708e87.1.1728299788064; Mon, 07 Oct 2024 04:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728299788; cv=none; d=google.com; s=arc-20240605; b=QsxJM3twe5aCqyiG7O33apiQxpgNyaacOM2EyRShGs42b9Vq5hPbAQ8h7GMYlHIIpj 3tqUkKVtjXJ4mVLfQfpppcUqpgo10wT3ImjvjrztP/CET1RTSLga1/LP0vZ7/Wk3Lsw6 Wb9UrwmU36AWRwawY+j+90Y3a9FS5e2qsyKzWPRLJqBX00wH8OucnlTu4FVuL0s2SNuE W0h0eYUO1FwaeyUPMpKqlRYkQF4JbdHRVygMDyYJpS177V510kT+YTXXCAqcjREGpXTP ks3c84XAXgAuErwRvB01nuUBsAhEYDkUeT3V4db4uSpOnP80bZEAzxD9mtfS3LngvGQj ndUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:dkim-signature:delivered-to; bh=ydPwpn2Bo3v0dprW9Hw7iW5MLY0Ut5Dl8vTDkKwoEmg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=D4oCzYGgCNoDpRg0zvTFkMqfTLOwdKLce6Y9+gv1Q0KbI62bTXPG0EGBW8XG7DXAwW Zl4lvn2ukVJu6W3fwhujYFajYwp2rRAyN778kEu2jLEWKMZUoigNZM9KVAdQQ6jJdXxA C92fn+mN1hAL2HoR9O72WSeoWFzRDex2tmzYIwUOgdjez+N3GjLMd/VWNnDYstHt8Yx+ GZPemI3BWJgO+axRqKpopPWV9dak7mRgagpcanY9taI0IEiD3Imeb5KVNoSaDIZL2H5N kmCYzie71TlP6oEYcoWuGlr5IKcqF9n7Pt46OOX0DcEh6l8LBsWt2RMSvOrkcV28JfxD wC3g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=i+eqY6Oi; 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 a640c23a62f3a-a992e81c64esi428854166b.924.2024.10.07.04.16.04; Mon, 07 Oct 2024 04:16:28 -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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=i+eqY6Oi; 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 6E2E868DB0E; Mon, 7 Oct 2024 13:50:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DB24E68DA16 for ; Mon, 7 Oct 2024 13:50:38 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=i+eqY6Oi; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 5435C4E1B for ; Mon, 7 Oct 2024 12:50:38 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 1BGKsY4vGhtm for ; Mon, 7 Oct 2024 12:50:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1728298236; bh=WEi9ASks6UgxTONmdTeFspInDn6yDaHenjWETa4yuho=; h=From:To:Subject:Date:In-Reply-To:References:From; b=i+eqY6OibqVVPPj0GkTxjFfUNs4mylgtSF670yMVTLTx/AbAYx2ouKaBtjEgCn5vB 1jKqM3lMUYL+rvh2FwZRz1xPHJe9Rnjwm4/aLfJC2/L8C+JEpBd5vEmtK7+DhSQOL5 s9pVisNst4Xw5d8mSLTHDnOMI4ELkZHmSssu9fVNcnJYO+q7sOIqSQjhr3OWhb7TLX rU0EEdjMnnCEmIBVeKtIF1VKLURC407RhRDESYllVHMqd/OzUe9g4whTQMktZO++Z8 GF9aZXQrKCmQdIXTjI9rlCZl0fqzkR8w8zR+g6eXYK/w3g4QwxXGLA484nPBfhYz4L mLEEfgkPckUNg== 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 mail1.khirnov.net (Postfix) with ESMTPS id C5407EFF for ; Mon, 7 Oct 2024 12:50:36 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 6A6593A0F02 for ; Mon, 07 Oct 2024 12:50:30 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Oct 2024 12:50:13 +0200 Message-ID: <20241007105016.1597-2-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241007105016.1597-1-anton@khirnov.net> References: <20241007105016.1597-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] fftools/cmdutils: do not treat single '-' as an option in locate_option() 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: gKRlLl0uZ3Z4 Fixes early parsing of trailing -v/-loglevel while using '-' to output to stdout. --- fftools/cmdutils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 9eb49dbf20..8ac20bf049 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -492,8 +492,9 @@ int locate_option(int argc, char **argv, const OptionDef *options, for (i = 1; i < argc; i++) { const char *cur_opt = argv[i]; - if (*cur_opt++ != '-') + if (!(cur_opt[0] == '-' && cur_opt[1])) continue; + cur_opt++; po = find_option(options, cur_opt); if (!po->name && cur_opt[0] == 'n' && cur_opt[1] == 'o') From patchwork Mon Oct 7 10:50:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 52086 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:938f:0:b0:48e:c0f8:d0de with SMTP id z15csp1831850vqg; Mon, 7 Oct 2024 03:50:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVmwggRCcWd9IfB1fGX6xYwuTIrtoiLPttZ8AtD3x/jTxqEgwJ5WpDNVosGfYuyFFUKzZiJQeMn89nrctnLQ9Ei@gmail.com X-Google-Smtp-Source: AGHT+IGiJuzG9w5jc+MSdC2wlIXQWvA9xBExjhaUY6W0IbN+tZ9/peikJ29RcigmMzHn/mPwPg6g X-Received: by 2002:a17:907:9693:b0:a99:3d93:c8bc with SMTP id a640c23a62f3a-a993d93cc22mr867470566b.13.1728298249450; Mon, 07 Oct 2024 03:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728298249; cv=none; d=google.com; s=arc-20240605; b=FH4FHuH8ckd1fv+qdZ9NkFoq/KvBtBgssINZmcK3YynzfXL97PXQ5wribg3uva8YB6 6dDinlXyaGZGdodEATYxF10Z7Kr8SYa+wVCboaPt75RtJugj0MXdEDtjYat4pWUO9sRr DxjaJlcfzsq/NzydGfy3bskbK8DAfNByiv0ymgr7GXq8mCRgW1tenXLAVenNY9PNRtEu LkYhYMeccp3syeWfIsmAIWViNdRRrZjdX4pDVVb/yJc3AcHonsHMqN/7cPTdU9JoYpeo /Eqb1H34zs0P7hMaHIacM2NNVoMJ4vtArdB6FHcYsckrSfTxYc6yAjwam3x6Xc5nThnr Cztg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:dkim-signature:delivered-to; bh=SSfLouTB7nN6uBD0G5b1cT8wxIe1m77kTfigqMUxPF4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=b5yrqi1Mz657dt0kXfUOIGYosG7KJvSyYrH5aV3g85vSeFJ2ECsi53QCqruWFB9GLu WoO+Q3KF4dQ6qk6VQy6QmiE+n+IPLPRFmY7JGoonk3UwP23gSxVvMFJCQF9V+b77yk1O qQzgfMFFndcmeRGaDc5T8QtolGSNcOyxO+yV74yXIfo33SBrE+m4fpR+MBt0HuPhvDGv D/LCLk0agSxOqXcchum1cWo4nRs//V4xb+f34daPAFh51S2c9JxhlH12hZxM8j9W54x9 IzSqFMMUL/u2pjogV/2hFzrjST/DE5TD1bTP4hbJnpfBLIA+HhXsl2vnepi4dIANi0vY nGrA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=nGmEn1+x; 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 a640c23a62f3a-a99420e6fd8si309685266b.342.2024.10.07.03.50.49; Mon, 07 Oct 2024 03:50:49 -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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=nGmEn1+x; 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 7EF9068DAC8; Mon, 7 Oct 2024 13:50:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D0D1A68D449 for ; Mon, 7 Oct 2024 13:50:38 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=nGmEn1+x; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id DA55D4E18 for ; Mon, 7 Oct 2024 12:50:37 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id jlOL2Ht0Sg66 for ; Mon, 7 Oct 2024 12:50:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1728298236; bh=bdaM/5ENpK4XVpbLA3aolWfCTHCHW3HQidk8UWOBXkw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nGmEn1+xl5Kg7XjulixDHdDDVJ0fCyBZlMgQK9oyzz5yzHVZfOOqKXi+kWJiz6reQ 8xei3oSK5uj4RPjcHYNI1Sg0fC7kfelvGVD0cHI7DVCxm2D4VYjV+PtXWMVPc1ciE8 gRTd+IUhEWuez2mwTeDktcWWS1l5WOAjN1MOqU+PRBWODnBnT8Y878Ra2oespA7RSx Cm5aNxIhAJnM8R/dNji+O5B6TaDhdLJDSlwVvZVsgKuyYjXz9seur0k/pIViXRCBHg EOsOhbiAZVEHJfHv/9A7hCKcjGVSOwnY7eOICHUHZWpwHn6uio8lOwHcSS+kyT0h/8 iPEfNknR8DODA== 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 mail1.khirnov.net (Postfix) with ESMTPS id CA4C14DF6 for ; Mon, 7 Oct 2024 12:50:36 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 759CE3A0F41 for ; Mon, 07 Oct 2024 12:50:30 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Oct 2024 12:50:14 +0200 Message-ID: <20241007105016.1597-3-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241007105016.1597-1-anton@khirnov.net> References: <20241007105016.1597-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] fftools/ffmpeg_opt: add a struct to be passed as opaque to global-option handlers 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: LqKn1b8aMhxv Will be useful in following commits. --- fftools/ffmpeg_opt.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index f639a1cf0a..052e68e943 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -86,6 +86,12 @@ int ignore_unknown_streams = 0; int copy_unknown_streams = 0; int recast_media = 0; +// this struct is passed as the optctx argument +// to func_arg() for global options +typedef struct GlobalOptionsContext { + Scheduler *sch; +} GlobalOptionsContext; + static void uninit_options(OptionsContext *o) { /* all OPT_SPEC and OPT_TYPE_STRING can be freed in generic way */ @@ -611,8 +617,8 @@ static int opt_attach(void *optctx, const char *opt, const char *arg) static int opt_sdp_file(void *optctx, const char *opt, const char *arg) { - Scheduler *sch = optctx; - return sch_sdp_filename(sch, arg); + GlobalOptionsContext *go = optctx; + return sch_sdp_filename(go->sch, arg); } #if CONFIG_VAAPI @@ -1150,18 +1156,18 @@ static int opt_audio_qscale(void *optctx, const char *opt, const char *arg) static int opt_filter_complex(void *optctx, const char *opt, const char *arg) { - Scheduler *sch = optctx; + GlobalOptionsContext *go = optctx; char *graph_desc = av_strdup(arg); if (!graph_desc) return AVERROR(ENOMEM); - return fg_create(NULL, graph_desc, sch); + return fg_create(NULL, graph_desc, go->sch); } #if FFMPEG_OPT_FILTER_SCRIPT static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg) { - Scheduler *sch = optctx; + GlobalOptionsContext *go = optctx; char *graph_desc = file_read(arg); if (!graph_desc) return AVERROR(EINVAL); @@ -1169,7 +1175,7 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char * av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -/filter_complex %s instead\n", opt, arg); - return fg_create(NULL, graph_desc, sch); + return fg_create(NULL, graph_desc, go->sch); } #endif @@ -1346,6 +1352,7 @@ static int open_files(OptionGroupList *l, const char *inout, Scheduler *sch, int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch) { + GlobalOptionsContext go = { .sch = sch }; OptionParseContext octx; const char *errmsg = NULL; int ret; @@ -1361,7 +1368,7 @@ int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch) } /* apply global options */ - ret = parse_optgroup(sch, &octx.global_opts, options); + ret = parse_optgroup(&go, &octx.global_opts, options); if (ret < 0) { errmsg = "parsing global options"; goto fail; From patchwork Mon Oct 7 10:50:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 52097 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:938f:0:b0:48e:c0f8:d0de with SMTP id z15csp2043558vqg; Mon, 7 Oct 2024 09:17:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVdZ8CIy53gh0pwrzchXoI5CA/EsCdjcT++2009z4ff19J26OrOgmyU/Kp05spECwmPaxbc80jjcb56vgrGLNxk@gmail.com X-Google-Smtp-Source: AGHT+IGQmd6NVPhbmFtoFgUcjtUvVBUCYp4sgVdISEn656K71BmOp3A+k+HxkjLhuUdaPYs9I/c8 X-Received: by 2002:a05:6512:1389:b0:539:958f:1b8b with SMTP id 2adb3069b0e04-539ab9eb03fmr5406164e87.50.1728317765822; Mon, 07 Oct 2024 09:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728317765; cv=none; d=google.com; s=arc-20240605; b=iKZhp5FD6fhq3JGp55aEW8k95aoK30FpiU1sm+sQUisout3felzMeLvMYivii3cHvC 2CawM/hR5J3UZCjdtX4gG179PVeC7HPvRsSw/wB8Tb84ql7r8bryqhMlOBSTO70d7Up4 cRNigIGIt1Khobtiznv7TFos7RgkqtHOKIhIW7n+SbZJGG0JG4mT8wpqF20w1vb0/K65 OiawYGTC2cKKdWrmr8xuq2yfAb1B8HmAf6UGNp4G/9Y+a1uKhsPHwDjIyr7DnYs6VlXJ gVYMvFE55bjsGJziWE5voy7d8Lbq5R76ONY6xWYpMDwTvQg44JMPEzArhCZ6WZA4XziC XxRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:dkim-signature:delivered-to; bh=yaFYHGO6TdLuxlhgKCDCVBmiqdlCAd5ux0oyuFgvixI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=jOEFc9VdFLODenm0WVtJK/QB9+cJgV36g6xoCWH/vrWLpdL7VfS3+L+p1vNlag795s W5s3zLFAp9hPO/8IVg8wcVKIJjWlL/YQDMhnkPvO9aaj3GYhZCrYtf1FM+0Cnth69FLo oRcqC+mI9DK3oKgaf8tAgNp9z8kUMv2Iu7YLnliy3UacRSkOXISqIzlwLyAOzaI9MVoU Bp4UXMSpRvPnQXfYr3+hnUSx2pvKvvX2nU6Vr5rutD3YtSIRT0nsP/hxdvinwjbgeulh QWb/Vfh3R1JAzqI9CQ6OsZtWLI82YQrno8JOxqieJsQR0ZWLRHFlLL9vr/DKFzQ4y+n+ KKTg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=n8h2+Oh1; 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 2adb3069b0e04-539aff25736si1990702e87.355.2024.10.07.09.16.05; Mon, 07 Oct 2024 09:16:05 -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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=n8h2+Oh1; 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 0145768DAE5; Mon, 7 Oct 2024 13:50:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D3DC768D9E9 for ; Mon, 7 Oct 2024 13:50:38 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=n8h2+Oh1; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 4B4324DF6 for ; Mon, 7 Oct 2024 12:50:38 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id c84WYn2ItACN for ; Mon, 7 Oct 2024 12:50:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1728298236; bh=vOgys0xq7qQA/gR6TaF9AwWx5Fn2/gQJHmrpxQO6eqQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=n8h2+Oh1E7ti/RLv0pz2VeR/VYX0aqMt4VvIU0Wo3+B29iTSt8eMb4UX3G5xixj91 hc+5oXKtyxNMFVE+Ta3ZopLMy01GE0mmwY4m18IY4APzf9MVByNYxtTPgFNB+QCX30 MxOHYKCAI6m2rM15qm6FUOfl6AluVgR19bsVMBQ89UfepBqYnq8y2fNWXnmPLNZTi/ INx137WAb0SjHkkPDw585hf8+afIj9gZ2mhWzxHTcZUKZ4+Py7QJjXXt9GiDmwGjJK eYbA/ZHaTdJvpYf6sW7UkTxBRZoWTBM5Qt5rpI5aW5PBLNU7Y+X4+dZ5Dl7qkK4f8x nvJfWdgwwOIGQ== 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 mail1.khirnov.net (Postfix) with ESMTPS id CBB0E4E04 for ; Mon, 7 Oct 2024 12:50:36 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 817923A1A1B for ; Mon, 07 Oct 2024 12:50:30 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Oct 2024 12:50:15 +0200 Message-ID: <20241007105016.1597-4-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241007105016.1597-1-anton@khirnov.net> References: <20241007105016.1597-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] fftools/ffmpeg_filter: do not leak graph_desc on fg_create() failure 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: 21YPojaQP+ji fg_create() is passed a malloced string and assumed to always tak ownership of it. --- fftools/ffmpeg_filter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index faab003e71..4d444c161f 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1058,8 +1058,10 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch) int ret = 0; fgp = av_mallocz(sizeof(*fgp)); - if (!fgp) + if (!fgp) { + av_freep(&graph_desc); return AVERROR(ENOMEM); + } fg = &fgp->fg; if (pfg) { @@ -1068,6 +1070,7 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch) } else { ret = av_dynarray_add_nofree(&filtergraphs, &nb_filtergraphs, fgp); if (ret < 0) { + av_freep(&graph_desc); av_freep(&fgp); return ret; } From patchwork Mon Oct 7 10:50:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 52088 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:938f:0:b0:48e:c0f8:d0de with SMTP id z15csp1836661vqg; Mon, 7 Oct 2024 04:01:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW79vw6/pnRc5ax8Ihm2nZxIGhA+bdyEWflDcJJ4Zv0hJCitZ6ybtrtcHoTIyupkkRyUFBArG+OQ6cVpt2OahHJ@gmail.com X-Google-Smtp-Source: AGHT+IETGIHRhIOM2bV6qx5fLUvg6dLxrg+ukXZ2rZSG7mmNqapkXI1RE9U6tkVpHpF7RtxcxO1u X-Received: by 2002:a05:6512:2345:b0:52f:c398:8780 with SMTP id 2adb3069b0e04-539ac15a96dmr3249875e87.18.1728298866775; Mon, 07 Oct 2024 04:01:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728298866; cv=none; d=google.com; s=arc-20240605; b=F+QAFu2IzgoC86SIFya2rJIB6nBlx6XugxROP0/z1BoD0jR8aCbuQBuEdEq/+ze6gd hM0bDXxQ+j8UYXw9A48on+Sh3l2EDoLsVXOcEvHIft8qLK9Kx+CBsG6OmAkNrLdPiASi CGp4EuNTH0R12GegG5DF6gFm/OBoQeyU8DdgzBacWGEz+Pt5+JpuaqpW+vlcdxUqRHME aaQlrapWMuQhYYivJ6zhnAtTiz/SRRwyjsgg6/ai9kHN7V1plHsco9XOWbAFOXoRQXNG cDsKwMAbMf1oU52qwMQHiWOLod03ldSEnB617ihRV8z1owM+BGJAO9sfdce20GuCvC57 +nMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:dkim-signature:delivered-to; bh=GTw6W27ZyyykG7/3cpnKkVI6Dow5qNarI132VvtlQLk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=I82Lb7gE4GdL6ctaJkkSPXEkpJshby/YgEXEM23xPhfBuG4Ya+DlET5g0Gn44aumna nsrNEXgGFWuh6fdC39gVtNwTLUFPg7wvTA7UapDDtA5WdPnN6rZv/O8rP5psLpu0neZy VVBDejZxLPc7oi/F+Qmpk7KBshaW6lD9ndz7phxnQRxUUo5EUWO2svek8LnVrkqR6u5C 7aLaT55+SuqtmfagPr7F8TYeIv+bDgGe1CJfHv4alzGOOgZZofVsfDWYh6xCgXZsDNwK v9t2bK2CSEat5/xzL/HjiyoQclSQhKnae8Ic1B5IPS0DWvsI77FoLzerUyEEr5sEhzQI DqHA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=IAGuUwi+; 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 2adb3069b0e04-539b001ffd4si1691803e87.575.2024.10.07.04.01.06; Mon, 07 Oct 2024 04:01:06 -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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=IAGuUwi+; 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 BC72368D9E9; Mon, 7 Oct 2024 13:50:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D769568DA05 for ; Mon, 7 Oct 2024 13:50:38 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=IAGuUwi+; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id DEA924E19 for ; Mon, 7 Oct 2024 12:50:37 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id kQ1-SFLuVpJU for ; Mon, 7 Oct 2024 12:50:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1728298236; bh=licT51CD8xa0pzj6UHta8kaOGfZpSkcGePHv4ZqKTg8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IAGuUwi+F72Zfan0pIg+8x9NkduuegxBW0/pJZyUFSFYhGt2r+qzTo/BqJKUWR8PE tTIcY+ioWbhgRti2YSAPgdkzts7xykTJMAYjaAxW0FVuHr7yUqtW1+3++XWS5Pb7d4 OPIH8PQQ9Huef9x9SUobfMH9XodngFyifLfiyqm9YsZfRpnMP14zyeBgWMKRniSBhn KZsSN7X2QxsAMO8RS7laNYV3wq97pbJzFiObZMvLg6KuBOwrmVBnreRTvI9ZZwORR2 1eARk6FlSsGXW8w8TK+7eQfoLundQQuXtP7R5KlvBRpCN0judXMGKm7A/2l7rQo9Sk AtKDnh5lTpGzQ== 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 mail1.khirnov.net (Postfix) with ESMTPS id CD9E84E05 for ; Mon, 7 Oct 2024 12:50:36 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 8D37B3A1A81 for ; Mon, 07 Oct 2024 12:50:30 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Oct 2024 12:50:16 +0200 Message-ID: <20241007105016.1597-5-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241007105016.1597-1-anton@khirnov.net> References: <20241007105016.1597-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/5] fftools/ffmpeg: supply hw device context to probe-filtergraphs 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: dZBT5oGMIhns I.e. those that are only used to figure out input/output counts, since some filters might expect a valid hw device in init and refuse to initalize otherwise. This requires complex filtergraphs to be created in a separate step after parsing global options, after all hw devices are guaranteed to exist. --- fftools/ffmpeg_filter.c | 3 ++- fftools/ffmpeg_opt.c | 43 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 4d444c161f..4524a3e535 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1097,7 +1097,8 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch) return AVERROR(ENOMEM);; graph->nb_threads = 1; - ret = graph_parse(graph, fgp->graph_desc, &inputs, &outputs, NULL); + ret = graph_parse(graph, fgp->graph_desc, &inputs, &outputs, + hw_device_for_filter()); if (ret < 0) goto fail; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 052e68e943..9bf0c4f0c4 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -90,6 +90,9 @@ int recast_media = 0; // to func_arg() for global options typedef struct GlobalOptionsContext { Scheduler *sch; + + char **filtergraphs; + int nb_filtergraphs; } GlobalOptionsContext; static void uninit_options(OptionsContext *o) @@ -1157,25 +1160,45 @@ static int opt_audio_qscale(void *optctx, const char *opt, const char *arg) static int opt_filter_complex(void *optctx, const char *opt, const char *arg) { GlobalOptionsContext *go = optctx; - char *graph_desc = av_strdup(arg); + char *graph_desc; + int ret; + + graph_desc = av_strdup(arg); if (!graph_desc) return AVERROR(ENOMEM); - return fg_create(NULL, graph_desc, go->sch); + ret = GROW_ARRAY(go->filtergraphs, go->nb_filtergraphs); + if (ret < 0) { + av_freep(&graph_desc); + return ret; + } + go->filtergraphs[go->nb_filtergraphs - 1] = graph_desc; + + return 0; } #if FFMPEG_OPT_FILTER_SCRIPT static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg) { GlobalOptionsContext *go = optctx; - char *graph_desc = file_read(arg); + char *graph_desc; + int ret; + + graph_desc = file_read(arg); if (!graph_desc) return AVERROR(EINVAL); av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -/filter_complex %s instead\n", opt, arg); - return fg_create(NULL, graph_desc, go->sch); + ret = GROW_ARRAY(go->filtergraphs, go->nb_filtergraphs); + if (ret < 0) { + av_freep(&graph_desc); + return ret; + } + go->filtergraphs[go->nb_filtergraphs - 1] = graph_desc; + + return 0; } #endif @@ -1377,6 +1400,14 @@ int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch) /* configure terminal and setup signal handlers */ term_init(); + /* create complex filtergraphs */ + for (int i = 0; i < go.nb_filtergraphs; i++) { + ret = fg_create(NULL, go.filtergraphs[i], sch); + go.filtergraphs[i] = NULL; + if (ret < 0) + goto fail; + } + /* open input files */ ret = open_files(&octx.groups[GROUP_INFILE], "input", sch, ifile_open); if (ret < 0) { @@ -1412,6 +1443,10 @@ int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch) goto fail; fail: + for (int i = 0; i < go.nb_filtergraphs; i++) + av_freep(&go.filtergraphs[i]); + av_freep(&go.filtergraphs); + uninit_parse_context(&octx); if (ret < 0 && ret != AVERROR_EXIT) { av_log(NULL, AV_LOG_FATAL, "Error %s: %s\n",