System Shock video
This is a cutscene and audio log format employed by Looking Glass Studios in its game System Shock. They are stored inside resource archive and thus have no extension or name, only numerical ID.
Header format:
4 bytes - "MOVI" 4 bytes - number of chunks 4 bytes - TOC size 4 bytes - data size 4 bytes - duration 4 bytes - frames per second in fixed-point 16-bit format (i.e. FPS * 65536) 2 bytes - width 2 bytes - height 2 bytes - bits per pixel (should be 0 or 8) 2 bytes - some palette flag 2 bytes - number of audio channels 2 bytes - bits per audio sample 4 bytes - sample rate in fixed-point format 216 bytes - padding 768 bytes - initial palette
TOC entry format:
3 bytes - timestamp 1 byte - flags (bits 3-6) and type (bits 0-2) 4 bytes - offset
Chunk types are:
- 0 - EOF
- 1 - video frame
- 2 - audio
- 3 - subtitle
- 4 - palette
- 5 - tables
Video frame
There are two possible frame coding modes.
When chunk flags are not equal to 0xF, frame uses RLE and has update rectangle position and dimensions stored as 16-bit integers before RLE data. Otherwise frame is coded with 4x4 tiles employing Huffman compression and vector quantisation (this mode is used for SVGA videos).
RLE opcodes:
- 0x00 -- run mode (with count byte and colour value following)
- 0x01..0x7F -- copy 1-127 pixels
- 0x80 -- long mode, read 16-bit opcode:
- 0x0000 -- end of decoding
- 0x0001..0x7FFF -- skip 1-32767 pixels
- 0x8000..0xBFFF -- copy 0-16383 pixels
- 0xC000..0xFFFF -- read colour value, output it 0-16383 times
- 0x81..0xFF -- skip 1-127 pixels
Tile mode works on frame split into 4x4 tiles with tile operations packed into Huffman-compressed tokens. Known operations are:
- fill tile with a pair of colours (those values are part of the token)
- fill tile with a pair of colours (those values are part of the token) using mask
- fill tile with four/eight/sixteen colours using mask, token contains offset in the colour table for the colours to be used
- leave some tiles unchanged
- leave the rest of the current tile row unchanged
- repeat previous operation N times
It is worth noting that if the first colour value is zero, then tile is coded in update mode with zero value meaning "leave pixel unchanged".
Palette chunk
If chunk flags are 0, chunk contains new palette. If chunk flags are 1, current palette should be zeroed out.
Table chunk
Chunk flags determine table type. 0 means the colours used in tiled decoding, 1 means Huffman LUT definition (also for tiled decoding).
Huffman LUT is stored run-encoded (3 bytes - token value, 1 byte - repeat count) with initial 32-bit value telling the length of unpacked table.