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/smc.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'libavcodec/smc.c') diff --git a/libavcodec/smc.c b/libavcodec/smc.c index 1834003a39..de81a43e91 100644 --- a/libavcodec/smc.c +++ b/libavcodec/smc.c @@ -35,6 +35,7 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "bytestream.h" +#include "internal.h" #define CPAIR 2 #define CQUAD 4 @@ -429,15 +430,13 @@ static int smc_decode_frame(AVCodecContext *avctx, int buf_size = avpkt->size; SmcContext *s = avctx->priv_data; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); + int ret; bytestream2_init(&s->gb, buf, buf_size); - s->frame.reference = 1; - s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | - FF_BUFFER_HINTS_REUSABLE | FF_BUFFER_HINTS_READABLE; - if (avctx->reget_buffer(avctx, &s->frame)) { + if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0) { av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; + return ret; } if (pal) { @@ -448,7 +447,8 @@ static int smc_decode_frame(AVCodecContext *avctx, smc_decode_stream(s); *got_frame = 1; - *(AVFrame*)data = s->frame; + if ((ret = av_frame_ref(data, &s->frame)) < 0) + return ret; /* always report that the buffer was completely consumed */ return buf_size; @@ -458,8 +458,7 @@ static av_cold int smc_decode_end(AVCodecContext *avctx) { SmcContext *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