MGIF

From MultimediaWiki
Jump to navigation Jump to search

This is a video format employing LZW compression (hence the name). Beside that it does not seem to have anything common with GIF.

Video is organised into frame blocks that may contain several chunks with e.g. video or audio data with video data employing LZW compression. One remarkable thing about LZW compression scheme employed here is that it uses delta compression: actual bytes are coded as a difference to the previously decoded value (or 0 after each LZW restart). Images are always 320x180.

File header:

 6 bytes - "MGIF97"
 3 bytes - unknown
 4 bytes - number of blocks
 582 bytes - unknown/ignored (data starts at offset 0x253)

Each block starts with a byte telling number of chunks in it and 24-bit size. Each chunk also starts with 8-bit type and 24-bit size. Known chunk types are:

  • 1 -- intra frame (LZW-compressed image)
  • 2 -- inter frame (LZW-compressed delta data)
  • 3 -- RGB555 palette
  • 4 -- audio

Inter frames data is organised (after LZW) into two parts (opcodes and pixel data) with 32-bit value in the very beginning being the pixel data offset. Decoding is rather simple: if top two bits of the opcode are set, end this line and skip following number of lines as defined in low 6 bits of the opcode; otherwise opcode is a number of pixel pairs to copy.