aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/kgv1dec.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/kgv1dec.c
parent6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff)
downloadffmpeg-759001c534287a96dc96d1e274665feb7059145d.tar.gz
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/kgv1dec.c')
-rw-r--r--libavcodec/kgv1dec.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c
index 01655a54b8..74ae6b7ffe 100644
--- a/libavcodec/kgv1dec.c
+++ b/libavcodec/kgv1dec.c
@@ -32,20 +32,20 @@
typedef struct {
AVCodecContext *avctx;
- AVFrame prev, cur;
+ AVFrame prev;
} KgvContext;
static void decode_flush(AVCodecContext *avctx)
{
KgvContext * const c = avctx->priv_data;
- if (c->prev.data[0])
- avctx->release_buffer(avctx, &c->prev);
+ av_frame_unref(&c->prev);
}
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
+ AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
const uint8_t *buf_end = buf + avpkt->size;
KgvContext * const c = avctx->priv_data;
@@ -65,17 +65,15 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return res;
if (w != avctx->width || h != avctx->height) {
- if (c->prev.data[0])
- avctx->release_buffer(avctx, &c->prev);
+ av_frame_unref(&c->prev);
avcodec_set_dimensions(avctx, w, h);
}
maxcnt = w * h;
- c->cur.reference = 3;
- if ((res = ff_get_buffer(avctx, &c->cur)) < 0)
+ if ((res = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return res;
- out = (uint16_t *) c->cur.data[0];
+ out = (uint16_t *) frame->data[0];
if (c->prev.data[0]) {
prev = (uint16_t *) c->prev.data[0];
} else {
@@ -156,12 +154,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (outcnt - maxcnt)
av_log(avctx, AV_LOG_DEBUG, "frame finished with %d diff\n", outcnt - maxcnt);
- *got_frame = 1;
- *(AVFrame*)data = c->cur;
+ av_frame_unref(&c->prev);
+ if ((res = av_frame_ref(&c->prev, frame)) < 0)
+ return res;
- if (c->prev.data[0])
- avctx->release_buffer(avctx, &c->prev);
- FFSWAP(AVFrame, c->cur, c->prev);
+ *got_frame = 1;
return avpkt->size;
}