[FFmpeg-devel] [RFC] missing close/free functions for avformat?

Reimar Döffinger Reimar.Doeffinger
Sat Dec 15 19:02:17 CET 2007

On Sat, Dec 15, 2007 at 05:51:29PM +0100, Michael Niedermayer wrote:
> On Sat, Dec 15, 2007 at 05:38:02PM +0100, Michael Niedermayer wrote:
> > On Sat, Dec 15, 2007 at 05:28:51PM +0100, Reimar D?ffinger wrote:
> > > unless I missed something there are no corresponding close/free
> > > functions for av_alloc_format_context and av_open_input_stream.
> > > But these are part of the public API, what use are they if there
> > > is no proper way in freeing the allocated memory...
> > > It actually seems to me that almost everything except the url_fclose
> > > should go into a av_free_format_context, do you agree with that?
> > 
> > have you tried:
> > 
> > av_alloc_format_context() - av_free()

Yes, basically that works but then there is still no way to just get
rid of e.g. the stuff that av_find_stream_info allocates.
Making the user do that by hand seems like a really bad idea to me.

> > av_open_input_stream()    - av_close_input_file

This assumes there is an URLContext behind the ByteIOContext, if there
is not it crashes. I don't know if that case is supposed to be
supported, but at least it makes it not an exact counterpart, since
av_open_input_stream does not do any url_fopen...

> and yes this should be documented, also iam not against simplifying
> things or moving common operations into some function ...

They are not quite common operations, actually I just try to use
libavformat without URLProtocol, since URLProtocol stuff is quite messy
IMO for that use case, since e.g. you'll have to avoid registering it
twice and you can't make the URLProtocol struct itself const since the
next pointer is in it etc.

Reimar D?ffinger

More information about the ffmpeg-devel mailing list