From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id 6FB654CFE0
	for <ffmpegdev@gitmailbox.com>; Tue, 15 Apr 2025 21:11:47 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7628F687D31;
	Wed, 16 Apr 2025 00:11:42 +0300 (EEST)
Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net
 [217.70.183.196])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9468C687AAB
 for <ffmpeg-devel@ffmpeg.org>; Wed, 16 Apr 2025 00:11:35 +0300 (EEST)
Received: by mail.gandi.net (Postfix) with ESMTPSA id E44A843396
 for <ffmpeg-devel@ffmpeg.org>; Tue, 15 Apr 2025 21:11:34 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc;
 s=gm1; t=1744751495;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=H1BuD26BRSalSZHkYN1umEMkk7NiZlYfyKRfYpvQHuY=;
 b=n7Cu1abRo+NlG46kBkBYYsXO6iEqSpD3jrI+M4Lmaoru8UuDCNee/9iRSqvC+B4zPwSO0W
 x4Xl//rtfnyD4bRWIrSFhpZF8cPRUEoqOvti2tBA8ey+YeEiLxRGHkYjpFnS8r7ZHMpDku
 Ij35VjhkpxQvI1swMz9ziswxx21Z8vI5ViFxAiSFdaoxpLOK+0hSSjSaECILCbnINIvkly
 ji3/kzFmubDE0//qB/IDg7TSV8eFmyEL1Z0kAkmT+/nB3LEHJdCb/Zh1ymwyfkNU1hyySf
 3IVu6Dp80rn25+krptnQ9DnuPStYHM4wDMV5FIl3Zg4G4v8kS8juNmJ13G4SXQ==
Date: Tue, 15 Apr 2025 23:11:34 +0200
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Message-ID: <20250415211134.GV4991@pb2>
References: <20250415181433.530161-1-michael@niedermayer.cc>
 <20250415181433.530161-5-michael@niedermayer.cc>
 <Z_6pR62oq4act_V1@phare.normalesup.org> <20250415190631.GS4991@pb2>
 <Z_6wIk52_3NeQBlv@phare.normalesup.org>
MIME-Version: 1.0
In-Reply-To: <Z_6wIk52_3NeQBlv@phare.normalesup.org>
X-GND-State: clean
X-GND-Score: -70
X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvvdegheegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlhcuvffnffculdeftddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfpihgvuggvrhhmrgihvghruceomhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtqeenucggtffrrghtthgvrhhnpeeigeektdejudffjefhteegjedtgeettefggedthfejgfevhfetgeekjedtvdfhveenucfkphepgedurdeiiedrieejrdduudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedurdeiiedrieejrdduudefpdhhvghloheplhhotggrlhhhohhsthdpmhgrihhlfhhrohhmpehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgdpnhgspghrtghpthhtohepuddprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvghgrdhorhhg
X-GND-Sasl: michael@niedermayer.cc
Subject: Re: [FFmpeg-devel] [PATCH v2 5/6] libavutil: Add AVMap
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: multipart/mixed; boundary="===============0924634830045507967=="
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250415211134.GV4991@pb2/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>


--===============0924634830045507967==
Content-Type: multipart/signed; micalg=pgp-sha512;
	protocol="application/pgp-signature"; boundary="5JFNVeSa50x870UU"
Content-Disposition: inline


--5JFNVeSa50x870UU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Apr 15, 2025 at 09:14:42PM +0200, Nicolas George wrote:
> Michael Niedermayer (HE12025-04-15):
> > Where exactly would that benefit FFmpeg ?
> > Dictionaries generally are used to move stuff aorund, like metadata or
> > options.
> > Or may be used in the future to keep track of some mappings like
> > timestamps to file positions during demuxing or muxing
> > Or maybe codecs/formats lookup from name
> > None of these are confined to a single local function
>=20
> 	AVMap opts =3D av_map_create(cmp, NULL, NULL);
> 	av_map_add(opts, "threads", "12");
> 	av_map_add(opts, "crf", "18");
> 	av_map_add(opts, "preset", "veryslow");
> 	av_map_assert_small(opts);
> 	ret =3D av_codec_open3(ctx, codec, opts);

Allocating and creating 12 threads and encoding a x264 video
(i guess this is x264) with "preset", "veryslow" will overshadow the
25 nanoseconds of a malloc() call

or is the goal to avoid the error handling?
I think the 12 threads encoder will fail if the map run out of memory

also in the specific example
av_codec_open3(ctx, codec, NULL);
will no longer work as NULL is a pointer and AVMap here looks like
it would not be


>=20
> > i like av_map_new() because "new" is short
>=20
> The exact name does not matter to me. I forgot that we usually use
> _alloc() for the case you implemented, so _new() is absolutely fine for
> this.
>=20
> av_map_assert_small() should assert that no dynamic allocation happened,
> and at assert level 2 that the internal buffer is less than halfway full.

>
> > and sizeof(AVMap) is not public API
>=20
> It should be public API like I did for BPrint, that is my point.

AVMap should be public but the implementation should not be any more
public than needed.
That way users cannot by mistake mess with internals and we can
improve the internal implementation without ABI/API breakage

thx

[...]

--=20
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes

--5JFNVeSa50x870UU
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZ/7LggAKCRBhHseHBAsP
q5nUAJ9C3vC02ctnnhjE2goQO7T284avXwCeNbE5zTbkeBVxnyaq7+pEbLgDh5Y=
=xhQC
-----END PGP SIGNATURE-----

--5JFNVeSa50x870UU--

--===============0924634830045507967==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

--===============0924634830045507967==--