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/iff.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'libavcodec/iff.c') diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 584e7f983f..08d548b0ea 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -168,8 +168,6 @@ static av_cold int decode_init(AVCodecContext *avctx) if (!s->planebuf) return AVERROR(ENOMEM); - s->frame.reference = 1; - return 0; } @@ -256,15 +254,11 @@ static int decode_frame_ilbm(AVCodecContext *avctx, const uint8_t *buf_end = buf+buf_size; int y, plane, res; - if (s->init) { - if ((res = avctx->reget_buffer(avctx, &s->frame)) < 0) { - av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return res; - } - } else if ((res = ff_get_buffer(avctx, &s->frame)) < 0) { - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + if ((res = ff_reget_buffer(avctx, &s->frame)) < 0) return res; - } else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != AV_PIX_FMT_GRAY8) { + + if (!s->init && avctx->bits_per_coded_sample <= 8 && + avctx->pix_fmt != AV_PIX_FMT_GRAY8) { if ((res = cmap_read_palette(avctx, (uint32_t*)s->frame.data[1])) < 0) return res; } @@ -298,8 +292,11 @@ static int decode_frame_ilbm(AVCodecContext *avctx, } } + if ((res = av_frame_ref(data, &s->frame)) < 0) + return res; + *got_frame = 1; - *(AVFrame*)data = s->frame; + return buf_size; } @@ -313,15 +310,11 @@ static int decode_frame_byterun1(AVCodecContext *avctx, const uint8_t *buf_end = buf+buf_size; int y, plane, res; - if (s->init) { - if ((res = avctx->reget_buffer(avctx, &s->frame)) < 0) { - av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return res; - } - } else if ((res = ff_get_buffer(avctx, &s->frame)) < 0) { - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + if ((res = ff_reget_buffer(avctx, &s->frame)) < 0) return res; - } else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != AV_PIX_FMT_GRAY8) { + + if (!s->init && avctx->bits_per_coded_sample <= 8 && + avctx->pix_fmt != AV_PIX_FMT_GRAY8) { if ((res = cmap_read_palette(avctx, (uint32_t*)s->frame.data[1])) < 0) return res; } @@ -354,16 +347,18 @@ static int decode_frame_byterun1(AVCodecContext *avctx, } } + if ((res = av_frame_ref(data, &s->frame)) < 0) + return res; + *got_frame = 1; - *(AVFrame*)data = s->frame; + return buf_size; } static av_cold int decode_end(AVCodecContext *avctx) { IffContext *s = avctx->priv_data; - if (s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); + av_frame_unref(&s->frame); av_freep(&s->planebuf); return 0; } -- cgit v1.2.3