- FourCC: KGV1
- Sample: http://samples.mplayerhq.hu/V-codecs/kgv1.avi
Codec used for capturing videos in some Sega emulator called Kega.
It produces output in RGB565 and coding is LZ-like.
Frame starts with two bytes which code real dimensions as multiple of 8 minus 1 block (i.e.
width = (src + 1) * 8;, same for height), the rest is coded data.
Coded data consists of 16-bit LSB control words with possible extensions:
111x xxyy yyyy yyyy- copy
(y+3)pixels from positive offset
offsets[x]in the previous frame. If
offsets[x]is not yet defined for this frame, read 24-bit LSB word after this code word. Naturally, this is possible only in interframes. The offset may wrap around the frame, depending on the current offset position.
110y yyyy yyyy yyyy- read run length value minus four from next byte (i.e.
run = get_byte() + 4) and copy pixels from negative offset
y+1(e.g. offset 0 means RLE, offset 1 means repeating last two pixels, etc.)
101y yyyy yyyy yyyy- same as above but always copy 3 pixels from given offset
100y yyyy yyyy yyyy- same as above but always copy 2 pixels from given offset
0ppp pppp pppp pppp-
pis pixel value, simply output it.
Implementing decoder is left as an exercise for reader.