Browse Source

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>
tags/n0.8
Martin Storsjö Ronald S. Bultje 14 years ago
parent
commit
f124b087ee
3 changed files with 17 additions and 6 deletions
  1. +8
    -2
      libavformat/avformat.h
  2. +8
    -3
      libavformat/utils.c
  3. +1
    -1
      libavformat/version.h

+ 8
- 2
libavformat/avformat.h View File

@@ -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);

@@ -1229,6 +1229,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.
*


+ 8
- 3
libavformat/utils.c View File

@@ -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];


+ 1
- 1
libavformat/version.h View File

@@ -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, \


Loading…
Cancel
Save