Legend Entertainment Q

From MultimediaWiki
Jump to navigation Jump to search
  • Company: Legend Entertainment

The format stores paletted video and raw audio stream for some game cutscenes or animations (while others may be stored in FLIC format). The format consists of 26-byte header followed by a series of 6-byte chunk headers and optional chunk payload. All data is little-endian.

File header

 2 bytes - magic 0x6839
 1 byte  - version
 1 byte  - ignored
 2 bytes - width in blocks
 2 bytes - height in blocks
 1 byte  - block width (should be 4)
 1 byte  - block height (should be 4)
 2 bytes - number of frames
 4 bytes - offset to the frame data (palette and optional method signalling chunks are stored before that offset)
 1 byte  - frames per second
 3 bytes - ignored
 2 bytes - unknown
 4 bytes - audio chunk size

Chunk types

Chunk header consists of 16-bit chunk type and 32-bit chunk size.

Chunk types:

  • 0xFFFF - end of stream
  • 0 - audio
  • 1 - VGA palette
  • 2 - video frame
  • 3 - video frame (probably with additional coordinates to update just the part of image)
  • 4 - video frame (probably with additional coordinates to update just the part of image)
  • 5 - up to 128 most common 16-bit patterns used by the following frames
  • 6 - a marker signalling different decoding algorithm (chunk size should be ignored)
  • 7 - a marker signalling different decoding algorithm (chunk size should be ignored)
  • 8 - RIFF WAV header
  • 9 - unknown, probably another video frame chunk
  • 10 - padding?
  • 11 - unknown, probably another video frame chunk

Video compression

Video frame is compressed as a sequence of 4x4 blocks using mainly Block Truncation Coding and reusing other frame blocks (either by not updating it or by copying some other frame block). The compressed data is essentially a stream of opcodes that tell how to decode the following block (or several blocks).

Opcodes:

  • xx xx (xx < 0xF8) - fill the block with xx value
  • xx yy ii (xx < 0xF8, ii < 0x80) - fill the block using the pattern from chunk type 5 with index ii (top bit first) and colours xx and yy
  • xx yy pppp (xx < 0xF8, pppp >= 0x8000) - fill the block using the 16-bit pattern pppp (top bit first) and colours xx and yy
  • 0xF8 - TODO
  • 0xF9 nn - repeat previous block nn times
  • 0xFA nnnn - copy the block at absolute 16-bit position nnnn
  • 0xFB - see below
  • 0xFC mm - copy the block using the motion vector mm from the table below
  • 0xFD nn - copy the block after the current one using offset nn
  • 0xFE nn - copy the block before the current one using offset nn
  • 0xFF - leave the block unchanged

0xFB opcode methods

Depending on initialisation chunk (e.g. chunk type 7 being present in the beginning) this opcode invokes a different unpacking method.

Pattern blocks sequence (default?)

The following blocks contain only a 8- or 16-bit pattern (00..7F for pattern index 8000..FFFF for actual pattern) and reuse colours from the last pattern block.

Raw blocks sequence (when chunk 7 is present)

If the data starts with byte value less than 0xF8 then the following 16 bytes are copied into the output block, otherwise fill block with several colours depending on the code:

  • 0xF8 - should not happen, skip
  • 0xF9 - fill the block using 32-bit pattern (with 2 bits per pixel) and following 3 colours
  • 0xFA - fill the block using 32-bit pattern (with 2 bits per pixel) and following 4 colours
  • 0xFB - fill the block using 2x24-bit pattern (3 bits per pixel, each 4x2 block has its own 24-bit pattern) and following 5 colours
  • 0xFC - fill the block using 2x24-bit pattern and following 6 colours
  • 0xFD - fill the block using 2x24-bit pattern and following 7 colours
  • 0xFE - fill the block using 2x24-bit pattern and following 8 colours
  • 0xFF - should not happen, skip

Motion vectors table

Motion vectors are also used with the whole blocks so e.g. (-5, 8) means taking 4x4 block that is 5 blocks to the left and eight blocks down from the current one.

 ( 0,  8), ( 1,  8), ( 2,  8), ( 3,  8), ( 4,  8), ( 5,  8), ( 6,  8), ( 7,  8),
 (-8,  8), (-1,  8), (-2,  8), (-3,  8), (-4,  8), (-5,  8), (-6,  8), (-7,  8),
 ( 0,  9), ( 1,  9), ( 2,  9), ( 3,  9), ( 4,  9), ( 5,  9), ( 6,  9), ( 7,  9),
 (-8,  9), (-1,  9), (-2,  9), (-3,  9), (-4,  9), (-5,  9), (-6,  9), (-7,  9),
 ( 0,  2), ( 1,  2), ( 2,  2), ( 3,  2), ( 4,  2), ( 5,  2), ( 6,  2), ( 7,  2),
 (-8,  2), (-1,  2), (-2,  2), (-3,  2), (-4,  2), (-5,  2), (-6,  2), (-7,  2),
 ( 0,  3), ( 1,  3), ( 2,  3), ( 3,  3), ( 4,  3), ( 5,  3), ( 6,  3), ( 7,  3),
 (-8,  3), (-1,  3), (-2,  3), (-3,  3), (-4,  3), (-5,  3), (-6,  3), (-7,  3),
 ( 0,  4), ( 1,  4), ( 2,  4), ( 3,  4), ( 4,  4), ( 5,  4), ( 6,  4), ( 7,  4),
 (-8,  4), (-1,  4), (-2,  4), (-3,  4), (-4,  4), (-5,  4), (-6,  4), (-7,  4),
 ( 0,  5), ( 1,  5), ( 2,  5), ( 3,  5), ( 4,  5), ( 5,  5), ( 6,  5), ( 7,  5),
 (-8,  5), (-1,  5), (-2,  5), (-3,  5), (-4,  5), (-5,  5), (-6,  5), (-7,  5),
 ( 0,  6), ( 1,  6), ( 2,  6), ( 3,  6), ( 4,  6), ( 5,  6), ( 6,  6), ( 7,  6),
 (-8,  6), (-1,  6), (-2,  6), (-3,  6), (-4,  6), (-5,  6), (-6,  6), (-7,  6),
 ( 0,  7), ( 1,  7), ( 2,  7), ( 3,  7), ( 4,  7), ( 5,  7), ( 6,  7), ( 7,  7),
 (-8,  7), (-1,  7), (-2,  7), (-3,  7), (-4,  7), (-5,  7), (-6,  7), (-7,  7),
 ( 0, -8), ( 1, -8), ( 2, -8), ( 3, -8), ( 4, -8), ( 5, -8), ( 6, -8), ( 7, -8),
 (-8, -8), (-1, -8), (-2, -8), (-3, -8), (-4, -8), (-5, -8), (-6, -8), (-7, -8),
 ( 0, -9), ( 1, -9), ( 2, -9), ( 3, -9), ( 4, -9), ( 5, -9), ( 6, -9), ( 7, -9),
 (-8, -9), (-1, -9), (-2, -9), (-3, -9), (-4, -9), (-5, -9), (-6, -9), (-7, -9),
 ( 0, -2), ( 1, -2), ( 2, -2), ( 3, -2), ( 4, -2), ( 5, -2), ( 6, -2), ( 7, -2),
 (-8, -2), (-1, -2), (-2, -2), (-3, -2), (-4, -2), (-5, -2), (-6, -2), (-7, -2),
 ( 0, -3), ( 1, -3), ( 2, -3), ( 3, -3), ( 4, -3), ( 5, -3), ( 6, -3), ( 7, -3),
 (-8, -3), (-1, -3), (-2, -3), (-3, -3), (-4, -3), (-5, -3), (-6, -3), (-7, -3),
 ( 0, -4), ( 1, -4), ( 2, -4), ( 3, -4), ( 4, -4), ( 5, -4), ( 6, -4), ( 7, -4),
 (-8, -4), (-1, -4), (-2, -4), (-3, -4), (-4, -4), (-5, -4), (-6, -4), (-7, -4),
 ( 0, -5), ( 1, -5), ( 2, -5), ( 3, -5), ( 4, -5), ( 5, -5), ( 6, -5), ( 7, -5),
 (-8, -5), (-1, -5), (-2, -5), (-3, -5), (-4, -5), (-5, -5), (-6, -5), (-7, -5),
 ( 0, -6), ( 1, -6), ( 2, -6), ( 3, -6), ( 4, -6), ( 5, -6), ( 6, -6), ( 7, -6),
 (-8, -6), (-1, -6), (-2, -6), (-3, -6), (-4, -6), (-5, -6), (-6, -6), (-7, -6),
 ( 0, -7), ( 1, -7), ( 2, -7), ( 3, -7), ( 4, -7), ( 5, -7), ( 6, -7), ( 7, -7),
 (-8, -7), (-1, -7), (-2, -7), (-3, -7), (-4, -7), (-5, -7), (-6, -7), (-7, -7)

Games that use Q format