[FFmpeg-devel] [PATCH 2/7] lavfi/buffersink: add a flag for retrieving stream parameters
Nicolas George
george at nsup.org
Thu Sep 26 17:45:40 EEST 2024
James Almer (12024-09-25):
> It still requires allocating it before using it, but since a normal
> filterchain will have buffersrc -> [...] -> buffersink, the same allocated
> struct can be used for both.
A filter chain can have buffersinks but no buffersrc, if it uses other
sources. Also, a dynamic allocation does the same damage to the code
readability and reliability whether it is in a speed-critical part of
the code or not.
We should be trying to REMOVE instances where a dynamic allocation is
necessary, not add to them. This consideration takes precedence over
cosmetic considerations like internal consistency or adherence to
established practices (aka coding like Java developers who see C for the
first time).
In this case, that means we should find a solution without dynamic
allocation for buffersink and then implement it for buffersrc also
rather than using the solution with dynamic allocation on both.
And we should do that especially because it is very easy: two solutions
came to me in the first few minutes, more could come.
- Let callers allocate their structure as they wish, on the stack if
necessary, pass sizeof(params) as an extra argument and use memcpy()
to fetch/return it.
- Have an instance of the struct in the buffersrc/sink and make it
available for that use.
Regards,
--
Nicolas George
More information about the ffmpeg-devel
mailing list