From: Nicolas George <george@nsup.org> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH v3] libavutil: Add AVMap Date: Thu, 17 Apr 2025 19:57:46 +0200 Message-ID: <aAFBGsbuU5SG2ma4@phare.normalesup.org> (raw) In-Reply-To: <20250417165241.3266643-1-michael@niedermayer.cc> Michael Niedermayer (HE12025-04-17): > +AVMap *av_map_new(AVMapCompareFunc cmp_keyvalue, int cmp_flags, AVMapCopyFunc copy, AVMapFreeFunc freef) > +{ > + AVMap *s = av_mallocz(sizeof(*s)); > + if (!s) > + return NULL; > + > + s->copy = copy; > + s->freef = freef; > + > + av_map_add_cmp_func(s, cmp_keyvalue, cmp_flags); > + > + return s; > +} If you do not want to do the version where dynamic allocation can be avoided, would you at least consider using _alloc() for this? It is only to letters more, it is consistent with the rest of the API and it would leave _new() available if somebody adds the lighter version. I really do not understand why you do not want to do this: it is a very useful low-hanging fruit, and it is quite elegant and fun to implement. Alas, you did not reply to my last round of arguments. > + * @param keyvalue_cmp compare function, will be passed the key + value concatenated. Please no. Pass the key and the value separately to the compare function. > +/** > + * Add a compatible compare function to the map. > + * The function will later be selected by using AV_MAP_CMP_* flags > + * > + * Functions must be added from most specific to least specific, that is if a AVMap is build > + * with a case insensitive compare no case sensitive compare functions can be added. This is > + * to avoid building non functional AVMaps. > + * > + * > + * @see av_map_new > + * > + * @param cmp compare function to be added. > + * cmp(a,b) must return 0 or be equal to the previously added compare function for (a,b), if it returns 0 it also must do so for all > + * elements between a and b > + * > + * @param cmp_flags a combination of AV_MAP_CMP_*, note key/keyvalue and truncated vs non truncated > + * are mandatory to be specified > + * > + * @return a negative error code if the cmp_flags are illegal or unsupported for this AVMap > + * If you know your flags are valid, then you dont need to check the return > + */ > +int av_map_add_cmp_func(AVMap *m, AVMapCompareFunc cmp, int cmp_flags); This whole thing with multiple compare functions makes the code quite hard to understand. And not just the code: it makes the API itself hard to understand. I think the practical goal it server could be achieved in a simpler way. If I understand correctly, it servers to allow the equivalent of AV_DICT_IGNORE_SUFFIX and such. It would be simpler to have a flag to av_map_find() to let it return the first key >= to the searched key. Regards, -- Nicolas George _______________________________________________ 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-17 17:57 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-04-17 16:52 Michael Niedermayer 2025-04-17 17:57 ` Nicolas George [this message] 2025-04-17 20:12 ` Michael Niedermayer 2025-04-18 14:46 ` Leo Izen 2025-04-19 1:23 ` Michael Niedermayer 2025-04-19 13:03 ` Nicolas George 2025-04-19 16:23 ` Michael Niedermayer 2025-04-19 17:23 ` Nicolas George 2025-04-19 17:36 ` Nicolas George 2025-04-19 10:36 ` Leo Izen 2025-04-19 14:39 ` 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=aAFBGsbuU5SG2ma4@phare.normalesup.org \ --to=george@nsup.org \ --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