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/motionpixels.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'libavcodec/motionpixels.c') diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index c2bd0f4d2b..c205735c90 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -22,6 +22,7 @@ #include "avcodec.h" #include "get_bits.h" #include "dsputil.h" +#include "internal.h" #define MAX_HUFF_CODES 16 @@ -244,13 +245,11 @@ static int mp_decode_frame(AVCodecContext *avctx, int buf_size = avpkt->size; MotionPixelsContext *mp = avctx->priv_data; GetBitContext gb; - int i, count1, count2, sz; + int i, count1, count2, sz, ret; - mp->frame.reference = 1; - mp->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; - if (avctx->reget_buffer(avctx, &mp->frame)) { + if ((ret = ff_reget_buffer(avctx, &mp->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; + return ret; } /* le32 bitstream msb first */ @@ -295,8 +294,9 @@ static int mp_decode_frame(AVCodecContext *avctx, ff_free_vlc(&mp->vlc); end: + if ((ret = av_frame_ref(data, &mp->frame)) < 0) + return ret; *got_frame = 1; - *(AVFrame *)data = mp->frame; return buf_size; } @@ -308,8 +308,7 @@ static av_cold int mp_decode_end(AVCodecContext *avctx) av_freep(&mp->vpt); av_freep(&mp->hpt); av_freep(&mp->bswapbuf); - if (mp->frame.data[0]) - avctx->release_buffer(avctx, &mp->frame); + av_frame_unref(&mp->frame); return 0; } -- cgit v1.2.3