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/anm.c | |
parent | 6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff) | |
download | ffmpeg-759001c534287a96dc96d1e274665feb7059145d.tar.gz |
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/anm.c')
-rw-r--r-- | libavcodec/anm.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/libavcodec/anm.c b/libavcodec/anm.c index af148a6fd0..9f1cc397f9 100644 --- a/libavcodec/anm.c +++ b/libavcodec/anm.c @@ -26,9 +26,10 @@ #include "avcodec.h" #include "bytestream.h" +#include "internal.h" typedef struct AnmContext { - AVFrame frame; + AVFrame *frame; int palette[AVPALETTE_COUNT]; GetByteContext gb; int x; ///< x coordinate position @@ -41,7 +42,10 @@ static av_cold int decode_init(AVCodecContext *avctx) avctx->pix_fmt = AV_PIX_FMT_PAL8; - s->frame.reference = 1; + s->frame = av_frame_alloc(); + if (!s->frame) + return AVERROR(ENOMEM); + bytestream2_init(&s->gb, avctx->extradata, avctx->extradata_size); if (bytestream2_get_bytes_left(&s->gb) < 16 * 8 + 4 * 256) return AVERROR_INVALIDDATA; @@ -113,12 +117,12 @@ static int decode_frame(AVCodecContext *avctx, uint8_t *dst, *dst_end; int count, ret; - if ((ret = avctx->reget_buffer(avctx, &s->frame)) < 0){ + if ((ret = ff_reget_buffer(avctx, s->frame)) < 0){ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - dst = s->frame.data[0]; - dst_end = s->frame.data[0] + s->frame.linesize[0]*avctx->height; + dst = s->frame->data[0]; + dst_end = s->frame->data[0] + s->frame->linesize[0]*avctx->height; bytestream2_init(&s->gb, avpkt->data, buf_size); @@ -136,7 +140,7 @@ static int decode_frame(AVCodecContext *avctx, do { /* if statements are ordered by probability */ #define OP(gb, pixel, count) \ - op(&dst, dst_end, (gb), (pixel), (count), &s->x, avctx->width, s->frame.linesize[0]) + op(&dst, dst_end, (gb), (pixel), (count), &s->x, avctx->width, s->frame->linesize[0]) int type = bytestream2_get_byte(&s->gb); count = type & 0x7F; @@ -168,18 +172,20 @@ static int decode_frame(AVCodecContext *avctx, } } while (bytestream2_get_bytes_left(&s->gb) > 0); - memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); + memcpy(s->frame->data[1], s->palette, AVPALETTE_SIZE); *got_frame = 1; - *(AVFrame*)data = s->frame; + if ((ret = av_frame_ref(data, s->frame)) < 0) + return ret; + return buf_size; } static av_cold int decode_end(AVCodecContext *avctx) { AnmContext *s = avctx->priv_data; - if (s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); + + av_frame_free(&s->frame); return 0; } |