Commit 4ed68fdf authored by Martin Storsjö's avatar Martin Storsjö Committed by Michael Niedermayer

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: 's avatarRonald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit f124b087)
parent 173f19be
...@@ -1074,8 +1074,8 @@ attribute_deprecated AVFormatContext *av_alloc_format_context(void); ...@@ -1074,8 +1074,8 @@ attribute_deprecated AVFormatContext *av_alloc_format_context(void);
/** /**
* Allocate an AVFormatContext. * Allocate an AVFormatContext.
* Can be freed with av_free() but do not forget to free everything you * avformat_free_context() can be used to free the context and everything
* explicitly allocated as well! * allocated by the framework within it.
*/ */
AVFormatContext *avformat_alloc_context(void); AVFormatContext *avformat_alloc_context(void);
...@@ -1231,6 +1231,12 @@ void av_close_input_stream(AVFormatContext *s); ...@@ -1231,6 +1231,12 @@ void av_close_input_stream(AVFormatContext *s);
*/ */
void av_close_input_file(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. * Add a new stream to a media file.
* *
......
...@@ -2556,12 +2556,17 @@ int av_read_pause(AVFormatContext *s) ...@@ -2556,12 +2556,17 @@ int av_read_pause(AVFormatContext *s)
void av_close_input_stream(AVFormatContext *s) void av_close_input_stream(AVFormatContext *s)
{ {
int i;
AVStream *st;
flush_packet_queue(s); flush_packet_queue(s);
if (s->iformat->read_close) if (s->iformat->read_close)
s->iformat->read_close(s); 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++) { for(i=0;i<s->nb_streams;i++) {
/* free all data in a stream component */ /* free all data in a stream component */
st = s->streams[i]; st = s->streams[i];
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "libavutil/avutil.h" #include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 52 #define LIBAVFORMAT_VERSION_MAJOR 52
#define LIBAVFORMAT_VERSION_MINOR 95 #define LIBAVFORMAT_VERSION_MINOR 96
#define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment