Moving Puzzles MV
This is a format used in Moving Puzzle game series.
The format is majorly inspired by MOV but in little-endian mode (beside the numeric values, tags are reversed as well e.g. using "dhvm" instead of "mvhd").
Unlike MOV, chunks have flat structure and are located in the header section only (prefixed with 32-bit total size).
Most important chunk names are:
- "dhvm" / "mvhd" -- movie header
- "dhrt" / "trhd" -- track header, it contains track type (video or palette) as well as other track metadata
- "sfoc" / "cofs" -- chunk offsets
- "pmsc" / "csmp" -- sample mapping to chunk
- "ziss" / "ssiz" -- individual sample sizes
- "ruds" / "sdur" -- sample duration information
- "rcsd" / "dscr" -- data compression type (" elr" for RLE and "sszl" for LZSS)
- "csds" / "sdsc" -- unknown
- "yeks" / "skey" -- keyframe sample numers
RLE compression
RLE data starts with byte value of 1 followed by inter flag byte. In both modes opcodes 1-127 mean a run of next byte value 1-127 times and 128-255 mean copying 128-1 bytes of input to output, but in inter modes output data is not copied as is but rather XORed with the previous frame data.
LZSS compression
This is a variation of LZSS where flags and other values are interleaved at bit level. First byte contains in its nibbles the number of bits for offset and length operations, next three bytes are padding, then actual bitstream (MSB first) starts.
Decoding is trivial:
if get_bit() {
literal = get_bits(8);
output literal
} else {
offset = (1 << offset_bits) - get_bits(offset_bits);
length = get_bits(length_bits) + 2;
copy (length) bytes from (-offset) relative to the current data end
}