From 6d924b5a5f39e33a02c4b39cc5892911bb508d4e Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 14 Oct 2009 05:28:24 +0000 Subject: [PATCH] Release frame after decoding is done Originally committed as revision 20231 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/indeo2.c | 13 ++++++++++++- libavcodec/loco.c | 13 ++++++++++++- libavcodec/qdrw.c | 13 ++++++++++++- libavcodec/truemotion2.c | 6 ++++++ libavcodec/ulti.c | 13 ++++++++++++- libavcodec/wnv1.c | 13 ++++++++++++- libavcodec/xl.c | 13 ++++++++++++- 7 files changed, 78 insertions(+), 6 deletions(-) diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index 53624a107..87d1c909e 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -213,6 +213,17 @@ static av_cold int ir2_decode_init(AVCodecContext *avctx){ return 0; } +static av_cold int ir2_decode_end(AVCodecContext *avctx){ + Ir2Context * const ic = avctx->priv_data; + AVFrame *pic = &ic->picture; + + if (pic->data[0]) + avctx->release_buffer(avctx, pic); + av_freep(&ic->picture); + + return 0; +} + AVCodec indeo2_decoder = { "indeo2", CODEC_TYPE_VIDEO, @@ -220,7 +231,7 @@ AVCodec indeo2_decoder = { sizeof(Ir2Context), ir2_decode_init, NULL, - NULL, + ir2_decode_end, ir2_decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 2"), diff --git a/libavcodec/loco.c b/libavcodec/loco.c index 4fd64f4bd..9a01810c4 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -275,6 +275,17 @@ static av_cold int decode_init(AVCodecContext *avctx){ return 0; } +static av_cold int decode_end(AVCodecContext *avctx){ + LOCOContext * const l = avctx->priv_data; + AVFrame *pic = &l->pic; + + if (pic->data[0]) + avctx->release_buffer(avctx, pic); + av_freep(&l->pic); + + return 0; +} + AVCodec loco_decoder = { "loco", CODEC_TYPE_VIDEO, @@ -282,7 +293,7 @@ AVCodec loco_decoder = { sizeof(LOCOContext), decode_init, NULL, - NULL, + decode_end, decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("LOCO"), diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c index cd53bfb33..ae8a71a8a 100644 --- a/libavcodec/qdrw.c +++ b/libavcodec/qdrw.c @@ -140,6 +140,17 @@ static av_cold int decode_init(AVCodecContext *avctx){ return 0; } +static av_cold int decode_end(AVCodecContext *avctx){ + QdrawContext * const a = avctx->priv_data; + AVFrame *pic = &a->pic; + + if (pic->data[0]) + avctx->release_buffer(avctx, pic); + av_freep(&a->pic); + + return 0; +} + AVCodec qdraw_decoder = { "qdraw", CODEC_TYPE_VIDEO, @@ -147,7 +158,7 @@ AVCodec qdraw_decoder = { sizeof(QdrawContext), decode_init, NULL, - NULL, + decode_end, decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Apple QuickDraw"), diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index 09c500146..d73c88bd4 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -845,6 +845,7 @@ static av_cold int decode_init(AVCodecContext *avctx){ static av_cold int decode_end(AVCodecContext *avctx){ TM2Context * const l = avctx->priv_data; + AVFrame *pic = &l->pic; int i; if(l->last) @@ -862,6 +863,11 @@ static av_cold int decode_end(AVCodecContext *avctx){ av_free(l->U2); av_free(l->V2); } + + if (pic->data[0]) + avctx->release_buffer(avctx, pic); + av_freep(&l->pic); + return 0; } diff --git a/libavcodec/ulti.c b/libavcodec/ulti.c index f58874a60..a5aec1a3a 100644 --- a/libavcodec/ulti.c +++ b/libavcodec/ulti.c @@ -55,6 +55,17 @@ static av_cold int ulti_decode_init(AVCodecContext *avctx) return 0; } +static av_cold int ulti_decode_end(AVCodecContext *avctx){ + UltimotionDecodeContext *s = avctx->priv_data; + AVFrame *pic = &s->frame; + + if (pic->data[0]) + avctx->release_buffer(avctx, pic); + av_freep(&s->frame); + + return 0; +} + static const int block_coords[8] = // 4x4 block coords in 8x8 superblock { 0, 0, 0, 4, 4, 4, 4, 0}; @@ -401,7 +412,7 @@ AVCodec ulti_decoder = { sizeof(UltimotionDecodeContext), ulti_decode_init, NULL, - NULL, + ulti_decode_end, ulti_decode_frame, CODEC_CAP_DR1, NULL, diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c index aec474f2d..9f13fd5b7 100644 --- a/libavcodec/wnv1.c +++ b/libavcodec/wnv1.c @@ -143,6 +143,17 @@ static av_cold int decode_init(AVCodecContext *avctx){ return 0; } +static av_cold int decode_end(AVCodecContext *avctx){ + WNV1Context * const l = avctx->priv_data; + AVFrame *pic = &l->pic; + + if (pic->data[0]) + avctx->release_buffer(avctx, pic); + av_freep(&l->pic); + + return 0; +} + AVCodec wnv1_decoder = { "wnv1", CODEC_TYPE_VIDEO, @@ -150,7 +161,7 @@ AVCodec wnv1_decoder = { sizeof(WNV1Context), decode_init, NULL, - NULL, + decode_end, decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Winnov WNV1"), diff --git a/libavcodec/xl.c b/libavcodec/xl.c index fb4241f25..277e92a67 100644 --- a/libavcodec/xl.c +++ b/libavcodec/xl.c @@ -128,6 +128,17 @@ static av_cold int decode_init(AVCodecContext *avctx){ return 0; } +static av_cold int decode_end(AVCodecContext *avctx){ + VideoXLContext * const a = avctx->priv_data; + AVFrame *pic = &a->pic; + + if (pic->data[0]) + avctx->release_buffer(avctx, pic); + av_freep(&a->pic); + + return 0; +} + AVCodec xl_decoder = { "xl", CODEC_TYPE_VIDEO, @@ -135,7 +146,7 @@ AVCodec xl_decoder = { sizeof(VideoXLContext), decode_init, NULL, - NULL, + decode_end, decode_frame, CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Miro VideoXL"), -- 2.11.0