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/flashsv.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'libavcodec/flashsv.c') diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 3c5a35c0dd..3f211926e3 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -41,6 +41,7 @@ #include "avcodec.h" #include "bytestream.h" #include "get_bits.h" +#include "internal.h" typedef struct BlockInfo { uint8_t *pos; @@ -238,7 +239,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, { int buf_size = avpkt->size; FlashSVContext *s = avctx->priv_data; - int h_blocks, v_blocks, h_part, v_part, i, j; + int h_blocks, v_blocks, h_part, v_part, i, j, ret; GetBitContext gb; /* no supplementary picture */ @@ -327,13 +328,9 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, s->image_width, s->image_height, s->block_width, s->block_height, h_blocks, v_blocks, h_part, v_part); - s->frame.reference = 3; - s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | - FF_BUFFER_HINTS_PRESERVE | - FF_BUFFER_HINTS_REUSABLE; - if (avctx->reget_buffer(avctx, &s->frame) < 0) { + if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; + return ret; } /* loop over all block columns */ @@ -358,8 +355,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, s->diff_height = cur_blk_height; if (8 * size > get_bits_left(&gb)) { - avctx->release_buffer(avctx, &s->frame); - s->frame.data[0] = NULL; + av_frame_unref(&s->frame); return AVERROR_INVALIDDATA; } @@ -441,8 +437,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, memcpy(s->keyframe, s->frame.data[0], s->frame.linesize[0] * avctx->height); } + if ((ret = av_frame_ref(data, &s->frame)) < 0) + return ret; + *got_frame = 1; - *(AVFrame*)data = s->frame; if ((get_bits_count(&gb) / 8) != buf_size) av_log(avctx, AV_LOG_ERROR, "buffer not fully consumed (%d != %d)\n", @@ -458,8 +456,7 @@ static av_cold int flashsv_decode_end(AVCodecContext *avctx) FlashSVContext *s = avctx->priv_data; inflateEnd(&s->zstream); /* release the frame if needed */ - if (s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); + av_frame_unref(&s->frame); /* free the tmpblock */ av_free(s->tmpblock); -- cgit v1.2.3