From: Michael Niedermayer <michael@niedermayer.cc> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH] avutil/map: [WIP] Introduction Date: Wed, 23 Apr 2025 23:25:12 +0200 Message-ID: <20250423212512.GT4991@pb2> (raw) In-Reply-To: <20250423204617.GS4991@pb2> [-- Attachment #1.1: Type: text/plain, Size: 4056 bytes --] Hi Nicolas On Wed, Apr 23, 2025 at 10:46:17PM +0200, Michael Niedermayer wrote: > Hi Nicolas > > On Mon, Apr 21, 2025 at 05:01:19PM +0200, Nicolas George wrote: > > Michael Niedermayer (HE12025-04-20): [...] > > > + * > > > + * > > > + * ----------- Retrieving an entry -------------- > > > + * > > > + * AVMapEntry *e = av_map_get(map, "cat", AV_MAP_CMP_KEY); //Find an entry with the key = "cat" > > > + * > > > + * AVMapEntry *e = av_map_get(map, "cat", AV_MAP_CMP_KEY+AV_MAP_CMP_CASE_INSENSITIVE); //Find an entry with the key = "cat", "Cat", "cAt", ... > > > > > + * // this will only work if one of the set compare functions is case insensitive > > > > This is crucial: how? (This is redundant with my next remark.) > > > > > + * > > > + * > > > + * ----------- Iterating over all elements ------ > > > + * > > > + * const AVMapEntry *t = NULL; > > > + * while ((t = av_map_iterate(s, t))) > > > + * printf("%s=%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 ----------- > > > + * > > > > > + * Each map has a primary compare function, which is used for ordering elements. > > > + * Additional (compatible) compare functions can be added with av_map_add_cmp_func() > > > + * > > > + * What "compaibility" means here is that every added function returns 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 case insensitive > > > + * compare would not be possible > > > > Code examples needed. For example: a map where key = name, value = 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? > > The phone numbers i have seen are not affected by case sensitivity. > So case sensitivity only matters for the name (which is in key) > > This should work: > > AVMap *map = 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); > > 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 sensitivity 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 can 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 insensitive matching key. Its still alot less asymptotically thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] [-- Attachment #2: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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".
next prev parent reply other threads:[~2025-04-23 21:25 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-04-20 2:29 Michael Niedermayer 2025-04-21 15:01 ` Nicolas George 2025-04-23 20:46 ` Michael Niedermayer 2025-04-23 21:25 ` Michael Niedermayer [this message] 2025-04-21 19:55 ` Marton Balint 2025-04-23 0:31 ` Michael Niedermayer 2025-04-23 21:16 ` Marton Balint 2025-04-24 11:52 ` Michael Niedermayer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250423212512.GT4991@pb2 \ --to=michael@niedermayer.cc \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git