[FFmpeg-devel] [PATCH] lavu/buffer: add release function
nfxjfg at googlemail.com
Tue Feb 25 17:47:04 CET 2014
On Sun, 23 Feb 2014 23:19:23 +0100
Lukasz Marek <lukasz.m.luki at gmail.com> wrote:
> new function allows to unref buffer and obtain its data.
> + * Free a given reference and pass underlaying data to user provided pointer.
> + * If there is more than one reference then data is copied.
> + *
> + * @param buf the reference to be released. The pointer is set to NULL on return.
> + * @param data pointer to be passed with underlaying data.
> + * @return 0 on success, a negative AVERROR on failure.
> + *
> + * @note on error buffer is properly released and *data is set to NULL.
> + */
> +int av_buffer_release(AVBufferRef **buf, uint8_t **data);
What's the point of this? You can access the data at any time, as long
as you have a reference to it. You can use av_buffer_make_writeable
(not sure if I spelled this correctly) to get an exclusive buffer. If
there are more than 1 references or the buffer is marked read-only,
then it will make a copy.
Keep in mind that a buffer can come from a user application. There is
no way you could free such a buffer correctly by destroying the buffer
reference and just returning the raw data.
More information about the ffmpeg-devel