diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-04-05 08:36:00 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-05-18 10:17:41 +0200 |
commit | fd056029f45a9f6d213d9fce8165632042511d4f (patch) | |
tree | a8d099315752e011355e129cda5a77e50e5444d2 /libavcodec/avcodec.h | |
parent | e1b66778b6ee82a192b5895e23c4e135f7269326 (diff) | |
download | ffmpeg-fd056029f45a9f6d213d9fce8165632042511d4f.tar.gz |
lavc: add avcodec_free_context().
Right now, the caller has to manually manage some allocated
AVCodecContext fields, like extradata or subtitle_header. This is
fragile and prone to leaks, especially if we want to add more such
fields in the future.
The only reason for this behaviour is so that the AVStream codec context
can be reused for decoding. Such reuse is discouraged anyway, so this
commit is the first step to deprecating it.
Diffstat (limited to 'libavcodec/avcodec.h')
-rw-r--r-- | libavcodec/avcodec.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index c76ee04cf5..5640710850 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3146,9 +3146,8 @@ void avcodec_register(AVCodec *codec); void avcodec_register_all(void); /** - * Allocate an AVCodecContext and set its fields to default values. The - * resulting struct can be deallocated by calling avcodec_close() on it followed - * by av_free(). + * Allocate an AVCodecContext and set its fields to default values. The + * resulting struct should be freed with avcodec_free_context(). * * @param codec if non-NULL, allocate private data and initialize defaults * for the given codec. It is illegal to then call avcodec_open2() @@ -3163,6 +3162,12 @@ void avcodec_register_all(void); AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); /** + * Free the codec context and everything associated with it and write NULL to + * the provided pointer. + */ +void avcodec_free_context(AVCodecContext **avctx); + +/** * Set the fields of the given AVCodecContext to default values corresponding * to the given codec (defaults may be codec-dependent). * |