diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-11-21 21:34:46 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-03-08 07:38:30 +0100 |
commit | 759001c534287a96dc96d1e274665feb7059145d (patch) | |
tree | 6ace9560c20aa30db92067c5b45d7bd86e458d10 /libavcodec/vb.c | |
parent | 6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff) | |
download | ffmpeg-759001c534287a96dc96d1e274665feb7059145d.tar.gz |
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/vb.c')
-rw-r--r-- | libavcodec/vb.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/libavcodec/vb.c b/libavcodec/vb.c index 8bb1a70cc1..df0fef98d2 100644 --- a/libavcodec/vb.c +++ b/libavcodec/vb.c @@ -41,7 +41,6 @@ enum VBFlags { typedef struct VBDecContext { AVCodecContext *avctx; - AVFrame pic; uint8_t *frame, *prev_frame; uint32_t pal[AVPALETTE_COUNT]; @@ -189,6 +188,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { VBDecContext * const c = avctx->priv_data; + AVFrame *frame = data; uint8_t *outptr, *srcptr; int i, j, ret; int flags; @@ -197,10 +197,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, bytestream2_init(&c->stream, avpkt->data, avpkt->size); - if (c->pic.data[0]) - avctx->release_buffer(avctx, &c->pic); - c->pic.reference = 1; - if ((ret = ff_get_buffer(avctx, &c->pic)) < 0) { + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } @@ -222,22 +219,21 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, vb_decode_palette(c, size); } - memcpy(c->pic.data[1], c->pal, AVPALETTE_SIZE); - c->pic.palette_has_changed = flags & VB_HAS_PALETTE; + memcpy(frame->data[1], c->pal, AVPALETTE_SIZE); + frame->palette_has_changed = flags & VB_HAS_PALETTE; - outptr = c->pic.data[0]; + outptr = frame->data[0]; srcptr = c->frame; for (i = 0; i < avctx->height; i++) { memcpy(outptr, srcptr, avctx->width); srcptr += avctx->width; - outptr += c->pic.linesize[0]; + outptr += frame->linesize[0]; } FFSWAP(uint8_t*, c->frame, c->prev_frame); *got_frame = 1; - *(AVFrame*)data = c->pic; /* always report that the buffer was completely consumed */ return avpkt->size; @@ -262,8 +258,6 @@ static av_cold int decode_end(AVCodecContext *avctx) av_freep(&c->frame); av_freep(&c->prev_frame); - if(c->pic.data[0]) - avctx->release_buffer(avctx, &c->pic); return 0; } |