From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id F17124777E for ; Thu, 21 Sep 2023 19:58:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 117CB68C8F7; Thu, 21 Sep 2023 22:58:43 +0300 (EEST) Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 776D968C8D5 for ; Thu, 21 Sep 2023 22:58:37 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 38LJwauG027963 ; Thu, 21 Sep 2023 21:58:36 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id 94B21E007C; Thu, 21 Sep 2023 21:58:36 +0200 (CEST) Date: Thu, 21 Sep 2023 21:58:36 +0200 From: Nicolas George To: FFmpeg development discussions and patches Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Thu, 21 Sep 2023 21:58:36 +0200 (CEST) Subject: Re: [FFmpeg-devel] [PATCH 02/42] avcodec/refstruct: Add simple API for refcounted objects 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 Cc: Andreas Rheinhardt Content-Type: multipart/mixed; boundary="===============5354584399841827699==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============5354584399841827699== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="LZ6PyvJ8kgsvRui5" Content-Disposition: inline --LZ6PyvJ8kgsvRui5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Andreas Rheinhardt (12023-09-19): > For now, this API is supposed to replace all the internal uses > of reference counted objects in libavcodec; "internal" here > means that the object is created in libavcodec and is never > put directly in the hands of anyone outside of it. >=20 > It is intended to be made public eventually, but for now > I enjoy the ability to modify it freely. >=20 > Several shortcomings of the AVBuffer API motivated this API: Thanks for stating qualms that I have had for a long time about this API. An API like this one would have been really useful when the new channel layout structure was integrated. On a brighter note, it will be really useful if we finally turn the library's global state into a structure that can exist in multiple instances. > This brings with it > one further downside: It is not apparent from the pointer itself > whether the underlying object is managed by the refstruct API > or whether this pointer is a reference to it (or merely a pointer > to it). I do not count it as a downside: it is just how the C language is supposed to work. When we get a pointer, there is nothing written on it that says whether we are supposed to free(), av_free(), g_object_unref() it or just do nothing. People who cannot track static pointer ownership in their sleep should do Java. Also, you probably do not remember, three years ago I started proposing a similar idea, and it got bikeshedded to death: http://ffmpeg.org/pipermail/ffmpeg-devel/2020-June/265227.html The difference is: You make this API universal using void pointers and callbacks, and you make it convenient by hiding the internals using pointer arithmetic. I achieve more or less the same using a template to generate code, with the extra benefit that it is type-safe. I see a few places in the code below where you pay the price for your design choice. I think you should consider taking a few ideas from my version. Regards, --=20 Nicolas George --LZ6PyvJ8kgsvRui5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE6ooRQGBoNzw0KnwPcZVLI8pNxgwFAmUMoGoACgkQcZVLI8pN xgxsRA//dUt6cKZLYxxFZGuzLjPRnzgzG4DHb6gg4oISAf5QrGWkpyQUWDYD8nB8 xHpQnxDFfizI2LQvoVTFaBtbVbBMsIPuKMj5eQRgi6CPc1vYnspXyMxvWgEyB9S/ 0ItbLZsjdef3R+M1IMQDtXHzyHzvIqwYCgaXNTk1N5IUvvTZKnDVn/4SdEECGSXN Q/7sgdnJfcUIdTmv2wxQPsdTyd+G9ZqCtizCw/nW9HZXgNYfgMYnJRJm5BLiAaiq HzBeht9r/zLvfIMbmyqtizp7OmmJ2t6TwKuk4qpC44aXrPNJ6q2a9zaQ606WVqwr WUFtvSbbJCxF6hDvokqv92N2TFCs/8wFHxs8ACzbFLS8wq9EucMuFmPnF3J5D3Tx WtsuSOmMGOr+rbvV9Et+uzgiCzhC/QfIKZJeI/GCkUYEQLu5TKQgA7JhqLTkdIVv BROB3od98HuMFo7PEp+0K2HkuxzRZPZOHwDccIhEKRmzhmxpWXPU1lkLP/piUvql 5c2k5Xd4PvEda4cjUaDPMHmD80vPqNPv+zZJlh/CWuydbURjZBV5Z98jtqa/8HkK LGgZbQmVCbdBNVXvJQU29MRwAImBGWjt+V8Nb6S0AC1pCvtRGFO2ijm1KT7ns+wb o/kxJ75XtmkR0eUp0Yfe7a5b/vzwE9Mg90KddZo7SGmqX6Fh0yc= =tk9a -----END PGP SIGNATURE----- --LZ6PyvJ8kgsvRui5-- --===============5354584399841827699== 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". --===============5354584399841827699==--