From patchwork Mon Mar 4 13:06:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46757 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2789382pzb; Mon, 4 Mar 2024 05:08:54 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXdfSFScAHGwiRX+aYJw+fif/V8buW7fvxa2kQu+xilot0QwLu4CPUJSpZxcbvAqIc9LmoqmXDx9uA/cVyw0cgkoRZAgzKbw+3UKw== X-Google-Smtp-Source: AGHT+IGf7zBifC6obCiW19Ms/mmg34fey2MDWz7YmIV8lYFUzqjwUKdXSyLmQ1qTUJdXugOewgDj X-Received: by 2002:a17:907:a786:b0:a43:6ba0:522b with SMTP id vx6-20020a170907a78600b00a436ba0522bmr5788503ejc.1.1709557733958; Mon, 04 Mar 2024 05:08:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557733; cv=none; d=google.com; s=arc-20160816; b=B+2zVWDW3WPuOg83Vsp1PvT6RaKGM96QC42MN3GZiJZZhA4wGd6mTAbOOsvYw+2Kri 3xzCZmoR5OacYlCWiRsal3pqERycrKdEpTYFhGf7YDCSKvuZea9lxDaqjd1UA1Ih9IjO ndqKYkaODHpu2qyVqh/pQWUPN3VA6ql9fPRPgO/m5hTacYEL/t8EXuZTXh6lSKgUz/X0 Wz9Z148+gTpQKAd3VYhegt6TdymFa8NGytj9aWmW+/aFkUA5+B+0UwPqDDGIPRDMFynN OrVpghGY5csxtfxqkk4vd+jDIVJx+KvANSvs+7DNIiMVbNN2j43KWFQXQT4I8m9ekYvI C/rQ== 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:dkim-signature:delivered-to; bh=gfISCa/igjMZ8bLIahtr1nZPNqPgVQKKVP3NULqRP94=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=sfES0WRl3/hWgw9VpNE1MvWkojACOP1Q0hRyeKmBlFYcKobk1ryh7ydpCoXAQPgKPk IUZGoX+nulYdmBjUCJJCsbFNOujc8tuLfJ+OD5S4Fb69pAyo9lnHtpxSdO1mGjF26On5 ABR3WCmu00h/DA2CNDPNbO5X2pqJvmg8HX7jsxnjquPpQbxP3vT6rZSSVoG0J99Dtwz0 FwWoXZoTECR/dEDRhxcB5StDBuAk0N2BBto2gH7xIzKApSLJ5WEKj2xcsZurbaxc5T8L gLr04G6sDGTV5JEj0qNnX3Ps3U+mSYx/FlBAaiTpENBDw9pmbo/KeGUJydZiuxE9Pmnp VXNQ==; 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=L6JnEC2x; 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 lj27-20020a170906f9db00b00a3f89681212si3830721ejb.101.2024.03.04.05.08.51; Mon, 04 Mar 2024 05:08: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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=L6JnEC2x; 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 1A02C68D446; Mon, 4 Mar 2024 15:07:23 +0200 (EET) 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 6C44568D43B for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) 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=L6JnEC2x; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id EA8864D3E for ; Mon, 4 Mar 2024 14:07:08 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 4u5llzm96hVy for ; Mon, 4 Mar 2024 14:07:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=Itn1Z2BVuifxV3igR8UIKPpOb+btRTjIEigEcFT+OD8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L6JnEC2x84Plb28TQkj9vNo7h/EH60iOfjyAV9k2c9boMibauMSjV1iGHydkzDKJs 6wgsX/9aerbMHkj//3/eTpZH5n2wDtnGtvOpUF21LNW/H0irhMNHJ9yZ3jzKecQRcO qT7p/ztDLjdklmVjhDh32fcOIwr+y7pNJHenNHcdt0AGxQZ/qdTos6c6h2rGcbhGn2 rRsV1VlUbR1TsnO19grEO+hUrE+lL+ETYAfnzFYaRgVCKL9SoZAv6q0V10+Z2eUH8p 3ULJ72LmfmcIqe7knHW021rAIAeBpi8Md6rsJX1+n4bHvak7f/qlw8wnnZ2Tbj2PkA Ue+4sz/oh7JJQ== 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 671774D52 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 134463A0B9C for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:20 +0100 Message-ID: <20240304130657.30631-5-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/29] lavu/opt: distinguish between native and foreign access for AVOption fields 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: o3OJTmt1057a Native access is from the code that declared the options, foreign access is from code that is using the options. Forbid foreign access to AVOption.offset/default_val, for which there is no good reason, and which should allow us more freedom in extending their semantics in a compatible way. --- libavutil/opt.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libavutil/opt.h b/libavutil/opt.h index e34b8506f8..e402f6a0a0 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -43,6 +43,16 @@ * ("objects"). An option can have a help text, a type and a range of possible * values. Options may then be enumerated, read and written to. * + * There are two modes of access to members of AVOption and its child structs. + * One is called 'native access', and refers to access from the code that + * declares the AVOption in question. The other is 'foreign access', and refers + * to access from other code. + * + * Certain struct members in this header are documented as 'native access only' + * or similar - it means that only the code that declared the AVOption in + * question is allowed to access the field. This allows us to extend the + * semantics of those fields without breaking API compatibility. + * * @section avoptions_implement Implementing AVOptions * This section describes how to add AVOptions capabilities to a struct. * @@ -301,6 +311,8 @@ typedef struct AVOption { const char *help; /** + * Native access only. + * * The offset relative to the context structure where the option * value is stored. It should be 0 for named constants. */ @@ -308,6 +320,8 @@ typedef struct AVOption { enum AVOptionType type; /** + * Native access only. + * * the default value for scalar options */ union {