aboutsummaryrefslogtreecommitdiff
path: root/libavcodec/kgv1dec.c
diff options
context:
space:
mode:
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 6b81095af9..9c4823988e 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 = c->cur.data[0];
+ out = frame->data[0];
if (c->prev.data[0]) {
prev = c->prev.data[0];
} else {
@@ -147,12 +145,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;
}