Kega Video: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:
Codec used for capturing videos in some Sega emulator called Kega.
Codec used for capturing videos in some Sega emulator called Kega.


It produces output in RGB565 and coding is LZ-like.
It produces output in RGB555 and coding is LZ-like.


Frame starts with two bytes which code real dimensions as multiple of 8 minus 1 block (i.e. <code>width = (src[0] + 1) * 8;</code>, same for height), the rest is coded data.
Frame starts with two bytes which code real dimensions as multiple of 8 minus 1 block (i.e. <code>width = (src[0] + 1) * 8;</code>, same for height), the rest is coded data.
Line 10: Line 10:
Coded data consists of 16-bit LSB control words with possible extensions:
Coded data consists of 16-bit LSB control words with possible extensions:


#  <code>111x xxyy yyyy yyyy</code> - copy <code>(y+3)</code> pixels from positive offset <code>offsets[x]</code> in the previous frame. If <code>offsets[x]</code> 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.
#  <code>111x xxyy yyyy yyyy</code> - copy <code>(y+3)</code> pixels from positive offset <code>offsets[x]</code> in the previous frame. If <code>offsets[x]</code> 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 output position.
#  <code>110y yyyy yyyy yyyy</code> - read run length value minus four from next byte (i.e. <code>run = get_byte() + 4</code>) and copy  pixels from negative offset <code>y+1</code> (e.g. offset 0 means RLE, offset 1 means repeating last two pixels, etc.)
#  <code>110y yyyy yyyy yyyy</code> - read run length value minus four from next byte (i.e. <code>run = get_byte() + 4</code>) and copy  pixels from negative offset <code>y+1</code> (e.g. offset 0 means RLE, offset 1 means repeating last two pixels, etc.)
#  <code>101y yyyy yyyy yyyy</code> - same as above but always copy 3 pixels from given offset
#  <code>101y yyyy yyyy yyyy</code> - same as above but always copy 3 pixels from given offset

Revision as of 08:47, 3 February 2010

Codec used for capturing videos in some Sega emulator called Kega.

It produces output in RGB555 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[0] + 1) * 8;, same for height), the rest is coded data.

Coded data consists of 16-bit LSB control words with possible extensions:

  1. 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 output position.
  2. 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.)
  3. 101y yyyy yyyy yyyy - same as above but always copy 3 pixels from given offset
  4. 100y yyyy yyyy yyyy - same as above but always copy 2 pixels from given offset
  5. 0ppp pppp pppp pppp - p is pixel value, simply output it.

Implementing decoder is left as an exercise for reader.