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/bmv.c | |
parent | 6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff) | |
download | ffmpeg-759001c534287a96dc96d1e274665feb7059145d.tar.gz |
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/bmv.c')
-rw-r--r-- | libavcodec/bmv.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/libavcodec/bmv.c b/libavcodec/bmv.c index 75c550f3f5..b6b685b556 100644 --- a/libavcodec/bmv.c +++ b/libavcodec/bmv.c @@ -43,7 +43,6 @@ enum BMVFlags{ typedef struct BMVDecContext { AVCodecContext *avctx; - AVFrame pic; uint8_t *frame, frame_base[SCREEN_WIDE * (SCREEN_HIGH + 1)]; uint32_t pal[256]; @@ -198,6 +197,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt) { BMVDecContext * const c = avctx->priv_data; + AVFrame *frame = data; int type, scr_off; int i, ret; uint8_t *srcptr, *outptr; @@ -240,11 +240,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, scr_off = 0; } - if (c->pic.data[0]) - avctx->release_buffer(avctx, &c->pic); - - c->pic.reference = 3; - 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; } @@ -254,20 +250,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, return AVERROR_INVALIDDATA; } - memcpy(c->pic.data[1], c->pal, AVPALETTE_SIZE); - c->pic.palette_has_changed = type & BMV_PALETTE; + memcpy(frame->data[1], c->pal, AVPALETTE_SIZE); + frame->palette_has_changed = type & BMV_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]; } *got_frame = 1; - *(AVFrame*)data = c->pic; /* always report that the buffer was completely consumed */ return pkt->size; @@ -285,16 +280,6 @@ static av_cold int decode_init(AVCodecContext *avctx) return 0; } -static av_cold int decode_end(AVCodecContext *avctx) -{ - BMVDecContext *c = avctx->priv_data; - - if (c->pic.data[0]) - avctx->release_buffer(avctx, &c->pic); - - return 0; -} - static const int bmv_aud_mults[16] = { 16512, 8256, 4128, 2064, 1032, 516, 258, 192, 129, 88, 64, 56, 48, 40, 36, 32 }; @@ -328,7 +313,7 @@ static int bmv_aud_decode_frame(AVCodecContext *avctx, void *data, /* get output buffer */ frame->nb_samples = total_blocks * 32; - if ((ret = ff_get_buffer(avctx, frame)) < 0) { + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } @@ -356,7 +341,6 @@ AVCodec ff_bmv_video_decoder = { .id = AV_CODEC_ID_BMV_VIDEO, .priv_data_size = sizeof(BMVDecContext), .init = decode_init, - .close = decode_end, .decode = decode_frame, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Discworld II BMV video"), |