[Libav-user] How to keep AVFrame data after codec close
Bruce Wheaton
bruce at spearmorgan.com
Fri Dec 6 17:06:48 CET 2013
> On Dec 6, 2013, at 0:17, Eric Beuque <eric.beuque at gmail.com> wrote:
>
>
>> On Thu, Dec 5, 2013 at 9:22 PM, Paul B Mahol <onemda at gmail.com> wrote:
>> On 12/5/13, Bruce Wheaton <bruce at spearmorgan.com> wrote:
>> > On Dec 5, 2013, at 3:41 AM, Paul B Mahol <onemda at gmail.com> wrote:
>> >
>> >> On 12/5/13, Eric Beuque <eric.beuque at gmail.com> wrote:
>> >>> How i can tell libavcodec that i want to become the owner of the data
>> >>> and
>> >>> be able to free it, to without codec context instance? I was thinking
>> >>> about
>> >>> using get/release_buffer functions, but i don't know how to compute size
>> >>> of
>> >>> the data.
>> >>>
>> >>> Is data memcpy the only way to do this?
>> >>>
>> >>> Note, that i also can't upgrade to new version of FFMPEG.
>> >>>
>> >>> Thanks for your help.
>> >>>
>> >>
>> >> Use reference counting system.
>> >> They you need to manually free frame once you will not need it
>> >> (otherwise you leak memory), so you do not need to do copy.
>> >
>> >
>> > In my recent experiments, it seemed that closing the codec actually frees
>> > all buffers, regardless of reference count. That makes sense - if the codec
>> > is gone, what would detect the decreased reference count?
>>
>> That sound wrong to me, either when decoding or encoding frames should
>> not be freed if frame is still used.
>
> I agree with Paul. I think this is the expected behavior for developers.
Let's say I agree with both of you. Nonetheless, a frame's ref count is a variable, not a function. After it gets decremented to mark you don't want it, something that runs (presumably that had been run by your code, such as a decode function) must then detect that and reuse the frame.
I know that if you break down the whole chain (codecs and the format context) the frames get removed - deleting the frames triggers a signal on double free. I was speculating that the frame 'belong' to the codec, which generated them.
So whatever we wish happened - you can't keep the frames you get from decoding indefinitely. You can probably keep something else alive just to keep them in play.
>
>>
>> >
>> > Bruce
>> > _______________________________________________
>> > Libav-user mailing list
>> > Libav-user at ffmpeg.org
>> > http://ffmpeg.org/mailman/listinfo/libav-user
>> >
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20131206/2c4a69a6/attachment.html>
More information about the Libav-user
mailing list