Lego Pirates of the Caribbean FMV

From MultimediaWiki
Jump to navigation Jump to search

This seems to be a JPEG-based cutscene format with optional audio.

Header:

 4 bytes - "FMV!"
 2 bytes - version
 2 bytes - header length
 2 bytes - width
 2 bytes - height
 4 bytes - total number of macroblocks?
 4 bytes - unknown
 2 bytes - framerate
 4 bytes - flags (4 - audio present)
 4 bytes - unknown

Audio header (if flag bit 2 is set):

 2 bytes - unknown
 4 bytes - sample rate
 1 byte  - unknown
 1 byte  - unknown
 1 byte  - unknown
 1 byte  - unknown

The rest of the file seems to be composed of chunks with the following signatures and 32-bit payload sizes:

  • "FMVk" - key frame
  • "FMVd" - delta frame
  • "FMVn" - no frame (repeat last decoded frame)
  • "FMA\0" - audio data

Key frame data:

 4 bytes - "FMVk"
 4 bytes - data size
 2 bytes - metadata size
 N bytes - RLE-compressed metadata
 1 byte  - quality
 (first frame only) Huffman data
 encoded macroblocks

Delta frame data:

 4 bytes - "FMVd"
 4 bytes - data size
 2 bytes - metadata size
 N bytes - RLE-compressed metadata
 1 byte  - quality
 encoded macroblocks

Frame metadata is macroblock coding types using RLE scheme using a twice repeated value as a trigger for run mode. Next byte in this case tells what to do (0-2: repeat last byte 1-3 times, 128-255 means this byte contains top 7 bits of run length and next byte is low 8 bits of it, otherwise it is run length and the next byte should be repeated N+1 times).

Quality value is used to generate luma and chroma quantisation matrices in the same way as libjpeg does.

Huffman data is stored as 16 symbol counts (for each possible bit length) followed by the symbols.

Macroblock coding types:

  • 0 - skip
  • 1 - motion block with 5-bit motion vector components
  • 2 - fill block with three bytes, one for each plane
  • 255 - DCT-coded macroblock