From 759001c534287a96dc96d1e274665feb7059145d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 21 Nov 2012 21:34:46 +0100 Subject: lavc decoders: work with refcounted frames. --- libavcodec/mmvideo.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'libavcodec/mmvideo.c') diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c index 784b939734..7101f8033f 100644 --- a/libavcodec/mmvideo.c +++ b/libavcodec/mmvideo.c @@ -34,6 +34,7 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "bytestream.h" +#include "internal.h" #define MM_PREAMBLE_SIZE 6 @@ -60,8 +61,6 @@ static av_cold int mm_decode_init(AVCodecContext *avctx) avctx->pix_fmt = AV_PIX_FMT_PAL8; - s->frame.reference = 1; - return 0; } @@ -187,9 +186,9 @@ static int mm_decode_frame(AVCodecContext *avctx, buf_size -= MM_PREAMBLE_SIZE; bytestream2_init(&s->gb, buf, buf_size); - if (avctx->reget_buffer(avctx, &s->frame) < 0) { + if ((res = ff_reget_buffer(avctx, &s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; + return res; } switch(type) { @@ -209,8 +208,10 @@ static int mm_decode_frame(AVCodecContext *avctx, memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); + if ((res = av_frame_ref(data, &s->frame)) < 0) + return res; + *got_frame = 1; - *(AVFrame*)data = s->frame; return buf_size; } @@ -219,8 +220,7 @@ static av_cold int mm_decode_end(AVCodecContext *avctx) { MmContext *s = avctx->priv_data; - if(s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); + av_frame_unref(&s->frame); return 0; } -- cgit v1.2.3