[FFmpeg-devel] [PATCH] lavu/buffer: add release function

Lukasz Marek lukasz.m.luki at gmail.com
Fri Feb 28 01:21:22 CET 2014


On 25.02.2014 17:47, wm4 wrote:
> 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.

At some point application may don't need profits from using AVBufferRef, 
but may prefer to control "raw" buffer on some other way, like 
std::shared_ptr c++ hated here stuff :)

> 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.

I don't get it.


-- 
Best Regards,
Lukasz Marek

If you can't explain it simply, you don't understand it well enough. - 
Albert Einstein


More information about the ffmpeg-devel mailing list