Lempel-Ziv-Oberhumer Compressed Animation (LZA) ----------------------------------------------- The following is a description of the LZA animation file format. The LZA format was invented by Brian Strack Jensen, aka. goto64 of Purple, and can be used freely. I have released two PC utilities for the LZA format. One is an animation player for MCGA and SVGA (VESA 2.0 only). The other utility is an animation file converter from FLI/FLC to LZA. Both utilities require 386 or higher, and at least 2Mb RAM. Contacting info: E-mail: purple@diku.dk WWW homepages for Purple: http://www.diku.dk/students/purple/ Snail Mail: Brian Jensen Lindevej 2 Jorlunde DK-3550 Slangerup Denmark ----------------------------------------------------------------------------- File format for LZA ------------------- General header at the beginning of the file: Size in bytes |Type |Description ---------------------------------------------------------- 6 |Char |File signature: "LZANIM" 1 |Byte |Version (currently: 1) 2 |Word |Number of frames in animation 2 |Word |Screen width 2 |Word |Screen height 4 |Longint |Pause between frames (millisec.) Following this header is the actual frames, each with a header: Size in bytes |Type |Description ---------------------------------------------------------- 1 |Byte |Frame type, 1 = pixels, 2 = palette 2 |Word |Number of blocks A palette frame has just one block, containing the RGB data for the 256 color palette. This is not compressed, so the palette size is always 768 bytes. The pixel blocks all have this header: Size in bytes |Type |Description ---------------------------------------------------------- 2 |Word |Horizontal lines to skip 4 |Longint |Size of the compressed data block Following the block header, is the LZO compressed data for the block. The compression scheme used is LZO1C-9 (see LZO note at the end of this file). ----------------------------------------------------------------------------- Implementation notes -------------------- If you want to write a LZA player, there is a few things to remember. First of all, compared to flic, each line is NOT compressed individually. This means that decompression directly to the screen, can only be done with full screen animations. If you wish to play a non-full screen animation, or scale an animation, you need to decompress each frame to a virtual screen, before moving these data to the screen. You must also remember, that LZA skips the horizontal lines that are exactly the same as on the previous frame, so if you scale the animation, you must preserve the original frame. Pseudo code for LZA player: Initialize player, open LZA file, read the LZA header. Check signature and version. Clear the screen. For each frame in the animation do: Read frame header. If frame is a palette frame: Read 768 byte palette data, and set palette. Else if frame is a pixel frame: For each block in pixel frame: Read block header. Skip the number of lines stated in the header. Read the block's compressed data. Decompress the data using LZO1C. Pause for the number of milliseconds stated in the LZA header. Performance of LZA ------------------ When I designed LZA, my aim was to get a higher compression than FLI/FLC, without reducing the replay speed too much. Compared to FLI/FLC, LZA compresses better, when only a small part of a frame is repeated on the next frame. The replay speed is generally a little slower than FLI/FLC, but with an assembler implementation of the LZO1C-9 algorithm the replay speed could probably be improved. I've tested the LZA format with four FLI/FLC files. The files have the following characteristics: - PC2.FLI: Every frame is almost completely different from the previous. - SPACE2.FLC: Most of the top and bottom of the frame is the same in each frame, while the center part changes. - HIRES.FLC: Three stars change size or move across the unchanging background. - CAR01.FLC: Small rotating car on black background. Name |FLI/FLC size |LZA size |Size compared to FLI/FLC ----------------------------------------------------------------- PC2.FLI |1376948 bytes |664886 bytes | 48.3 % SPACE2.FLC | 675776 bytes |505834 bytes | 74.9 % HIRES.FLC | 231904 bytes |598154 bytes |257.9 % CAR01.FLC | 83214 bytes | 69820 bytes | 83.9 % LZO Note -------- The LZO1C-9 algoritm was invented by Markus Franz Xaver Johannes Oberhumer. His C library for the LZO routines version 0.11 was released for Public Domain the 29th of May 1996. His e-mail address is: markus.oberhumer@jk.uni-linz.ac.at His WWW homepage address is: http://www.infosys.tuwien.ac.at/Staff/lux/marco