[FFmpeg-devel] [PATCH 0/2]: allow hwaccel vda module to manage its buffers lifetime.
h.leppkes at gmail.com
Thu May 23 09:19:11 CEST 2013
On Thu, May 23, 2013 at 9:14 AM, Sebastien Zwickert <dilaroga at gmail.com> wrote:
> On May 23, 2013, at 8:29 AM, Hendrik Leppkes <h.leppkes at gmail.com> wrote:
>> On Wed, May 22, 2013 at 9:53 PM, Sebastien Zwickert <dilaroga at gmail.com> wrote:
>>> This patchset fixes memory leaks of vda core video buffers while seeking.
>>> It allows hwaccel modules to set a custom callback for freeing av buffers.
>>> Then vda decoder can flush correctly dropped frames.
>>> Thanks to Xidorn Quan who gives me good feebacks about the patch I shared
>>> with him in private.
>>> Sebastien Zwickert (2):
>>> hwaccel: allow to set a user-defined callback for releasing private
>>> av buffer.
>>> vda: use hwaccel custom callback for releasing private picture
>>> libavcodec/avcodec.h | 12 ++++++++++++
>>> libavcodec/h264.c | 9 ++++++++-
>>> libavcodec/mpegvideo.c | 9 ++++++++-
>>> libavcodec/vda.h | 12 +++++++++++-
>>> libavcodec/vda_h264.c | 18 ++++++++++++++++++
>>> 5 files changed, 57 insertions(+), 3 deletions(-)
>>> 188.8.131.52 (Apple Git-31.1)
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel at ffmpeg.org
>> You set frame->data to the same buffer that needs freeing, why not
>> simply also set frame->buf appropriately to a AVBufferRef you create,
>> so that it gets free'ed with a callback there?
>> No extra release buffer callback needed from where i stand.
> I'm not sure to understand correctly but the vda buffer is part of
> Core Video SDK which is based on a ref counted memory management
> and must be released with CVPixelBufferRelease().
> So custom callback for freeing Core Video types is necessary.
You can do that if you just create a AVBufferRef around your buffer
(you can specify a release callback for AVBufferRefs) and put it
somewhere in frame->buf, it'll be free'ed with the frame then.
I'm not really liking the new function in AVHWAccel, because its not
really required with the new buffer management functions.
Considering frame->data is set by the code, i think its safe to
also set frame->buf to the AVBufferRef managing this buffer without
worrying about user-code.
More information about the ffmpeg-devel