[FFmpeg-devel] [PATCH 2/8] lavu: new AVWriter API
Nicolas George
george at nsup.org
Tue May 2 19:53:43 EEST 2023
Rémi Denis-Courmont (12023-05-02):
> Indirecting the printf function seems pretty pointless. The last thing you
Please re-read the code, there is no other way of obtaining a va_list
from an actual argument than making a call to a vararg function.
> want are different implementations of printf() with different limitations. And
> it makes writing different backends needlessly complex, while you could just
> use vasprintf().
>
> Typically, with this kind of abstraction, only the raw bytes writing is
> abstracted away. Examples include funopen() and fopencookie().
>
> As for hypothetical use cases whence vasprintf() wouldb e "too slow", then
> should not use printf()-style or function pointers to begin with. Besides if
> you _really_ want to avoid the heap allocation, you can also use fopencookie()
> on systems that provide it or equivalent.
Being portable and not doing dynamic allocation are two major points of
the design, so you will excuse me if I pass on that suggestion.
> That sounds like it belongs in whichever backend actually wants to heap-
> allocate the output buffer, not the frontend.
There is nothing about heap allocation in this code. And if code can be
in the framework common to all backends, then it is where it belongs,
not duplicated in each backend.
> This is an abstraction inversion (and also highly inefficient) + what I noted
> above.
See above, it is necessary. (If you think it is not, try doing better.)
> This is an analogue of puts/fputs, not "print".
This is an analogue of puts, fputs and print, and I decided to call it
print.
> Same problems and overengineering as above.
I think you are missing something important about the purpose of this
code, but I cannot guess what exactly. Please be more detailed about why
you think it is overengineered and point how you would do it simpler.
Thanks for the comments.
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20230502/063c5c2d/attachment.sig>
More information about the ffmpeg-devel
mailing list