Karl Morton's Video Codec
Jump to navigation
Jump to search
- FourCC: KMVC
- Samples: http://www.mplayerhq.hu/MPlayer/samples/V-codecs/KMVC/
KMVC is used on various Worms PC games.
Common details
This codec operates on 8x8 or 16x16 blocks in 256 colors mode. This codec is also employs exotic bitstream reading: actually you need to read byte and when it's exhausted, read another byte, so flags and other data are very mixed.
Frame structure
Frame consists of the next parts: header byte, palette chunk (if needed), compressed blocks.
Header byte may have this bits set:
KPxx MMMM K - is keyframe P - palette is present xx - unknown bits MMMM - compression method (only methods 3 and 4 are known)
Details for palette chunk are still unknown. Compressed blocks are decoded with given method until frame is fully decoded.
Method 3 for block 8x8
This is method used in intraframes:
if(!getbit()){ val = getbyte(); fill block 8x8 with val; } else { for all subblocks 4x4 { if(!getbit()){ if(!getbit()){ val = getbyte(); fill block 4x4 with given val; } else { val = getbyte(); mx = val & 0xF; my = val >> 4; copy block 4x4 from offset (-mx, -my) } } else { for all subblocks 2x2 (in subblock 4x4) { if(!getbit()){ if(!getbit()){ val = getbyte(); fill block 2x2 with given val; } else { val = getbyte(); mx = val & 0xF; my = val >> 4; copy block 2x2 from offset (-mx, -my) } } else { block[0,0] = getbyte(); block[0,1] = getbyte(); block[1,0] = getbyte(); block[1,1] = getbyte(); } } } } }
Method 4 for block 8x8
[TODO]
Method 3 for block 16x16
[TODO]
Method 4 for block 16x16
[TODO]