summaryrefslogtreecommitdiff
path: root/libavcodec/iff.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-11-21 21:34:46 +0100
committerAnton Khirnov <anton@khirnov.net>2013-03-08 07:38:30 +0100
commit759001c534287a96dc96d1e274665feb7059145d (patch)
tree6ace9560c20aa30db92067c5b45d7bd86e458d10 /libavcodec/iff.c
parent6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff)
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/iff.c')
-rw-r--r--libavcodec/iff.c39
1 files changed, 17 insertions, 22 deletions
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;
}