[FFmpeg-devel] [PATCH] alloc_picture needs to free buffer when it's not going to use it

Daniel Kristjansson danielk
Fri Jul 20 19:27:17 CEST 2007

I'm resending this patch because my last message seems
to have been moderated and rejected due to my e-mailing
from the wrong e-mail account.

I've also added an 2nd patch which takes care of the

== original message below ==

If there is some problem with the buffer returned from
s->avctx->get_buffer(...) mpegvideo.c:alloc_picture(...)
returns an error code but never returns the picture with

The attached patch fixes this for the case when the
linesizes are wrong, or the age type or data are empty.

We might want to also do this when CHECKED_ALLOCZ fails,
but I'll leave that to the experts.

The reason I noticed this was because MythTV locks a frame
when get_buffer is called and releases it when release_buffer
is called. When a user played a video where the resolution
changed but the decoding library didn't pick up on it the
buffers were quickly exhausted. (This trigger is a separate
problem, which may even be MythTV specific.)

I may have misunderstood who picks up the pieces when 
alloc_picture() fails, if so I would appreciate a pointer
in the right direction.

-- Daniel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: alloc_picture_leak.patch
Type: text/x-patch
Size: 1101 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070720/f0b2ce4e/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alloc_picture_leak_with_allocz.patch
Type: text/x-patch
Size: 1704 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070720/f0b2ce4e/attachment-0001.bin>

More information about the ffmpeg-devel mailing list