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/mss4.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'libavcodec/mss4.c') diff --git a/libavcodec/mss4.c b/libavcodec/mss4.c index f4e4d8ddb4..a74c363dda 100644 --- a/libavcodec/mss4.c +++ b/libavcodec/mss4.c @@ -29,6 +29,7 @@ #include "bytestream.h" #include "dsputil.h" #include "get_bits.h" +#include "internal.h" #include "mss34dsp.h" #include "unary.h" @@ -553,11 +554,7 @@ static int mss4_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, return AVERROR_INVALIDDATA; } - c->pic.reference = 3; - c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | - FF_BUFFER_HINTS_PRESERVE | - FF_BUFFER_HINTS_REUSABLE; - if ((ret = avctx->reget_buffer(avctx, &c->pic)) < 0) { + if ((ret = ff_reget_buffer(avctx, &c->pic)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } @@ -566,7 +563,8 @@ static int mss4_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, : AV_PICTURE_TYPE_P; if (frame_type == SKIP_FRAME) { *got_frame = 1; - *(AVFrame*)data = c->pic; + if ((ret = av_frame_ref(data, &c->pic)) < 0) + return ret; return buf_size; } @@ -622,8 +620,10 @@ static int mss4_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, dst[2] += c->pic.linesize[2] * 16; } + if ((ret = av_frame_ref(data, &c->pic)) < 0) + return ret; + *got_frame = 1; - *(AVFrame*)data = c->pic; return buf_size; } @@ -649,7 +649,6 @@ static av_cold int mss4_decode_init(AVCodecContext *avctx) } avctx->pix_fmt = AV_PIX_FMT_YUV444P; - avctx->coded_frame = &c->pic; return 0; } @@ -659,8 +658,7 @@ static av_cold int mss4_decode_end(AVCodecContext *avctx) MSS4Context * const c = avctx->priv_data; int i; - if (c->pic.data[0]) - avctx->release_buffer(avctx, &c->pic); + av_frame_unref(&c->pic); for (i = 0; i < 3; i++) av_freep(&c->prev_dc[i]); mss4_free_vlcs(c); -- cgit v1.2.3