diff options
author | Martin Storsjö <martin@martin.st> | 2011-02-04 12:04:16 +0200 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-02-04 11:29:41 -0500 |
commit | f124b087eea442b65d809582527dfb5092a3463c (patch) | |
tree | 6e6dcd28660d2d0c6d22ec41e97b8c372053b801 | |
parent | 1338dc082354b87c0e26f7f2ab09df5964b7f993 (diff) | |
download | ffmpeg-f124b087eea442b65d809582527dfb5092a3463c.tar.gz |
libavformat: Add a function for freeing an AVFormatContext
This function is useful for freeing data structures allocated by
muxers, which currently have to be freed manually by the caller.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
-rw-r--r-- | libavformat/avformat.h | 10 | ||||
-rw-r--r-- | libavformat/utils.c | 11 | ||||
-rw-r--r-- | libavformat/version.h | 2 |
3 files changed, 17 insertions, 6 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index f9f9be5b02..83289e4604 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1072,8 +1072,8 @@ attribute_deprecated AVFormatContext *av_alloc_format_context(void); /** * Allocate an AVFormatContext. - * Can be freed with av_free() but do not forget to free everything you - * explicitly allocated as well! + * avformat_free_context() can be used to free the context and everything + * allocated by the framework within it. */ AVFormatContext *avformat_alloc_context(void); @@ -1230,6 +1230,12 @@ void av_close_input_stream(AVFormatContext *s); void av_close_input_file(AVFormatContext *s); /** + * Free an AVFormatContext and all its streams. + * @param s context to free + */ +void avformat_free_context(AVFormatContext *s); + +/** * Add a new stream to a media file. * * Can only be called in the read_header() function. If the flag diff --git a/libavformat/utils.c b/libavformat/utils.c index 6a5c0f066d..d12bbc26c6 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2556,12 +2556,17 @@ int av_read_pause(AVFormatContext *s) void av_close_input_stream(AVFormatContext *s) { - int i; - AVStream *st; - flush_packet_queue(s); if (s->iformat->read_close) s->iformat->read_close(s); + avformat_free_context(s); +} + +void avformat_free_context(AVFormatContext *s) +{ + int i; + AVStream *st; + for(i=0;i<s->nb_streams;i++) { /* free all data in a stream component */ st = s->streams[i]; diff --git a/libavformat/version.h b/libavformat/version.h index 4b95221b27..27f52e06e1 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -24,7 +24,7 @@ #include "libavutil/avutil.h" #define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 95 +#define LIBAVFORMAT_VERSION_MINOR 96 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |