[FFmpeg-devel] [PATCH] DeluxePaint Animation playback system
Stephen Backway
stev391
Wed Aug 26 13:33:32 CEST 2009
On Wed, 2009-08-26 at 20:45 +1000, Peter Ross wrote:
> Samples: http://www.google.com.au/search?q=filetype%3Aanm+lpf+anim
> (or any of the .ANM files bundled with Duke Nukem 3D...)
>
> Details: http://wiki.multimedia.cx/index.php?title=DeluxePaint_Animation
>
> Cheers,
>
> -- Peter
To save Diego some typing...
diff --git a/libavcodec/anm.c b/libavcodec/anm.c
new file mode 100644
index 0000000..72cc625
--- /dev/null
+++ b/libavcodec/anm.c
@@ -0,0 +1,151 @@
[...]
+static av_cold int decode_init(AVCodecContext *avctx){
+ AnmContext *s = avctx->priv_data;
+ uint8_t *buf;
+ int i;
+
+ avctx->pix_fmt = PIX_FMT_PAL8;
+
+ if (avctx->extradata_size != 16*8 + 4*256)
+ return -1;
+
+ /* manually allocate frame of width * height */
+ s->frame.reference = 1;
+ s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;
+ s->frame.linesize[0] = avctx->width;
+ s->frame.data[0] = av_malloc(avctx->width*avctx->height);
+ if (!s->frame.data[0])
+ return AVERROR_NOMEM;
+ s->frame.data[1] = av_malloc(AVPALETTE_SIZE);
align above. (and other places in this file [the demuxer appears to have
better alignment]).
+ if (!s->frame.data[1]) {
+ av_freep(&s->frame.data[0]);
+ return AVERROR_NOMEM;
+ }
+
+ buf = avctx->extradata + 16*8;
+ for(i = 0; i < 256; i++) {
+ ((int*)s->frame.data[1])[i] = AV_RL32(buf);
+ buf += 4;
+ }
perhaps use bytestream_get_le32(&buf) instead of AV_RL32(buf) and buf +=
4.
[...]
+
+static int decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ AVPacket *avpkt)
alignment
[...]
diff --git a/libavformat/anm.c b/libavformat/anm.c
new file mode 100644
index 0000000..d0a2632
--- /dev/null
+++ b/libavformat/anm.c
[...]
+static int read_header(AVFormatContext *s,
+ AVFormatParameters *ap)
alignment.
Regards,
Stephen.
More information about the ffmpeg-devel
mailing list