diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2013-06-21 21:56:18 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-06-22 11:58:46 +0200 |
commit | d76fff7df72dc458a331709707fc5292ac609aa7 (patch) | |
tree | f7e46a35c1fbffa63b282bb0aec49fc3caa37a78 /libavcodec/smvjpegdec.c | |
parent | 1a405c683e03681d5f55a896b056aab4ab63f8de (diff) | |
download | ffmpeg-d76fff7df72dc458a331709707fc5292ac609aa7.tar.gz |
smvjpeg: use refcounted frames to avoid mem leaks
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/smvjpegdec.c')
-rw-r--r-- | libavcodec/smvjpegdec.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/smvjpegdec.c b/libavcodec/smvjpegdec.c index d815ef18ca..d7178d77c3 100644 --- a/libavcodec/smvjpegdec.c +++ b/libavcodec/smvjpegdec.c @@ -111,6 +111,7 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx) s->avctx = avcodec_alloc_context3(codec); av_dict_set(&thread_opt, "threads", "1", 0); + s->avctx->refcounted_frames = 1; s->avctx->flags = avctx->flags; s->avctx->idct_algo = avctx->idct_algo; if (ff_codec_open2_recursive(s->avctx, codec, &thread_opt) < 0) { @@ -133,9 +134,10 @@ static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_siz cur_frame = avpkt->pts % s->frames_per_jpeg; /* Are we at the start of a block? */ - if (!cur_frame) + if (!cur_frame) { + av_frame_unref(mjpeg_data); ret = avcodec_decode_video2(s->avctx, mjpeg_data, &s->mjpeg_data_size, avpkt); - else if (!s->mjpeg_data_size) + } else if (!s->mjpeg_data_size) return AVERROR(EINVAL); desc = av_pix_fmt_desc_get(s->avctx->pix_fmt); @@ -177,6 +179,7 @@ static av_cold int smvjpeg_decode_end(AVCodecContext *avctx) MJpegDecodeContext *jpg = &s->jpg; jpg->picture_ptr = NULL; + av_frame_free(&s->picture[0]); av_frame_free(&s->picture[1]); ff_codec_close_recursive(s->avctx); av_freep(&s->avctx); |