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 C100843E10 for ; Mon, 15 Aug 2022 19:15:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4BCB768B920; Mon, 15 Aug 2022 22:15:36 +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 DC40B68B646 for ; Mon, 15 Aug 2022 22:15:29 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id E4CA260008 for ; Mon, 15 Aug 2022 19:15:27 +0000 (UTC) Date: Mon, 15 Aug 2022 21:15:26 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20220815191526.GS2088045@pb2> References: <20220615205649.GD11679@mariano> <20220616230127.GA173404@mariano> MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] The case for a good string API 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 Content-Type: multipart/mixed; boundary="===============6774154552006881484==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============6774154552006881484== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="fRTiclqxXzPSgD3k" Content-Disposition: inline --fRTiclqxXzPSgD3k Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 17, 2022 at 04:57:55PM +0200, Nicolas George wrote: > Stefano Sabatini (12022-06-17): > > I was thinking about mempool (and no, I don't think it's really > > neeeded for this use case). > >=20 > > I still had to read the implementation, now I think I got what this is > > about. >=20 > You have touched the main difference between AVWriter and BPrint. >=20 > BPrint is a specific implementation, it works the way it works and > return the string as a pointer and a length field. If you are not happy > with it, you must take it anyway. >=20 > AVWriter is a layer of abstraction. A very thin, very lightweight layer. > Very ffmpeg. >=20 > You can make an AVWriter out of anything, as long as it is something > where writing to it text makes sense. You just need to write a few > low-level callbacks to write bits of string, and benefit from the > high-level features of AVWriter. >=20 > There is already an AVWriter that will let you have a static-or-dynamic > buffer allocated with av_realloc(). In fact it is a BPrint inside of it, > because no need to duplicate the code. >=20 > There is already an AVWriter that will use a buffer you already have. > There is already an AVWriter that will write the text to the logs > without storing it. >=20 > If you are writing an application that is partially in Rust, you can > make an AVWriter that will store the text in a Rust String object. Same > goes with Perl, Java, whatever language. >=20 > If you are writing a GUI application, you can make an AVWriter that will > store the text directly in a text widget. >=20 > You can make an AVWriter that will change the character encoding of the > text, or compress it, or encrypt it, and write the result to another > AVWriter. >=20 > Your imagination is the limit. But if you only want good old C strings, > you do not need to know any of that, just use one of the built-in > AVWriter as shown in the documentation and you are good to go. >=20 > I have to confess, I am rather proud of the ideas I have had to make an > abstraction layer that is lightweight, nimble and future-proof at the > same time. Eventually, I would like to go further in that direction, for > example with side data types describing themselves how they can be > serialized / duplicated / referenced. But later. Sorry for my late reply. I do like the AVWriter idea, i think replacing BPrint by it is a good idea I only now looked at your examples you posted in april last year. I may have looked before, i dont remember but from these examples it looks nice Thanks [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu --fRTiclqxXzPSgD3k Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYvqbSgAKCRBhHseHBAsP qw0YAJ0Zmixr6gQThTRefvaXEdD6H74GlACfXD0hEZXwKEjvDnMM3LAsQ1jdBVQ= =9Mlz -----END PGP SIGNATURE----- --fRTiclqxXzPSgD3k-- --===============6774154552006881484== 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". --===============6774154552006881484==--