Iterated Systems Fractal Codec

From MultimediaWiki
Jump to navigation Jump to search

This is the only known true fractal codec. It has been licensed to different companies and forms the base of FVF and TMM-Frac. Beside slight header variations, all of them have the same bitstream format.

Video internally is coded as 8-bit greyscale or RGB24 but the output is delivered in either paletted or RGB16 format. Frame is split into 320x200 green plane and one plane with 160x100 red and blue planes. Each plane is split into 8x8 blocks that are further split into 4x4 blocks (in zig-zag order) and either individual 4x4 blocks or 8x8 blocks are coded.

Most of the block coding modes are affine transform, which means taking twice as large block from the reference buffer, throw out odd columns and lines, scale pixel values by three fourths, add brightness value (seven-bit value minus 64) and optionally apply an affine transform. There are eight possible affine transforms done as a combination of three base transform (if bit 0 is set then mirror block, if bit 1 is set then flip block, if bit 2 is set then transpose block).

Bitstream organisation

Frame data consists of three parts: 16-bit frame flags, motion offsets (16-bit count followed by 16-bit signed offsets) and block opcodes. Each opcode consists of 1-4 bytes treated as a series of bit fields (LSB first). VfW codec data starts with 32-bit offset to the palette data, other formats are documented at their own pages.

Frame flags:

  • 1 -- fractal frame, data should be decoded 16 times
  • 2 -- palette data present after the frame data
  • 4 -- swap buffers (reference and current output; for fractal frames that's done on each iteration of the decoding) and output new reference buffer
  • 8 -- skip frame (no data is coded)

Opcodes are:

  • 0-3 -- affine transform for 4x4 block. Next 7 bits code brightness adjustment, 14 bits after that code source block index.
  • 4 -- skip block run. Next 5 bits are run length minus one.
  • 5 -- motion block(s). Next bit tells if there's more than one motion block; then 4-bit index of motion offset value from the frame header follows; then (if signalled) an additional number of motion blocks (all with the same motion offset) minus one in eight-bit field.
  • 6 -- raw block. After the first byte sixteen bytes with new block data follow.
  • 7 -- extended opcode is in the next four bits.

Extended opcodes:

  • 0-7 -- affine transform for 8x8 block. Last bit in the first byte is unused, then there's 7-bit brightness, refinement block presence flag, 14-bit source block index flag, and finally 2-bit refined subblock index. In case when refined subblock is present, it is coded as normal block except opcode 7 is not allowed and skip/motion blocks modes apply to that one block only.
  • 12 -- long skip run. Top bit tells whether it's a long run (8-bit value plus 33) or a very long run (16-bit value plus 289).
  • 15 -- small raw block. After the first byte there's 16-bit absolute offset and 4 bytes of block data. This mode does not seem to be used.