diff options
Diffstat (limited to 'libavcodec/anm.c')
-rw-r--r-- | libavcodec/anm.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/libavcodec/anm.c b/libavcodec/anm.c index 08f5170..4e9737f 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,8 +42,10 @@ static av_cold int decode_init(AVCodecContext *avctx) avctx->pix_fmt = AV_PIX_FMT_PAL8; - avcodec_get_frame_defaults(&s->frame); - s->frame.reference = 3; + 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; @@ -114,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); @@ -137,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; @@ -169,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; } |