aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/avcodec.h
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-01-29 12:17:30 +0100
committerReinhard Tartler <siretart@tauware.de>2012-02-26 09:09:26 +0100
commitbafd38a352126385ec0dcea51017229373b1c2f3 (patch)
treeedfede87d1451678da2db01d0abee4bf3bb0d17b /libavcodec/avcodec.h
parent350d06d63fc758d047c050e0835f540277799f60 (diff)
downloadffmpeg-bafd38a352126385ec0dcea51017229373b1c2f3.tar.gz
lavc: make avcodec_close() work properly on unopened codecs.
I.e. free the priv_data and other stuff allocated in avcodec_alloc_context3() and not segfault. (cherry picked from commit 0e72ad95f9fef6a6b8ae55e47339a5c40526502f)
Diffstat (limited to 'libavcodec/avcodec.h')
-rw-r--r--libavcodec/avcodec.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 6db34fa78e..95e14d7c2d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3912,7 +3912,8 @@ AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
/**
* Allocate an AVCodecContext and set its fields to default values. The
- * resulting struct can be deallocated by simply calling av_free().
+ * resulting struct can be deallocated by calling avcodec_close() on it followed
+ * by av_free().
*
* @param codec if non-NULL, allocate private data and initialize defaults
* for the given codec. It is illegal to then call avcodec_open2()
@@ -4343,6 +4344,15 @@ int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVSubtitle *sub);
+/**
+ * Close a given AVCodecContext and free all the data associated with it
+ * (but not the AVCodecContext itself).
+ *
+ * Calling this function on an AVCodecContext that hasn't been opened will free
+ * the codec-specific data allocated in avcodec_alloc_context3() /
+ * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
+ * do nothing.
+ */
int avcodec_close(AVCodecContext *avctx);
/**