[FFmpeg-devel] [PATCH] Fix for rc_eq memory leak

Art Clarke aclarke
Sat Aug 16 02:45:21 CEST 2008

On Fri, Aug 8, 2008 at 3:02 PM, Stefano Sabatini <
stefano.sabatini-lala at poste.it> wrote:

> Rethinking at it, maybe my solution (to free rc_eq when the codec is
> closed) is a wrong solution.
> Suppose you want to close a codec, change some settings and then
> reopen it again, in this case you *don't want* to change the
> information contained in the context, you want indeed to actually keep
> it.
> I'm not sure if the priv_data and extradata contain informations which
> should be kept in the context independant, but I think it's safe to
> keep them.
> So rc_eq (and eventually priv_data and extradata) should be freed just
> before freeing the AVCodecContext itself, so your solution looks
> right.
> Maybe in order to avoid memory leaks a good idea could be to implement
> an avcodec_context_free()/avcodec_context_close() function (the latter
> could also call avcodec_close).
> So a plan could be:
> 1) revert 14260
> 2) to free rc_eq and friends just before a codec context is freed,
>   *or* use a new function for doing it.
> Point 2 implies your patch.

> >
> > All that said, I'm with you Stefano in that we need direction / thoughts
> > from the maintainer.  Who maintains libavformat/utils.c?
> Michael? (sorry for bothering you so often ;-))

Michael, sorry to ask again, but can you chime in on this?  Seems like
Stefano and I have agreed on the patch for the moment, but we both wonder
whether having an avcodec_context_free(...) type method is the way to go?

My gut on that is no; it is a big API change that stops people from
allocating avcodec_contexts on the stack.  But the downside is everyone
needs to do an av_free(...) on the rc_eq member.

- Art

More information about the ffmpeg-devel mailing list