Commit 015da6e3 authored by Peter Ross's avatar Peter Ross Committed by Ronald S. Bultje

anm decoder: move buffer allocation from decode_init() to decode_frame()

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
Signed-off-by: 's avatarRonald S. Bultje <rsbultje@gmail.com>
parent 3aa661ec
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
typedef struct AnmContext { typedef struct AnmContext {
AVFrame frame; AVFrame frame;
int palette[AVPALETTE_COUNT];
int x; ///< x coordinate position int x; ///< x coordinate position
} AnmContext; } AnmContext;
...@@ -44,14 +45,10 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -44,14 +45,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
return -1; return -1;
s->frame.reference = 1; s->frame.reference = 1;
if (avctx->get_buffer(avctx, &s->frame) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
buf = avctx->extradata + 16*8; buf = avctx->extradata + 16*8;
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
((uint32_t*)s->frame.data[1])[i] = bytestream_get_le32(&buf); s->palette[i] = bytestream_get_le32(&buf);
return 0; return 0;
} }
...@@ -172,6 +169,8 @@ static int decode_frame(AVCodecContext *avctx, ...@@ -172,6 +169,8 @@ static int decode_frame(AVCodecContext *avctx,
} }
} while (buf + 1 < buf_end); } while (buf + 1 < buf_end);
memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE);
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame; *(AVFrame*)data = s->frame;
return buf_size; return buf_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment