This is similar to what is done for AVStream. --- libavcodec/avcodec.h | 10 ++++++++++ libavcodec/utils.c | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 52fc2ee..98b0d8f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2905,6 +2905,16 @@ typedef struct AVCodecContext { * - decoding: Set by libavcodec before calling get_format() */ enum AVPixelFormat sw_pix_fmt; + + /** + * Additional data associated with the entire coded stream. + * + * - decoding: unused + * - encoding: may be set by libavcodec after avcodec_open2(). + */ + AVPacketSideData *coded_side_data; + int nb_coded_side_data; + } AVCodecContext; /** diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1721c09..799130f 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1598,9 +1598,11 @@ void avsubtitle_free(AVSubtitle *sub) av_cold int avcodec_close(AVCodecContext *avctx) { + int i; + if (avcodec_is_open(avctx)) { FramePool *pool = avctx->internal->pool; - int i; + if (HAVE_THREADS && avctx->internal->thread_ctx) ff_thread_free(avctx); if (avctx->codec && avctx->codec->close) @@ -1617,6 +1619,11 @@ av_cold int avcodec_close(AVCodecContext *avctx) av_freep(&avctx->internal); } + for (i = 0; i < avctx->nb_coded_side_data; i++) + av_freep(&avctx->coded_side_data[i].data); + av_freep(&avctx->coded_side_data); + avctx->nb_coded_side_data = 0; + if (avctx->priv_data && avctx->codec && avctx->codec->priv_class) av_opt_free(avctx->priv_data); av_opt_free(avctx); -- 2.0.0 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel