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 B974F4DC10
	for <ffmpegdev@gitmailbox.com>; Wed, 23 Apr 2025 21:25:25 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2658F68A210;
	Thu, 24 Apr 2025 00:25:20 +0300 (EEST)
Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net
 [217.70.183.195])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E29AE687D2C
 for <ffmpeg-devel@ffmpeg.org>; Thu, 24 Apr 2025 00:25:13 +0300 (EEST)
Received: by mail.gandi.net (Postfix) with ESMTPSA id 23D361FCE7
 for <ffmpeg-devel@ffmpeg.org>; Wed, 23 Apr 2025 21:25:12 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc;
 s=gm1; t=1745443513;
 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=Lvw/1B+gKoAXv5plGzyCFn91p/Ne3nACka6UmxDUZGI=;
 b=LKFMtlZO+hx43g1YNLzg+JdixXwHl7HAsDgYQuwkGIo0uEw5rmA+j8YmVWXAQPFDk2NPOH
 SN0/lXLE375r0gQVakn/SoUqMFaixeKdoAf4hV4ySctG7RzGUNP0RfjI3+xdTNhCGf6YsW
 y/gQKueU1I5mG0rM11XEHoD+jLJFvHc5wTZ+aQlggj4pz236wQStJVA2t3B83QpnD9huM+
 yTBSZP6I0Hdviz7YXM6kEvl1T4vn0mqbopm/wrjH9iSyLxLUJ5egbOhDm6029oetxoay4N
 jod4BRYRZ+2UK4L9resccs6Mqm4cb6+ewRzz5EexHII2UiJ/vRyqH779YhVfpQ==
Date: Wed, 23 Apr 2025 23:25:12 +0200
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Message-ID: <20250423212512.GT4991@pb2>
References: <20250420022929.724535-1-michael@niedermayer.cc>
 <aAZdv3D5O57mysFP@phare.normalesup.org> <20250423204617.GS4991@pb2>
MIME-Version: 1.0
In-Reply-To: <20250423204617.GS4991@pb2>
X-GND-State: clean
X-GND-Score: -70
X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvgeejieejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlhcuvffnffculdeftddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfpihgvuggvrhhmrgihvghruceomhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtqeenucggtffrrghtthgvrhhnpeeigeektdejudffjefhteegjedtgeettefggedthfejgfevhfetgeekjedtvdfhveenucfkphepgedurdeiiedrieejrdduudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedurdeiiedrieejrdduudefpdhhvghloheplhhotggrlhhhohhsthdpmhgrihhlfhhrohhmpehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgdpnhgspghrtghpthhtohepuddprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvghgrdhorhhg
X-GND-Sasl: michael@niedermayer.cc
Subject: Re: [FFmpeg-devel] [PATCH] avutil/map: [WIP] Introduction
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="===============4765944809230484554=="
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250423212512.GT4991@pb2/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>


--===============4765944809230484554==
Content-Type: multipart/signed; micalg=pgp-sha512;
	protocol="application/pgp-signature"; boundary="j/Q5F61r608Rr94D"
Content-Disposition: inline


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

Hi Nicolas

On Wed, Apr 23, 2025 at 10:46:17PM +0200, Michael Niedermayer wrote:
> Hi Nicolas
>=20
> On Mon, Apr 21, 2025 at 05:01:19PM +0200, Nicolas George wrote:
> > Michael Niedermayer (HE12025-04-20):
[...]
> > > + *
> > > + *
> > > + * ----------- Retrieving an entry --------------
> > > + *
> > > + * AVMapEntry *e =3D av_map_get(map, "cat", AV_MAP_CMP_KEY); //Find =
an entry with the key =3D "cat"
> > > + *
> > > + * AVMapEntry *e =3D av_map_get(map, "cat", AV_MAP_CMP_KEY+AV_MAP_CM=
P_CASE_INSENSITIVE); //Find an entry with the key =3D "cat", "Cat", "cAt", =
=2E..
> >=20
> > > + * // this will only work if one of the set compare functions is cas=
e insensitive
> >=20
> > This is crucial: how? (This is redundant with my next remark.)
> >=20
> > > + *
> > > + *
> > > + * ----------- Iterating over all elements ------
> > > + *
> > > + * const AVMapEntry *t =3D NULL;
> > > + * while ((t =3D av_map_iterate(s, t)))
> > > + *     printf("%s=3D%s %zu,%zu   ", t->key, t->value, t->keylen, t->=
valuelen);
> > > + *
> > > + *
> > > + * ----------- copying all elements of a mep into another map
> > > + *
> > > + * av_map_copy(dst, src);
> > > + *
> > > + *
> > > + * ----------- freeing a map ---------------------
> > > + *
> > > + * av_map_free(&map);
> > > + *
> > > + *
> > > + * ----------- multiple compare function in a single map -----------
> > > + *
> >=20
> > > + * Each map has a primary compare function, which is used for orderi=
ng elements.
> > > + * Additional (compatible) compare functions can be added with av_ma=
p_add_cmp_func()
> > > + *
> > > + * What "compaibility" means here is that every added function retur=
ns the same value
> > > + * as the primary function or 0.
> > > + *
> > > + * An example, Imagine we have "cat", "dog", "Dog", "fox"
> > > + * a function that treats "dog" and "Dog" as equal is compatible to =
this ordering
> > > + * OTOH
> > > + * if we have have strcmp() as primary function we would order like =
this:
> > > + * "Dog", "cat", "dog", "fox"
> > > + * and here we could not treat "dog" and "Dog" as equal, and thus ca=
se insensitive
> > > + * compare would not be possible
> >=20
> > Code examples needed. For example: a map where key =3D name, value =3D =
phone
> > number, with AV_MAP_CMP_KEYVALUE. How do we set it up to allow
> > case-insensitive lookups and name only lookups, and name only
> > case-insensitive lookups?
>=20
> The phone numbers i have seen are not affected by case sensitivity.
> So case sensitivity only matters for the name (which is in key)
>=20
> This should work:
>=20
> AVMap *map =3D av_map_alloc(av_map_supercmp_keyvalue, AV_MAP_CMP_KEYVALUE=
 + AV_MAP_CMP_CASE_SENSITIVE, NULL, NULL);
> av_map_add_cmp_func(map,       av_map_supercmp_key, AV_MAP_CMP_KEY      +=
 AV_MAP_CMP_CASE_SENSITIVE);
> av_map_add_cmp_func(map,             av_strcasecmp, AV_MAP_CMP_KEY      +=
 AV_MAP_CMP_CASE_INSENSITIVE);
>=20
> But the point you seem to try to raise, is correct,
> not every combination is possible

To elaborate on this

If we consider key_value and key searches and case sensitivity
then we have 6 possible things a user might want to search

for only the key there are case sensitive and case insensitive
for key_value there are 4 because both key and value have their own case se=
nsitivity

If we use the syntax or I and S for the key only, and II,SS,IS,SI for the
key_value ones, then we can have for example the following in the same map

I ,S ,SI,SS
I ,II,IS,SS
I ,II,SI,SS

If these combination of 4 out of 6 isnt good enough, the user can use 2 maps
or we can implement the remaining by iteration over the closest subset we c=
an
efficiently search for.
Currently we iterate over all entries with AVDictionary, if for a key value
both case insensitive match we have to iterate over all values from a insen=
sitive
matching key. Its still alot less asymptotically

thx

[...]

--=20
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu

--j/Q5F61r608Rr94D
Content-Type: application/pgp-signature; name="signature.asc"

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

iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCaAlargAKCRBhHseHBAsP
q/GeAJ9xdAFWd1Y6GXCu/cgHLyakov/DSACfey3Vf2mJogCqqyl7XKisEYxfH+U=
=L8X9
-----END PGP SIGNATURE-----

--j/Q5F61r608Rr94D--

--===============4765944809230484554==
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".

--===============4765944809230484554==--