summaryrefslogtreecommitdiffstats
path: root/libavcodec/kmvc.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/kmvc.c
parent6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff)
downloadffmpeg-streaming-759001c534287a96dc96d1e274665feb7059145d.zip
ffmpeg-streaming-759001c534287a96dc96d1e274665feb7059145d.tar.gz
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/kmvc.c')
-rw-r--r--libavcodec/kmvc.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
index 3ed01ad..574d053 100644
--- a/libavcodec/kmvc.c
+++ b/libavcodec/kmvc.c
@@ -41,7 +41,6 @@
*/
typedef struct KmvcContext {
AVCodecContext *avctx;
- AVFrame pic;
int setpal;
int palsize;
@@ -247,6 +246,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
KmvcContext *const ctx = avctx->priv_data;
+ AVFrame *frame = data;
uint8_t *out, *src;
int i, ret;
int header;
@@ -254,12 +254,8 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
bytestream2_init(&ctx->g, avpkt->data, avpkt->size);
- if (ctx->pic.data[0])
- avctx->release_buffer(avctx, &ctx->pic);
- ctx->pic.reference = 1;
- ctx->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
- if ((ret = ff_get_buffer(avctx, &ctx->pic)) < 0) {
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
@@ -277,15 +273,15 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
}
if (header & KMVC_KEYFRAME) {
- ctx->pic.key_frame = 1;
- ctx->pic.pict_type = AV_PICTURE_TYPE_I;
+ frame->key_frame = 1;
+ frame->pict_type = AV_PICTURE_TYPE_I;
} else {
- ctx->pic.key_frame = 0;
- ctx->pic.pict_type = AV_PICTURE_TYPE_P;
+ frame->key_frame = 0;
+ frame->pict_type = AV_PICTURE_TYPE_P;
}
if (header & KMVC_PALETTE) {
- ctx->pic.palette_has_changed = 1;
+ frame->palette_has_changed = 1;
// palette starts from index 1 and has 127 entries
for (i = 1; i <= ctx->palsize; i++) {
ctx->pal[i] = bytestream2_get_be24(&ctx->g);
@@ -293,17 +289,17 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
}
if (pal) {
- ctx->pic.palette_has_changed = 1;
+ frame->palette_has_changed = 1;
memcpy(ctx->pal, pal, AVPALETTE_SIZE);
}
if (ctx->setpal) {
ctx->setpal = 0;
- ctx->pic.palette_has_changed = 1;
+ frame->palette_has_changed = 1;
}
/* make the palette available on the way out */
- memcpy(ctx->pic.data[1], ctx->pal, 1024);
+ memcpy(frame->data[1], ctx->pal, 1024);
blocksize = bytestream2_get_byte(&ctx->g);
@@ -328,12 +324,12 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
return AVERROR_INVALIDDATA;
}
- out = ctx->pic.data[0];
+ out = frame->data[0];
src = ctx->cur;
for (i = 0; i < avctx->height; i++) {
memcpy(out, src, avctx->width);
src += 320;
- out += ctx->pic.linesize[0];
+ out += frame->linesize[0];
}
/* flip buffers */
@@ -346,7 +342,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
}
*got_frame = 1;
- *(AVFrame *) data = ctx->pic;
/* always report that the buffer was completely consumed */
return avpkt->size;
@@ -415,8 +410,6 @@ static av_cold int decode_end(AVCodecContext * avctx)
av_freep(&c->frm0);
av_freep(&c->frm1);
- if (c->pic.data[0])
- avctx->release_buffer(avctx, &c->pic);
return 0;
}
OpenPOWER on IntegriCloud