<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multimedia.cx/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=VAG</id>
	<title>MultimediaWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multimedia.cx/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=VAG"/>
	<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php/Special:Contributions/VAG"/>
	<updated>2026-04-22T08:54:12Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=14562</id>
		<title>DFA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=14562"/>
		<updated>2013-04-06T15:01:59Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* TDLT chunk */ tdlt sample file&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extensions: dfa&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/ http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/]&lt;br /&gt;
&lt;br /&gt;
DFA is a FMV format used in PC games developed by DreamForge.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
All multi-byte numbers are little endian. These files are comprised of chunks with the following format:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    chunk fourcc&lt;br /&gt;
  bytes 4-7    chunk size, not including 12-byte preamble&lt;br /&gt;
  bytes 8-11   chunk type, essentially numeric equivalent of fourcc&lt;br /&gt;
  bytes 12..   chunk payload&lt;br /&gt;
&lt;br /&gt;
A DFA file begins with a 128- (0x80-)byte header:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    file signature: 'DFIA'&lt;br /&gt;
  byte  4      version (= 0)&lt;br /&gt;
  byte  5      ? (output)&lt;br /&gt;
  bytes 6-7    number of frames&lt;br /&gt;
  bytes 8-9    frame width&lt;br /&gt;
  bytes 10-11  frame height&lt;br /&gt;
  bytes 12-15  frame rate&lt;br /&gt;
  bytes 16-19  first frame offset (= 0x80)&lt;br /&gt;
  bytes 20-23  ? (odirectory)&lt;br /&gt;
  bytes 24-127 unused&lt;br /&gt;
&lt;br /&gt;
Chunk types include:&lt;br /&gt;
&lt;br /&gt;
  EOFR (type 0)    end of frame, empty chunk&lt;br /&gt;
  PAL1 (type 1)    768-byte chunk containing a 6-bit VGA palette components&lt;br /&gt;
  COPY (type 2)    raw frame data&lt;br /&gt;
  TSW1 (type 3)    video frame, intra LZ-coded&lt;br /&gt;
  BDLT (type 4)    video frame, inter RLE-coded bytes&lt;br /&gt;
  WDLT (type 5)    video frame, inter RLE-coded words&lt;br /&gt;
  TDLT (type 6)    video frame, inter chains&lt;br /&gt;
  DSW1 (type 7)    video frame, inter LZ-coded&lt;br /&gt;
  BLCK (type 8)    solid frame, fill whole frame with the first byte of payload&lt;br /&gt;
  DDS1 (type 9)    video frame, inter LZ-coded, double-scaled&lt;br /&gt;
&lt;br /&gt;
=== TSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
First four bytes store number of stripes to change, next four bytes - offset inside frame. The rest is stripe data.&lt;br /&gt;
&lt;br /&gt;
Every stripe is coded with 16-bit LSB little-endian words in LZ77-like scheme:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else {&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== BDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to skip in frame before decoding, next two bytes code number of lines to decode.&lt;br /&gt;
&lt;br /&gt;
Every line is coded into segments, first byte of data tells how many segments are there. Every segment is coded as RLE, first byte&lt;br /&gt;
tells how many pixels to skip before decoding segment, second byte is treated as signed value with sign telling if it's copy or run:&lt;br /&gt;
&lt;br /&gt;
  while (segments--) {&lt;br /&gt;
     cur_line_ptr += get_byte();&lt;br /&gt;
     count = (int8_t)get_byte();&lt;br /&gt;
     if (count &amp;gt;= 0)&lt;br /&gt;
         get_buffer(cur_line_ptr, count);&lt;br /&gt;
     else&lt;br /&gt;
         memset(cur_line_ptr, get_byte(), -count);&lt;br /&gt;
     cur_line_ptr += abs(count);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== WDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to decode. Overall decoding is similar to BDLT chunk but with words copy instead of byte copy and different segment handling scheme:&lt;br /&gt;
&lt;br /&gt;
  while (lines--) {&lt;br /&gt;
    stripes = (int16_t)get_le16();&lt;br /&gt;
    while (stripes &amp;amp; 0xC000) {&lt;br /&gt;
      *frame_ptr += -stripes * width;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (stripes &amp;lt; 0) {&lt;br /&gt;
      frame_ptr[width - 1] = stripes &amp;amp; 0xFF;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    line_ptr = frame_ptr;&lt;br /&gt;
    while (stripes--) {&lt;br /&gt;
      line_ptr += get_byte();&lt;br /&gt;
      count = (int8_t)get_byte();&lt;br /&gt;
      if (count &amp;gt; 0) {&lt;br /&gt;
        get_buffer(line_ptr, count * 2);&lt;br /&gt;
        line_ptr += count * 2;&lt;br /&gt;
      } else {&lt;br /&gt;
        val = get_le16();&lt;br /&gt;
        for (i = 0; i &amp;lt; -count * 2; i++) {&lt;br /&gt;
          put_le16(line_ptr, val);&lt;br /&gt;
          line_ptr += 2;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    frame_ptr += width;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== TDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First four bytes code number of segments, each segment contains number of words to skip before decoding, number of words to copy and bytes to copy.&lt;br /&gt;
&lt;br /&gt;
  segments = getdword()&lt;br /&gt;
  while(segments--)&lt;br /&gt;
  {&lt;br /&gt;
    numcopy = getbyte()&lt;br /&gt;
    numskip = getbyte()&lt;br /&gt;
    output += numskip * 2&lt;br /&gt;
    output &amp;lt;- getbytes(numcopy * 2)&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
''Can't upload a sample to mplayerhq, grab it here and reupload yourself: http://www.sendspace.com/file/a9bn4j -- [[User:VAG|VAG]] 11:01, 6 April 2013 (EDT)''&lt;br /&gt;
&lt;br /&gt;
=== DSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as TSW1 chunk with the following differences:&lt;br /&gt;
&lt;br /&gt;
* first two bytes code number of stripes&lt;br /&gt;
* if getbit() returned zero, get and test another bit. If that bit is zero too then read literal (two bytes), else read 2-byte number and skip corresponding number of pixels. And report two bits read in any case.&lt;br /&gt;
&lt;br /&gt;
=== DDS1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as DSW1 chunk but it decodes in scaled mode - every skip is twice that large, literal is used to set 2x2 block and copying also fills 2x2 block with pixel value:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2 * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
        cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
        cur_frame_pos[width] = cur_frame_pos[width + 1] = cur_frame_pos[-offset];&lt;br /&gt;
        cur_frame_pos += 2;&lt;br /&gt;
      }&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else if (!(bitbuf &amp;amp; (mask &amp;lt;&amp;lt; 1)) {&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
    } else {&lt;br /&gt;
      cur_frame_pos += get_le16() * 2;&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 2;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Games using DFI ==&lt;br /&gt;
* [http://www.mobygames.com/game/anvil-of-dawn Anvil of Dawn]&lt;br /&gt;
* [http://www.mobygames.com/game/dos/chronomaster Chronomaster]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=14560</id>
		<title>DFA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=14560"/>
		<updated>2013-04-05T23:05:31Z</updated>

		<summary type="html">&lt;p&gt;VAG: typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extensions: dfa&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/ http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/]&lt;br /&gt;
&lt;br /&gt;
DFA is a FMV format used in PC games developed by DreamForge.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
All multi-byte numbers are little endian. These files are comprised of chunks with the following format:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    chunk fourcc&lt;br /&gt;
  bytes 4-7    chunk size, not including 12-byte preamble&lt;br /&gt;
  bytes 8-11   chunk type, essentially numeric equivalent of fourcc&lt;br /&gt;
  bytes 12..   chunk payload&lt;br /&gt;
&lt;br /&gt;
A DFA file begins with a 128- (0x80-)byte header:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    file signature: 'DFIA'&lt;br /&gt;
  byte  4      version (= 0)&lt;br /&gt;
  byte  5      ? (output)&lt;br /&gt;
  bytes 6-7    number of frames&lt;br /&gt;
  bytes 8-9    frame width&lt;br /&gt;
  bytes 10-11  frame height&lt;br /&gt;
  bytes 12-15  frame rate&lt;br /&gt;
  bytes 16-19  first frame offset (= 0x80)&lt;br /&gt;
  bytes 20-23  ? (odirectory)&lt;br /&gt;
  bytes 24-127 unused&lt;br /&gt;
&lt;br /&gt;
Chunk types include:&lt;br /&gt;
&lt;br /&gt;
  EOFR (type 0)    end of frame, empty chunk&lt;br /&gt;
  PAL1 (type 1)    768-byte chunk containing a 6-bit VGA palette components&lt;br /&gt;
  COPY (type 2)    raw frame data&lt;br /&gt;
  TSW1 (type 3)    video frame, intra LZ-coded&lt;br /&gt;
  BDLT (type 4)    video frame, inter RLE-coded bytes&lt;br /&gt;
  WDLT (type 5)    video frame, inter RLE-coded words&lt;br /&gt;
  TDLT (type 6)    video frame, inter chains&lt;br /&gt;
  DSW1 (type 7)    video frame, inter LZ-coded&lt;br /&gt;
  BLCK (type 8)    solid frame, fill whole frame with the first byte of payload&lt;br /&gt;
  DDS1 (type 9)    video frame, inter LZ-coded, double-scaled&lt;br /&gt;
&lt;br /&gt;
=== TSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
First four bytes store number of stripes to change, next four bytes - offset inside frame. The rest is stripe data.&lt;br /&gt;
&lt;br /&gt;
Every stripe is coded with 16-bit LSB little-endian words in LZ77-like scheme:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else {&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== BDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to skip in frame before decoding, next two bytes code number of lines to decode.&lt;br /&gt;
&lt;br /&gt;
Every line is coded into segments, first byte of data tells how many segments are there. Every segment is coded as RLE, first byte&lt;br /&gt;
tells how many pixels to skip before decoding segment, second byte is treated as signed value with sign telling if it's copy or run:&lt;br /&gt;
&lt;br /&gt;
  while (segments--) {&lt;br /&gt;
     cur_line_ptr += get_byte();&lt;br /&gt;
     count = (int8_t)get_byte();&lt;br /&gt;
     if (count &amp;gt;= 0)&lt;br /&gt;
         get_buffer(cur_line_ptr, count);&lt;br /&gt;
     else&lt;br /&gt;
         memset(cur_line_ptr, get_byte(), -count);&lt;br /&gt;
     cur_line_ptr += abs(count);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== WDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to decode. Overall decoding is similar to BDLT chunk but with words copy instead of byte copy and different segment handling scheme:&lt;br /&gt;
&lt;br /&gt;
  while (lines--) {&lt;br /&gt;
    stripes = (int16_t)get_le16();&lt;br /&gt;
    while (stripes &amp;amp; 0xC000) {&lt;br /&gt;
      *frame_ptr += -stripes * width;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (stripes &amp;lt; 0) {&lt;br /&gt;
      frame_ptr[width - 1] = stripes &amp;amp; 0xFF;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    line_ptr = frame_ptr;&lt;br /&gt;
    while (stripes--) {&lt;br /&gt;
      line_ptr += get_byte();&lt;br /&gt;
      count = (int8_t)get_byte();&lt;br /&gt;
      if (count &amp;gt; 0) {&lt;br /&gt;
        get_buffer(line_ptr, count * 2);&lt;br /&gt;
        line_ptr += count * 2;&lt;br /&gt;
      } else {&lt;br /&gt;
        val = get_le16();&lt;br /&gt;
        for (i = 0; i &amp;lt; -count * 2; i++) {&lt;br /&gt;
          put_le16(line_ptr, val);&lt;br /&gt;
          line_ptr += 2;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    frame_ptr += width;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== TDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First four bytes code number of segments, each segment contains number of words to skip before decoding, number of words to copy and bytes to copy.&lt;br /&gt;
&lt;br /&gt;
  segments = getdword()&lt;br /&gt;
  while(segments--)&lt;br /&gt;
  {&lt;br /&gt;
    numcopy = getbyte()&lt;br /&gt;
    numskip = getbyte()&lt;br /&gt;
    output += numskip * 2&lt;br /&gt;
    output &amp;lt;- getbytes(numcopy * 2)&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== DSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as TSW1 chunk with the following differences:&lt;br /&gt;
&lt;br /&gt;
* first two bytes code number of stripes&lt;br /&gt;
* if getbit() returned zero, get and test another bit. If that bit is zero too then read literal (two bytes), else read 2-byte number and skip corresponding number of pixels. And report two bits read in any case.&lt;br /&gt;
&lt;br /&gt;
=== DDS1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as DSW1 chunk but it decodes in scaled mode - every skip is twice that large, literal is used to set 2x2 block and copying also fills 2x2 block with pixel value:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2 * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
        cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
        cur_frame_pos[width] = cur_frame_pos[width + 1] = cur_frame_pos[-offset];&lt;br /&gt;
        cur_frame_pos += 2;&lt;br /&gt;
      }&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else if (!(bitbuf &amp;amp; (mask &amp;lt;&amp;lt; 1)) {&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
    } else {&lt;br /&gt;
      cur_frame_pos += get_le16() * 2;&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 2;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Games using DFI ==&lt;br /&gt;
* [http://www.mobygames.com/game/anvil-of-dawn Anvil of Dawn]&lt;br /&gt;
* [http://www.mobygames.com/game/dos/chronomaster Chronomaster]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=14559</id>
		<title>DFA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=14559"/>
		<updated>2013-04-05T23:04:38Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* File format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extensions: dfa&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/ http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/]&lt;br /&gt;
&lt;br /&gt;
DFA is a FMV format used in PC games develped by DreamForge.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
All multi-byte numbers are little endian. These files are comprised of chunks with the following format:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    chunk fourcc&lt;br /&gt;
  bytes 4-7    chunk size, not including 12-byte preamble&lt;br /&gt;
  bytes 8-11   chunk type, essentially numeric equivalent of fourcc&lt;br /&gt;
  bytes 12..   chunk payload&lt;br /&gt;
&lt;br /&gt;
A DFA file begins with a 128- (0x80-)byte header:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    file signature: 'DFIA'&lt;br /&gt;
  byte  4      version (= 0)&lt;br /&gt;
  byte  5      ? (output)&lt;br /&gt;
  bytes 6-7    number of frames&lt;br /&gt;
  bytes 8-9    frame width&lt;br /&gt;
  bytes 10-11  frame height&lt;br /&gt;
  bytes 12-15  frame rate&lt;br /&gt;
  bytes 16-19  first frame offset (= 0x80)&lt;br /&gt;
  bytes 20-23  ? (odirectory)&lt;br /&gt;
  bytes 24-127 unused&lt;br /&gt;
&lt;br /&gt;
Chunk types include:&lt;br /&gt;
&lt;br /&gt;
  EOFR (type 0)    end of frame, empty chunk&lt;br /&gt;
  PAL1 (type 1)    768-byte chunk containing a 6-bit VGA palette components&lt;br /&gt;
  COPY (type 2)    raw frame data&lt;br /&gt;
  TSW1 (type 3)    video frame, intra LZ-coded&lt;br /&gt;
  BDLT (type 4)    video frame, inter RLE-coded bytes&lt;br /&gt;
  WDLT (type 5)    video frame, inter RLE-coded words&lt;br /&gt;
  TDLT (type 6)    video frame, inter chains&lt;br /&gt;
  DSW1 (type 7)    video frame, inter LZ-coded&lt;br /&gt;
  BLCK (type 8)    solid frame, fill whole frame with the first byte of payload&lt;br /&gt;
  DDS1 (type 9)    video frame, inter LZ-coded, double-scaled&lt;br /&gt;
&lt;br /&gt;
=== TSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
First four bytes store number of stripes to change, next four bytes - offset inside frame. The rest is stripe data.&lt;br /&gt;
&lt;br /&gt;
Every stripe is coded with 16-bit LSB little-endian words in LZ77-like scheme:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else {&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== BDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to skip in frame before decoding, next two bytes code number of lines to decode.&lt;br /&gt;
&lt;br /&gt;
Every line is coded into segments, first byte of data tells how many segments are there. Every segment is coded as RLE, first byte&lt;br /&gt;
tells how many pixels to skip before decoding segment, second byte is treated as signed value with sign telling if it's copy or run:&lt;br /&gt;
&lt;br /&gt;
  while (segments--) {&lt;br /&gt;
     cur_line_ptr += get_byte();&lt;br /&gt;
     count = (int8_t)get_byte();&lt;br /&gt;
     if (count &amp;gt;= 0)&lt;br /&gt;
         get_buffer(cur_line_ptr, count);&lt;br /&gt;
     else&lt;br /&gt;
         memset(cur_line_ptr, get_byte(), -count);&lt;br /&gt;
     cur_line_ptr += abs(count);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== WDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to decode. Overall decoding is similar to BDLT chunk but with words copy instead of byte copy and different segment handling scheme:&lt;br /&gt;
&lt;br /&gt;
  while (lines--) {&lt;br /&gt;
    stripes = (int16_t)get_le16();&lt;br /&gt;
    while (stripes &amp;amp; 0xC000) {&lt;br /&gt;
      *frame_ptr += -stripes * width;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (stripes &amp;lt; 0) {&lt;br /&gt;
      frame_ptr[width - 1] = stripes &amp;amp; 0xFF;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    line_ptr = frame_ptr;&lt;br /&gt;
    while (stripes--) {&lt;br /&gt;
      line_ptr += get_byte();&lt;br /&gt;
      count = (int8_t)get_byte();&lt;br /&gt;
      if (count &amp;gt; 0) {&lt;br /&gt;
        get_buffer(line_ptr, count * 2);&lt;br /&gt;
        line_ptr += count * 2;&lt;br /&gt;
      } else {&lt;br /&gt;
        val = get_le16();&lt;br /&gt;
        for (i = 0; i &amp;lt; -count * 2; i++) {&lt;br /&gt;
          put_le16(line_ptr, val);&lt;br /&gt;
          line_ptr += 2;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    frame_ptr += width;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== TDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First four bytes code number of segments, each segment contains number of words to skip before decoding, number of words to copy and bytes to copy.&lt;br /&gt;
&lt;br /&gt;
  segments = getdword()&lt;br /&gt;
  while(segments--)&lt;br /&gt;
  {&lt;br /&gt;
    numcopy = getbyte()&lt;br /&gt;
    numskip = getbyte()&lt;br /&gt;
    output += numskip * 2&lt;br /&gt;
    output &amp;lt;- getbytes(numcopy * 2)&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== DSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as TSW1 chunk with the following differences:&lt;br /&gt;
&lt;br /&gt;
* first two bytes code number of stripes&lt;br /&gt;
* if getbit() returned zero, get and test another bit. If that bit is zero too then read literal (two bytes), else read 2-byte number and skip corresponding number of pixels. And report two bits read in any case.&lt;br /&gt;
&lt;br /&gt;
=== DDS1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as DSW1 chunk but it decodes in scaled mode - every skip is twice that large, literal is used to set 2x2 block and copying also fills 2x2 block with pixel value:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2 * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
        cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
        cur_frame_pos[width] = cur_frame_pos[width + 1] = cur_frame_pos[-offset];&lt;br /&gt;
        cur_frame_pos += 2;&lt;br /&gt;
      }&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else if (!(bitbuf &amp;amp; (mask &amp;lt;&amp;lt; 1)) {&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
    } else {&lt;br /&gt;
      cur_frame_pos += get_le16() * 2;&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 2;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Games using DFI ==&lt;br /&gt;
* [http://www.mobygames.com/game/anvil-of-dawn Anvil of Dawn]&lt;br /&gt;
* [http://www.mobygames.com/game/dos/chronomaster Chronomaster]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=14558</id>
		<title>DFA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=14558"/>
		<updated>2013-04-05T23:01:26Z</updated>

		<summary type="html">&lt;p&gt;VAG: name chunk #6, fix algo, add game&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extensions: dfa&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/ http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/]&lt;br /&gt;
&lt;br /&gt;
DFA is a FMV format used in PC games develped by DreamForge.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
All multi-byte numbers are little endian. These files are comprised of chunks with the following format:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    chunk fourcc&lt;br /&gt;
  bytes 4-7    chunk size, not including 12-byte preamble&lt;br /&gt;
  bytes 8-11   chunk type, essentially numeric equivalent of fourcc&lt;br /&gt;
  bytes 12..   chunk payload&lt;br /&gt;
&lt;br /&gt;
A DFA file begins with a 128- (0x80-)byte header:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    file signature: 'DFIA'&lt;br /&gt;
  byte  4      version (= 0)&lt;br /&gt;
  byte  5      ? (output)&lt;br /&gt;
  bytes 6-7    number of frames&lt;br /&gt;
  bytes 8-9    frame width&lt;br /&gt;
  bytes 10-11  frame height&lt;br /&gt;
  bytes 12-15  frame rate&lt;br /&gt;
  bytes 16-19  first frame offset (= 0x80)&lt;br /&gt;
  bytes 20-23  ? (odirectory)&lt;br /&gt;
  bytes 24-127 unused&lt;br /&gt;
&lt;br /&gt;
Chunk types include:&lt;br /&gt;
&lt;br /&gt;
  EOFR (type 0)    end of frame, empty chunk&lt;br /&gt;
  PAL1 (type 1)    768-byte chunk containing a 6-bit VGA palette components&lt;br /&gt;
  COPY (type 2)    raw frame data&lt;br /&gt;
  TSW1 (type 3)    video frame, intra LZ-coded&lt;br /&gt;
  BDLT (type 4)    video frame, inter RLE-coded bytes&lt;br /&gt;
  WDLT (type 5)    video frame, inter RLE-coded words&lt;br /&gt;
  TDLT (type 6)    not occured in known samples&lt;br /&gt;
  DSW1 (type 7)    video frame, inter LZ-coded&lt;br /&gt;
  BLCK (type 8)    solid frame, fill whole frame with the first byte of payload&lt;br /&gt;
  DDS1 (type 9)    video frame, inter LZ-coded, double-scaled&lt;br /&gt;
&lt;br /&gt;
=== TSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
First four bytes store number of stripes to change, next four bytes - offset inside frame. The rest is stripe data.&lt;br /&gt;
&lt;br /&gt;
Every stripe is coded with 16-bit LSB little-endian words in LZ77-like scheme:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else {&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== BDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to skip in frame before decoding, next two bytes code number of lines to decode.&lt;br /&gt;
&lt;br /&gt;
Every line is coded into segments, first byte of data tells how many segments are there. Every segment is coded as RLE, first byte&lt;br /&gt;
tells how many pixels to skip before decoding segment, second byte is treated as signed value with sign telling if it's copy or run:&lt;br /&gt;
&lt;br /&gt;
  while (segments--) {&lt;br /&gt;
     cur_line_ptr += get_byte();&lt;br /&gt;
     count = (int8_t)get_byte();&lt;br /&gt;
     if (count &amp;gt;= 0)&lt;br /&gt;
         get_buffer(cur_line_ptr, count);&lt;br /&gt;
     else&lt;br /&gt;
         memset(cur_line_ptr, get_byte(), -count);&lt;br /&gt;
     cur_line_ptr += abs(count);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== WDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to decode. Overall decoding is similar to BDLT chunk but with words copy instead of byte copy and different segment handling scheme:&lt;br /&gt;
&lt;br /&gt;
  while (lines--) {&lt;br /&gt;
    stripes = (int16_t)get_le16();&lt;br /&gt;
    while (stripes &amp;amp; 0xC000) {&lt;br /&gt;
      *frame_ptr += -stripes * width;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (stripes &amp;lt; 0) {&lt;br /&gt;
      frame_ptr[width - 1] = stripes &amp;amp; 0xFF;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    line_ptr = frame_ptr;&lt;br /&gt;
    while (stripes--) {&lt;br /&gt;
      line_ptr += get_byte();&lt;br /&gt;
      count = (int8_t)get_byte();&lt;br /&gt;
      if (count &amp;gt; 0) {&lt;br /&gt;
        get_buffer(line_ptr, count * 2);&lt;br /&gt;
        line_ptr += count * 2;&lt;br /&gt;
      } else {&lt;br /&gt;
        val = get_le16();&lt;br /&gt;
        for (i = 0; i &amp;lt; -count * 2; i++) {&lt;br /&gt;
          put_le16(line_ptr, val);&lt;br /&gt;
          line_ptr += 2;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    frame_ptr += width;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== TDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First four bytes code number of segments, each segment contains number of words to skip before decoding, number of words to copy and bytes to copy.&lt;br /&gt;
&lt;br /&gt;
  segments = getdword()&lt;br /&gt;
  while(segments--)&lt;br /&gt;
  {&lt;br /&gt;
    numcopy = getbyte()&lt;br /&gt;
    numskip = getbyte()&lt;br /&gt;
    output += numskip * 2&lt;br /&gt;
    output &amp;lt;- getbytes(numcopy * 2)&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== DSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as TSW1 chunk with the following differences:&lt;br /&gt;
&lt;br /&gt;
* first two bytes code number of stripes&lt;br /&gt;
* if getbit() returned zero, get and test another bit. If that bit is zero too then read literal (two bytes), else read 2-byte number and skip corresponding number of pixels. And report two bits read in any case.&lt;br /&gt;
&lt;br /&gt;
=== DDS1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as DSW1 chunk but it decodes in scaled mode - every skip is twice that large, literal is used to set 2x2 block and copying also fills 2x2 block with pixel value:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2 * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
        cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
        cur_frame_pos[width] = cur_frame_pos[width + 1] = cur_frame_pos[-offset];&lt;br /&gt;
        cur_frame_pos += 2;&lt;br /&gt;
      }&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else if (!(bitbuf &amp;amp; (mask &amp;lt;&amp;lt; 1)) {&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
    } else {&lt;br /&gt;
      cur_frame_pos += get_le16() * 2;&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 2;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Games using DFI ==&lt;br /&gt;
* [http://www.mobygames.com/game/anvil-of-dawn Anvil of Dawn]&lt;br /&gt;
* [http://www.mobygames.com/game/dos/chronomaster Chronomaster]&lt;br /&gt;
 &lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Bink_Video_2&amp;diff=14228</id>
		<title>Bink Video 2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Bink_Video_2&amp;diff=14228"/>
		<updated>2012-11-17T14:19:01Z</updated>

		<summary type="html">&lt;p&gt;VAG: it's missing, obviously&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* FourCC: KB2d (in [[Bink Container]])&lt;br /&gt;
* Company: [[RAD Game Tools]]&lt;br /&gt;
* Samples: ''ADD ME''&lt;br /&gt;
&lt;br /&gt;
Bink Video 2 is a successor to [[Bink Video]].&lt;br /&gt;
&lt;br /&gt;
(De)Compression details are presently unknown.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Bink_Video_2&amp;diff=14227</id>
		<title>Bink Video 2</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Bink_Video_2&amp;diff=14227"/>
		<updated>2012-11-17T14:15:52Z</updated>

		<summary type="html">&lt;p&gt;VAG: basic info&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* FourCC: KB2d (in [[Bink Container]])&lt;br /&gt;
* Company: [[RAD Game Tools]]&lt;br /&gt;
* Samples: ''ADD ME''&lt;br /&gt;
&lt;br /&gt;
Bink Video 2 is a successor to [[Bink Video]].&lt;br /&gt;
&lt;br /&gt;
(De)Compression details are presently unknown.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM4&amp;diff=14182</id>
		<title>HNM4</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM4&amp;diff=14182"/>
		<updated>2012-10-13T15:00:06Z</updated>

		<summary type="html">&lt;p&gt;VAG: more cats&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm&lt;br /&gt;
* Company: [[CRYO Interactive Entertainment]]&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/game-formats/hnm/losteden-hnm4/&lt;br /&gt;
&lt;br /&gt;
HNM4 is the third generation of the Cryo HNM video format. At least two decoder-incompatible variation of this format is known. Main version, operates in 320x200x256 resolution and simplified 640x480x256 spin-off, used in ALIENS game. Both formats share same container structure.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File header:&lt;br /&gt;
  dword signature     - file signature, &amp;quot;HNM4&amp;quot;&lt;br /&gt;
  dword unknown1      - probably format version&lt;br /&gt;
  word  width         - width of the frame&lt;br /&gt;
  word  height        - height of the frame&lt;br /&gt;
  dword filesize      - size of the entrie hnm file&lt;br /&gt;
  dword frames        - number of frames&lt;br /&gt;
  dword taboffset     - offset of the TAB chunk&lt;br /&gt;
  word  bits          - sound sample resolution&lt;br /&gt;
  word  channels      - number of sound channels&lt;br /&gt;
  dword framesize     - frame allocation size (width * height)&lt;br /&gt;
  byte  unknown2[16]  - seems to be unused&lt;br /&gt;
  byte  copyright[16] - &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The rest of the file organized on manner similar to [[HNM (1)]] format. All single-frame related chunks combined to superchunks, where each superchunk starts with 32-bit value, lower 24 bits of it indicates superchunk size and highest 8 bits - flags (unknown). Each chunk starts with another 24+8 bits length header followed by 4 bytes of chunk ID (where only 2 bytes can be actually used), and chunk data. Near the end of file usually TAB chunk located, it doesn't have an upper-level superchunk.&lt;br /&gt;
&lt;br /&gt;
=== PL Chunk ===&lt;br /&gt;
Palette. Stored in same format as used in [[HNM (1)]].&lt;br /&gt;
* ALIENS: However, non-zero bit 23 of ChunkId indicates that palette stored in complete 8-bits-per-component format, unlike regular 6-bits otherwise.&lt;br /&gt;
&lt;br /&gt;
=== IZ Chunk ===&lt;br /&gt;
Keyframe. See video decompression below.&lt;br /&gt;
&lt;br /&gt;
=== IU Chunk ===&lt;br /&gt;
Interframe. See video decompression below.&lt;br /&gt;
&lt;br /&gt;
=== SD Chunk ===&lt;br /&gt;
Sound data. [[PCM#Differential_PCM|DPCM]]-encoded sound fragment.&lt;br /&gt;
&lt;br /&gt;
== Decoding Video ==&lt;br /&gt;
=== Intraframes ===&lt;br /&gt;
Intraframe decompression is simialar to [[HNM (1)]] 0xFE frames. But with a few changes. Chunk data starts with small 4-bytes header:&lt;br /&gt;
  word width  - width of the frame&lt;br /&gt;
  byte height - height of the frame (only lower byte of it)&lt;br /&gt;
  byte mode   - rendering mode (always 0xFE ?)&lt;br /&gt;
&lt;br /&gt;
Then immediately followed by LZ-packed raster (without 6-byte compression header as was used before). LZ decompression algorithm remains the same, but bitreader use 32-bits queue and processing bits from highest to lowest.&lt;br /&gt;
&lt;br /&gt;
* You can safely ignore width/height/mode fields of the frame header as original decoder always renders whole frame regardless specified values.&lt;br /&gt;
&lt;br /&gt;
=== Interframes ===&lt;br /&gt;
==== HNM4 Interframe ====&lt;br /&gt;
Packed interframe consist of one or more compression codes. Depending on the code's count field following cases possible:&lt;br /&gt;
&lt;br /&gt;
  bits&lt;br /&gt;
    0..4 : count = 0&lt;br /&gt;
    5..7 : tag:&lt;br /&gt;
            0: copy next two bytes of input to the output&lt;br /&gt;
            1: skip (next byte of input) * 2 bytes of output&lt;br /&gt;
            2: skip (next word of input) * 2 bytes of output&lt;br /&gt;
            3: fill (next byte of input) * 2 of output with (next byte of input)&lt;br /&gt;
         else: finish the unpacking&lt;br /&gt;
 &lt;br /&gt;
   - or -&lt;br /&gt;
 &lt;br /&gt;
    0..4 : count &amp;lt;&amp;gt; 0&lt;br /&gt;
       5 : previous&lt;br /&gt;
       6 : backline&lt;br /&gt;
       7 : backward&lt;br /&gt;
       8 : swap&lt;br /&gt;
   9..23 : offset&lt;br /&gt;
&lt;br /&gt;
In this case for (count) pixel pairs, copy them from the (output + offset * 2 - 32768) of the current frame to the output. Flag bits modify various parameters of this scheme (multiple flags can be used):&lt;br /&gt;
* previous - copy pairs from the previous frame&lt;br /&gt;
* backline - first pixel located 2 lines above + (swap)&lt;br /&gt;
* backward - advance source pixel pairs in backward order&lt;br /&gt;
* swap     - swap pair's pixels&lt;br /&gt;
&lt;br /&gt;
==== HNM4A Interframe ====&lt;br /&gt;
HNM4A interframe is a simplified version of the HNM4 interframe. Code format:&lt;br /&gt;
  bits&lt;br /&gt;
    0..5 : count = 0&lt;br /&gt;
    6..7 : tag:&lt;br /&gt;
            0: skip (next byte of input) bytes of output&lt;br /&gt;
            1: draw 1x2 column of the output with next 2 bytes of input&lt;br /&gt;
            2: advance to the next line of output (but keep current x position)&lt;br /&gt;
            3: finish the unpacking&lt;br /&gt;
 &lt;br /&gt;
   - or -&lt;br /&gt;
 &lt;br /&gt;
    0..5 : count &amp;lt;&amp;gt; 0&lt;br /&gt;
       6 : previous&lt;br /&gt;
       7 : delta&lt;br /&gt;
   8..23 : offset&lt;br /&gt;
&lt;br /&gt;
For (count) 1x2 columns copy them from the (output + offset) to the output.&lt;br /&gt;
* previous - copy column from the previous frame&lt;br /&gt;
* delta    - copy column from (output + offset - 65536)&lt;br /&gt;
&lt;br /&gt;
=== Postprocessing ===&lt;br /&gt;
For HNM4 (but not HNM4A movies) you need to perform extra frame postprocessing by swapping pixels using following self-explaining example (assuming 4xN image):&lt;br /&gt;
&lt;br /&gt;
  Just unpacked frame       Final frame&lt;br /&gt;
      p0 p1 p2 p3    ==&amp;gt;    p0 p2 p4 p6&lt;br /&gt;
      p4 p5 p6 p7           p1 p3 p5 p7&lt;br /&gt;
          ...                   ...&lt;br /&gt;
&lt;br /&gt;
== Decoding Audio ==&lt;br /&gt;
'''TODO'''&lt;br /&gt;
&lt;br /&gt;
== Games Using HNM4 ==&lt;br /&gt;
* Lost Eden&lt;br /&gt;
* Hardline&lt;br /&gt;
* Aliens&lt;br /&gt;
* Dragon Lore&lt;br /&gt;
* Dragon Lore II&lt;br /&gt;
* Treasure Hunter&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14181</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14181"/>
		<updated>2012-10-13T14:55:27Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* Normal decoding */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative), bits meaning:&lt;br /&gt;
                             7 : stereo&lt;br /&gt;
                          6..5 : frequency in units of 11025Hz (i.e. frequency = value * 11025)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  frames2          -- upper part of frame counter, ignored by some implementations&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Audio chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller blocks. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games circa 1997.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets are little-endian and relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
=== Key-blocks decoding ===&lt;br /&gt;
Key-blocks are JPEG-encoded blocks in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,1,8,16,9,...) and quantization tables (16,11,10,16, 24,...; 17,18,24,47,99,...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's complement value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's complement value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, the first coefficient is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of a plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
=== WARP decoding ===&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x4 &lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 11 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 10 || 0&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 0 || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Keyblock is a JPEG-encoded macroblock.&lt;br /&gt;
* CrossCut means that the current block should be cut on to 4 smaller subblocks and each one processed independently, using the same scheme recursively.&lt;br /&gt;
* Motion means that the block is motion-coded and should be copied from some other part of the frame. To do so, read the next entry of the motion buffer and process it as follows:&lt;br /&gt;
** transformation mode = next 2 bits from bitbuffer (upper part) combined with bit 15 of motion (lower bit)&lt;br /&gt;
** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
** ymotion = (if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
* 2x2 blocks are always short motion coded, using no extra VLC:&lt;br /&gt;
** transformation mode = bits 1..3 of short motion&lt;br /&gt;
** motion index = bit 0 || bits 4..7 || bits 8..11 (total 9 bits)&lt;br /&gt;
** decode the index as follows:&lt;br /&gt;
 if index &amp;lt; 12 * 8&lt;br /&gt;
   xmotion = -2 - index % 12&lt;br /&gt;
   ymotion =  6 - index / 12&lt;br /&gt;
 else&lt;br /&gt;
   index -= 12 * 8&lt;br /&gt;
   xmotion = 19 - index % 32&lt;br /&gt;
   ymotion = -2 - index / 32&lt;br /&gt;
   if ymotion &amp;lt;= -8&lt;br /&gt;
    ymotion = ymotion - 1&lt;br /&gt;
&lt;br /&gt;
Block's source coordinates are the sum of current 8x8 macroblock's coordinates (not its subblock's!) and the xmotion and ymotion respectively. If x-coordinate happens to go out of frame, it should be wrapped around the line. Copy block at the following coordinates to the current, applying the transformation as specified.&lt;br /&gt;
&lt;br /&gt;
=== Normal decoding ===&lt;br /&gt;
Normal compression introduces interframes, more split modes and different short motion encoding.&lt;br /&gt;
&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x8 !! 8x4 !! 4x4 !! 2x4 !! 4x2 !! 2x2&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Keyframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 110 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 00 || 0 || n/a || 01 || 1 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 01 || n/a || 0 || 10 || n/a || 1 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 10 || n/a || n/a || 11 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 111 || 1 || 1 || 00 || 0 || 0  || n/a&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Interframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 011 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 100 || 10 || n/a || 101 || 111 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 101 || n/a || 10 || 110 || n/a || 111 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 1110 || n/a || n/a || 111 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Skip || 110 || 11 || 11 || 100 || 110 || 110 || 11&lt;br /&gt;
|-&lt;br /&gt;
| ShortMotion || 00 || 00 || 00 || 00 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 010 || 01 || 01 || 01 || 10 || 10 || 10&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* HorizontalCut splits the block horizontally, producing two subblocks of smaller height. Each one then processed recursively.&lt;br /&gt;
* VerticalCut is identical to HorizontalCut, but splits the block vertically.&lt;br /&gt;
* Skip simply copies the block from the previous frame.&lt;br /&gt;
* ShortMotion copies block from previous frame, using the spiral-encoded motion. Unlike regular motion, short motion is relative to subblock's coordinates, not the whole macroblock. Read ShortMotion index, then obtain block's relative coordinates as per illustration:&lt;br /&gt;
[[Image:HNM6Spiral.png]]&lt;br /&gt;
* Motion blocks are similar to WARP motion block, with minor enhancements:&lt;br /&gt;
** For keyframe motion is the same as for WARP, with the exception for blocks smaller than 4x4. For such blocks:&lt;br /&gt;
*** transformation mode = bits 12.14 of motion&lt;br /&gt;
*** xmotion = 63 - (bits 0..6 of motion)&lt;br /&gt;
*** ymotion = 6 - (bits 7..11 of motion)&lt;br /&gt;
** Keyframe's 2x2 blocks are always motion-coded as above.&lt;br /&gt;
&lt;br /&gt;
** For interframe motion is different. For blocks 4x4 and larger:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
*** ymotion = (if from previous frame then 64, otherwise if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
** For blocks smaller than 4x4:&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** if from current frame - same as for keyframe, see above. for previous frame:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** xmotion = 31 - (bits 0..5 of motion)&lt;br /&gt;
*** ymotion = 31 - (bits 6..11 of motion)&lt;br /&gt;
** Don't forget to wrap x motion around the line if it goes out of frame.&lt;br /&gt;
&lt;br /&gt;
=== Block transformation ===&lt;br /&gt;
During block copying, it can be additionally transformed. Transformation modes:&lt;br /&gt;
==== 0 - Normal copy ====&lt;br /&gt;
Copy block as is.&lt;br /&gt;
==== 1 - Horizontal flip ====&lt;br /&gt;
Swap left and right:&lt;br /&gt;
 abc -&amp;gt; cba&lt;br /&gt;
==== 2 -  Vertical flip ====&lt;br /&gt;
Swap up and down:&lt;br /&gt;
 a    c&lt;br /&gt;
 b -&amp;gt; b&lt;br /&gt;
 c    a&lt;br /&gt;
==== 3 - Cross flip ====&lt;br /&gt;
Swap both up-down and left-right:&lt;br /&gt;
 ab    fe&lt;br /&gt;
 cd -&amp;gt; dc&lt;br /&gt;
 ef    ba&lt;br /&gt;
==== 4 - Forward flip ====&lt;br /&gt;
Swap block around / :&lt;br /&gt;
 ab -&amp;gt; db &lt;br /&gt;
 cd    ca&lt;br /&gt;
==== 5 - Forward rotate ====&lt;br /&gt;
Rotate block 90 degrees clockwise:&lt;br /&gt;
 ab    eca    fe&lt;br /&gt;
 cd -&amp;gt; fdb -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 6 - Backward rotate ====&lt;br /&gt;
Rotate block 90 degrees counterclockwise:&lt;br /&gt;
 ab    bdf    fe&lt;br /&gt;
 cd -&amp;gt; ace -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 7 - Backward flip ====&lt;br /&gt;
Swap block around \ :&lt;br /&gt;
 ab -&amp;gt; ac&lt;br /&gt;
 cd    bd&lt;br /&gt;
&lt;br /&gt;
=== Bitexact decoding ===&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14180</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14180"/>
		<updated>2012-10-13T14:53:25Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* Format modifications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative), bits meaning:&lt;br /&gt;
                             7 : stereo&lt;br /&gt;
                          6..5 : frequency in units of 11025Hz (i.e. frequency = value * 11025)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  frames2          -- upper part of frame counter, ignored by some implementations&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Audio chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller blocks. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games circa 1997.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets are little-endian and relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
=== Key-blocks decoding ===&lt;br /&gt;
Key-blocks are JPEG-encoded blocks in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,1,8,16,9,...) and quantization tables (16,11,10,16, 24,...; 17,18,24,47,99,...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's complement value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's complement value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, the first coefficient is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of a plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
=== WARP decoding ===&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x4 &lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 11 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 10 || 0&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 0 || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Keyblock is a JPEG-encoded macroblock.&lt;br /&gt;
* CrossCut means that the current block should be cut on to 4 smaller subblocks and each one processed independently, using the same scheme recursively.&lt;br /&gt;
* Motion means that the block is motion-coded and should be copied from some other part of the frame. To do so, read the next entry of the motion buffer and process it as follows:&lt;br /&gt;
** transformation mode = next 2 bits from bitbuffer (upper part) combined with bit 15 of motion (lower bit)&lt;br /&gt;
** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
** ymotion = (if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
* 2x2 blocks are always short motion coded, using no extra VLC:&lt;br /&gt;
** transformation mode = bits 1..3 of short motion&lt;br /&gt;
** motion index = bit 0 || bits 4..7 || bits 8..11 (total 9 bits)&lt;br /&gt;
** decode the index as follows:&lt;br /&gt;
 if index &amp;lt; 12 * 8&lt;br /&gt;
   xmotion = -2 - index % 12&lt;br /&gt;
   ymotion =  6 - index / 12&lt;br /&gt;
 else&lt;br /&gt;
   index -= 12 * 8&lt;br /&gt;
   xmotion = 19 - index % 32&lt;br /&gt;
   ymotion = -2 - index / 32&lt;br /&gt;
   if ymotion &amp;lt;= -8&lt;br /&gt;
    ymotion = ymotion - 1&lt;br /&gt;
&lt;br /&gt;
Block's source coordinates are the sum of current 8x8 macroblock's coordinates (not its subblock's!) and the xmotion and ymotion respectively. If x-coordinate happens to go out of frame, it should be wrapped around the line. Copy block at the following coordinates to the current, applying the transformation as specified.&lt;br /&gt;
&lt;br /&gt;
=== Normal decoding ===&lt;br /&gt;
Normal compression introduces interframes, more split modes and different short motion encoding.&lt;br /&gt;
&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x8 !! 8x4 !! 4x4 !! 2x4 !! 4x2 !! 2x2&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Keyframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 110 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 00 || 0 || n/a || 01 || 1 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 01 || n/a || 0 || 10 || n/a || 1 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 10 || n/a || n/a || 11 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 111 || 1 || 1 || 00 || 0 || 0  || n/a&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Interframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 011 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 100 || 10 || n/a || 101 || 111 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 101 || n/a || 10 || 110 || n/a || 111 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 1110 || n/a || n/a || 111 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Skip || 110 || 11 || 11 || 100 || 110 || 110 || 11&lt;br /&gt;
|-&lt;br /&gt;
| ShortMotion || 00 || 00 || 00 || 00 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 010 || 01 || 01 || 01 || 10 || 10 || 10&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* HorizontalCut splits the block horizontally, producing two subblocks of smaller height. Each one then processed recursively.&lt;br /&gt;
* VerticalCut is identical to HorizontalCut, but splits the block vertically.&lt;br /&gt;
* Skip simply copies the block from the previous frame.&lt;br /&gt;
* ShortMotion copies block from previous frame, using the spiral-encoded motion. Unlike regular motion, short motion is relative to subblock's coordinates, not the whole macroblock. Read ShortMotion index, then obtain block's relative coordinates as per illustration:&lt;br /&gt;
[[Image:HNM6Spiral.png]]&lt;br /&gt;
* Motion blocks are similar to WARP motion block, with minor enhancements:&lt;br /&gt;
** For keyframe motion is the same as for WRAP, with the exception for blocks smaller than 4x4. For such blocks:&lt;br /&gt;
*** transformation mode = bits 12.14 of motion&lt;br /&gt;
*** xmotion = 63 - (bits 0..6 of motion)&lt;br /&gt;
*** ymotion = 6 - (bits 7..11 of motion)&lt;br /&gt;
** Keyframe's 2x2 blocks are always motion-coded as above.&lt;br /&gt;
&lt;br /&gt;
** For interframe motion is different. For blocks 4x4 and larger:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
*** ymotion = (if from previous frame then 64, otherwise if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
** For blocks smaller than 4x4:&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** if from current frame - same as for keyframe, see above. for previous frame:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** xmotion = 31 - (bits 0..5 of motion)&lt;br /&gt;
*** ymotion = 31 - (bits 6..11 of motion)&lt;br /&gt;
** Don't forget to wrap x motion around the line if it goes out of frame.&lt;br /&gt;
&lt;br /&gt;
=== Block transformation ===&lt;br /&gt;
During block copying, it can be additionally transformed. Transformation modes:&lt;br /&gt;
==== 0 - Normal copy ====&lt;br /&gt;
Copy block as is.&lt;br /&gt;
==== 1 - Horizontal flip ====&lt;br /&gt;
Swap left and right:&lt;br /&gt;
 abc -&amp;gt; cba&lt;br /&gt;
==== 2 -  Vertical flip ====&lt;br /&gt;
Swap up and down:&lt;br /&gt;
 a    c&lt;br /&gt;
 b -&amp;gt; b&lt;br /&gt;
 c    a&lt;br /&gt;
==== 3 - Cross flip ====&lt;br /&gt;
Swap both up-down and left-right:&lt;br /&gt;
 ab    fe&lt;br /&gt;
 cd -&amp;gt; dc&lt;br /&gt;
 ef    ba&lt;br /&gt;
==== 4 - Forward flip ====&lt;br /&gt;
Swap block around / :&lt;br /&gt;
 ab -&amp;gt; db &lt;br /&gt;
 cd    ca&lt;br /&gt;
==== 5 - Forward rotate ====&lt;br /&gt;
Rotate block 90 degrees clockwise:&lt;br /&gt;
 ab    eca    fe&lt;br /&gt;
 cd -&amp;gt; fdb -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 6 - Backward rotate ====&lt;br /&gt;
Rotate block 90 degrees counterclockwise:&lt;br /&gt;
 ab    bdf    fe&lt;br /&gt;
 cd -&amp;gt; ace -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 7 - Backward flip ====&lt;br /&gt;
Swap block around \ :&lt;br /&gt;
 ab -&amp;gt; ac&lt;br /&gt;
 cd    bd&lt;br /&gt;
&lt;br /&gt;
=== Bitexact decoding ===&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14179</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14179"/>
		<updated>2012-10-13T14:52:22Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* File Format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative), bits meaning:&lt;br /&gt;
                             7 : stereo&lt;br /&gt;
                          6..5 : frequency in units of 11025Hz (i.e. frequency = value * 11025)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  frames2          -- upper part of frame counter, ignored by some implementations&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller blocks. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games circa 1997.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets are little-endian and relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
=== Key-blocks decoding ===&lt;br /&gt;
Key-blocks are JPEG-encoded blocks in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,1,8,16,9,...) and quantization tables (16,11,10,16, 24,...; 17,18,24,47,99,...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's complement value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's complement value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, the first coefficient is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of a plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
=== WARP decoding ===&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x4 &lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 11 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 10 || 0&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 0 || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Keyblock is a JPEG-encoded macroblock.&lt;br /&gt;
* CrossCut means that the current block should be cut on to 4 smaller subblocks and each one processed independently, using the same scheme recursively.&lt;br /&gt;
* Motion means that the block is motion-coded and should be copied from some other part of the frame. To do so, read the next entry of the motion buffer and process it as follows:&lt;br /&gt;
** transformation mode = next 2 bits from bitbuffer (upper part) combined with bit 15 of motion (lower bit)&lt;br /&gt;
** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
** ymotion = (if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
* 2x2 blocks are always short motion coded, using no extra VLC:&lt;br /&gt;
** transformation mode = bits 1..3 of short motion&lt;br /&gt;
** motion index = bit 0 || bits 4..7 || bits 8..11 (total 9 bits)&lt;br /&gt;
** decode the index as follows:&lt;br /&gt;
 if index &amp;lt; 12 * 8&lt;br /&gt;
   xmotion = -2 - index % 12&lt;br /&gt;
   ymotion =  6 - index / 12&lt;br /&gt;
 else&lt;br /&gt;
   index -= 12 * 8&lt;br /&gt;
   xmotion = 19 - index % 32&lt;br /&gt;
   ymotion = -2 - index / 32&lt;br /&gt;
   if ymotion &amp;lt;= -8&lt;br /&gt;
    ymotion = ymotion - 1&lt;br /&gt;
&lt;br /&gt;
Block's source coordinates are the sum of current 8x8 macroblock's coordinates (not its subblock's!) and the xmotion and ymotion respectively. If x-coordinate happens to go out of frame, it should be wrapped around the line. Copy block at the following coordinates to the current, applying the transformation as specified.&lt;br /&gt;
&lt;br /&gt;
=== Normal decoding ===&lt;br /&gt;
Normal compression introduces interframes, more split modes and different short motion encoding.&lt;br /&gt;
&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x8 !! 8x4 !! 4x4 !! 2x4 !! 4x2 !! 2x2&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Keyframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 110 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 00 || 0 || n/a || 01 || 1 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 01 || n/a || 0 || 10 || n/a || 1 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 10 || n/a || n/a || 11 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 111 || 1 || 1 || 00 || 0 || 0  || n/a&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Interframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 011 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 100 || 10 || n/a || 101 || 111 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 101 || n/a || 10 || 110 || n/a || 111 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 1110 || n/a || n/a || 111 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Skip || 110 || 11 || 11 || 100 || 110 || 110 || 11&lt;br /&gt;
|-&lt;br /&gt;
| ShortMotion || 00 || 00 || 00 || 00 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 010 || 01 || 01 || 01 || 10 || 10 || 10&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* HorizontalCut splits the block horizontally, producing two subblocks of smaller height. Each one then processed recursively.&lt;br /&gt;
* VerticalCut is identical to HorizontalCut, but splits the block vertically.&lt;br /&gt;
* Skip simply copies the block from the previous frame.&lt;br /&gt;
* ShortMotion copies block from previous frame, using the spiral-encoded motion. Unlike regular motion, short motion is relative to subblock's coordinates, not the whole macroblock. Read ShortMotion index, then obtain block's relative coordinates as per illustration:&lt;br /&gt;
[[Image:HNM6Spiral.png]]&lt;br /&gt;
* Motion blocks are similar to WARP motion block, with minor enhancements:&lt;br /&gt;
** For keyframe motion is the same as for WRAP, with the exception for blocks smaller than 4x4. For such blocks:&lt;br /&gt;
*** transformation mode = bits 12.14 of motion&lt;br /&gt;
*** xmotion = 63 - (bits 0..6 of motion)&lt;br /&gt;
*** ymotion = 6 - (bits 7..11 of motion)&lt;br /&gt;
** Keyframe's 2x2 blocks are always motion-coded as above.&lt;br /&gt;
&lt;br /&gt;
** For interframe motion is different. For blocks 4x4 and larger:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
*** ymotion = (if from previous frame then 64, otherwise if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
** For blocks smaller than 4x4:&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** if from current frame - same as for keyframe, see above. for previous frame:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** xmotion = 31 - (bits 0..5 of motion)&lt;br /&gt;
*** ymotion = 31 - (bits 6..11 of motion)&lt;br /&gt;
** Don't forget to wrap x motion around the line if it goes out of frame.&lt;br /&gt;
&lt;br /&gt;
=== Block transformation ===&lt;br /&gt;
During block copying, it can be additionally transformed. Transformation modes:&lt;br /&gt;
==== 0 - Normal copy ====&lt;br /&gt;
Copy block as is.&lt;br /&gt;
==== 1 - Horizontal flip ====&lt;br /&gt;
Swap left and right:&lt;br /&gt;
 abc -&amp;gt; cba&lt;br /&gt;
==== 2 -  Vertical flip ====&lt;br /&gt;
Swap up and down:&lt;br /&gt;
 a    c&lt;br /&gt;
 b -&amp;gt; b&lt;br /&gt;
 c    a&lt;br /&gt;
==== 3 - Cross flip ====&lt;br /&gt;
Swap both up-down and left-right:&lt;br /&gt;
 ab    fe&lt;br /&gt;
 cd -&amp;gt; dc&lt;br /&gt;
 ef    ba&lt;br /&gt;
==== 4 - Forward flip ====&lt;br /&gt;
Swap block around / :&lt;br /&gt;
 ab -&amp;gt; db &lt;br /&gt;
 cd    ca&lt;br /&gt;
==== 5 - Forward rotate ====&lt;br /&gt;
Rotate block 90 degrees clockwise:&lt;br /&gt;
 ab    eca    fe&lt;br /&gt;
 cd -&amp;gt; fdb -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 6 - Backward rotate ====&lt;br /&gt;
Rotate block 90 degrees counterclockwise:&lt;br /&gt;
 ab    bdf    fe&lt;br /&gt;
 cd -&amp;gt; ace -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 7 - Backward flip ====&lt;br /&gt;
Swap block around \ :&lt;br /&gt;
 ab -&amp;gt; ac&lt;br /&gt;
 cd    bd&lt;br /&gt;
&lt;br /&gt;
=== Bitexact decoding ===&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14178</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14178"/>
		<updated>2012-10-13T14:52:00Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* File Format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative), bits meaning:&lt;br /&gt;
                             7 : stereo&lt;br /&gt;
                          6..5 : frequency in units of 11025 (i.e. frequency = value * 11025)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  frames2          -- upper part of frame counter, ignored by some implementations&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller blocks. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games circa 1997.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets are little-endian and relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
=== Key-blocks decoding ===&lt;br /&gt;
Key-blocks are JPEG-encoded blocks in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,1,8,16,9,...) and quantization tables (16,11,10,16, 24,...; 17,18,24,47,99,...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's complement value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's complement value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, the first coefficient is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of a plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
=== WARP decoding ===&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x4 &lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 11 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 10 || 0&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 0 || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Keyblock is a JPEG-encoded macroblock.&lt;br /&gt;
* CrossCut means that the current block should be cut on to 4 smaller subblocks and each one processed independently, using the same scheme recursively.&lt;br /&gt;
* Motion means that the block is motion-coded and should be copied from some other part of the frame. To do so, read the next entry of the motion buffer and process it as follows:&lt;br /&gt;
** transformation mode = next 2 bits from bitbuffer (upper part) combined with bit 15 of motion (lower bit)&lt;br /&gt;
** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
** ymotion = (if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
* 2x2 blocks are always short motion coded, using no extra VLC:&lt;br /&gt;
** transformation mode = bits 1..3 of short motion&lt;br /&gt;
** motion index = bit 0 || bits 4..7 || bits 8..11 (total 9 bits)&lt;br /&gt;
** decode the index as follows:&lt;br /&gt;
 if index &amp;lt; 12 * 8&lt;br /&gt;
   xmotion = -2 - index % 12&lt;br /&gt;
   ymotion =  6 - index / 12&lt;br /&gt;
 else&lt;br /&gt;
   index -= 12 * 8&lt;br /&gt;
   xmotion = 19 - index % 32&lt;br /&gt;
   ymotion = -2 - index / 32&lt;br /&gt;
   if ymotion &amp;lt;= -8&lt;br /&gt;
    ymotion = ymotion - 1&lt;br /&gt;
&lt;br /&gt;
Block's source coordinates are the sum of current 8x8 macroblock's coordinates (not its subblock's!) and the xmotion and ymotion respectively. If x-coordinate happens to go out of frame, it should be wrapped around the line. Copy block at the following coordinates to the current, applying the transformation as specified.&lt;br /&gt;
&lt;br /&gt;
=== Normal decoding ===&lt;br /&gt;
Normal compression introduces interframes, more split modes and different short motion encoding.&lt;br /&gt;
&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x8 !! 8x4 !! 4x4 !! 2x4 !! 4x2 !! 2x2&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Keyframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 110 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 00 || 0 || n/a || 01 || 1 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 01 || n/a || 0 || 10 || n/a || 1 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 10 || n/a || n/a || 11 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 111 || 1 || 1 || 00 || 0 || 0  || n/a&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Interframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 011 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 100 || 10 || n/a || 101 || 111 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 101 || n/a || 10 || 110 || n/a || 111 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 1110 || n/a || n/a || 111 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Skip || 110 || 11 || 11 || 100 || 110 || 110 || 11&lt;br /&gt;
|-&lt;br /&gt;
| ShortMotion || 00 || 00 || 00 || 00 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 010 || 01 || 01 || 01 || 10 || 10 || 10&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* HorizontalCut splits the block horizontally, producing two subblocks of smaller height. Each one then processed recursively.&lt;br /&gt;
* VerticalCut is identical to HorizontalCut, but splits the block vertically.&lt;br /&gt;
* Skip simply copies the block from the previous frame.&lt;br /&gt;
* ShortMotion copies block from previous frame, using the spiral-encoded motion. Unlike regular motion, short motion is relative to subblock's coordinates, not the whole macroblock. Read ShortMotion index, then obtain block's relative coordinates as per illustration:&lt;br /&gt;
[[Image:HNM6Spiral.png]]&lt;br /&gt;
* Motion blocks are similar to WARP motion block, with minor enhancements:&lt;br /&gt;
** For keyframe motion is the same as for WRAP, with the exception for blocks smaller than 4x4. For such blocks:&lt;br /&gt;
*** transformation mode = bits 12.14 of motion&lt;br /&gt;
*** xmotion = 63 - (bits 0..6 of motion)&lt;br /&gt;
*** ymotion = 6 - (bits 7..11 of motion)&lt;br /&gt;
** Keyframe's 2x2 blocks are always motion-coded as above.&lt;br /&gt;
&lt;br /&gt;
** For interframe motion is different. For blocks 4x4 and larger:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
*** ymotion = (if from previous frame then 64, otherwise if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
** For blocks smaller than 4x4:&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** if from current frame - same as for keyframe, see above. for previous frame:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** xmotion = 31 - (bits 0..5 of motion)&lt;br /&gt;
*** ymotion = 31 - (bits 6..11 of motion)&lt;br /&gt;
** Don't forget to wrap x motion around the line if it goes out of frame.&lt;br /&gt;
&lt;br /&gt;
=== Block transformation ===&lt;br /&gt;
During block copying, it can be additionally transformed. Transformation modes:&lt;br /&gt;
==== 0 - Normal copy ====&lt;br /&gt;
Copy block as is.&lt;br /&gt;
==== 1 - Horizontal flip ====&lt;br /&gt;
Swap left and right:&lt;br /&gt;
 abc -&amp;gt; cba&lt;br /&gt;
==== 2 -  Vertical flip ====&lt;br /&gt;
Swap up and down:&lt;br /&gt;
 a    c&lt;br /&gt;
 b -&amp;gt; b&lt;br /&gt;
 c    a&lt;br /&gt;
==== 3 - Cross flip ====&lt;br /&gt;
Swap both up-down and left-right:&lt;br /&gt;
 ab    fe&lt;br /&gt;
 cd -&amp;gt; dc&lt;br /&gt;
 ef    ba&lt;br /&gt;
==== 4 - Forward flip ====&lt;br /&gt;
Swap block around / :&lt;br /&gt;
 ab -&amp;gt; db &lt;br /&gt;
 cd    ca&lt;br /&gt;
==== 5 - Forward rotate ====&lt;br /&gt;
Rotate block 90 degrees clockwise:&lt;br /&gt;
 ab    eca    fe&lt;br /&gt;
 cd -&amp;gt; fdb -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 6 - Backward rotate ====&lt;br /&gt;
Rotate block 90 degrees counterclockwise:&lt;br /&gt;
 ab    bdf    fe&lt;br /&gt;
 cd -&amp;gt; ace -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 7 - Backward flip ====&lt;br /&gt;
Swap block around \ :&lt;br /&gt;
 ab -&amp;gt; ac&lt;br /&gt;
 cd    bd&lt;br /&gt;
&lt;br /&gt;
=== Bitexact decoding ===&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14177</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14177"/>
		<updated>2012-10-13T14:51:08Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* File Format */ explain several fields&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative), bits meaning:&lt;br /&gt;
            8 : stereo&lt;br /&gt;
         7..6 : frequency in units of 11025 (i.e. frequency = value * 11025)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  frames2          -- upper part of frame counter, ignored by some implementations&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller blocks. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games circa 1997.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets are little-endian and relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
=== Key-blocks decoding ===&lt;br /&gt;
Key-blocks are JPEG-encoded blocks in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,1,8,16,9,...) and quantization tables (16,11,10,16, 24,...; 17,18,24,47,99,...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's complement value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's complement value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, the first coefficient is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of a plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
=== WARP decoding ===&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x4 &lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 11 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 10 || 0&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 0 || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Keyblock is a JPEG-encoded macroblock.&lt;br /&gt;
* CrossCut means that the current block should be cut on to 4 smaller subblocks and each one processed independently, using the same scheme recursively.&lt;br /&gt;
* Motion means that the block is motion-coded and should be copied from some other part of the frame. To do so, read the next entry of the motion buffer and process it as follows:&lt;br /&gt;
** transformation mode = next 2 bits from bitbuffer (upper part) combined with bit 15 of motion (lower bit)&lt;br /&gt;
** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
** ymotion = (if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
* 2x2 blocks are always short motion coded, using no extra VLC:&lt;br /&gt;
** transformation mode = bits 1..3 of short motion&lt;br /&gt;
** motion index = bit 0 || bits 4..7 || bits 8..11 (total 9 bits)&lt;br /&gt;
** decode the index as follows:&lt;br /&gt;
 if index &amp;lt; 12 * 8&lt;br /&gt;
   xmotion = -2 - index % 12&lt;br /&gt;
   ymotion =  6 - index / 12&lt;br /&gt;
 else&lt;br /&gt;
   index -= 12 * 8&lt;br /&gt;
   xmotion = 19 - index % 32&lt;br /&gt;
   ymotion = -2 - index / 32&lt;br /&gt;
   if ymotion &amp;lt;= -8&lt;br /&gt;
    ymotion = ymotion - 1&lt;br /&gt;
&lt;br /&gt;
Block's source coordinates are the sum of current 8x8 macroblock's coordinates (not its subblock's!) and the xmotion and ymotion respectively. If x-coordinate happens to go out of frame, it should be wrapped around the line. Copy block at the following coordinates to the current, applying the transformation as specified.&lt;br /&gt;
&lt;br /&gt;
=== Normal decoding ===&lt;br /&gt;
Normal compression introduces interframes, more split modes and different short motion encoding.&lt;br /&gt;
&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x8 !! 8x4 !! 4x4 !! 2x4 !! 4x2 !! 2x2&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Keyframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 110 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 00 || 0 || n/a || 01 || 1 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 01 || n/a || 0 || 10 || n/a || 1 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 10 || n/a || n/a || 11 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 111 || 1 || 1 || 00 || 0 || 0  || n/a&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Interframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 011 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 100 || 10 || n/a || 101 || 111 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 101 || n/a || 10 || 110 || n/a || 111 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 1110 || n/a || n/a || 111 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Skip || 110 || 11 || 11 || 100 || 110 || 110 || 11&lt;br /&gt;
|-&lt;br /&gt;
| ShortMotion || 00 || 00 || 00 || 00 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 010 || 01 || 01 || 01 || 10 || 10 || 10&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* HorizontalCut splits the block horizontally, producing two subblocks of smaller height. Each one then processed recursively.&lt;br /&gt;
* VerticalCut is identical to HorizontalCut, but splits the block vertically.&lt;br /&gt;
* Skip simply copies the block from the previous frame.&lt;br /&gt;
* ShortMotion copies block from previous frame, using the spiral-encoded motion. Unlike regular motion, short motion is relative to subblock's coordinates, not the whole macroblock. Read ShortMotion index, then obtain block's relative coordinates as per illustration:&lt;br /&gt;
[[Image:HNM6Spiral.png]]&lt;br /&gt;
* Motion blocks are similar to WARP motion block, with minor enhancements:&lt;br /&gt;
** For keyframe motion is the same as for WRAP, with the exception for blocks smaller than 4x4. For such blocks:&lt;br /&gt;
*** transformation mode = bits 12.14 of motion&lt;br /&gt;
*** xmotion = 63 - (bits 0..6 of motion)&lt;br /&gt;
*** ymotion = 6 - (bits 7..11 of motion)&lt;br /&gt;
** Keyframe's 2x2 blocks are always motion-coded as above.&lt;br /&gt;
&lt;br /&gt;
** For interframe motion is different. For blocks 4x4 and larger:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
*** ymotion = (if from previous frame then 64, otherwise if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
** For blocks smaller than 4x4:&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** if from current frame - same as for keyframe, see above. for previous frame:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** xmotion = 31 - (bits 0..5 of motion)&lt;br /&gt;
*** ymotion = 31 - (bits 6..11 of motion)&lt;br /&gt;
** Don't forget to wrap x motion around the line if it goes out of frame.&lt;br /&gt;
&lt;br /&gt;
=== Block transformation ===&lt;br /&gt;
During block copying, it can be additionally transformed. Transformation modes:&lt;br /&gt;
==== 0 - Normal copy ====&lt;br /&gt;
Copy block as is.&lt;br /&gt;
==== 1 - Horizontal flip ====&lt;br /&gt;
Swap left and right:&lt;br /&gt;
 abc -&amp;gt; cba&lt;br /&gt;
==== 2 -  Vertical flip ====&lt;br /&gt;
Swap up and down:&lt;br /&gt;
 a    c&lt;br /&gt;
 b -&amp;gt; b&lt;br /&gt;
 c    a&lt;br /&gt;
==== 3 - Cross flip ====&lt;br /&gt;
Swap both up-down and left-right:&lt;br /&gt;
 ab    fe&lt;br /&gt;
 cd -&amp;gt; dc&lt;br /&gt;
 ef    ba&lt;br /&gt;
==== 4 - Forward flip ====&lt;br /&gt;
Swap block around / :&lt;br /&gt;
 ab -&amp;gt; db &lt;br /&gt;
 cd    ca&lt;br /&gt;
==== 5 - Forward rotate ====&lt;br /&gt;
Rotate block 90 degrees clockwise:&lt;br /&gt;
 ab    eca    fe&lt;br /&gt;
 cd -&amp;gt; fdb -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 6 - Backward rotate ====&lt;br /&gt;
Rotate block 90 degrees counterclockwise:&lt;br /&gt;
 ab    bdf    fe&lt;br /&gt;
 cd -&amp;gt; ace -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 7 - Backward flip ====&lt;br /&gt;
Swap block around \ :&lt;br /&gt;
 ab -&amp;gt; ac&lt;br /&gt;
 cd    bd&lt;br /&gt;
&lt;br /&gt;
=== Bitexact decoding ===&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14171</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14171"/>
		<updated>2012-09-08T19:15:56Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* Video Format */ typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller blocks. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games circa 1997.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets are little-endian and relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
=== Key-blocks decoding ===&lt;br /&gt;
Key-blocks are JPEG-encoded blocks in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,1,8,16,9,...) and quantization tables (16,11,10,16, 24,...; 17,18,24,47,99,...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's complement value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's complement value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, the first coefficient is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of a plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
=== WARP decoding ===&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x4 &lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 11 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 10 || 0&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 0 || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Keyblock is a JPEG-encoded macroblock.&lt;br /&gt;
* CrossCut means that the current block should be cut on to 4 smaller subblocks and each one processed independently, using the same scheme recursively.&lt;br /&gt;
* Motion means that the block is motion-coded and should be copied from some other part of the frame. To do so, read the next entry of the motion buffer and process it as follows:&lt;br /&gt;
** transformation mode = next 2 bits from bitbuffer (upper part) combined with bit 15 of motion (lower bit)&lt;br /&gt;
** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
** ymotion = (if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
* 2x2 blocks are always short motion coded, using no extra VLC:&lt;br /&gt;
** transformation mode = bits 1..3 of short motion&lt;br /&gt;
** motion index = bit 0 || bits 4..7 || bits 8..11 (total 9 bits)&lt;br /&gt;
** decode the index as follows:&lt;br /&gt;
 if index &amp;lt; 12 * 8&lt;br /&gt;
   xmotion = -2 - index % 12&lt;br /&gt;
   ymotion =  6 - index / 12&lt;br /&gt;
 else&lt;br /&gt;
   index -= 12 * 8&lt;br /&gt;
   xmotion = 19 - index % 32&lt;br /&gt;
   ymotion = -2 - index / 32&lt;br /&gt;
   if ymotion &amp;lt;= -8&lt;br /&gt;
    ymotion = ymotion - 1&lt;br /&gt;
&lt;br /&gt;
Block's source coordinates are the sum of current 8x8 macroblock's coordinates (not its subblock's!) and the xmotion and ymotion respectively. If x-coordinate happens to go out of frame, it should be wrapped around the line. Copy block at the following coordinates to the current, applying the transformation as specified.&lt;br /&gt;
&lt;br /&gt;
=== Normal decoding ===&lt;br /&gt;
Normal compression introduces interframes, more split modes and different short motion encoding.&lt;br /&gt;
&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x8 !! 8x4 !! 4x4 !! 2x4 !! 4x2 !! 2x2&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Keyframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 110 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 00 || 0 || n/a || 01 || 1 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 01 || n/a || 0 || 10 || n/a || 1 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 10 || n/a || n/a || 11 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 111 || 1 || 1 || 00 || 0 || 0  || n/a&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Interframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 011 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 100 || 10 || n/a || 101 || 111 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 101 || n/a || 10 || 110 || n/a || 111 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 1110 || n/a || n/a || 111 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Skip || 110 || 11 || 11 || 100 || 110 || 110 || 11&lt;br /&gt;
|-&lt;br /&gt;
| ShortMotion || 00 || 00 || 00 || 00 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 010 || 01 || 01 || 01 || 10 || 10 || 10&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* HorizontalCut splits the block horizontally, producing two subblocks of smaller height. Each one then processed recursively.&lt;br /&gt;
* VerticalCut is identical to HorizontalCut, but splits the block vertically.&lt;br /&gt;
* Skip simply copies the block from the previous frame.&lt;br /&gt;
* ShortMotion copies block from previous frame, using the spiral-encoded motion. Unlike regular motion, short motion is relative to subblock's coordinates, not the whole macroblock. Read ShortMotion index, then obtain block's relative coordinates as per illustration:&lt;br /&gt;
[[Image:HNM6Spiral.png]]&lt;br /&gt;
* Motion blocks are similar to WARP motion block, with minor enhancements:&lt;br /&gt;
** For keyframe motion is the same as for WRAP, with the exception for blocks smaller than 4x4. For such blocks:&lt;br /&gt;
*** transformation mode = bits 12.14 of motion&lt;br /&gt;
*** xmotion = 63 - (bits 0..6 of motion)&lt;br /&gt;
*** ymotion = 6 - (bits 7..11 of motion)&lt;br /&gt;
** Keyframe's 2x2 blocks are always motion-coded as above.&lt;br /&gt;
&lt;br /&gt;
** For interframe motion is different. For blocks 4x4 and larger:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
*** ymotion = (if from previous frame then 64, otherwise if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
** For blocks smaller than 4x4:&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** if from current frame - same as for keyframe, see above. for previous frame:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** xmotion = 31 - (bits 0..5 of motion)&lt;br /&gt;
*** ymotion = 31 - (bits 6..11 of motion)&lt;br /&gt;
** Don't forget to wrap x motion around the line if it goes out of frame.&lt;br /&gt;
&lt;br /&gt;
=== Block transformation ===&lt;br /&gt;
During block copying, it can be additionally transformed. Transformation modes:&lt;br /&gt;
==== 0 - Normal copy ====&lt;br /&gt;
Copy block as is.&lt;br /&gt;
==== 1 - Horizontal flip ====&lt;br /&gt;
Swap left and right:&lt;br /&gt;
 abc -&amp;gt; cba&lt;br /&gt;
==== 2 -  Vertical flip ====&lt;br /&gt;
Swap up and down:&lt;br /&gt;
 a    c&lt;br /&gt;
 b -&amp;gt; b&lt;br /&gt;
 c    a&lt;br /&gt;
==== 3 - Cross flip ====&lt;br /&gt;
Swap both up-down and left-right:&lt;br /&gt;
 ab    fe&lt;br /&gt;
 cd -&amp;gt; dc&lt;br /&gt;
 ef    ba&lt;br /&gt;
==== 4 - Forward flip ====&lt;br /&gt;
Swap block around / :&lt;br /&gt;
 ab -&amp;gt; db &lt;br /&gt;
 cd    ca&lt;br /&gt;
==== 5 - Forward rotate ====&lt;br /&gt;
Rotate block 90 degrees clockwise:&lt;br /&gt;
 ab    eca    fe&lt;br /&gt;
 cd -&amp;gt; fdb -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 6 - Backward rotate ====&lt;br /&gt;
Rotate block 90 degrees counterclockwise:&lt;br /&gt;
 ab    bdf    fe&lt;br /&gt;
 cd -&amp;gt; ace -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 7 - Backward flip ====&lt;br /&gt;
Swap block around \ :&lt;br /&gt;
 ab -&amp;gt; ac&lt;br /&gt;
 cd    bd&lt;br /&gt;
&lt;br /&gt;
=== Bitexact decoding ===&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14170</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14170"/>
		<updated>2012-09-08T18:53:24Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* Block transformation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller block. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets a relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
=== Key-blocks decoding ===&lt;br /&gt;
Key-blocks are JPEG-encoded blocks in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,  1,  8, 16,  9, ...) and quantization tables (16, 11, 10, 16,  24, ... ; 17, 18, 24, 47, 99, ...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's compliment value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's compliment value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, first entry is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
=== WARP decoding ===&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x4 &lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 11 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 10 || 0&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 0 || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Keyblock is a JPEG-encoded macroblock&lt;br /&gt;
* CrossCut means that the current block should be cut on to 4 smaller subblocks and each one processed independently, using the same scheme recursively.&lt;br /&gt;
* Motion means that the block is motion-coded and should be copied from some other part of the frame. To do so, read the next entry of the motion buffer and process it as follows:&lt;br /&gt;
** transformation mode = next 2 bits from bitbuffer (upper part) combined with bit 15 of motion (lower bit.)&lt;br /&gt;
** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
** ymotion = (if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
* 2x2 blocks are always short motion coded, using no extra VLC&lt;br /&gt;
** transformation mode = bits 1..3 of short motion&lt;br /&gt;
** motion index = bit 0 || bits 4..7 || bits 8..11 (total 9 bits)&lt;br /&gt;
** decode the index as follows:&lt;br /&gt;
 if index &amp;lt; 12 * 8&lt;br /&gt;
   xmotion = -2 - index % 12&lt;br /&gt;
   ymotion =  6 - index / 12&lt;br /&gt;
 else&lt;br /&gt;
   index -= 12 * 8&lt;br /&gt;
   xmotion = 19 - index % 32&lt;br /&gt;
   ymotion = -2 - index / 32&lt;br /&gt;
   if ymotion &amp;lt;= -8&lt;br /&gt;
    ymotion = ymotion - 1&lt;br /&gt;
&lt;br /&gt;
Block's source coordinates are the sum of current 8x8 macroblock's coordinates (not it's subblock's!) and the xmotion and ymotion respectively. If x-coordinate happens to go out of frame, it should be wrapped around the line. Copy block at the following coordinates to the current, applying the transformation as specified.&lt;br /&gt;
&lt;br /&gt;
=== Normal decoding ===&lt;br /&gt;
Normal compression introduces interframes, more split modes and different short motion encoding.&lt;br /&gt;
&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x8 !! 8x4 !! 4x4 !! 2x4 !! 4x2 !! 2x2&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Keyframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 110 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 00 || 0 || n/a || 01 || 1 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 01 || n/a || 0 || 10 || n/a || 1 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 10 || n/a || n/a || 11 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 111 || 1 || 1 || 00 || 0 || 0  || n/a&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Interframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 011 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 100 || 10 || n/a || 101 || 111 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 101 || n/a || 10 || 110 || n/a || 111 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 1110 || n/a || n/a || 111 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Skip || 110 || 11 || 11 || 100 || 110 || 110 || 11&lt;br /&gt;
|-&lt;br /&gt;
| ShortMotion || 00 || 00 || 00 || 00 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 010 || 01 || 01 || 01 || 10 || 10 || 10&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* HorizontalCut splits the block horizontally, producing two subblocks of smaller height. Each one then processed recursively.&lt;br /&gt;
* VerticalCut is identical to HorizontalCut, but splits the block vertically.&lt;br /&gt;
* Skip simply copies the block from the previous frame&lt;br /&gt;
* ShortMotion copies block from previous frame, using the spiral-encoded motion. Unlike regular motion, short motion is relative to subblock's coordinates, not the whole macroblock. Read ShortMotion index, then obtain block's relative coordinates as per illustration:&lt;br /&gt;
[[Image:HNM6Spiral.png]]&lt;br /&gt;
* Motion blocks are similar to WARP motion block, with minor enhancements&lt;br /&gt;
** For keyframe motion is the same as for WRAP, with the exception for blocks smaller than 4x4. For such blocks:&lt;br /&gt;
*** transformation mode = bits 12.14 of motion&lt;br /&gt;
*** xmotion = 63 - (bits 0..6 of motion)&lt;br /&gt;
*** ymotion = 6 - (bits 7..11 of motion)&lt;br /&gt;
** Keyframe's 2x2 blocks are always motion-coded as above.&lt;br /&gt;
&lt;br /&gt;
** For interframe motion is different. For blocks 4x4 and larger:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
*** ymotion = (if from previous frame then 64, otherwise if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
** For blocks smaller than 4x4:&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** if from current frame - same as for keyframe, see above. for previous frame:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** xmotion = 31 - (bits 0..5 of motion)&lt;br /&gt;
*** ymotion = 31 - (bits 6..11 of motion)&lt;br /&gt;
** Don't forget to wrap x motion around the line if it goes out of frame&lt;br /&gt;
&lt;br /&gt;
=== Block transformation ===&lt;br /&gt;
During block copying, it can be additionally transformed. Transformation modes:&lt;br /&gt;
==== 0 - Normal copy ====&lt;br /&gt;
Copy block as is.&lt;br /&gt;
==== 1 - Horizontal flip ====&lt;br /&gt;
Swap left and right&lt;br /&gt;
 abc -&amp;gt; cba&lt;br /&gt;
==== 2 -  Vertical flip ====&lt;br /&gt;
Swap up and down&lt;br /&gt;
 a    c&lt;br /&gt;
 b -&amp;gt; b&lt;br /&gt;
 c    a&lt;br /&gt;
==== 3 - Cross flip ====&lt;br /&gt;
Swap both up-down and left-right&lt;br /&gt;
 ab    fe&lt;br /&gt;
 cd -&amp;gt; dc&lt;br /&gt;
 ef    ba&lt;br /&gt;
==== 4 - Forward flip ====&lt;br /&gt;
Swap block around /&lt;br /&gt;
 ab -&amp;gt; db &lt;br /&gt;
 cd    ca&lt;br /&gt;
==== 5 - Forward rotate ====&lt;br /&gt;
Rotate block 90 degrees clockwise&lt;br /&gt;
 ab    eca    fe&lt;br /&gt;
 cd -&amp;gt; fdb -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 6 - Backward rotate ====&lt;br /&gt;
Rotate block 90 degrees counterclockwise&lt;br /&gt;
 ab    bdf    fe&lt;br /&gt;
 cd -&amp;gt; ace -&amp;gt; dc&lt;br /&gt;
 ef           ba&lt;br /&gt;
==== 7 - Backward flip ====&lt;br /&gt;
Swap block around \&lt;br /&gt;
 ab -&amp;gt; ac&lt;br /&gt;
 cd    bd&lt;br /&gt;
&lt;br /&gt;
=== Bitexact decoding ===&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14169</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14169"/>
		<updated>2012-09-08T18:32:29Z</updated>

		<summary type="html">&lt;p&gt;VAG: realing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller block. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets a relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
=== Key-blocks decoding ===&lt;br /&gt;
Key-blocks are JPEG-encoded blocks in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,  1,  8, 16,  9, ...) and quantization tables (16, 11, 10, 16,  24, ... ; 17, 18, 24, 47, 99, ...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's compliment value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's compliment value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, first entry is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
=== WARP decoding ===&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x4 &lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 11 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 10 || 0&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 0 || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Keyblock is a JPEG-encoded macroblock&lt;br /&gt;
* CrossCut means that the current block should be cut on to 4 smaller subblocks and each one processed independently, using the same scheme recursively.&lt;br /&gt;
* Motion means that the block is motion-coded and should be copied from some other part of the frame. To do so, read the next entry of the motion buffer and process it as follows:&lt;br /&gt;
** transformation mode = next 2 bits from bitbuffer (upper part) combined with bit 15 of motion (lower bit.)&lt;br /&gt;
** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
** ymotion = (if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
* 2x2 blocks are always short motion coded, using no extra VLC&lt;br /&gt;
** transformation mode = bits 1..3 of short motion&lt;br /&gt;
** motion index = bit 0 || bits 4..7 || bits 8..11 (total 9 bits)&lt;br /&gt;
** decode the index as follows:&lt;br /&gt;
 if index &amp;lt; 12 * 8&lt;br /&gt;
   xmotion = -2 - index % 12&lt;br /&gt;
   ymotion =  6 - index / 12&lt;br /&gt;
 else&lt;br /&gt;
   index -= 12 * 8&lt;br /&gt;
   xmotion = 19 - index % 32&lt;br /&gt;
   ymotion = -2 - index / 32&lt;br /&gt;
   if ymotion &amp;lt;= -8&lt;br /&gt;
    ymotion = ymotion - 1&lt;br /&gt;
&lt;br /&gt;
Block's source coordinates are the sum of current 8x8 macroblock's coordinates (not it's subblock's!) and the xmotion and ymotion respectively. If x-coordinate happens to go out of frame, it should be wrapped around the line. Copy block at the following coordinates to the current, applying the transformation as specified.&lt;br /&gt;
&lt;br /&gt;
=== Normal decoding ===&lt;br /&gt;
Normal compression introduces interframes, more split modes and different short motion encoding.&lt;br /&gt;
&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x8 !! 8x4 !! 4x4 !! 2x4 !! 4x2 !! 2x2&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Keyframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 110 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 00 || 0 || n/a || 01 || 1 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 01 || n/a || 0 || 10 || n/a || 1 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 10 || n/a || n/a || 11 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 111 || 1 || 1 || 00 || 0 || 0  || n/a&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Interframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 011 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 100 || 10 || n/a || 101 || 111 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 101 || n/a || 10 || 110 || n/a || 111 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 1110 || n/a || n/a || 111 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Skip || 110 || 11 || 11 || 100 || 110 || 110 || 11&lt;br /&gt;
|-&lt;br /&gt;
| ShortMotion || 00 || 00 || 00 || 00 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 010 || 01 || 01 || 01 || 10 || 10 || 10&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* HorizontalCut splits the block horizontally, producing two subblocks of smaller height. Each one then processed recursively.&lt;br /&gt;
* VerticalCut is identical to HorizontalCut, but splits the block vertically.&lt;br /&gt;
* Skip simply copies the block from the previous frame&lt;br /&gt;
* ShortMotion copies block from previous frame, using the spiral-encoded motion. Unlike regular motion, short motion is relative to subblock's coordinates, not the whole macroblock. Read ShortMotion index, then obtain block's relative coordinates as per illustration:&lt;br /&gt;
[[Image:HNM6Spiral.png]]&lt;br /&gt;
* Motion blocks are similar to WARP motion block, with minor enhancements&lt;br /&gt;
** For keyframe motion is the same as for WRAP, with the exception for blocks smaller than 4x4. For such blocks:&lt;br /&gt;
*** transformation mode = bits 12.14 of motion&lt;br /&gt;
*** xmotion = 63 - (bits 0..6 of motion)&lt;br /&gt;
*** ymotion = 6 - (bits 7..11 of motion)&lt;br /&gt;
** Keyframe's 2x2 blocks are always motion-coded as above.&lt;br /&gt;
&lt;br /&gt;
** For interframe motion is different. For blocks 4x4 and larger:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
*** ymotion = (if from previous frame then 64, otherwise if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
** For blocks smaller than 4x4:&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** if from current frame - same as for keyframe, see above. for previous frame:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** xmotion = 31 - (bits 0..5 of motion)&lt;br /&gt;
*** ymotion = 31 - (bits 6..11 of motion)&lt;br /&gt;
** Don't forget to wrap x motion around the line if it goes out of frame&lt;br /&gt;
&lt;br /&gt;
=== Block transformation ===&lt;br /&gt;
&lt;br /&gt;
=== Bitexact decoding ===&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14168</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14168"/>
		<updated>2012-09-08T18:26:33Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* Normal decoding */ decoding&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller block. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets a relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
== JPEG Blocks decoding ==&lt;br /&gt;
JPEG blocks are encoded in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,  1,  8, 16,  9, ...) and quantization tables (16, 11, 10, 16,  24, ... ; 17, 18, 24, 47, 99, ...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's compliment value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's compliment value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, first entry is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
== WARP decoding ==&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x4 &lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 11 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 10 || 0&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 0 || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Keyblock is a JPEG-encoded macroblock&lt;br /&gt;
* CrossCut means that the current block should be cut on to 4 smaller subblocks and each one processed independently, using the same scheme recursively.&lt;br /&gt;
* Motion means that the block is motion-coded and should be copied from some other part of the frame. To do so, read the next entry of the motion buffer and process it as follows:&lt;br /&gt;
** transformation mode = next 2 bits from bitbuffer (upper part) combined with bit 15 of motion (lower bit.)&lt;br /&gt;
** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
** ymotion = (if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
* 2x2 blocks are always short motion coded, using no extra VLC&lt;br /&gt;
** transformation mode = bits 1..3 of short motion&lt;br /&gt;
** motion index = bit 0 || bits 4..7 || bits 8..11 (total 9 bits)&lt;br /&gt;
** decode the index as follows:&lt;br /&gt;
 if index &amp;lt; 12 * 8&lt;br /&gt;
   xmotion = -2 - index % 12&lt;br /&gt;
   ymotion =  6 - index / 12&lt;br /&gt;
 else&lt;br /&gt;
   index -= 12 * 8&lt;br /&gt;
   xmotion = 19 - index % 32&lt;br /&gt;
   ymotion = -2 - index / 32&lt;br /&gt;
   if ymotion &amp;lt;= -8&lt;br /&gt;
    ymotion = ymotion - 1&lt;br /&gt;
&lt;br /&gt;
Block's source coordinates are the sum of current 8x8 macroblock's coordinates (not it's subblock's!) and the xmotion and ymotion respectively. If x-coordinate happens to go out of frame, it should be wrapped around the line. Copy block at the following coordinates to the current, applying the transformation as specified.&lt;br /&gt;
&lt;br /&gt;
== Normal decoding ==&lt;br /&gt;
Normal compression introduces interframes, more split modes and different short motion encoding.&lt;br /&gt;
&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x8 !! 8x4 !! 4x4 !! 2x4 !! 4x2 !! 2x2&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Keyframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 110 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 00 || 0 || n/a || 01 || 1 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 01 || n/a || 0 || 10 || n/a || 1 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 10 || n/a || n/a || 11 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 111 || 1 || 1 || 00 || 0 || 0  || n/a&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;8&amp;quot; style=&amp;quot;text-align: center;&amp;quot; bgcolor=&amp;quot;#f0f0f0&amp;quot; | Interframe&lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 011 || n/a || n/a || n/a || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| HorizontalCut || 100 || 10 || n/a || 101 || 111 || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| VerticalCut || 101 || n/a || 10 || 110 || n/a || 111 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 1110 || n/a || n/a || 111 || n/a || n/a || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Skip || 110 || 11 || 11 || 100 || 110 || 110 || 11&lt;br /&gt;
|-&lt;br /&gt;
| ShortMotion || 00 || 00 || 00 || 00 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 010 || 01 || 01 || 01 || 10 || 10 || 10&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* HorizontalCut splits the block horizontally, producing two subblocks of smaller height. Each one then processed recursively.&lt;br /&gt;
* VerticalCut is identical to HorizontalCut, but splits the block vertically.&lt;br /&gt;
* Skip simply copies the block from the previous frame&lt;br /&gt;
* ShortMotion copies block from previous frame, using the spiral-encoded motion. Unlike regular motion, short motion is relative to subblock's coordinates, not the whole macroblock. Read ShortMotion index, then obtain block's relative coordinates as per illustration:&lt;br /&gt;
[[Image:HNM6Spiral.png]]&lt;br /&gt;
* Motion blocks are similar to WARP motion block, with minor enhancements&lt;br /&gt;
** For keyframe motion is the same as for WRAP, with the exception for blocks smaller than 4x4. For such blocks:&lt;br /&gt;
*** transformation mode = bits 12.14 of motion&lt;br /&gt;
*** xmotion = 63 - (bits 0..6 of motion)&lt;br /&gt;
*** ymotion = 6 - (bits 7..11 of motion)&lt;br /&gt;
** Keyframe's 2x2 blocks are always motion-coded as above.&lt;br /&gt;
&lt;br /&gt;
** For interframe motion is different. For blocks 4x4 and larger:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
*** ymotion = (if from previous frame then 64, otherwise if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
** For blocks smaller than 4x4:&lt;br /&gt;
*** if bit 15 of motion is zero then source is the previous frame, current frame otherwise&lt;br /&gt;
*** if from current frame - same as for keyframe, see above. for previous frame:&lt;br /&gt;
*** transformation mode = next 3 bits from bitbuffer&lt;br /&gt;
*** xmotion = 31 - (bits 0..5 of motion)&lt;br /&gt;
*** ymotion = 31 - (bits 6..11 of motion)&lt;br /&gt;
** Don't forget to wrap x motion around the line if it goes out of frame&lt;br /&gt;
&lt;br /&gt;
== Bitexact decoding ==&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=File:HNM6Spiral.png&amp;diff=14167</id>
		<title>File:HNM6Spiral.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=File:HNM6Spiral.png&amp;diff=14167"/>
		<updated>2012-09-08T17:57:34Z</updated>

		<summary type="html">&lt;p&gt;VAG: HNM6 Short Motion vector illustration&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;HNM6 Short Motion vector illustration&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14166</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14166"/>
		<updated>2012-09-08T15:48:43Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* WARP decoding */ decoding&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller block. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets a relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
== JPEG Blocks decoding ==&lt;br /&gt;
JPEG blocks are encoded in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,  1,  8, 16,  9, ...) and quantization tables (16, 11, 10, 16,  24, ... ; 17, 18, 24, 47, 99, ...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's compliment value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's compliment value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, first entry is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
== WARP decoding ==&lt;br /&gt;
Macroblocks are encoded using the following VLC codes:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;border-collapse: collapse; border-style: dashed; border-color: #2f6fab;&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#f0f0f0&amp;quot; |&lt;br /&gt;
! Block type !! 8x8 !! 4x4 &lt;br /&gt;
|-&lt;br /&gt;
| Keyblock || 11 || n/a&lt;br /&gt;
|-&lt;br /&gt;
| Motion || 10 || 0&lt;br /&gt;
|-&lt;br /&gt;
| CrossCut || 0 || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Keyblock is a JPEG-encoded macroblock&lt;br /&gt;
* CrossCut means that the current block should be cut on to 4 smaller subblocks and each one processed independently, using the same scheme recursively.&lt;br /&gt;
* Motion means that the block is motion-coded and should be copied from some other part of the frame. To do so, read the next entry of the motion buffer and process it as follows:&lt;br /&gt;
** transformation mode = next 2 bits from bitbuffer (upper part) combined with bit 15 of motion (lower bit.)&lt;br /&gt;
** xmotion = 128 - (bits 7..14 of motion)&lt;br /&gt;
** ymotion = (if block is not 8x8, then 4) - (bits 0..6 of motion)&lt;br /&gt;
* 2x2 blocks are always short motion coded, using no extra VLC&lt;br /&gt;
** transformation mode = bits 1..3 of short motion&lt;br /&gt;
** motion index = bit 0 || bits 4..7 || bits 8..11 (total 9 bits)&lt;br /&gt;
** decode the index as follows:&lt;br /&gt;
 if index &amp;lt; 12 * 8&lt;br /&gt;
   xmotion = -2 - index % 12&lt;br /&gt;
   ymotion =  6 - index / 12&lt;br /&gt;
 else&lt;br /&gt;
   index -= 12 * 8&lt;br /&gt;
   xmotion = 19 - index % 32&lt;br /&gt;
   ymotion = -2 - index / 32&lt;br /&gt;
   if ymotion &amp;lt;= -8&lt;br /&gt;
    ymotion = ymotion - 1&lt;br /&gt;
&lt;br /&gt;
Block's source coordinates are the sum of current 8x8 macroblock's coordinates (not it's subblock's!) and the xmotion and ymotion respectively. If x-coordinate happens to go out of frame, it should be wrapped around the line. Copy block at the following coordinates to the current, applying the transformation as specified.&lt;br /&gt;
&lt;br /&gt;
== Normal decoding ==&lt;br /&gt;
&lt;br /&gt;
== Bitexact decoding ==&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14165</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14165"/>
		<updated>2012-09-08T14:58:13Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* Video Format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller block. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets a relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
== JPEG Blocks decoding ==&lt;br /&gt;
JPEG blocks are encoded in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,  1,  8, 16,  9, ...) and quantization tables (16, 11, 10, 16,  24, ... ; 17, 18, 24, 47, 99, ...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's compliment value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's compliment value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, first entry is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
== WARP decoding ==&lt;br /&gt;
&lt;br /&gt;
== Normal decoding ==&lt;br /&gt;
&lt;br /&gt;
== Bitexact decoding ==&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14164</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14164"/>
		<updated>2012-09-08T14:52:04Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* JPEG Blocks decoding */ initial coefficient&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller block. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets a relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing the blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
== JPEG Blocks decoding ==&lt;br /&gt;
JPEG blocks are encoded in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,  1,  8, 16,  9, ...) and quantization tables (16, 11, 10, 16,  24, ... ; 17, 18, 24, 47, 99, ...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's compliment value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's compliment value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, first entry is s44, then read nibbles and fill the rest of coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
== WARP decoding ==&lt;br /&gt;
&lt;br /&gt;
== Normal decoding ==&lt;br /&gt;
&lt;br /&gt;
== Bitexact decoding ==&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14163</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14163"/>
		<updated>2012-09-08T14:46:42Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* JPEG Blocks decoding */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller block. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets a relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing the blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
== JPEG Blocks decoding ==&lt;br /&gt;
JPEG blocks are encoded in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,  1,  8, 16,  9, ...) and quantization tables (16, 11, 10, 16,  24, ... ; 17, 18, 24, 47, 99, ...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's compliment value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's compliment value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, read a nibble and fill the coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
== WARP decoding ==&lt;br /&gt;
&lt;br /&gt;
== Normal decoding ==&lt;br /&gt;
&lt;br /&gt;
== Bitexact decoding ==&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14162</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14162"/>
		<updated>2012-09-08T14:45:04Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* JPEG Blocks decoding */ better this way&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller block. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets a relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing the blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
== JPEG Blocks decoding ==&lt;br /&gt;
JPEG blocks are encoded in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,  1,  8, 16,  9, ...) and quantization tables (16, 11, 10, 16,  24, ... ; 17, 18, 24, 47, 99, ...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
* s2 - signed two-bit 2's compliment value of a half, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's compliment value of a nibble, no zero point&lt;br /&gt;
* s44 - signed eight-bit value of two nibbles, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, read a nibble and fill the coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half.&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2, s2&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
== WARP decoding ==&lt;br /&gt;
&lt;br /&gt;
== Normal decoding ==&lt;br /&gt;
&lt;br /&gt;
== Bitexact decoding ==&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14161</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14161"/>
		<updated>2012-09-08T14:41:06Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* JPEG Blocks decoding */ decoding&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller block. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets a relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing the blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
== JPEG Blocks decoding ==&lt;br /&gt;
JPEG blocks are encoded in YUV 4:4:4 format. The requantization, [[IDCT]] and colorspace conversion steps are identical to standard [[JPEG]]. Standard zigzag (0,  1,  8, 16,  9, ...) and quantization tables (16, 11, 10, 16,  24, ... ; 17, 18, 24, 47, 99, ...) used as well. &lt;br /&gt;
&lt;br /&gt;
The only custom feature used is the coefficients encoding. Instead of Huffman coding they are stored using RLE scheme.&lt;br /&gt;
&lt;br /&gt;
Macroblock's jpeg data is accessed by 4-bit nibbles, lower nibble of each byte first. Also, the following primitives are used:&lt;br /&gt;
* s2 - signed two-bit 2's compliment value, no zero point (i.e. 0b00 -&amp;gt; 1, 0b01 -&amp;gt; 2, 0b10 -&amp;gt; -2, 0b11 -&amp;gt; -1)&lt;br /&gt;
* s4 - signed four-bit 2's compliment value, no zero point&lt;br /&gt;
* s44 - signed eight-bit value, with zero point (this is basically (signextend(nibble1) &amp;lt;&amp;lt; 4) | nibble2)&lt;br /&gt;
* half - half of a nibble, upper part first, then lower (i.e. read a nibble, process upper part of it upon first use, lower part upon second)&lt;br /&gt;
&lt;br /&gt;
For each plane of 8x8 coefficients, read a nibble and fill the coefficients as follows until the whole plane is complete. Repeat for each Y, U and V plane.&lt;br /&gt;
&lt;br /&gt;
  0 - fill remainder of plane with zeros&lt;br /&gt;
  1 - 0, 0, 0, 0&lt;br /&gt;
  2 - 0, 1&lt;br /&gt;
  3 - 0, -1&lt;br /&gt;
  4 - 0, 0, 1&lt;br /&gt;
  5 - 0, 0, -1&lt;br /&gt;
  6 - 0, 0, 0, 1&lt;br /&gt;
  7 - 0, 0, 0, -1&lt;br /&gt;
  8 - zeros = half, tail = half.&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+2) coefficients with s2(half)&lt;br /&gt;
  9 - zeros = half, tail = half&lt;br /&gt;
      fill (zeros+1) coefficients with 0&lt;br /&gt;
      fill (tail+1) coefficients with s4&lt;br /&gt;
 10 - s2(half), s2(half)&lt;br /&gt;
 11 - s4&lt;br /&gt;
 12 - s4, s4&lt;br /&gt;
 13 - s4, s4, s4&lt;br /&gt;
 14 - 0&lt;br /&gt;
 15 - s44&lt;br /&gt;
&lt;br /&gt;
== WARP decoding ==&lt;br /&gt;
&lt;br /&gt;
== Normal decoding ==&lt;br /&gt;
&lt;br /&gt;
== Bitexact decoding ==&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14160</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14160"/>
		<updated>2012-09-08T13:51:53Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* Video Format */ basic video outline&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video compression relies on a concept of Key-blocks, encoded with [[JPEG]]-like algorithm and motion blocks, derived from previously drawn blocks. The frame is encoded in 8x8 or smaller block. The Key-blocks are always 8x8 and directly encoded, while motion blocks heavily rely on [[D&amp;amp;C]] approach and various block transformation techniques. Generally, this codec is quite similar to [[4XM]] codec and [[Mobiclip]] codecs, because it's written by the same people.&lt;br /&gt;
&lt;br /&gt;
There are two variants of HNM6 video codec.&lt;br /&gt;
* WARP codec. Prototype codec, simplified version. Used in a very little number of games.&lt;br /&gt;
* Normal (yes, that's how it's called internally) codec. Fully-featured version, widely used.&lt;br /&gt;
&lt;br /&gt;
Both version has identical bitstream layout. Frame data begins this the following header:&lt;br /&gt;
&lt;br /&gt;
 s32  quality            -- JPEG quality index, negative value indicates that the frame is a keyframe&lt;br /&gt;
 u32  bitbuffer          -- offset of bitbuffer&lt;br /&gt;
 u32  motionbuffer       -- offset of motion vector buffer&lt;br /&gt;
 u32  shortmotionbuffer  -- offset of short motion vector buffer&lt;br /&gt;
 u32  jpegbuffer         -- offset of jpeg data buffer&lt;br /&gt;
 u32  jpegend            -- offset of jpeg data buffer end&lt;br /&gt;
&lt;br /&gt;
All offsets a relative to this header.&lt;br /&gt;
&lt;br /&gt;
* quality is a standard [[JPEG]] quality value (0..100%). Negative value is used to specify a keyframe (for Normal codec only.)&lt;br /&gt;
* bitbuffer points to frame's VLC-encoded macroblocks. This kind of data is accessed by a bit-reader with 32-bit internal queue, MSB bit comes out first.&lt;br /&gt;
* motion buffer points to array of u16 motion vectors, used to copy blocks from various areas of the frame&lt;br /&gt;
* short motion buffer is used for accessing the blocks near the current macroblock. Each entry of buffer is 12 bits long, accessed in LSB order.&lt;br /&gt;
* jpeg buffer points to array of encoded [[JPEG]] macroblocks&lt;br /&gt;
&lt;br /&gt;
== JPEG Blocks decoding ==&lt;br /&gt;
&lt;br /&gt;
== WARP decoding ==&lt;br /&gt;
&lt;br /&gt;
== Normal decoding ==&lt;br /&gt;
&lt;br /&gt;
== Bitexact decoding ==&lt;br /&gt;
While you can use stock [[JPEG]] routines to decode Key-blocks, if you want to produce bitexact output you need to use very specific code to do so.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14159</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14159"/>
		<updated>2012-09-08T13:06:21Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* IX Chunk */ warp chunk&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IW Chunk ===&lt;br /&gt;
Video frame, WARP format.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame, normal format.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14158</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14158"/>
		<updated>2012-09-08T13:01:19Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* File Format */ revisit file header&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[2]      -- usually 0&lt;br /&gt;
 u8   audioflags       -- nonzero value indicates file has APC sound (not authoritative)&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u16  frames           -- number of frames&lt;br /&gt;
 u16  reserved2&lt;br /&gt;
 u32  reserved3        -- usually 0, but sometimes &amp;quot;V107&amp;quot;, &amp;quot;V108&amp;quot; - version?&lt;br /&gt;
 u16  speed            -- playback speed in fps, may be zero (?assume 15 fps then?)&lt;br /&gt;
 u16  maxbuffer        -- number of frame buffers used&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by frame's individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame.&lt;br /&gt;
&lt;br /&gt;
== Format modifications ==&lt;br /&gt;
&lt;br /&gt;
At least one known game (Riverworld) uses slightly different HNM6 container format, most likely due to different sound encoding. This format is just a small enhancement of the original, but it's not backward compatible.&lt;br /&gt;
&lt;br /&gt;
Standard HNM6 header continues with additional audio description header:&lt;br /&gt;
&lt;br /&gt;
 u32  freq&lt;br /&gt;
 u32  bits&lt;br /&gt;
 u32  channels&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u8   copyright[28]  -- &amp;quot;HNMS 1.1 by SARRET Hubert\0\0\0&amp;quot;&lt;br /&gt;
 u32  ?              -- some initial audio samples?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
 u32  ?&lt;br /&gt;
&lt;br /&gt;
Each frame chunk followed by an audio chunk, however, this audio chunk size is not counted by frame's chunk size field.&lt;br /&gt;
Frame chunk format:&lt;br /&gt;
&lt;br /&gt;
 u32  sig[4]          -- &amp;quot;SOUN&amp;quot;&lt;br /&gt;
 u32  chunksize       -- including this preamble&lt;br /&gt;
 u8   data[]&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14157</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=14157"/>
		<updated>2012-09-08T12:24:57Z</updated>

		<summary type="html">&lt;p&gt;VAG: categorize&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[3]&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u32  frames&lt;br /&gt;
 u32  reserved2&lt;br /&gt;
 u32  maxbuffer        -- max buffer size (typically 0x20000)&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=UBB&amp;diff=14038</id>
		<title>UBB</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=UBB&amp;diff=14038"/>
		<updated>2012-04-15T17:21:10Z</updated>

		<summary type="html">&lt;p&gt;VAG: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension:  ubb , sometimes hnm&lt;br /&gt;
* Company: [[CRYO Interactive Entertainment]]&lt;br /&gt;
* Samples: '''ADD ME'''&lt;br /&gt;
&lt;br /&gt;
UBB2 is another generation of FMV format developed by Cryo. It is an improved version of [[HNM4]] format. While general container format remains the same, video encoding is slightly improved.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
Remains the same as was used in [[HNM4]]. Following parts has changed:&lt;br /&gt;
* File signature is &amp;quot;UBB2&amp;quot; now.&lt;br /&gt;
* Video chunk has &amp;quot;IV&amp;quot; TwoCC.&lt;br /&gt;
&lt;br /&gt;
== Video Compression ==&lt;br /&gt;
The video frame is encoded in a series of horizontal colums of variable width and height. However, columns height (and some of their coding properties) may only change at the beginning of new line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Encoded stream consist of column copy mode bytes:&lt;br /&gt;
 bits:&lt;br /&gt;
      7 - swap rows/columns&lt;br /&gt;
      6 - vertical reverse&lt;br /&gt;
      5 - horizontal reverse&lt;br /&gt;
   4..0 - column width index (table lookup, see below)&lt;br /&gt;
&lt;br /&gt;
Each of such code generally means ''&amp;quot;copy a width-by-height column from some other place to the current, using flags provided.&amp;quot;''&lt;br /&gt;
&amp;lt;br&amp;gt;Flags behavior can be illustrated as follows (assuming 2x3 block and the source points to 'M' pixel):&lt;br /&gt;
 Source      Normal   Horizontal   Vertical   Swap&lt;br /&gt;
     &lt;br /&gt;
  ABCDE        MN         ML          MN       MR&lt;br /&gt;
  FGHIJ        RS         RQ          HI       NS&lt;br /&gt;
  KLMNO   -&amp;gt;   WX         WV          CD       OT&lt;br /&gt;
  PQRST                     &lt;br /&gt;
  UVWXY                     &lt;br /&gt;
&lt;br /&gt;
Multiple flags can be used together.&lt;br /&gt;
&lt;br /&gt;
Encoded column width depends on column's height:&lt;br /&gt;
 2: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,34,36,38,40,44,48,52,56&lt;br /&gt;
 3: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,24,26,28,30,32,34,36,38,40,42,44&lt;br /&gt;
 4: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,28,30,32,34,36,38&lt;br /&gt;
&lt;br /&gt;
Source column offset may be an &amp;quot;absolute&amp;quot; offset - byte distance from the current column, or relative X:Y offset.&lt;br /&gt;
* For absolute offset read next 2-byte value (unsigned, little-endian) and add base oofset.&lt;br /&gt;
* For relative offset read next byte, extract X and Y deltas from it and add base deltas.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Certain combination used for special purposes. Those are:&lt;br /&gt;
* 0x20 - skip: read next byte (width) and copy width+1 column from previous frame&lt;br /&gt;
* 0x60 - solo: draw 1-pixel wide column using next bytes of input&lt;br /&gt;
* 0xA0 - draw: read next byte (width) and draw width+2 column using next bytes of input (top-down, left-right)&lt;br /&gt;
* 0xE0 - mode: examine next byte.&lt;br /&gt;
**   if byte is zero, then read two bytes (width, color) and fill width+1 column with color.&lt;br /&gt;
**   if byte is non-zero, change the decoding properties as follows:&lt;br /&gt;
 +------+--------+--------+--------+----------+---------+--------+&lt;br /&gt;
 | byte | height | source | offset | Y.X bits |  X-base | Y-base |&lt;br /&gt;
 +------+--------+--------+--------+----------+---------+--------+&lt;br /&gt;
 |   1  |                    end of decoding                     |&lt;br /&gt;
 +------+--------+--------+--------+----------+---------+--------+&lt;br /&gt;
 |   2  |   2    |  prev  | -32768 |   N/A    |   N/A   |   N/A  |&lt;br /&gt;
 |   3  |   3    |  prev  | -32768 |   N/A    |   N/A   |   N/A  |&lt;br /&gt;
 |   4  |   4    |  prev  | -32768 |   N/A    |   N/A   |   N/A  |&lt;br /&gt;
 |   5  |   2    |  prev  |   N/A  |   4.4    |   -8    |   -8   |&lt;br /&gt;
 |   6  |   3    |  prev  |   N/A  |   4.4    |   -8    |   -8   |&lt;br /&gt;
 |   7  |   4    |  prev  |   N/A  |   4.4    |   -8    |   -8   |&lt;br /&gt;
 +------+--------+--------+--------+----------+---------+--------+&lt;br /&gt;
 |   8  |   2    |  prev  |   N/A  |   4.4    |   -2    |   -8   |&lt;br /&gt;
 |   9  |   2    |  prev  |   N/A  |   4.4    |   -14   |   -8   |&lt;br /&gt;
 |  10  |   2    |  prev  |   N/A  |   4.4    |   -8    |   -2   |&lt;br /&gt;
 |  11  |   2    |  prev  |   N/A  |   4.4    |   -8    |   -14  |&lt;br /&gt;
 |  12  |   2    |  prev  |   N/A  |   4.4    |   -2    |   -2   |&lt;br /&gt;
 |  13  |   2    |  prev  |   N/A  |   4.4    |   -14   |   -2   |&lt;br /&gt;
 |  14  |   2    |  prev  |   N/A  |   4.4    |   -2    |   -14  |&lt;br /&gt;
 |  15  |   2    |  prev  |   N/A  |   4.4    |   -14   |   -14  |&lt;br /&gt;
 +------+--------+--------+--------+----------+---------+--------+&lt;br /&gt;
 |  16  |   3    |  prev  |   N/A  |   4.4    |   -2    |   -8   |&lt;br /&gt;
 |  17  |   3    |  prev  |   N/A  |   4.4    |   -14   |   -8   |&lt;br /&gt;
 |  18  |   3    |  prev  |   N/A  |   4.4    |   -8    |   -2   |&lt;br /&gt;
 |  19  |   3    |  prev  |   N/A  |   4.4    |   -8    |   -14  |&lt;br /&gt;
 |  20  |   3    |  prev  |   N/A  |   4.4    |   -2    |   -2   |&lt;br /&gt;
 |  21  |   3    |  prev  |   N/A  |   4.4    |   -14   |   -2   |&lt;br /&gt;
 |  22  |   3    |  prev  |   N/A  |   4.4    |   -2    |   -14  |&lt;br /&gt;
 |  23  |   3    |  prev  |   N/A  |   4.4    |   -14   |   -14  |&lt;br /&gt;
 +------+--------+--------+--------+----------+---------+--------+&lt;br /&gt;
 |  24  |   4    |  prev  |   N/A  |   4.4    |   -2    |   -8   |&lt;br /&gt;
 |  25  |   4    |  prev  |   N/A  |   4.4    |   -14   |   -8   |&lt;br /&gt;
 |  26  |   4    |  prev  |   N/A  |   4.4    |   -8    |   -2   |&lt;br /&gt;
 |  27  |   4    |  prev  |   N/A  |   4.4    |   -8    |   -14  |&lt;br /&gt;
 |  28  |   4    |  prev  |   N/A  |   4.4    |   -2    |   -2   |&lt;br /&gt;
 |  29  |   4    |  prev  |   N/A  |   4.4    |   -14   |   -2   |&lt;br /&gt;
 |  30  |   4    |  prev  |   N/A  |   4.4    |   -2    |   -14  |&lt;br /&gt;
 |  31  |   4    |  prev  |   N/A  |   4.4    |   -14   |   -14  |&lt;br /&gt;
 +------+--------+--------+--------+----------+---------+--------+&lt;br /&gt;
 |  32  |   2    |  curr  | -65536 |   N/A    |   N/A   |   N/A  |&lt;br /&gt;
 |  33  |   2    |  curr  |   N/A  |   3.5    |   -16   |   -8   |&lt;br /&gt;
 |  34  |   2    |  curr  |   N/A  |   4.4    |   -8    |   -16  |&lt;br /&gt;
 |  35  |   2    |  curr  |   N/A  |   4.4    |   -24   |   -16  |&lt;br /&gt;
 |  36  |   2    |  curr  |   N/A  |   4.4    |   +8    |   -16  |&lt;br /&gt;
 |  37  |   2    |  curr  |   N/A  |   5.3    |   -4    |   -32  |&lt;br /&gt;
 |  38  |   2    |  curr  |   N/A  |   5.3    |   -12   |   -32  |&lt;br /&gt;
 |  39  |   2    |  curr  |   N/A  |   5.3    |   +4    |   -32  |&lt;br /&gt;
 +------+--------+--------+--------+----------+---------+--------+&lt;br /&gt;
 |  40  |   3    |  curr  | -65536 |   N/A    |   N/A   |   N/A  |&lt;br /&gt;
 |  41  |   3    |  curr  |   N/A  |   3.5    |   -16   |   -8   |&lt;br /&gt;
 |  42  |   3    |  curr  |   N/A  |   4.4    |   -8    |   -16  |&lt;br /&gt;
 |  43  |   3    |  curr  |   N/A  |   4.4    |   -24   |   -16  |&lt;br /&gt;
 |  44  |   3    |  curr  |   N/A  |   4.4    |   +8    |   -16  |&lt;br /&gt;
 |  45  |   3    |  curr  |   N/A  |   5.3    |   -4    |   -32  |&lt;br /&gt;
 |  46  |   3    |  curr  |   N/A  |   5.3    |   -12   |   -32  |&lt;br /&gt;
 |  47  |   3    |  curr  |   N/A  |   5.3    |   +4    |   -32  |&lt;br /&gt;
 +------+--------+--------+--------+----------+---------+--------+&lt;br /&gt;
* prev means source is the previous frame, curr - current&lt;br /&gt;
* Y.X means &amp;quot;Y&amp;quot; value in upper Y bits of byte, &amp;quot;X&amp;quot; in lower X bits.&lt;br /&gt;
&lt;br /&gt;
== Trivia ==&lt;br /&gt;
Apparently this format has another less-used name - HNM5.&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
== Games Using UBB ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.mobygames.com/game/megarace-2 Megarace II]&lt;br /&gt;
* lots of others&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Psygnosis_SMV&amp;diff=14024</id>
		<title>Psygnosis SMV</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Psygnosis_SMV&amp;diff=14024"/>
		<updated>2012-03-31T09:20:52Z</updated>

		<summary type="html">&lt;p&gt;VAG: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: smv&lt;br /&gt;
* Company: [[Psygnosis]]&lt;br /&gt;
* Samples: http://cd.textfiles.com/cdaction/cdaction04/FILM/&lt;br /&gt;
&lt;br /&gt;
SMV is a short-lived FMV format used in the PC game [http://www.mobygames.com/game/dos/wipeout Wipeout] by Psygnosis. It employs LZ-like compression to encode 8-bit palettized video and audio.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
An SMV file consist of a number of chunks with unique [[TwoCC]]. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
  u16 chunkid&lt;br /&gt;
  u16 chunklen&lt;br /&gt;
  u8  payload[chunklen]&lt;br /&gt;
&lt;br /&gt;
=== ST chunk ===&lt;br /&gt;
File header. Encodes basic movie properties.&lt;br /&gt;
&lt;br /&gt;
  u16 width           -- movie width&lt;br /&gt;
  u16 height          --  and height&lt;br /&gt;
  u16 mbwidth         -- macroblock width&lt;br /&gt;
  u16 mbheight        --  and height&lt;br /&gt;
  u16 frames          -- number of video frames&lt;br /&gt;
  u16 colors          -- number of used colors&lt;br /&gt;
  u16 nibbles         -- offset of frame's nibble data&lt;br /&gt;
  -- if chunk size is &amp;gt;= 15&lt;br /&gt;
  u8  codec           -- video codec format&lt;br /&gt;
&lt;br /&gt;
* Codec field may be absent, in such case assume codec 0.&lt;br /&gt;
* mbwidth is always 16, mbheight may be either 16 or 8.&lt;br /&gt;
* Movie playback rate is 12 FPS.&lt;br /&gt;
&lt;br /&gt;
=== GP chunk ===&lt;br /&gt;
New palette. Contains a number of 6-bit [[RGB]] entries, as specified in ST chunk.&lt;br /&gt;
&lt;br /&gt;
=== MU chunk ===&lt;br /&gt;
Sound chunk. Contains audio fragment in 15862Hz, 8-bit, unsigned, mono format. If the payload size is equal to the amount of audio data for a frame (i.e. the size is freq / fps, which is equal to 1321) then the audio data is stored in raw [[PCM]] format. Otherwise, it's additionally LZ-word-packed.&lt;br /&gt;
&lt;br /&gt;
=== FR chunk ===&lt;br /&gt;
Frame chunk. Contains encoded video frame.&lt;br /&gt;
&lt;br /&gt;
=== FE chunk ===&lt;br /&gt;
End of the movie. No payload.&lt;br /&gt;
&lt;br /&gt;
== Video Compression ==&lt;br /&gt;
&lt;br /&gt;
=== Video Codec 0 ===&lt;br /&gt;
&lt;br /&gt;
 LZUnpack(payload, temp, words)&lt;br /&gt;
 DrawBlocks(temp)&lt;br /&gt;
&lt;br /&gt;
=== Video Codec 1 ===&lt;br /&gt;
&lt;br /&gt;
 LZUnpack(payload, temp, bytes)&lt;br /&gt;
 DrawBlocks(temp)&lt;br /&gt;
&lt;br /&gt;
=== Video Codec 2 ===&lt;br /&gt;
&lt;br /&gt;
 LZUnpack(payload, temp, bytes)&lt;br /&gt;
 UnpackPartitions(temp, temp2)&lt;br /&gt;
 DrawBlocks(temp2)&lt;br /&gt;
&lt;br /&gt;
UnpackPartitions decodes Macroblock's nibbles.&lt;br /&gt;
&lt;br /&gt;
Source frame is broken on to several equal partitions, 2 across by 4 down. Encoded partitions format:&lt;br /&gt;
&lt;br /&gt;
  u8  pixels[16 * num_mblocks]          -- passed as is to DrawBlocks()&lt;br /&gt;
  for each partition&lt;br /&gt;
    u8  codebook[256][2]                -- nibbles codebook for each partition&lt;br /&gt;
  for each partition&lt;br /&gt;
    for each macroblock&lt;br /&gt;
      u8  index[mb_width*mb_height/4]   -- index of codebook entry&lt;br /&gt;
&lt;br /&gt;
Each entry of codebook encodes 4 nibbles. First byte encodes two nibbles of upper macroblock's line, second - next line, and so on.&lt;br /&gt;
&lt;br /&gt;
=== Video Codec 3 ===&lt;br /&gt;
This codec is never used, but the code is still in place.&lt;br /&gt;
&lt;br /&gt;
 if GetByte()&lt;br /&gt;
   LZUnpack(payload, temp, bytes)&lt;br /&gt;
   UnpackSpecial(temp, temp2)&lt;br /&gt;
   DrawBlocks(temp2)&lt;br /&gt;
 else&lt;br /&gt;
   same as codec 1&lt;br /&gt;
&lt;br /&gt;
UnpackSpecial performs advanced decompression. '''TODO''' ''this may be some common algorithm''&lt;br /&gt;
&lt;br /&gt;
=== Macroblocks drawing ===&lt;br /&gt;
Macroblocks are stored in the following format:&lt;br /&gt;
&lt;br /&gt;
  u8 pixels[16 * num_mblocks]&lt;br /&gt;
  u4 nibbles[num_mblocks]&lt;br /&gt;
&lt;br /&gt;
Size of pixels[] is equal to ST chunk's ''nibbles''.&lt;br /&gt;
For each macroblock draw it by indexing its pixels by nibbles. First nibble stored in top 4 bits of byte.&lt;br /&gt;
&lt;br /&gt;
== Common Algorithms ==&lt;br /&gt;
=== LZ decompression ===&lt;br /&gt;
This is a more-or-less common LZ77-like algorithm. It can operate in two modes: byte mode and words mode. Mode affects backchain offset encoding.&lt;br /&gt;
* &amp;quot;next bit&amp;quot; means next bit from the internal 8-bit bitreader queue. Queue refilled with the input stream bytes, bits are consumed starting from the highest.&lt;br /&gt;
* &amp;quot;next byte&amp;quot; means raw octet from the input stream&lt;br /&gt;
&lt;br /&gt;
  repeat&lt;br /&gt;
 &lt;br /&gt;
    if next bit == 0&lt;br /&gt;
      output next byte&lt;br /&gt;
    else&lt;br /&gt;
      if next bit == 0&lt;br /&gt;
        offset = next byte&lt;br /&gt;
      else&lt;br /&gt;
        if byte mode&lt;br /&gt;
          offset = next 3 bits || next byte  + 1&lt;br /&gt;
        if words mode&lt;br /&gt;
          offset = next 2 bits || next byte  + 1  *2&lt;br /&gt;
 &lt;br /&gt;
      if next bit == 0        length = 2&lt;br /&gt;
      else if next bit == 0   length = 3 + next bit&lt;br /&gt;
      else if next bit == 0   length = 5 + next bit&lt;br /&gt;
      else if next bit == 0   length = 7&lt;br /&gt;
      else if next byte != 0  length = 7 + this byte&lt;br /&gt;
      else finish unpacking&lt;br /&gt;
 &lt;br /&gt;
      copy length bytes from output - offset to output&lt;br /&gt;
       note that, bytes may overlap to repeat itself&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Noctropolis_VID&amp;diff=13907</id>
		<title>Noctropolis VID</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Noctropolis_VID&amp;diff=13907"/>
		<updated>2012-02-20T21:47:42Z</updated>

		<summary type="html">&lt;p&gt;VAG: add another game&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;: ''See also [[VID]]''&lt;br /&gt;
&lt;br /&gt;
* Extensions: vid&lt;br /&gt;
* Company: Flashpoint Productions, Inc.&lt;br /&gt;
* Year: 1994&lt;br /&gt;
* Samples: '''TODO'''&lt;br /&gt;
&lt;br /&gt;
VID is an FMV format first appeared in the computer game [http://www.mobygames.com/game/dos/noctropolis Noctropolis]. Uses basic [[RLE]] compression.&lt;br /&gt;
&lt;br /&gt;
A file consists of a header and a number of frame chunks. All numbers are little endian.&lt;br /&gt;
&lt;br /&gt;
== File header ==&lt;br /&gt;
&lt;br /&gt;
  + 0 s8  Signature[4]   -- &amp;quot;VID&amp;quot;&lt;br /&gt;
  + 4 s8  Version        -- usually 2&lt;br /&gt;
  + 5 s16 Frames         -- number of video frames (not chunks!)&lt;br /&gt;
  + 7 s16 Width          -- frame width and height&lt;br /&gt;
  + 9 s16 Height&lt;br /&gt;
  + B s16 Unknown        -- related to playback speed?&lt;br /&gt;
  + D s16 Rate           -- playback rate (?)&lt;br /&gt;
&lt;br /&gt;
== Frame chunks ==&lt;br /&gt;
Each chunk begins with a byte chunk type then followed by payload of variable length.&lt;br /&gt;
&lt;br /&gt;
=== 0x00 - Intraframe ===&lt;br /&gt;
&lt;br /&gt;
u16 sync value, followed by Width * Height frame raster&lt;br /&gt;
&lt;br /&gt;
=== 0x01 - Interframe ===&lt;br /&gt;
&lt;br /&gt;
u16 sync value, followed by RLE-compressed raster. Version 2 movies has extra zero byte after it (if not ended permaturely by a stop-code.) Decompression algorithm:&lt;br /&gt;
&lt;br /&gt;
 while frame is not complete&lt;br /&gt;
   len = next byte of input&lt;br /&gt;
   if len is 0 finish&lt;br /&gt;
   if high bit of len is set&lt;br /&gt;
     leave (len &amp;amp; 0x7F) pixels unchanged&lt;br /&gt;
   else&lt;br /&gt;
     draw next (len) pixels&lt;br /&gt;
&lt;br /&gt;
=== 0x02 - Palette ===&lt;br /&gt;
&lt;br /&gt;
256 6-bit [[RGB]] [[DAC]] triplets.&lt;br /&gt;
&lt;br /&gt;
=== 0x03 - RLE Intraframe ===&lt;br /&gt;
&lt;br /&gt;
Same as 0x01, but no stop-codes and instead of skipping pixels, fill them with the next byte of input.&lt;br /&gt;
&lt;br /&gt;
=== 0x04 - Partial Interframe ===&lt;br /&gt;
&lt;br /&gt;
Same as 0x01, but has an extra u16 value after the sync field denotes how many horizontal lines to skip before start of decoding.&lt;br /&gt;
&lt;br /&gt;
=== 0x7C - Audio Start ===&lt;br /&gt;
&lt;br /&gt;
u16 sync, followed by u8 sampling frequency in SoundBlaster [[VOC]] format, then followed by u16 size of data and corresponding amount of actual [[PCM]] data in Mono, 8-bit Unsigned format.&lt;br /&gt;
&lt;br /&gt;
=== 0x7D - Audio Continue ===&lt;br /&gt;
&lt;br /&gt;
Same as 0x7C, but no sync/frequency fields.&lt;br /&gt;
&lt;br /&gt;
== Games Using VID ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.mobygames.com/game/dos/noctropolis Noctropolis]&lt;br /&gt;
* [http://www.mobygames.com/game/synnergist Synnergist]&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Origin_Flic_Codec&amp;diff=13906</id>
		<title>Origin Flic Codec</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Origin_Flic_Codec&amp;diff=13906"/>
		<updated>2012-02-20T21:37:07Z</updated>

		<summary type="html">&lt;p&gt;VAG: categorize&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* FourCC: JYV1, JYA1, RRV1, RRV2&lt;br /&gt;
* Company: Origin Systems &lt;br /&gt;
* Samples: ask Mike &lt;br /&gt;
&lt;br /&gt;
''Please rename this codec name to something more original''&lt;br /&gt;
&lt;br /&gt;
Origin Flic Codec is a relatively simple palettized video codec used in PC version of Crusader: No Remorse game. Data is packaged inside standard [[AVI]] container and employs relatively simple [[RLE]] compression. Audio stored in uncompressed [[PCM]] form. It is rumored that codec's FourCCs are actually based on game developer's names (not confirmed.)&lt;br /&gt;
&lt;br /&gt;
== Video Codec ==&lt;br /&gt;
A video movie uses fixed palette, stored in corresponding AVI Stream Format chunk.&lt;br /&gt;
&lt;br /&gt;
Video frame is encoded in a series of slices, where each slice encodes a number of horizontal lines of picture. Number of slices depends on FourCC and is:&lt;br /&gt;
* JYV1, RRV1 - 5 slices&lt;br /&gt;
* RRV2 - 15 slices&lt;br /&gt;
Therefore, each slice contains VideoHeight/slices raster lines.&lt;br /&gt;
&lt;br /&gt;
Frame chunk consist of the following parts:&lt;br /&gt;
&lt;br /&gt;
 u32 slicetable[num_slices]&lt;br /&gt;
 -- for each slice --&lt;br /&gt;
 u32 codes_size;&lt;br /&gt;
 u8 codes[codes_size]&lt;br /&gt;
 u8 raster[]&lt;br /&gt;
 --------------------&lt;br /&gt;
where each entry of slicetable points to corresponding codes/raster block (offsets are relative to beginning of the chunk.)&lt;br /&gt;
&lt;br /&gt;
Video decompression is performed as follows (for each slice):&lt;br /&gt;
&lt;br /&gt;
 flipflop = flip&lt;br /&gt;
 while slice is not complete&lt;br /&gt;
  idx = GetBits(4);&lt;br /&gt;
  blocksize = BaseLength[idx];&lt;br /&gt;
  if idx != 0 and idx != 8&lt;br /&gt;
    blocksize += GetBits(FineLengthBits[idx]);&lt;br /&gt;
  if flipflop == flip&lt;br /&gt;
    leave blocksize pixels unchanged&lt;br /&gt;
  else&lt;br /&gt;
    draw blocksize pixels from raster[]&lt;br /&gt;
  flip flop&lt;br /&gt;
&lt;br /&gt;
  BaseLength[]     = {0, 1&amp;lt;&amp;lt;7, 1&amp;lt;&amp;lt;3, 0, 1&amp;lt;&amp;lt;1,  0, 1&amp;lt;&amp;lt;5, 0,&lt;br /&gt;
                      1, 1&amp;lt;&amp;lt;8, 1&amp;lt;&amp;lt;4, 0, 1&amp;lt;&amp;lt;2,  0, 1&amp;lt;&amp;lt;6, 0};&lt;br /&gt;
  FineLengthBits[] = {0,    7,    3, 0,    1, 16,    5, 0,&lt;br /&gt;
                      1,    8,    4, 0,    2, 24,    6, 0};&lt;br /&gt;
&lt;br /&gt;
GetBits() reads variable number of bits from codes[], highest bits of lowest byte first.&lt;br /&gt;
For RRV* FourCCs 'leave' and 'draw' command skips/doubles each pixel when decoding a keyframe (i.e. a keyframe should be upscaled horizontally.)&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Noctropolis_VID&amp;diff=13905</id>
		<title>Noctropolis VID</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Noctropolis_VID&amp;diff=13905"/>
		<updated>2012-02-20T21:36:02Z</updated>

		<summary type="html">&lt;p&gt;VAG: typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;: ''See also [[VID]]''&lt;br /&gt;
&lt;br /&gt;
* Extensions: vid&lt;br /&gt;
* Company: Flashpoint Productions, Inc.&lt;br /&gt;
* Year: 1994&lt;br /&gt;
* Samples: '''TODO'''&lt;br /&gt;
&lt;br /&gt;
VID is an FMV format used in the computer game [http://www.mobygames.com/game/dos/noctropolis Noctropolis]. Uses basic [[RLE]] compression.&lt;br /&gt;
&lt;br /&gt;
A file consists of a header and a number of frame chunks. All numbers are little endian.&lt;br /&gt;
&lt;br /&gt;
== File header ==&lt;br /&gt;
&lt;br /&gt;
  + 0 s8  Signature[4]   -- &amp;quot;VID&amp;quot;&lt;br /&gt;
  + 4 s8  Version        -- usually 2&lt;br /&gt;
  + 5 s16 Frames         -- number of video frames (not chunks!)&lt;br /&gt;
  + 7 s16 Width          -- frame width and height&lt;br /&gt;
  + 9 s16 Height&lt;br /&gt;
  + B s16 Unknown        -- related to playback speed?&lt;br /&gt;
  + D s16 Rate           -- playback rate (?)&lt;br /&gt;
&lt;br /&gt;
== Frame chunks ==&lt;br /&gt;
Each chunk begins with a byte chunk type then followed by payload of variable length.&lt;br /&gt;
&lt;br /&gt;
=== 0x00 - Intraframe ===&lt;br /&gt;
&lt;br /&gt;
u16 sync value, followed by Width * Height frame raster&lt;br /&gt;
&lt;br /&gt;
=== 0x01 - Interframe ===&lt;br /&gt;
&lt;br /&gt;
u16 sync value, followed by RLE-compressed raster. Version 2 movies has extra zero byte after it (if not ended permaturely by a stop-code.) Decompression algorithm:&lt;br /&gt;
&lt;br /&gt;
 while frame is not complete&lt;br /&gt;
   len = next byte of input&lt;br /&gt;
   if len is 0 finish&lt;br /&gt;
   if high bit of len is set&lt;br /&gt;
     leave (len &amp;amp; 0x7F) pixels unchanged&lt;br /&gt;
   else&lt;br /&gt;
     draw next (len) pixels&lt;br /&gt;
&lt;br /&gt;
=== 0x02 - Palette ===&lt;br /&gt;
&lt;br /&gt;
256 6-bit [[RGB]] [[DAC]] triplets.&lt;br /&gt;
&lt;br /&gt;
=== 0x03 - RLE Intraframe ===&lt;br /&gt;
&lt;br /&gt;
Same as 0x01, but no stop-codes and instead of skipping pixels, fill them with the next byte of input.&lt;br /&gt;
&lt;br /&gt;
=== 0x04 - Partial Interframe ===&lt;br /&gt;
&lt;br /&gt;
Same as 0x01, but has an extra u16 value after the sync field denotes how many horizontal lines to skip before start of decoding.&lt;br /&gt;
&lt;br /&gt;
=== 0x7C - Audio Start ===&lt;br /&gt;
&lt;br /&gt;
u16 sync, followed by u8 sampling frequency in SoundBlaster [[VOC]] format, then followed by u16 size of data and corresponding amount of actual [[PCM]] data in Mono, 8-bit Unsigned format.&lt;br /&gt;
&lt;br /&gt;
=== 0x7D - Audio Continue ===&lt;br /&gt;
&lt;br /&gt;
Same as 0x7C, but no sync/frequency fields.&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Origin_Flic_Codec&amp;diff=13865</id>
		<title>Origin Flic Codec</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Origin_Flic_Codec&amp;diff=13865"/>
		<updated>2012-02-17T00:44:18Z</updated>

		<summary type="html">&lt;p&gt;VAG: doh!&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* FourCC: JYV1, JYA1, RRV1, RRV2&lt;br /&gt;
* Company: Origin Systems &lt;br /&gt;
* Samples: ask Mike &lt;br /&gt;
&lt;br /&gt;
''Please rename this codec name to something more original''&lt;br /&gt;
&lt;br /&gt;
Origin Flic Codec is a relatively simple palettized video codec used in PC version of Crusader: No Remorse game. Data is packaged inside standard [[AVI]] container and employs relatively simple [[RLE]] compression. Audio stored in uncompressed [[PCM]] form. It is rumored that codec's FourCCs are actually based on game developer's names (not confirmed.)&lt;br /&gt;
&lt;br /&gt;
== Video Codec ==&lt;br /&gt;
A video movie uses fixed palette, stored in corresponding AVI Stream Format chunk.&lt;br /&gt;
&lt;br /&gt;
Video frame is encoded in a series of slices, where each slice encodes a number of horizontal lines of picture. Number of slices depends on FourCC and is:&lt;br /&gt;
* JYV1, RRV1 - 5 slices&lt;br /&gt;
* RRV2 - 15 slices&lt;br /&gt;
Therefore, each slice contains VideoHeight/slices raster lines.&lt;br /&gt;
&lt;br /&gt;
Frame chunk consist of the following parts:&lt;br /&gt;
&lt;br /&gt;
 u32 slicetable[num_slices]&lt;br /&gt;
 -- for each slice --&lt;br /&gt;
 u32 codes_size;&lt;br /&gt;
 u8 codes[codes_size]&lt;br /&gt;
 u8 raster[]&lt;br /&gt;
 --------------------&lt;br /&gt;
where each entry of slicetable points to corresponding codes/raster block (offsets are relative to beginning of the chunk.)&lt;br /&gt;
&lt;br /&gt;
Video decompression is performed as follows (for each slice):&lt;br /&gt;
&lt;br /&gt;
 flipflop = flip&lt;br /&gt;
 while slice is not complete&lt;br /&gt;
  idx = GetBits(4);&lt;br /&gt;
  blocksize = BaseLength[idx];&lt;br /&gt;
  if idx != 0 and idx != 8&lt;br /&gt;
    blocksize += GetBits(FineLengthBits[idx]);&lt;br /&gt;
  if flipflop == flip&lt;br /&gt;
    leave blocksize pixels unchanged&lt;br /&gt;
  else&lt;br /&gt;
    draw blocksize pixels from raster[]&lt;br /&gt;
  flip flop&lt;br /&gt;
&lt;br /&gt;
  BaseLength[]     = {0, 1&amp;lt;&amp;lt;7, 1&amp;lt;&amp;lt;3, 0, 1&amp;lt;&amp;lt;1,  0, 1&amp;lt;&amp;lt;5, 0,&lt;br /&gt;
                      1, 1&amp;lt;&amp;lt;8, 1&amp;lt;&amp;lt;4, 0, 1&amp;lt;&amp;lt;2,  0, 1&amp;lt;&amp;lt;6, 0};&lt;br /&gt;
  FineLengthBits[] = {0,    7,    3, 0,    1, 16,    5, 0,&lt;br /&gt;
                      1,    8,    4, 0,    2, 24,    6, 0};&lt;br /&gt;
&lt;br /&gt;
GetBits() reads variable number of bits from codes[], highest bits of lowest byte first.&lt;br /&gt;
For RRV* FourCCs 'leave' and 'draw' command skips/doubles each pixel when decoding a keyframe (i.e. a keyframe should be upscaled horizontally.)&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Origin_Flic_Codec&amp;diff=13864</id>
		<title>Origin Flic Codec</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Origin_Flic_Codec&amp;diff=13864"/>
		<updated>2012-02-17T00:42:50Z</updated>

		<summary type="html">&lt;p&gt;VAG: ok, you asked for it&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* FourCC: JYV1, JYA1, RRV1, RRV2&lt;br /&gt;
* Company: Origin Systems &lt;br /&gt;
* Samples: ask Mike &lt;br /&gt;
&lt;br /&gt;
''Please rename this codec name to something more original''&lt;br /&gt;
&lt;br /&gt;
Origin Flic Codec is a relatively simple palettized video codec used in PC version of Crusader: No Remorse game. Data is packaged inside standard [[AVI]] container and employs relatively simple [[RLE]] compression. Audio stored in uncompressed [[PCM]] form. It is rumored that codec's FourCCs are actually based on game developer's names (not confirmed.)&lt;br /&gt;
&lt;br /&gt;
== Video Codec ==&lt;br /&gt;
A video movie uses fixed palette, stored in corresponding AVI Stream Format chunk.&lt;br /&gt;
&lt;br /&gt;
Video frame is encoded in a series of slices, where each slice encodes a number of horizontal lines of picture. Number of slices depends on FourCC and is:&lt;br /&gt;
* JYV1, RRV1 - 5 slices&lt;br /&gt;
* RRV2 - 15 slices&lt;br /&gt;
Therefore, each slice contains VideoWidth/slices raster lines.&lt;br /&gt;
&lt;br /&gt;
Frame chunk consist of the following parts:&lt;br /&gt;
&lt;br /&gt;
 u32 slicetable[num_slices]&lt;br /&gt;
 -- for each slice --&lt;br /&gt;
 u32 codes_size;&lt;br /&gt;
 u8 codes[codes_size]&lt;br /&gt;
 u8 raster[]&lt;br /&gt;
 --------------------&lt;br /&gt;
where each entry of slicetable points to corresponding codes/raster block (offsets are relative to beginning of the chunk.)&lt;br /&gt;
&lt;br /&gt;
Video decompression is performed as follows (for each slice):&lt;br /&gt;
&lt;br /&gt;
 flipflop = flip&lt;br /&gt;
 while slice is not complete&lt;br /&gt;
  idx = GetBits(4);&lt;br /&gt;
  blocksize = BaseLength[idx];&lt;br /&gt;
  if idx != 0 and idx != 8&lt;br /&gt;
    blocksize += GetBits(FineLengthBits[idx]);&lt;br /&gt;
  if flipflop == flip&lt;br /&gt;
    leave blocksize pixels unchanged&lt;br /&gt;
  else&lt;br /&gt;
    draw blocksize pixels from raster[]&lt;br /&gt;
  flip flop&lt;br /&gt;
&lt;br /&gt;
  BaseLength[]     = {0, 1&amp;lt;&amp;lt;7, 1&amp;lt;&amp;lt;3, 0, 1&amp;lt;&amp;lt;1,  0, 1&amp;lt;&amp;lt;5, 0,&lt;br /&gt;
                      1, 1&amp;lt;&amp;lt;8, 1&amp;lt;&amp;lt;4, 0, 1&amp;lt;&amp;lt;2,  0, 1&amp;lt;&amp;lt;6, 0};&lt;br /&gt;
  FineLengthBits[] = {0,    7,    3, 0,    1, 16,    5, 0,&lt;br /&gt;
                      1,    8,    4, 0,    2, 24,    6, 0};&lt;br /&gt;
&lt;br /&gt;
GetBits() reads variable number of bits from codes[], highest bits of lowest byte first.&lt;br /&gt;
For RRV* FourCCs 'leave' and 'draw' command skips/doubles each pixel when decoding a keyframe (i.e. a keyframe should be upscaled horizontally.)&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=13831</id>
		<title>HNM6</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=HNM6&amp;diff=13831"/>
		<updated>2012-02-05T17:30:54Z</updated>

		<summary type="html">&lt;p&gt;VAG: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: hnm &lt;br /&gt;
* Company: CRYO Interactive Entertainment &lt;br /&gt;
* Samples: &lt;br /&gt;
&lt;br /&gt;
HNM6 is the latest variant of [[HNM]] video format by Cryo. Unlike its previous versions, it has Hi-color video support.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
File consist of a main header, followed by frame chunks. Each frame chunk consist of individual audio and video chunks. All numbers are little-endian.&lt;br /&gt;
&lt;br /&gt;
 u8   sig[4]           -- file signature, &amp;quot;HNM6&amp;quot;&lt;br /&gt;
 u8   reserved[3]&lt;br /&gt;
 u8   bpp&lt;br /&gt;
 u16  width&lt;br /&gt;
 u16  height&lt;br /&gt;
 u32  filesize&lt;br /&gt;
 u32  frames&lt;br /&gt;
 u32  reserved2&lt;br /&gt;
 u32  maxbuffer        -- max buffer size (typically 0x20000)&lt;br /&gt;
 u32  maxchunk         -- max frame chunk size&lt;br /&gt;
 u8   note[16]&lt;br /&gt;
 u8   copyright[16]    -- &amp;quot;-Copyright CRYO-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Each frame chunk begins with u32 chunk size (including this size field), then followed by individual chunks:&lt;br /&gt;
&lt;br /&gt;
  u32  chunksize       -- chunk size including this field, excluding padding&lt;br /&gt;
  u16  chunkid         -- TWOCC chunk id&lt;br /&gt;
  u16  reserved&lt;br /&gt;
  u8   data[]&lt;br /&gt;
  u8   padding[]       -- pads chunk to 4-byte boundary&lt;br /&gt;
&lt;br /&gt;
=== AA Chunk ===&lt;br /&gt;
APC Audio. See [[CRYO APC]]&lt;br /&gt;
&lt;br /&gt;
=== BB Chunk ===&lt;br /&gt;
Audio continuation.&lt;br /&gt;
&lt;br /&gt;
=== IX Chunk ===&lt;br /&gt;
Video frame.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Noctropolis_VID&amp;diff=13580</id>
		<title>Noctropolis VID</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Noctropolis_VID&amp;diff=13580"/>
		<updated>2011-08-06T13:08:36Z</updated>

		<summary type="html">&lt;p&gt;VAG: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;: ''See also [[VID]]''&lt;br /&gt;
&lt;br /&gt;
* Extensions: vid&lt;br /&gt;
* Company: Flashpoint Productions, Inc.&lt;br /&gt;
* Year: 1994&lt;br /&gt;
* Samples: '''TODO'''&lt;br /&gt;
&lt;br /&gt;
VID is an FMV format used in the computer game [http://www.mobygames.com/game/dos/noctropolis Noctropolis]. Uses basic [[RLE]] compression.&lt;br /&gt;
&lt;br /&gt;
A file consists of a header and a number of frame chunks. All numbers are little endian.&lt;br /&gt;
&lt;br /&gt;
== File header ==&lt;br /&gt;
&lt;br /&gt;
  + 0 s8  Signature[4]   -- &amp;quot;VID&amp;quot;&lt;br /&gt;
  + 4 s8  Version        -- usually 2&lt;br /&gt;
  + 5 s16 Frames         -- number of video frames (not chunks!)&lt;br /&gt;
  + 7 s16 Width          -- frame width and height&lt;br /&gt;
  + 9 s16 Height&lt;br /&gt;
  + B s16 Unknown        -- releated to playback speed?&lt;br /&gt;
  + D s16 Rate           -- playback rate (?)&lt;br /&gt;
&lt;br /&gt;
== Frame chunks ==&lt;br /&gt;
Each chunk begins with a byte chunk type then followed by payload of variable length.&lt;br /&gt;
&lt;br /&gt;
=== 0x00 - Intraframe ===&lt;br /&gt;
&lt;br /&gt;
u16 sync value, followed by Width * Height frame raster&lt;br /&gt;
&lt;br /&gt;
=== 0x01 - Interframe ===&lt;br /&gt;
&lt;br /&gt;
u16 sync value, followed by RLE-compressed raster. Version 2 movies has extra zero byte after this (if not ended permaturely by a stop-code.) Decompression algorithm:&lt;br /&gt;
&lt;br /&gt;
 while frame is not complete&lt;br /&gt;
   len = next byte of input&lt;br /&gt;
   if len is 0 finish&lt;br /&gt;
   if high bit of len is set&lt;br /&gt;
     leave (len &amp;amp; 0x7F) pixels unchanged&lt;br /&gt;
   else&lt;br /&gt;
     draw next (len) pixels&lt;br /&gt;
&lt;br /&gt;
=== 0x02 - Palette ===&lt;br /&gt;
&lt;br /&gt;
256 6-bit [[RGB]] [[DAC]] triplets.&lt;br /&gt;
&lt;br /&gt;
=== 0x03 - RLE Intraframe ===&lt;br /&gt;
&lt;br /&gt;
Same as 0x01, but no stop-codes and instead of skipping pixels, fill them with the next byte of input.&lt;br /&gt;
&lt;br /&gt;
=== 0x04 - Partial Interframe ===&lt;br /&gt;
&lt;br /&gt;
Same as 0x01, but has an extra u16 value after the sync field denotes how many horizontal lines to skip before start of decoding.&lt;br /&gt;
&lt;br /&gt;
=== 0x7C - Audio Start ===&lt;br /&gt;
&lt;br /&gt;
u16 sync, followed by u8 sampling frequency in SoundBlaster [[VOC]] format, then followed by u16 size of data and corresponding amount of actual [[PCM]] data in Mono, 8-bit Unsigned format.&lt;br /&gt;
&lt;br /&gt;
=== 0x7D - Audio Continue ===&lt;br /&gt;
&lt;br /&gt;
Same as 0x7C, but no sync/frequency fields.&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Electronic_Arts_Formats&amp;diff=13569</id>
		<title>Electronic Arts Formats</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Electronic_Arts_Formats&amp;diff=13569"/>
		<updated>2011-07-30T22:54:16Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* Games Using Electronic Arts Multimedia Formats */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extensions: ASF, CMV, DCT, SND, TGI, TGV, TGQ, WVE, UV, UV2, VID, MAD, VP6&lt;br /&gt;
* Company: [[Electronic Arts]]&lt;br /&gt;
&lt;br /&gt;
Electronic Arts, the video game publishing empire, and the various constituent development houses under its umbrella, have deployed a number of multimedia formats in its games.&lt;br /&gt;
&lt;br /&gt;
EA multimedia formats are comprised of a series of blocks with the following format:&lt;br /&gt;
&lt;br /&gt;
 bytes 0-3    block type [[FourCC]]&lt;br /&gt;
 bytes 4-7    block size (including this 8-byte preamble)&lt;br /&gt;
 bytes 8..    block payload&lt;br /&gt;
&lt;br /&gt;
It is important to note that there is no consistent byte order for multi-byte numbers. However, order is optimized for target platform, i.e. little-endian for PC/PS/XBOX and big-endian for Mac/Saturn/GameCube.&lt;br /&gt;
&lt;br /&gt;
== Chunk Types ==&lt;br /&gt;
&lt;br /&gt;
* Audio&lt;br /&gt;
** [[Electronic Arts SEAD]]: SEAD, SNDC, SEND&lt;br /&gt;
** [[Electronic Arts 1SNx]]: 1SNh, 1SNd, 1SNl, 1SNe&lt;br /&gt;
** [[Electronic Arts SCxl]]: SCHl, SCCl, SCDl, SCLl, SCEl, and SHEN, SCEN, SDEN, SEEN&lt;br /&gt;
* Video&lt;br /&gt;
** [[Electronic Arts CMV]]: MVIh, MVIf, MVIe&lt;br /&gt;
** [[Electronic Arts TGV]]: kVGT, fVGT&lt;br /&gt;
** [[Electronic Arts DCT]]: mTCD&lt;br /&gt;
** [[Electronic Arts TGQ]]: pQTG, TGQs (rumored MUVf?)&lt;br /&gt;
** [[Electronic Arts TQI]]: pIQT, (rumored UV2f?)&lt;br /&gt;
** [[Electronic Arts MAD]]: MADk, MADm, MADe&lt;br /&gt;
** [[Electronic Arts VP6]]: MVhd, MV0K, MV0F&lt;br /&gt;
** [[Electronic Arts MPC]]: MPCh&lt;br /&gt;
&lt;br /&gt;
== Games Using Electronic Arts Multimedia Formats ==&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! Name !! File Ext !! Video Codec !! Audio Codec || Byte Order&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/dos/nhl-95 NHL 95]&lt;br /&gt;
| cmv || CMV || none || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/dos/nhl-96 NHL 96]&lt;br /&gt;
| tgv || ? || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/dos/cybermage-darklight-awakening CyberMage: Darklight Awakening]&lt;br /&gt;
| tgv || TGV || 1SNx/EACS/pcm_s8 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-96 FIFA '96]&lt;br /&gt;
| tgv || TGV || 1SNx/EACS/pcm_s16 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-97 FIFA '97]&lt;br /&gt;
| tgv || TGV || SCHl/PATl/TMpl/adpcm_ima_? || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-98 FIFA '98]&lt;br /&gt;
| dct || DCT || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-99 FIFA '99]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed Need for Speed]&lt;br /&gt;
| tgv || TGV || 1SNx/EACS/pcm_s8 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/privateer-2-the-darkening Privateer 2: The Darkening]&lt;br /&gt;
| tgv || TGV || SEAD/adpcm_ima_ea_sead || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/dos/nba-live-96 NBA Live 96]&lt;br /&gt;
| tgv || TGV || 1SNh/EACS/adpcm_ima_ea_eacs || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-ii Need for Speed 2]&lt;br /&gt;
| dct || DCT || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-ii Need for Speed 2 (Demo)]&lt;br /&gt;
| uv || TGQ || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|[http://www.mobygames.com/game/beasts-bumpkins Beasts and Bumpkins]&lt;br /&gt;
| vid || TQI || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| m10 || none || PT/microtalk10:1? || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/dungeon-keeper-2 Dungeon Keeper 2]&lt;br /&gt;
| tgq || TQI (no typo) || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/saturn/warcraft-ii-the-dark-saga Warcraft II: The Dark Saga (Sega Saturn)]&lt;br /&gt;
| tgq || TGQ || ? || be&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/superbike-2001 Superbike 2001]&lt;br /&gt;
| tgq || TQI (yes) || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/saturn/crusader-no-remorse Crusader: No Remorse (Sega Saturn)]&lt;br /&gt;
| tgq || TGQ || 1SNh/EACS/mulaw || be&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/harry-potter-quidditch-world-cup Harry Potter: Quidditch World Cup]&lt;br /&gt;
| tgq || TQI (not a typo) || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/wing-commander-prophecy Wing Commander: Prophecy]&lt;br /&gt;
| wve || TQI || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/the-sims The Sims]&lt;br /&gt;
| wve || TQI || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/nba-live-99 NBA Live 99]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-iii-hot-pursuit Need for Speed 3: Hot Pursuit]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-high-stakes Need for Speed 4: High Stakes]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-porsche-unleashed Need for Speed 5: Porsche]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea_r1 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-hot-pursuit-2 Need for Speed 6: Hot Pursuit 2]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea_r1 || le&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot;| [http://www.mobygames.com/game/nba-live-2003 NBA Live 2003]&lt;br /&gt;
| mad || MAD || pcm_s16le_planar || le&lt;br /&gt;
|-&lt;br /&gt;
| asf || none || SCHl/PT/mp3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-2005 FIFA 2004]&lt;br /&gt;
| mad || ? || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-2005 FIFA 2005]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea_r1, SCHl/PT/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/simcity-4-rush-hour Sim City 4: Rush Hour]&lt;br /&gt;
| mad || MAD || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/sims-2 The Sims 2]&lt;br /&gt;
| mad || MAD || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/ps2/need-for-speed-underground Need for Speed: Underground (PlayStation 2)]&lt;br /&gt;
| mpc || MPC || SCHl/PT/adpcm_ea_r2 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/ps2/fifa-soccer-07 FIFA 2007 (PlayStation 2)]&lt;br /&gt;
| mpc || MPC || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-underground-2 Need for Speed: Underground 2]&lt;br /&gt;
| vp6 || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-most-wanted Need for Speed: Most Wanted]&lt;br /&gt;
| vp6 || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-carbon Need for Speed: Carbon]&lt;br /&gt;
| vp6 || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/lord-of-the-rings-the-battle-for-middle-earth The Lord of the Rings: The Battle for Middle Earth]&lt;br /&gt;
| vp6 || VP6 || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/lord-of-the-rings-the-battle-for-middle-earth-ii The Lord of the Rings: The Battle for Middle Earth II]&lt;br /&gt;
| vp6 || VP6 || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/lord-of-the-rings-the-battle-for-middle-earth-ii-the-rise-of-the The Lord of the Rings: The Battle for Middle Earth II - The Rise of the Witch-King]&lt;br /&gt;
| vp6 || VP6 || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/command-conquer-3-tiberium-wars Command &amp;amp; Conquer: Tiberium Wars]&lt;br /&gt;
| vp6/snd || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/command-conquer-3-kanes-wrath Command &amp;amp; Conquer: Tiberium Wars: Kane's Wrath]&lt;br /&gt;
| vp6/snd || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-prostreet Need for Speed: Pro Street]&lt;br /&gt;
| vp6 || VP6 || SHEN/GSTR/ealayer3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/command-conquer-red-alert-3 Red Alert 3]&lt;br /&gt;
| vp6/snd || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| Red Alert 3: Uprising&lt;br /&gt;
| vp6/snd || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/burnout-paradise-the-ultimate-box Burnout Paradise: The Ultimate Box]&lt;br /&gt;
| vp6/sns || VP6 || ealayer3 w/o header || le&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In addition to FMV, the EA audio chunk types are frequently used throughout Electronic Arts games for music tracks, audio effects and speech. Older titles use the .ASF file extension for individual music tracks, whereas newer titles store multiple audio sequentially within the one file (hence rational for the ending chunk types) and use a variety of file extensions. &lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Electronic_Arts_SCxl&amp;diff=13568</id>
		<title>Electronic Arts SCxl</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Electronic_Arts_SCxl&amp;diff=13568"/>
		<updated>2011-07-30T22:46:33Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* SCHl or SHEN */ dirty PATl/TMpl info&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Company: [[Electronic Arts]]&lt;br /&gt;
* Samples: TBD.&lt;br /&gt;
&lt;br /&gt;
SCxl is an audio stream format used in various games published by companies under the Electronic Arts umbrella.&lt;br /&gt;
&lt;br /&gt;
== Chunk Types ==&lt;br /&gt;
See [[Electronic Arts Formats]] for file format description.&lt;br /&gt;
&lt;br /&gt;
=== SCHl or SHEN ===&lt;br /&gt;
Header. Contains special Patch record, describes all vital audio parameters.&lt;br /&gt;
&lt;br /&gt;
==== PATl patch ====&lt;br /&gt;
Used in very old files.&lt;br /&gt;
&lt;br /&gt;
* PATl block&lt;br /&gt;
&lt;br /&gt;
  offset type   description&lt;br /&gt;
      0  byte   Tag, &amp;quot;PATl&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''TODO'''&lt;br /&gt;
&lt;br /&gt;
* TMpl block&lt;br /&gt;
&lt;br /&gt;
  offset type   description&lt;br /&gt;
      0  byte   Tag, &amp;quot;TMpl&amp;quot;&lt;br /&gt;
      4  byte   Version, 0&lt;br /&gt;
      5  byte   Sample width (bits)&lt;br /&gt;
      6  byte   Channels&lt;br /&gt;
      7  byte   ?&lt;br /&gt;
      8  byte   ?&lt;br /&gt;
      9  byte   ?&lt;br /&gt;
      A  int16  Frequency&lt;br /&gt;
      C  int32  ?&lt;br /&gt;
     10  int32  ?&lt;br /&gt;
     14  int32  ?&lt;br /&gt;
     18  int32  ?&lt;br /&gt;
&lt;br /&gt;
==== PT patch ====&lt;br /&gt;
&lt;br /&gt;
  offset type   description&lt;br /&gt;
      0  byte   Tag, should be 'PT'&lt;br /&gt;
      2  int16  Platform identifier&lt;br /&gt;
                 0x00  PC&lt;br /&gt;
                 0x03  Macintosh&lt;br /&gt;
                 0x05  Playstation 2&lt;br /&gt;
                 0x06  Game Cube&lt;br /&gt;
                 0x07  Xbox&lt;br /&gt;
                 0x09  Xenon (Xbox 360)&lt;br /&gt;
                 0x0A  PSP&lt;br /&gt;
      4  ...    Patch substream&lt;br /&gt;
&lt;br /&gt;
===== Default Audio Format =====&lt;br /&gt;
&lt;br /&gt;
* 16 bits&lt;br /&gt;
* Mono&lt;br /&gt;
* 22050 kHz&lt;br /&gt;
* XA compression&lt;br /&gt;
&lt;br /&gt;
==== GSTR patch ====&lt;br /&gt;
&lt;br /&gt;
  offset type   description&lt;br /&gt;
      0  byte   Tag, should be 'GSTR'&lt;br /&gt;
      4  int32  Unknown, presumably version or platform id&lt;br /&gt;
      8  ...    Patch substream&lt;br /&gt;
&lt;br /&gt;
===== Default Audio Format =====&lt;br /&gt;
&lt;br /&gt;
* 16 bits&lt;br /&gt;
* Mono&lt;br /&gt;
* 48000 kHz&lt;br /&gt;
* XA compression&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Patch substream ====&lt;br /&gt;
&lt;br /&gt;
Patch substream consist of a series of small chunks, tagged with unique byte identifiers. General substream format is:&lt;br /&gt;
&lt;br /&gt;
 Tag[, Length, Data][, ...]&lt;br /&gt;
&lt;br /&gt;
* Tag is an unique identifier of the data. Several tags doesn't contain any data, thus, has no Length and Data fields.&lt;br /&gt;
* Length is a single byte, unless it's value is 0xFF. In this case, extra 4-bytes value of the actual length follows, stored in big-endian order.&lt;br /&gt;
* Data is a big-endian number of Length bytes total, meaning is specific to particular Tag.&lt;br /&gt;
&lt;br /&gt;
Note, that patch substream may not include various tags/values or even be completely empty at all. In this case default audio parameters is used (listed above).&lt;br /&gt;
&lt;br /&gt;
==== Known patch tags ====&lt;br /&gt;
&lt;br /&gt;
* 0x00 - Unknown&lt;br /&gt;
* 0x05 - Unknown&lt;br /&gt;
* 0x0B - Unknown&lt;br /&gt;
* 0x13 - Unknown&lt;br /&gt;
* 0x1B - Unknown&lt;br /&gt;
* 0x80 - Compression version.&lt;br /&gt;
          0x01   EA XA ADPCM R1&lt;br /&gt;
          0x02   EA XA ADPCM R2&lt;br /&gt;
          0x03   EA XA ADPCM R3&lt;br /&gt;
* 0x82 - Number of channels.&lt;br /&gt;
* 0x83 - Compression type.&lt;br /&gt;
          0x00   PCM Signed Interleaved Data&lt;br /&gt;
          0x07   EA XA ADPCM&lt;br /&gt;
          0x09   Unknown&lt;br /&gt;
* 0x84 - Sample rate (Hertz).&lt;br /&gt;
* 0x85 - Total count of samples in the stream.&lt;br /&gt;
* 0x86 - Loop offset&lt;br /&gt;
* 0x87 - Loop length&lt;br /&gt;
* 0x88 - Data offset (relevant only to Electronic Arts Bank Format)&lt;br /&gt;
* 0x8A - End of the format description substream. No data.&lt;br /&gt;
* 0x8C - Unknown&lt;br /&gt;
* 0x92 - Bytes per sample&lt;br /&gt;
* 0x9C - Unknown&lt;br /&gt;
* 0x9D - Unknown&lt;br /&gt;
* 0xA0 - Compression type.&lt;br /&gt;
          0x00*  PCM Signed 16-bit Interleaved (LE)&lt;br /&gt;
          0x01*  PCM Signed 16-bit Interleaved (BE)&lt;br /&gt;
          0x02*  PCM Signed 8-bit Interleaved&lt;br /&gt;
          0x04   MicroTalk 10:1&lt;br /&gt;
          0x05*  VAG ADPCM&lt;br /&gt;
          0x07*  PCM Signed 16-bit Planar (BE)&lt;br /&gt;
          0x08   PCM Signed 16-bit Planar (LE)&lt;br /&gt;
          0x09   PCM Signed 8-bit Planar&lt;br /&gt;
          0x0A   EA XA ADPCM&lt;br /&gt;
          0x0B*  PCM Unsigned 8-bit Interleaved&lt;br /&gt;
          0x0C*  CD XA&lt;br /&gt;
          0x0E*  MP3 Layer 1&lt;br /&gt;
          0x0F*  MP3 Layer 2&lt;br /&gt;
          0x10   MP3 Layer 3&lt;br /&gt;
          0x12*  Game Cube ADPCM&lt;br /&gt;
          0x13*  PCM Signed 24-bit Interleaved (LE)&lt;br /&gt;
          0x14*  XBOX ADPCM&lt;br /&gt;
          0x15*  PCM Signed 24-bit Interleaved (BE)&lt;br /&gt;
          0x16   MicroTalk 5:1&lt;br /&gt;
          0x17   EALayer3&lt;br /&gt;
 * Denotes codec supported by [[Electronic Arts Sound eXchange]], but has not yet been observed in a computer game.&lt;br /&gt;
* 0xFC, 0xFD - Begin the format description portion of substream. No data.&lt;br /&gt;
* 0xFE - Begin of the envelope portion of substeam. No Data.&lt;br /&gt;
* 0xFF - End of substream. No data.&lt;br /&gt;
&lt;br /&gt;
=== SCCl or SCEN ===&lt;br /&gt;
Holds single 4-byte value, indicates total number of SCDl or SDEN chunks in the stream.&lt;br /&gt;
&lt;br /&gt;
=== SCDl or SDEN ===&lt;br /&gt;
Data. Actual audio data in format, specified by SCHl or SHEN chunk.&lt;br /&gt;
&lt;br /&gt;
=== SCLl ===&lt;br /&gt;
Loop.&lt;br /&gt;
&lt;br /&gt;
=== SCEl or SEEN ===&lt;br /&gt;
End. Indicates end of the stream. Contains no data.&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Electronic_Arts_Formats&amp;diff=13567</id>
		<title>Electronic Arts Formats</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Electronic_Arts_Formats&amp;diff=13567"/>
		<updated>2011-07-30T22:15:08Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* Games Using Electronic Arts Multimedia Formats */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extensions: ASF, CMV, DCT, SND, TGI, TGV, TGQ, WVE, UV, UV2, VID, MAD, VP6&lt;br /&gt;
* Company: [[Electronic Arts]]&lt;br /&gt;
&lt;br /&gt;
Electronic Arts, the video game publishing empire, and the various constituent development houses under its umbrella, have deployed a number of multimedia formats in its games.&lt;br /&gt;
&lt;br /&gt;
EA multimedia formats are comprised of a series of blocks with the following format:&lt;br /&gt;
&lt;br /&gt;
 bytes 0-3    block type [[FourCC]]&lt;br /&gt;
 bytes 4-7    block size (including this 8-byte preamble)&lt;br /&gt;
 bytes 8..    block payload&lt;br /&gt;
&lt;br /&gt;
It is important to note that there is no consistent byte order for multi-byte numbers. However, order is optimized for target platform, i.e. little-endian for PC/PS/XBOX and big-endian for Mac/Saturn/GameCube.&lt;br /&gt;
&lt;br /&gt;
== Chunk Types ==&lt;br /&gt;
&lt;br /&gt;
* Audio&lt;br /&gt;
** [[Electronic Arts SEAD]]: SEAD, SNDC, SEND&lt;br /&gt;
** [[Electronic Arts 1SNx]]: 1SNh, 1SNd, 1SNl, 1SNe&lt;br /&gt;
** [[Electronic Arts SCxl]]: SCHl, SCCl, SCDl, SCLl, SCEl, and SHEN, SCEN, SDEN, SEEN&lt;br /&gt;
* Video&lt;br /&gt;
** [[Electronic Arts CMV]]: MVIh, MVIf, MVIe&lt;br /&gt;
** [[Electronic Arts TGV]]: kVGT, fVGT&lt;br /&gt;
** [[Electronic Arts DCT]]: mTCD&lt;br /&gt;
** [[Electronic Arts TGQ]]: pQTG, TGQs (rumored MUVf?)&lt;br /&gt;
** [[Electronic Arts TQI]]: pIQT, (rumored UV2f?)&lt;br /&gt;
** [[Electronic Arts MAD]]: MADk, MADm, MADe&lt;br /&gt;
** [[Electronic Arts VP6]]: MVhd, MV0K, MV0F&lt;br /&gt;
** [[Electronic Arts MPC]]: MPCh&lt;br /&gt;
&lt;br /&gt;
== Games Using Electronic Arts Multimedia Formats ==&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! Name !! File Ext !! Video Codec !! Audio Codec || Byte Order&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/dos/nhl-95 NHL 95]&lt;br /&gt;
| cmv || CMV || none || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/dos/nhl-96 NHL 96]&lt;br /&gt;
| tgv || ? || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/dos/cybermage-darklight-awakening CyberMage: Darklight Awakening]&lt;br /&gt;
| tgv || TGV || 1SNx/EACS/pcm_s8 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-96 FIFA '96]&lt;br /&gt;
| tgv || TGV || 1SNx/EACS/pcm_s16 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-97 FIFA '97]&lt;br /&gt;
| tgv || TGV || SCHl/PATl/TMpl/adpcm_ima_? || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-98 FIFA '98]&lt;br /&gt;
| dct || DCT || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-99 FIFA '99]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed Need for Speed]&lt;br /&gt;
| tgv || TGV || 1SNx/EACS/pcm_s8 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/privateer-2-the-darkening Privateer 2: The Darkening]&lt;br /&gt;
| tgv || TGV || SEAD/adpcm_ima_ea_sead || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/dos/nba-live-96 NBA Live 96]&lt;br /&gt;
| tgv || TGV || 1SNh/EACS/adpcm_ima_ea_eacs || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-ii Need for Speed 2]&lt;br /&gt;
| dct || DCT || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-ii Need for Speed 2 (Demo)]&lt;br /&gt;
| uv || TGQ || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|[http://www.mobygames.com/game/beasts-bumpkins Beasts and Bumpkins]&lt;br /&gt;
| vid || TQI || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| m10 || none || PT/microtalk10:1? || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/dungeon-keeper-2 Dungeon Keeper 2]&lt;br /&gt;
| tgq || TQI (no typo) || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/saturn/warcraft-ii-the-dark-saga Warcraft II: The Dark Saga (Sega Saturn)]&lt;br /&gt;
| tgq || TGQ || ? || be&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/superbike-2001 Superbike 2001]&lt;br /&gt;
| tgq || ? || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/saturn/crusader-no-remorse Crusader: No Remorse (Sega Saturn)]&lt;br /&gt;
| tgq || TGQ || 1SNh/EACS/mulaw || be&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/harry-potter-quidditch-world-cup Harry Potter: Quidditch World Cup]&lt;br /&gt;
| tgq || TQI (not a typo) || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/wing-commander-prophecy Wing Commander: Prophecy]&lt;br /&gt;
| wve || TQI || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/the-sims The Sims]&lt;br /&gt;
| wve || TQI || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/nba-live-99 NBA Live 99]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-iii-hot-pursuit Need for Speed 3: Hot Pursuit]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-high-stakes Need for Speed 4: High Stakes]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-porsche-unleashed Need for Speed 5: Porsche]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea_r1 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-hot-pursuit-2 Need for Speed 6: Hot Pursuit 2]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea_r1 || le&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot;| [http://www.mobygames.com/game/nba-live-2003 NBA Live 2003]&lt;br /&gt;
| mad || MAD || pcm_s16le_planar || le&lt;br /&gt;
|-&lt;br /&gt;
| asf || none || SCHl/PT/mp3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-2005 FIFA 2004]&lt;br /&gt;
| mad || ? || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/fifa-soccer-2005 FIFA 2005]&lt;br /&gt;
| mad || MAD || SCHl/PT/adpcm_ea_r1, SCHl/PT/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/simcity-4-rush-hour Sim City 4: Rush Hour]&lt;br /&gt;
| mad || MAD || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/sims-2 The Sims 2]&lt;br /&gt;
| mad || MAD || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/ps2/need-for-speed-underground Need for Speed: Underground (PlayStation 2)]&lt;br /&gt;
| mpc || MPC || SCHl/PT/adpcm_ea_r2 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/ps2/fifa-soccer-07 FIFA 2007 (PlayStation 2)]&lt;br /&gt;
| mpc || MPC || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-underground-2 Need for Speed: Underground 2]&lt;br /&gt;
| vp6 || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-most-wanted Need for Speed: Most Wanted]&lt;br /&gt;
| vp6 || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-carbon Need for Speed: Carbon]&lt;br /&gt;
| vp6 || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/lord-of-the-rings-the-battle-for-middle-earth The Lord of the Rings: The Battle for Middle Earth]&lt;br /&gt;
| vp6 || VP6 || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/lord-of-the-rings-the-battle-for-middle-earth-ii The Lord of the Rings: The Battle for Middle Earth II]&lt;br /&gt;
| vp6 || VP6 || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/lord-of-the-rings-the-battle-for-middle-earth-ii-the-rise-of-the The Lord of the Rings: The Battle for Middle Earth II - The Rise of the Witch-King]&lt;br /&gt;
| vp6 || VP6 || ? || ?&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/command-conquer-3-tiberium-wars Command &amp;amp; Conquer: Tiberium Wars]&lt;br /&gt;
| vp6/snd || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/command-conquer-3-kanes-wrath Command &amp;amp; Conquer: Tiberium Wars: Kane's Wrath]&lt;br /&gt;
| vp6/snd || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/need-for-speed-prostreet Need for Speed: Pro Street]&lt;br /&gt;
| vp6 || VP6 || SHEN/GSTR/ealayer3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/command-conquer-red-alert-3 Red Alert 3]&lt;br /&gt;
| vp6/snd || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| Red Alert 3: Uprising&lt;br /&gt;
| vp6/snd || VP6 || SCHl/GSTR/adpcm_ea_r3 || le&lt;br /&gt;
|-&lt;br /&gt;
| [http://www.mobygames.com/game/windows/burnout-paradise-the-ultimate-box Burnout Paradise: The Ultimate Box]&lt;br /&gt;
| vp6/sns || VP6 || ealayer3 w/o header || le&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In addition to FMV, the EA audio chunk types are frequently used throughout Electronic Arts games for music tracks, audio effects and speech. Older titles use the .ASF file extension for individual music tracks, whereas newer titles store multiple audio sequentially within the one file (hence rational for the ending chunk types) and use a variety of file extensions. &lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Duck_TrueMotion_1&amp;diff=13566</id>
		<title>Duck TrueMotion 1</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Duck_TrueMotion_1&amp;diff=13566"/>
		<updated>2011-07-30T21:53:51Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* Games Using Duck TrueMotion 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* FOURCCs: DUCK,PVEZ&lt;br /&gt;
* Company: [[On2|On2 (formerly Duck)]]&lt;br /&gt;
* Patents: US #6,181,822, &amp;quot;Data compression apparatus and method&amp;quot;&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/V-codecs/DUCK/&lt;br /&gt;
&lt;br /&gt;
Duck TrueMotion 1 (TM1) is the first video codec developed by The Duck Corporation. It uses [[Differential Coding|differential pulse code modulation]] and interframe differencing. The primary application for which Duck TrueMotion 1 was developed is gaming software, typically on PC or Sega Saturn titles.&lt;br /&gt;
&lt;br /&gt;
== Underlying Concepts ==&lt;br /&gt;
&lt;br /&gt;
TM1 operates on bidirectional delta quantization. The mathematical premise of delta coding is simple addition. For example, take the following sequence of numbers:&lt;br /&gt;
&lt;br /&gt;
  82 84 81 80 86 88 85&lt;br /&gt;
&lt;br /&gt;
All of the numbers are reasonably large (on a scale of 0..255 in this example). However, they are quite similar to each other. Using delta coding, only the differences between successive numbers are stored:&lt;br /&gt;
&lt;br /&gt;
  82 +2 -3 -1 +6 +2 -3&lt;br /&gt;
&lt;br /&gt;
The first number is still large but since the remaining numbers are clustered close to each other, the deltas are relatively small. Thus, the deltas require less information to encode. &lt;br /&gt;
&lt;br /&gt;
TM1 takes this concept and extends it to 2 dimensions. A particular pixel is assumed to have a pixel directly above it and a pixel directly to the left (if neither of these pixels exist in the frame, e.g., for the top-left corner pixel, 0 is used in place of the non-existant pixels). The current pixel is decoded as the sum of the up and left pixels, plus a delta from the encoded video bitstream.&lt;br /&gt;
&lt;br /&gt;
  encoded video bitstream: ...D5 D6 D7 D8...&lt;br /&gt;
  &lt;br /&gt;
  decoded video frame:&lt;br /&gt;
    A B C D&lt;br /&gt;
    E F G H&lt;br /&gt;
    &lt;br /&gt;
In this example, the encoded video bitstream is sitting at delta D5 when it is time to decode pixel E. A is the pixel above E. There is no pixel to the left of E, so 0 is used as the left value. Thus:&lt;br /&gt;
&lt;br /&gt;
  E = A + 0 + D5&lt;br /&gt;
&lt;br /&gt;
In the case of pixel F, both the up and left pixel values (called the vertical and horizontal predictors, respectively) are available:&lt;br /&gt;
&lt;br /&gt;
  F = B + E + D6&lt;br /&gt;
&lt;br /&gt;
That is the general idea behind decoding TM1 data. The actual decoding algorithm is more involved. The TM1 bytestream actually contains a series of indices that point into tables with the delta values to be&lt;br /&gt;
applied to the vertical and horizontal predictor pixels. These tables only specify small deltas to be added to pixel predictors. When a larger delta is needed because the delta between 2 numbers is too large, then a special bytestream code indicates that the next delta is to be multiplied by 5 before it is applied.&lt;br /&gt;
&lt;br /&gt;
TM1 operates on 4x4 macroblocks of pixels. Each block in a frame can be broken into 4 2x2 blocks, 2 halves (either 4x2 or 2x4), or encoded as a 4x4 block. The block type is encoded in the frame header.&lt;br /&gt;
&lt;br /&gt;
While the TM1 algorithm operates on RGB colorspace data at the input and output level, it borrows some ideas from YUV colorspaces. For more information of RGB and YUV colorspaces, see the References section.&lt;br /&gt;
&lt;br /&gt;
TM1 uses a modified colorspace that embodies luminance (Y) and chrominance (C) information encoded as RGB deltas. Since Y information is more important to the human eye than C information, the Y data must be updated more frequently than the C data (i.e., more Y predictors than C predictors are applied to the image). For a every pixel within a given block in a macroblock, a Y predictor must be applied. However, only one C predictor is applied for each block in the macroblock.&lt;br /&gt;
&lt;br /&gt;
== TrueMotion v1 Frame Format and Header ==&lt;br /&gt;
&lt;br /&gt;
All multi-byte numbers are stored in little endian format.&lt;br /&gt;
&lt;br /&gt;
An encoded intraframe (keyframe) of TM1 data is laid out as:&lt;br /&gt;
&lt;br /&gt;
  header  |  predictor indices&lt;br /&gt;
&lt;br /&gt;
An encoded interframe is laid out as:&lt;br /&gt;
&lt;br /&gt;
  header  |  block change bits  |  predictor indices&lt;br /&gt;
&lt;br /&gt;
The difference between the 2 types of frames is that an interframe has a section of bits that specify which blocks in the frame are unchanged from the previous frame.&lt;br /&gt;
&lt;br /&gt;
A TM1 header is quasi-encrypted with a logical XOR operation. This is probably done to provide some obfuscation of the header and thwart casual inspection of the data format.&lt;br /&gt;
&lt;br /&gt;
An encoded TM1 frame begins with the one byte that indicates the length of the decrypted header, only with a dummy high bit and rotated left by 5. To obtain the actual length from byte B:&lt;br /&gt;
&lt;br /&gt;
  L = ((B &amp;gt;&amp;gt; 5) | (B &amp;lt;&amp;lt; 3)) &amp;amp; 0x7F&lt;br /&gt;
&lt;br /&gt;
Then, decrypt the header by starting with byte 1 in the encoded frame (indexing from 0) and XORing each byte with its successive byte. Assuming the header is of length L bytes as computed above, and that the encoded header starts at buffer[1] (buffer[0] had the rotated length), the decode process is:&lt;br /&gt;
&lt;br /&gt;
  for (i = 1; i &amp;lt; L; i++)&lt;br /&gt;
    decoded_header[i - 1] = buffer[i] ^ buffer[i + 1];&lt;br /&gt;
&lt;br /&gt;
The decoded header data structure is laid out as follows:&lt;br /&gt;
&lt;br /&gt;
  byte 0       compression method&lt;br /&gt;
  byte 1       delta set&lt;br /&gt;
  byte 2       vector set&lt;br /&gt;
  bytes 3-4    frame height&lt;br /&gt;
  bytes 5-6    frame width&lt;br /&gt;
  bytes 7-8    checksum&lt;br /&gt;
  byte 9       version&lt;br /&gt;
  byte 10      header type&lt;br /&gt;
  byte 11      flags&lt;br /&gt;
  byte 12      control&lt;br /&gt;
  bytes 13-14  x offset&lt;br /&gt;
  bytes 15-16  y offset&lt;br /&gt;
  bytes 17-18  width&lt;br /&gt;
  bytes 19-20  height&lt;br /&gt;
  &lt;br /&gt;
The compression method field indicates the type of compression used to encode this frame. There are 2 general types: 16-bit and 24-bit. Further, each has 4 block sizes to select from. The valid compression types are&lt;br /&gt;
&lt;br /&gt;
  0, 9, 11, 13, 15: NOP frames; frame is unchanged from previous frame&lt;br /&gt;
  1:  16-bit 4x4 (V)&lt;br /&gt;
  2:  16-bit 4x4 (H)&lt;br /&gt;
  3:  16-bit 4x2 (V)&lt;br /&gt;
  4:  16-bit 4x2 (H)&lt;br /&gt;
  5:  16-bit 2x4 (V)&lt;br /&gt;
  6:  16-bit 2x4 (H)&lt;br /&gt;
  7:  16-bit 2x2 (V)&lt;br /&gt;
  8:  16-bit 2x2 (H)&lt;br /&gt;
  10: 24-bit 4x4 (H)&lt;br /&gt;
  12: 24-bit 4x2 (H)&lt;br /&gt;
  14: 24-bit 2x4 (H)&lt;br /&gt;
  16: 24-bit 2x2 (H)&lt;br /&gt;
 &amp;gt;16: invalid compression type&lt;br /&gt;
&lt;br /&gt;
The (H) and (V) designations come from the original Duck source code. It is unclear what they mean, except for the common horizontal and vertical designations common in video terminology.&lt;br /&gt;
&lt;br /&gt;
The delta set and vector set fields are used to generate the set of predictor tables that will be used to decode this frame.&lt;br /&gt;
&lt;br /&gt;
The height and width fields should be the same as those specified in the AVI file that contains the data.&lt;br /&gt;
&lt;br /&gt;
The checksum field appears to contain the frame's sequence number modulo 512. The first frame is 0x0000 and the next frame is 0x0001. Frame #511 has a checksum of 0x01FF while frame #512 wraps around to 0x0000.&lt;br /&gt;
&lt;br /&gt;
If the version field is less than 2, then the frame is intracoded (this may indicate that early versions of the coding method was purely intracoded). If the version field is greater than or equal to 2, then if the header type field is 2 or 3, the flags field has bit 4 set (flags &amp;amp; 0x10) to indicate an intraframe; else if the header type field is greater than 3, then the header is invalid; else the frame is intracoded.&lt;br /&gt;
&lt;br /&gt;
The purpose of the control field is unclear.&lt;br /&gt;
&lt;br /&gt;
The x &amp;amp; y offset, width, and height fields apparently pertain to a sprite mode that is not covered in this document.&lt;br /&gt;
&lt;br /&gt;
== 16-bit Data ==&lt;br /&gt;
&lt;br /&gt;
Decoding a 16-bit frame requires 2 tables. The tables can change from one frame to the next and must be rebuilt if the header specified a new table. One table contains the C predictors while the other contains the Y predictors.&lt;br /&gt;
&lt;br /&gt;
Each table consists of 1024 32-bit entries. Each group of 4 entries corresponds to a byte index from 0..255. Each entry contains a double pixel predictor shifted left by one. If the very last bit (bit 0) in the 32-bit entry is 0, then there is another predictor for that index. If the last bit is 1, then this predictor is the last one for this list.&lt;br /&gt;
&lt;br /&gt;
For example...&lt;br /&gt;
&lt;br /&gt;
  A B C D ...&lt;br /&gt;
  E F G H ...&lt;br /&gt;
  I J K L ...&lt;br /&gt;
  M N O P ...&lt;br /&gt;
&lt;br /&gt;
'''(UNFINISHED)'''&lt;br /&gt;
&lt;br /&gt;
== 24-bit Data ==&lt;br /&gt;
&lt;br /&gt;
The process of decoding a 24-bit frame is similar to that of decoding a 16-bit frame. However, the frame is decoded into 2 separate planes, a Y plane and a C plane, and recombined into a final RGB map at render time.&lt;br /&gt;
&lt;br /&gt;
'''(UNFINISHED)'''&lt;br /&gt;
&lt;br /&gt;
== Duck TrueMotion v1 Tables ==&lt;br /&gt;
&lt;br /&gt;
[http://svn.mplayerhq.hu/ffmpeg/trunk/libavcodec/truemotion1data.h?view=markup&amp;amp;rev=4679 http://svn.mplayerhq.hu/ffmpeg/trunk/libavcodec/truemotion1data.h?view=markup&amp;amp;rev=4679]&lt;br /&gt;
&lt;br /&gt;
== Games Using Duck TrueMotion 1 ==&lt;br /&gt;
These software titles are known to use the Duck TrueMotion 1 video codec to encode full motion video:&lt;br /&gt;
&lt;br /&gt;
* [http://www.mobygames.com/game/saturn/blazing-dragons Blazing Dragons (Sega Saturn)]&lt;br /&gt;
* Congo (Sega Saturn)&lt;br /&gt;
* [http://www.mobygames.com/game/saturn/horde The Horde (Sega Saturn)]&lt;br /&gt;
* [http://www.mobygames.com/game/saturn/nhl-all-star-hockey NHL All-Star Hockey (Sega Saturn)]&lt;br /&gt;
* [http://www.mobygames.com/game/phantasmagoria-a-puzzle-of-flesh Phantasmagoria: A Puzzle of Flesh (DOS &amp;amp; Windows)]&lt;br /&gt;
* [http://www.mobygames.com/game/santa-fe-mysteries-the-elk-moon-murder Santa Fe Mysteries: The Elk Moon Murder (DOS &amp;amp; Windows)]&lt;br /&gt;
* [http://www.mobygames.com/game/saturn/solar-eclipse Solar Eclipse (Sega Saturn)]&lt;br /&gt;
* [http://www.mobygames.com/game/saturn/sonic-3d-blast Sonic 3D Blast (Sega Saturn)]&lt;br /&gt;
* [http://www.mobygames.com/game/spycraft-the-great-game Spycraft: The Great Game (DOS &amp;amp; Windows)]&lt;br /&gt;
* [http://www.mobygames.com/game/saturn/theme-park Theme Park (Sega Saturn)]&lt;br /&gt;
* [http://www.mobygames.com/game/saturn/virtua-cop-2 Virtua Cop 2 (Sega Saturn)]&lt;br /&gt;
* [http://www.mobygames.com/game/saturn/virtua-fighter-2 Virtua Fighter 2 (Sega Saturn)]&lt;br /&gt;
* [http://www.mobygames.com/game/windows/zork-grand-inquisitor Zork: Grand Inquisitor (Windows)]&lt;br /&gt;
* [http://www.mobygames.com/game/windows/zork-nemesis-the-forbidden-lands Zork Nemesis: The Forbidden Lands (Windows)]&lt;br /&gt;
* Bubble Bobble special CD release with Rainbow Island (DOS) by Acclaim&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Incomplete Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Reaper&amp;diff=13558</id>
		<title>Reaper</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Reaper&amp;diff=13558"/>
		<updated>2011-07-24T16:19:27Z</updated>

		<summary type="html">&lt;p&gt;VAG: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: fmv&lt;br /&gt;
&lt;br /&gt;
Psygnosis' 1999 title [http://www.mobygames.com/game/windows/rollcage Rollcage] included directory full of video with a .fmv extension.  The first 8 bytes of the files contain a header of &amp;quot;!Reaper!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Looking at the strings in the either of the games binaries (Glide or Direct3D) the string &amp;quot;Reaper '95 Version 1.30, (c) Paul Hughes&amp;quot; can also be found.&lt;br /&gt;
&lt;br /&gt;
The game (its PSX version) take advantage of an [[MDEC]] chip, therefore the video encoding is an [[MPEG]] variant and audio is [[IMA ADPCM]] packaged in a custom container. &lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All numbers are little-endian. File consist of a main header:&lt;br /&gt;
&lt;br /&gt;
 s8  signature[8]   -- &amp;quot;!Reaper!&amp;quot;  (but only first 5 characters actually checked)&lt;br /&gt;
 s32 headersize     -- size of the header and coefficients table (i.e. it's an offset of the first data chunk)&lt;br /&gt;
 s16 width          -- video width&lt;br /&gt;
 s16 height         -- video height&lt;br /&gt;
 s16 coeffsize      -- size of the decompressed coefficients table&lt;br /&gt;
 s16 audiotype      -- 0 - no sound, 1 - IMA sound&lt;br /&gt;
 s16 audiorate      -- audio frequency&lt;br /&gt;
 s16 audiobits      -- sound sample bits (always 16?)&lt;br /&gt;
 s16 audiochnl      -- 1 - mono, 2 - stereo&lt;br /&gt;
 s16 unknown&lt;br /&gt;
 &lt;br /&gt;
then followed by packed coefficients table (size = headersize - sizeof(header)) and then followed by frame chunks.&lt;br /&gt;
Chunk format:&lt;br /&gt;
 u32 signature      -- chunk type&lt;br /&gt;
 u32 size           -- chunk size, including this header&lt;br /&gt;
 u8  payload[]      -- chunk payload&lt;br /&gt;
&lt;br /&gt;
Observed chunk types:&lt;br /&gt;
* 0x0B85120F - video chunk&lt;br /&gt;
* 0x90FC0302 - audio chunk&lt;br /&gt;
* 0xD6BD0106 - ?&lt;br /&gt;
&lt;br /&gt;
== Video Decompression ==&lt;br /&gt;
&lt;br /&gt;
'''TODO'''&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Undiscovered Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=AMF&amp;diff=13557</id>
		<title>AMF</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=AMF&amp;diff=13557"/>
		<updated>2011-07-23T20:45:42Z</updated>

		<summary type="html">&lt;p&gt;VAG: mention another AMF format&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: amf&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/amf/ http://samples.mplayerhq.hu/game-formats/amf/]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Not to be confused with [[Asylum Music Format]]''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AMF is a very simple video file format used in the game [http://www.mobygames.com/game/dos/manic-karts Manic Karts].&lt;br /&gt;
Contains only [[RLE]]-encoded palettized video.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
&lt;br /&gt;
All numbers are little-endian. File begins with an 8-byte header:&lt;br /&gt;
&lt;br /&gt;
 u16  numframes    -- number of frames&lt;br /&gt;
 u16  width        -- frame width&lt;br /&gt;
 u16  height       -- frame height&lt;br /&gt;
 u16  unknown      -- unknown/unused, always 2&lt;br /&gt;
&lt;br /&gt;
and is followed by at least numframes + 1 frame chunks. Each frame chunk begins with a short header:&lt;br /&gt;
&lt;br /&gt;
 u8   type         -- chunk type&lt;br /&gt;
 u16  size         -- chunk payload size (w/o this header)&lt;br /&gt;
&lt;br /&gt;
and then followed by a chunk payload.&lt;br /&gt;
&lt;br /&gt;
Observed chunk types:&lt;br /&gt;
* 0x3E - palette chunk (always first chunk in file) Payload format:&lt;br /&gt;
 u8  firstcolor                -- first color of palette to update (always 64)&lt;br /&gt;
 RGB palette[256-firstcolor]   -- new palette entries (always 256-64 = 192 triplets), 6-bits [[DAC]] values&lt;br /&gt;
* 0x3F - video frame chunk (a video file has total numframes chunks of this type) Contains compressed video data&lt;br /&gt;
* all other chunk types are ignored/skipped.&lt;br /&gt;
&lt;br /&gt;
Note: palette can not be changed during playback. Playback rate is about 10 fps.&lt;br /&gt;
&lt;br /&gt;
== Video Decompression ==&lt;br /&gt;
&lt;br /&gt;
 while input buffer is not exhausted&lt;br /&gt;
   tag = next byte of input&lt;br /&gt;
   tag is:&lt;br /&gt;
     &amp;lt;  0x20 : skip (tag) pixels&lt;br /&gt;
     == 0x20 : skip (DecodeLength) pixels&lt;br /&gt;
     &amp;lt;  0x3F : fill (tag - 0x21 + 2) pixels with the next byte of input&lt;br /&gt;
     == 0x3F : fill (DecodeLength) pixels with the next byte of input&lt;br /&gt;
     &amp;gt;= 0x40 : draw (tag)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
DecodeLength loads variable-sized length value:&lt;br /&gt;
&lt;br /&gt;
  length = 32&lt;br /&gt;
  repeat&lt;br /&gt;
    delta = next byte of input&lt;br /&gt;
    length += delta&lt;br /&gt;
  until delta != 0xFF&lt;br /&gt;
&lt;br /&gt;
== Trivia ==&lt;br /&gt;
&lt;br /&gt;
The MANIC.AMF file has several [[BMP]] files attached at the end.&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=AMF&amp;diff=13556</id>
		<title>AMF</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=AMF&amp;diff=13556"/>
		<updated>2011-07-23T20:20:26Z</updated>

		<summary type="html">&lt;p&gt;VAG: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: amf&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/amf/ http://samples.mplayerhq.hu/game-formats/amf/]&lt;br /&gt;
&lt;br /&gt;
AMF is a very simple video file format used in the game [http://www.mobygames.com/game/dos/manic-karts Manic Karts].&lt;br /&gt;
Contains only [[RLE]]-encoded palettized video.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
&lt;br /&gt;
All numbers are little-endian. File begins with an 8-byte header:&lt;br /&gt;
&lt;br /&gt;
 u16  numframes    -- number of frames&lt;br /&gt;
 u16  width        -- frame width&lt;br /&gt;
 u16  height       -- frame height&lt;br /&gt;
 u16  unknown      -- unknown/unused, always 2&lt;br /&gt;
&lt;br /&gt;
and is followed by at least numframes + 1 frame chunks. Each frame chunk begins with a short header:&lt;br /&gt;
&lt;br /&gt;
 u8   type         -- chunk type&lt;br /&gt;
 u16  size         -- chunk payload size (w/o this header)&lt;br /&gt;
&lt;br /&gt;
and then followed by a chunk payload.&lt;br /&gt;
&lt;br /&gt;
Observed chunk types:&lt;br /&gt;
* 0x3E - palette chunk (always first chunk in file) Payload format:&lt;br /&gt;
 u8  firstcolor                -- first color of palette to update (always 64)&lt;br /&gt;
 RGB palette[256-firstcolor]   -- new palette entries (always 256-64 = 192 triplets), 6-bits [[DAC]] values&lt;br /&gt;
* 0x3F - video frame chunk (a video file has total num_frames chunks of this type) Contains compressed video data&lt;br /&gt;
* all other chunk types are ignored/skipped.&lt;br /&gt;
&lt;br /&gt;
Note: palette can not be changed during playback. Playback rate is about 10 fps.&lt;br /&gt;
&lt;br /&gt;
== Video Decompression ==&lt;br /&gt;
&lt;br /&gt;
 while input buffer is not exhausted&lt;br /&gt;
   tag = next byte of input&lt;br /&gt;
   tag is:&lt;br /&gt;
     &amp;lt;  0x20 : skip (tag) pixels&lt;br /&gt;
     == 0x20 : skip (DecodeLength) pixels&lt;br /&gt;
     &amp;lt;  0x3F : fill (tag - 0x21 + 2) pixels with the next byte of input&lt;br /&gt;
     == 0x3F : fill (DecodeLength) pixels with the next byte of input&lt;br /&gt;
     &amp;gt;= 0x40 : draw (tag)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
DecodeLength loads variable-sized length value:&lt;br /&gt;
&lt;br /&gt;
  length = 32&lt;br /&gt;
  repeat&lt;br /&gt;
    delta = next byte of input&lt;br /&gt;
    length += delta&lt;br /&gt;
  until delta != 0xFF&lt;br /&gt;
&lt;br /&gt;
== Trivia ==&lt;br /&gt;
&lt;br /&gt;
The MANIC.AMF file has several [[BMP]] files attached at the end.&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Formats missing in FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=H.264_Prediction&amp;diff=13422</id>
		<title>H.264 Prediction</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=H.264_Prediction&amp;diff=13422"/>
		<updated>2011-04-23T06:50:43Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* Plane */ ohh, Mike, Mike...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents the various prediction methods used in [[H.264]] and related formats such as [[Sorenson Video 3]], [[RealVideo 4]], and [[On2 VP8]].&lt;br /&gt;
&lt;br /&gt;
== 4x4 Prediction Modes ==&lt;br /&gt;
&lt;br /&gt;
4x4 prediction modes vary between different codecs. While they are almost the same for [[H.264]] and [[Sorenson Video 3]], [[RealVideo 4]] has a different order for these modes and some of them significantly differ from H.264 counterparts (by using left predictors where H.264 does not and down left predictors which are not used elsewhere).&lt;br /&gt;
&lt;br /&gt;
=== Vertical ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 0&lt;br /&gt;
* SVQ3: mode 0&lt;br /&gt;
* RV40: mode 1&lt;br /&gt;
* VP8: not used&lt;br /&gt;
&lt;br /&gt;
     | T0  T1  T2  T3&lt;br /&gt;
 ---------------------&lt;br /&gt;
     | T0  T1  T2  T3&lt;br /&gt;
     | T0  T1  T2  T3&lt;br /&gt;
     | T0  T1  T2  T3&lt;br /&gt;
     | T0  T1  T2  T3&lt;br /&gt;
&lt;br /&gt;
=== Vertical (VP8) ===&lt;br /&gt;
&lt;br /&gt;
* H.264: not used&lt;br /&gt;
* SVQ3: not used&lt;br /&gt;
* RV40: not used&lt;br /&gt;
* VP8: mode 2&lt;br /&gt;
&lt;br /&gt;
  LT | T0  T1  T2  T3  T4&lt;br /&gt;
 ------------------------&lt;br /&gt;
     |  a   b   c   d&lt;br /&gt;
     |  a   b   c   d&lt;br /&gt;
     |  a   b   c   d&lt;br /&gt;
     |  a   b   c   d&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
  a = (LT + 2*T0 + T1 + 2) &amp;gt;&amp;gt; 2&lt;br /&gt;
  b = (T0 + 2*T1 + T2 + 2) &amp;gt;&amp;gt; 2&lt;br /&gt;
  c = (T1 + 2*T2 + T3 + 2) &amp;gt;&amp;gt; 2&lt;br /&gt;
  d = (T2 + 2*T3 + T4 + 2) &amp;gt;&amp;gt; 2&lt;br /&gt;
&lt;br /&gt;
=== Horizontal ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 1&lt;br /&gt;
* SVQ3: mode 1&lt;br /&gt;
* RV40: mode 2&lt;br /&gt;
* VP8: not used&lt;br /&gt;
&lt;br /&gt;
     | &lt;br /&gt;
 ---------------------&lt;br /&gt;
  L0 | L0  L0  L0  L0&lt;br /&gt;
  L1 | L1  L1  L1  L1&lt;br /&gt;
  L2 | L2  L2  L2  L2&lt;br /&gt;
  L3 | L3  L3  L3  L3&lt;br /&gt;
&lt;br /&gt;
=== Horizontal (VP8) ===&lt;br /&gt;
&lt;br /&gt;
* H.264: not used&lt;br /&gt;
* SVQ3: not used&lt;br /&gt;
* RV40: not used&lt;br /&gt;
* VP8: mode 3&lt;br /&gt;
&lt;br /&gt;
  LT | &lt;br /&gt;
 --------------------&lt;br /&gt;
  L0 |  a   a   a   a&lt;br /&gt;
  L1 |  b   b   b   b&lt;br /&gt;
  L2 |  c   c   c   c&lt;br /&gt;
  L3 |  d   d   d   d&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
  a = (LT + 2*L0 + L1 + 2) &amp;gt;&amp;gt; 2&lt;br /&gt;
  b = (L0 + 2*L1 + L2 + 2) &amp;gt;&amp;gt; 2&lt;br /&gt;
  c = (L1 + 2*L2 + L3 + 2) &amp;gt;&amp;gt; 2&lt;br /&gt;
  d = (L2 + 2*L3 + L3 + 2) &amp;gt;&amp;gt; 2&lt;br /&gt;
&lt;br /&gt;
=== DC ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 2&lt;br /&gt;
* SVQ3: mode 2&lt;br /&gt;
* RV40: mode 0&lt;br /&gt;
* VP8: mode 0&lt;br /&gt;
&lt;br /&gt;
     | T0  T1  T2  T3&lt;br /&gt;
 ---------------------&lt;br /&gt;
  L0 |  a   a   a   a&lt;br /&gt;
  L1 |  a   a   a   a&lt;br /&gt;
  L2 |  a   a   a   a&lt;br /&gt;
  L3 |  a   a   a   a&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
 if top and left predictors are available&lt;br /&gt;
   a = (T0 + T1 + T2 + T3 + L0 + L1 + L2 + L3 + 4) / 8&lt;br /&gt;
 else if top predictors are available&lt;br /&gt;
   a = (T0 + T1 + T2 + T3 + 2) / 4&lt;br /&gt;
 else if left predictors are available&lt;br /&gt;
   a = (L0 + L1 + L2 + L3 + 2) / 4&lt;br /&gt;
 else&lt;br /&gt;
   a = 128&lt;br /&gt;
&lt;br /&gt;
Note that the VP8 reference code does not make any provisions for either or both sets of predictors to be missing.&lt;br /&gt;
&lt;br /&gt;
=== Diagonal Down/Left ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 3&lt;br /&gt;
* SVQ3: not used&lt;br /&gt;
* RV40: not used&lt;br /&gt;
* VP8: mode 4&lt;br /&gt;
&lt;br /&gt;
     | T0  T1  T2  T3  T4  T5  T6  T7&lt;br /&gt;
 -------------------------------------&lt;br /&gt;
     |  a   b   c   d&lt;br /&gt;
     |  b   c   d   e&lt;br /&gt;
     |  c   d   e   f&lt;br /&gt;
     |  d   e   f   g&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
  a = (T0 + 2*T1 + T2 + 2) / 4&lt;br /&gt;
  b = (T1 + 2*T2 + T3 + 2) / 4&lt;br /&gt;
  c = (T2 + 2*T3 + T4 + 2) / 4&lt;br /&gt;
  d = (T3 + 2*T4 + T5 + 2) / 4&lt;br /&gt;
  e = (T4 + 2*T5 + T6 + 2) / 4&lt;br /&gt;
  f = (T5 + 2*T6 + T7 + 2) / 4&lt;br /&gt;
  g = (T6 + 3*T7      + 2) / 4&lt;br /&gt;
&lt;br /&gt;
=== Diagonal Down/Left (SVQ3) ===&lt;br /&gt;
&lt;br /&gt;
* H.264: not used&lt;br /&gt;
* SVQ3: mode 3&lt;br /&gt;
* RV40: not used&lt;br /&gt;
* VP8: not used&lt;br /&gt;
&lt;br /&gt;
     |     T1  T2  T3&lt;br /&gt;
 ---------------------&lt;br /&gt;
     |  a   b   c   c&lt;br /&gt;
  L1 |  b   c   c   c&lt;br /&gt;
  L2 |  c   c   c   c&lt;br /&gt;
  L3 |  c   c   c   c&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
  a = (L1 + T1) / 2&lt;br /&gt;
  b = (L2 + T2) / 2&lt;br /&gt;
  c = (L3 + T3) / 2&lt;br /&gt;
&lt;br /&gt;
=== Diagonal Down/Left (RV40) ===&lt;br /&gt;
&lt;br /&gt;
* H.264: not used&lt;br /&gt;
* SVQ3: not used&lt;br /&gt;
* RV40: mode 4&lt;br /&gt;
* VP8: not used&lt;br /&gt;
&lt;br /&gt;
     | T0  T1  T2  T3  T4  T5  T6  T7&lt;br /&gt;
 -------------------------------------&lt;br /&gt;
  L0 |  a   b   c   d&lt;br /&gt;
  L1 |  b   c   d   e&lt;br /&gt;
  L2 |  c   d   e   f&lt;br /&gt;
  L3 |  d   e   f   g&lt;br /&gt;
  L4 |&lt;br /&gt;
  L5 |&lt;br /&gt;
  L6 |&lt;br /&gt;
  L7 |&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
  a = (T0 + 2*T1 + T2 + L0 + 2*L1 + L2 + 4) / 8&lt;br /&gt;
  b = (T1 + 2*T2 + T3 + L1 + 2*L2 + L3 + 4) / 8&lt;br /&gt;
  c = (T2 + 2*T3 + T4 + L2 + 2*L3 + L4 + 4) / 8&lt;br /&gt;
  d = (T3 + 2*T4 + T5 + L3 + 2*L4 + L5 + 4) / 8&lt;br /&gt;
  e = (T4 + 2*T5 + T6 + L4 + 2*L5 + L6 + 4) / 8&lt;br /&gt;
  f = (T5 + 2*T6 + T7 + L5 + 2*L6 + L7 + 4) / 8&lt;br /&gt;
  g = (T6 +   T7      + L6 +   L7      + 2) / 4&lt;br /&gt;
&lt;br /&gt;
=== Diagonal Down/Right ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 4&lt;br /&gt;
* SVQ3: mode 4&lt;br /&gt;
* RV40: mode 3&lt;br /&gt;
* VP8: mode 5&lt;br /&gt;
&lt;br /&gt;
  LT | T0  T1  T2  T3&lt;br /&gt;
 ---------------------&lt;br /&gt;
  L0 |  d   e   f   g&lt;br /&gt;
  L1 |  c   d   e   f&lt;br /&gt;
  L2 |  b   c   d   e&lt;br /&gt;
  L3 |  a   b   c   d&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
  a = (L3 + 2*L2 + L1 + 2) / 4&lt;br /&gt;
  b = (L2 + 2*L1 + L0 + 2) / 4&lt;br /&gt;
  c = (L1 + 2*L0 + LT + 2) / 4&lt;br /&gt;
  d = (L0 + 2*LT + T0 + 2) / 4&lt;br /&gt;
  e = (LT + 2*T0 + T1 + 2) / 4&lt;br /&gt;
  f = (T0 + 2*T1 + T2 + 2) / 4&lt;br /&gt;
  g = (T1 + 2*T2 + T3 + 2) / 4&lt;br /&gt;
&lt;br /&gt;
=== Vertical/Right ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 5&lt;br /&gt;
* SVQ3: mode 5&lt;br /&gt;
* RV40: mode 5&lt;br /&gt;
* VP8: mode 6&lt;br /&gt;
&lt;br /&gt;
  LT | T0  T1  T2  T3&lt;br /&gt;
 ---------------------&lt;br /&gt;
  L0 |  a   b   c   d&lt;br /&gt;
  L1 |  e   f   g   h&lt;br /&gt;
  L2 |  i   a   b   c&lt;br /&gt;
     |  j   e   f   g&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
  a = (LT + T0 + 1) / 2&lt;br /&gt;
  b = (T0 + T1 + 1) / 2&lt;br /&gt;
  c = (T1 + T2 + 1) / 2&lt;br /&gt;
  d = (T2 + T3 + 1) / 2&lt;br /&gt;
  e = (L0 + 2*LT + T0 + 2) / 4&lt;br /&gt;
  f = (LT + 2*T0 + T1 + 2) / 4&lt;br /&gt;
  g = (T0 + 2*T1 + T2 + 2) / 4&lt;br /&gt;
  h = (T1 + 2*T2 + T3 + 2) / 4&lt;br /&gt;
  i = (LT + 2*L0 + L1 + 2) / 4&lt;br /&gt;
  j = (L0 + 2*L1 + L2 + 2) / 4&lt;br /&gt;
&lt;br /&gt;
=== Horizontal/Down ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 6&lt;br /&gt;
* SVQ3: mode 6&lt;br /&gt;
* RV40: mode 8&lt;br /&gt;
* VP8: mode 8&lt;br /&gt;
&lt;br /&gt;
  LT | T0  T1  T2  &lt;br /&gt;
 ---------------------&lt;br /&gt;
  L0 |  a   b   c   d&lt;br /&gt;
  L1 |  e   f   a   b&lt;br /&gt;
  L2 |  g   h   e   f&lt;br /&gt;
  L3 |  i   j   g   h&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
  a = (LT + L0 + 1) / 2&lt;br /&gt;
  b = (L0 + 2*LT + T0 + 2) / 4&lt;br /&gt;
  c = (LT + 2*T0 + T1 + 2) / 4&lt;br /&gt;
  d = (T0 + 2*T1 + T2 + 2) / 4&lt;br /&gt;
  e = (L0 + L1 + 1) / 2&lt;br /&gt;
  f = (LT + 2*L0 + L1 + 2) / 4&lt;br /&gt;
  g = (L1 + L2 + 1) / 2&lt;br /&gt;
  h = (L0 + 2*L1 + L2 + 2) / 4&lt;br /&gt;
  g = (L2 + L3 + 1) / 2&lt;br /&gt;
  j = (L1 + 2*L2 + L3 + 2) / 4&lt;br /&gt;
&lt;br /&gt;
=== Vertical/Left ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 7&lt;br /&gt;
* SVQ3: mode 7&lt;br /&gt;
* RV40: mode 6&lt;br /&gt;
* VP8: mode 7&lt;br /&gt;
&lt;br /&gt;
     | T0  T1  T2  T3  T4  T5  T6 &lt;br /&gt;
 ---------------------------------&lt;br /&gt;
     |  a   b   c   d&lt;br /&gt;
  L1 |  f   g   h   i&lt;br /&gt;
  L2 |  b   c   d   e&lt;br /&gt;
  L3 |  g   h   i   j&lt;br /&gt;
  L4 |&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
  a = (T0 + T1 + 1) / 2&lt;br /&gt;
  b = (T1 + T2 + 1) / 2&lt;br /&gt;
  c = (T2 + T3 + 1) / 2&lt;br /&gt;
  d = (T3 + T4 + 1) / 2&lt;br /&gt;
  e = (T4 + T5 + 1) / 2&lt;br /&gt;
  f = (T0 + 2*T1 + T2 + 2) / 4&lt;br /&gt;
  g = (T1 + 2*T2 + T3 + 2) / 4&lt;br /&gt;
  h = (T2 + 2*T3 + T4 + 2) / 4&lt;br /&gt;
  i = (T3 + 2*T4 + T5 + 2) / 4&lt;br /&gt;
  j = (T4 + 2*T5 + T6 + 2) / 4&lt;br /&gt;
&lt;br /&gt;
For RV40 two coefficients differ:&lt;br /&gt;
&lt;br /&gt;
  a = (2*T0 + 2*T1 + L1 + 2*L2 +   L3 +      4) / 8&lt;br /&gt;
  f = (  T0 + 2*T1 + T2 +   L2 + 2*L3 + L4 + 4) / 8&lt;br /&gt;
&lt;br /&gt;
For VP8, 3 coefficients differ:&lt;br /&gt;
&lt;br /&gt;
  c = (T2 + T3 + T4 + 2) / 4&lt;br /&gt;
  e = (T4 + 2*T5 + T6 + 2) / 4&lt;br /&gt;
  j = (T5 + 2*T6 + T7 + 2) / 4&lt;br /&gt;
&lt;br /&gt;
=== Horizontal/Up ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 8&lt;br /&gt;
* SVQ3: mode 8&lt;br /&gt;
* RV40: not used&lt;br /&gt;
* VP8: mode 9&lt;br /&gt;
&lt;br /&gt;
     | &lt;br /&gt;
 ---------------------&lt;br /&gt;
  L0 |  a   b   c   d&lt;br /&gt;
  L1 |  c   d   e   f&lt;br /&gt;
  L2 |  e   f   g   g&lt;br /&gt;
  L3 |  g   g   g   g&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
  a = (L0 + L1 + 1) / 2&lt;br /&gt;
  b = (L0 + 2*L1 + L2 + 2) / 4&lt;br /&gt;
  c = (L1 + L2 + 1) / 2&lt;br /&gt;
  d = (L1 + 2*L2 + L3 + 2) / 4&lt;br /&gt;
  e = (L2 + L3 + 1) / 2&lt;br /&gt;
  f = (L2 + 3*L3      + 2) / 4&lt;br /&gt;
  g = L3&lt;br /&gt;
&lt;br /&gt;
=== Horizontal/Up (RV40)===&lt;br /&gt;
&lt;br /&gt;
* H.264: not used&lt;br /&gt;
* SVQ3: not used&lt;br /&gt;
* RV40: mode 7&lt;br /&gt;
* VP8: not used&lt;br /&gt;
&lt;br /&gt;
     | T0  T1  T2  T3  T4  T5  T6  T7&lt;br /&gt;
 -------------------------------------&lt;br /&gt;
  L0 |  a   b   c   d&lt;br /&gt;
  L1 |  c   d   e   f&lt;br /&gt;
  L2 |  e   f   g   h&lt;br /&gt;
  L3 |  g   h   i   j&lt;br /&gt;
  L4 |&lt;br /&gt;
  L5 |&lt;br /&gt;
  L6 |&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
  a = (T1 + 2*T2 + T3 + 2*L0 + 2*L1 +      4) / 8&lt;br /&gt;
  b = (T2 + 2*T3 + T4 +   L0 + 2*L1 + L2 + 4) / 8&lt;br /&gt;
  c = (T3 + 2*T4 + T5 + 2*L1 + 2*L2 +      4) / 8&lt;br /&gt;
  d = (T4 + 2*T5 + T6 +   L1 + 2*L2 + L3 + 4) / 8&lt;br /&gt;
  e = (T5 + 2*T6 + T7 + 2*L2 + 2*L3 +      4) / 8&lt;br /&gt;
  f = (T6 + 3*T7 +        L2 + 3*L3 +      4) / 8&lt;br /&gt;
  g = (T6 +   T7 +        L3 +   L4      + 2) / 4&lt;br /&gt;
  h = (                   L3 + 2*L4 + L5 + 2) / 4&lt;br /&gt;
  i = (                   L4 +   L5      + 1) / 2&lt;br /&gt;
  j = (                   L4 + 2*L5 + L6 + 2) / 4&lt;br /&gt;
&lt;br /&gt;
=== TrueMotion (VP8) ===&lt;br /&gt;
&lt;br /&gt;
* H.264: not used&lt;br /&gt;
* SVQ3: not used&lt;br /&gt;
* RV40: not used&lt;br /&gt;
* VP8: mode 1&lt;br /&gt;
&lt;br /&gt;
  LT | T0  T1  T2  T3&lt;br /&gt;
 ---------------------&lt;br /&gt;
  L0 |  a   .   .   .&lt;br /&gt;
  L1 |  .   b   .   .&lt;br /&gt;
  L2 |  .   .   c   .&lt;br /&gt;
  L3 |  .   .   .   d&lt;br /&gt;
&lt;br /&gt;
where this pattern is satisfied:&lt;br /&gt;
&lt;br /&gt;
  a = SATURATE_U8(T0 - LT + L0)&lt;br /&gt;
  b = SATURATE_U8(T1 - LT + L1)&lt;br /&gt;
  c = SATURATE_U8(T2 - LT + L2)&lt;br /&gt;
  d = SATURATE_U8(T3 - LT + L3)&lt;br /&gt;
&lt;br /&gt;
I.e., for each of the 16 samples: (top predictor for column) - (left/top predictor) + (left predictor for row), then saturate in an unsigned byte range 0..255.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 16x16 Prediction Modes ==&lt;br /&gt;
&lt;br /&gt;
=== DC ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 0&lt;br /&gt;
* SVQ3: mode 0&lt;br /&gt;
* RV40: mode 0&lt;br /&gt;
* VP8: mode 0&lt;br /&gt;
&lt;br /&gt;
Using the 16 top predictors (T0..T15) and the 16 left predictors (L0..L15), set all 256 elements to the mean, computed as:&lt;br /&gt;
&lt;br /&gt;
 if top and left predictors are available&lt;br /&gt;
   mean = (sum(T0..T15) + sum(L0..L15) + 16) / 32&lt;br /&gt;
 else if top predictors are available&lt;br /&gt;
   mean = (sum(T0..T15) + 8) / 16&lt;br /&gt;
 else if left predictors are available&lt;br /&gt;
   mean = (sum(L0..L15) + 8) / 16&lt;br /&gt;
 else&lt;br /&gt;
   mean = 128&lt;br /&gt;
&lt;br /&gt;
=== Vertical ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 1&lt;br /&gt;
* SVQ3: mode 1&lt;br /&gt;
* RV40: mode 1&lt;br /&gt;
* VP8: mode 1&lt;br /&gt;
&lt;br /&gt;
      | T0  T1  T2  T3  T4  ..  T15&lt;br /&gt;
 -------------------------- .. -----&lt;br /&gt;
      | T0  T1  T2  T3  T4  ..  T15&lt;br /&gt;
      | T0  T1  T2  T3  T4  ..  T15&lt;br /&gt;
      | T0  T1  T2  T3  T4  ..  T15&lt;br /&gt;
  ......&lt;br /&gt;
      | T0  T1  T2  T3  T4  ..  T15&lt;br /&gt;
&lt;br /&gt;
=== Horizontal ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 2&lt;br /&gt;
* SVQ3: mode 2&lt;br /&gt;
* RV40: mode 2&lt;br /&gt;
* VP8: mode 2&lt;br /&gt;
&lt;br /&gt;
      |&lt;br /&gt;
 --------------------------- .. -----&lt;br /&gt;
   L0 |  L0  L0  L0  L0  L0  ..   L0&lt;br /&gt;
   L1 |  L1  L1  L1  L1  L1  ..   L1&lt;br /&gt;
   L2 |  L2  L2  L2  L2  L2  ..   L2&lt;br /&gt;
  ......&lt;br /&gt;
  L15 | L15 L15 L15 L15 L15  ..  L15&lt;br /&gt;
&lt;br /&gt;
=== Plane ===&lt;br /&gt;
&lt;br /&gt;
* H.264: mode 3&lt;br /&gt;
* SVQ3: mode 3&lt;br /&gt;
* RV40: mode 3&lt;br /&gt;
* VP8: not used&lt;br /&gt;
&lt;br /&gt;
Notice that SVQ3 and RV40 follow a slightly different method here.&lt;br /&gt;
&lt;br /&gt;
Given the top predictors (T0..T15), left predictors (L0..L15) and the left-top corner predictor (LT) arranged as follows:&lt;br /&gt;
&lt;br /&gt;
   LT |    T0        T1        T2     ..    T15&lt;br /&gt;
 -----------------------------------  ..  --------&lt;br /&gt;
   L0 | c[ 0, 0]  c[ 1, 0]  c[ 2, 0]  ..  c[15, 0]&lt;br /&gt;
   L1 | c[ 0, 1]  c[ 1, 1]  c[ 2, 1]  ..  c[15, 1]&lt;br /&gt;
  ......&lt;br /&gt;
  L15 | c[ 0,15]  c[ 1,15]  c[ 2,15]  ..  c[15,15]&lt;br /&gt;
&lt;br /&gt;
Compute H' and V':&lt;br /&gt;
 H' = 1* (T8 - T6) +&lt;br /&gt;
      2* (T9 - T5) +&lt;br /&gt;
      3*(T10 - T4) +&lt;br /&gt;
      4*(T11 - T3) +&lt;br /&gt;
      5*(T12 - T2) +&lt;br /&gt;
      6*(T13 - T1) +&lt;br /&gt;
      7*(T14 - T0) +&lt;br /&gt;
      8*(T15 - LT)&lt;br /&gt;
&lt;br /&gt;
 V' = 1* (L8 - L6) +&lt;br /&gt;
      2* (L9 - L5) +&lt;br /&gt;
      3*(L10 - L4) +&lt;br /&gt;
      4*(L11 - L3) +&lt;br /&gt;
      5*(L12 - L2) +&lt;br /&gt;
      6*(L13 - L1) +&lt;br /&gt;
      7*(L14 - L0) +&lt;br /&gt;
      8*(L15 - LT)&lt;br /&gt;
&lt;br /&gt;
For H.264, compute H and V as:&lt;br /&gt;
&lt;br /&gt;
  H = (5*H' + 32) / 64&lt;br /&gt;
  V = (5*V' + 32) / 64&lt;br /&gt;
&lt;br /&gt;
For SVQ3, compute H and V as:&lt;br /&gt;
&lt;br /&gt;
  V = (5*(H'/4)) / 16&lt;br /&gt;
  H = (5*(V'/4)) / 16 &lt;br /&gt;
  (notice that V and H are computed from H' and V', respectively)&lt;br /&gt;
&lt;br /&gt;
For RV40, compute H and V as:&lt;br /&gt;
&lt;br /&gt;
  H = (5*(H' &amp;gt;&amp;gt; 2)) &amp;gt;&amp;gt; 4&lt;br /&gt;
  V = (5*(V' &amp;gt;&amp;gt; 2)) &amp;gt;&amp;gt; 4 &lt;br /&gt;
  (like SVQ3 but without swapping and it's important to use shifts here instead of divisions)&lt;br /&gt;
&lt;br /&gt;
The final process for filling in the 16x16 block is:&lt;br /&gt;
&lt;br /&gt;
  a = 16 * (L15 + T15 + 1) - 7*(V+H)&lt;br /&gt;
  for (j = 0..15)&lt;br /&gt;
    for (i = 0..15)&lt;br /&gt;
      b = a + V * j + H * i&lt;br /&gt;
      c[i,j] = SATURATE_U8(b / 32)&lt;br /&gt;
&lt;br /&gt;
The SATURATE_U8() function indicates that the result of the operation should be bounded to an unsigned 8-bit range (0..255).&lt;br /&gt;
&lt;br /&gt;
=== TrueMotion (VP8) ===&lt;br /&gt;
&lt;br /&gt;
* H.264: not used&lt;br /&gt;
* SVQ3: not used&lt;br /&gt;
* RV40: not used&lt;br /&gt;
* VP8: mode 3&lt;br /&gt;
&lt;br /&gt;
Given the top predictors (T0..T15), left predictors (L0..L15) and the left-top corner predictor (LT) arranged as follows:&lt;br /&gt;
&lt;br /&gt;
   LT |    T0        T1        T2     ..    T15&lt;br /&gt;
 -----------------------------------  ..  --------&lt;br /&gt;
   L0 | c[ 0, 0]  c[ 1, 0]  c[ 2, 0]  ..  c[15, 0]&lt;br /&gt;
   L1 | c[ 0, 1]  c[ 1, 1]  c[ 2, 1]  ..  c[15, 1]&lt;br /&gt;
  ......&lt;br /&gt;
  L15 | c[ 0,15]  c[ 1,15]  c[ 2,15]  ..  c[15,15]&lt;br /&gt;
&lt;br /&gt;
Compute c[t,l] as:&lt;br /&gt;
&lt;br /&gt;
  c[t,l] = SATURATE_U8(L[l] + T[t] - LT)&lt;br /&gt;
&lt;br /&gt;
I.e., for each element, sum the left and top predictors for the row and column, respectively, and subtract the left-top predictor. Then, saturate the result between 0 and 255.&lt;br /&gt;
&lt;br /&gt;
[[Category:Compression Theory]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=RNC_ProPack&amp;diff=13340</id>
		<title>RNC ProPack</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=RNC_ProPack&amp;diff=13340"/>
		<updated>2011-03-12T17:23:47Z</updated>

		<summary type="html">&lt;p&gt;VAG: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;RNC Pro-Pack is a general data compression library (like [[zlib]]), RNC is acronym for author's company name, Rob Northen Computing.&lt;br /&gt;
&lt;br /&gt;
Packer DOS binary, along with assembly decoding modules (barely useable nowdays) can be freely downloaded [http://aminet.net/package/util/pack/RNC_ProPack here].&lt;br /&gt;
&lt;br /&gt;
There are several known variants in the wild, version 1 was employed to compress data files in various games, like Beneath a Steel Sky or Dungeon Keeper, version 2 seems to be used in [[ETV]] codec.&lt;br /&gt;
&lt;br /&gt;
== Header ==&lt;br /&gt;
&lt;br /&gt;
All numbers are stored as big-endian.&lt;br /&gt;
&lt;br /&gt;
  3 bytes   signature &amp;quot;RNC&amp;quot;&lt;br /&gt;
  1 byte    version&lt;br /&gt;
  4 bytes   unpacked data length&lt;br /&gt;
  4 bytes   packed data length&lt;br /&gt;
  2 bytes   CRC-16 of packed data&lt;br /&gt;
  2 bytes   CRC-16 of unpacked data&lt;br /&gt;
  2 bytes   overlap size (used for inplace unpacking)&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
As an extra protection measure against curious hackers compressed data can be encrypted with secret 16-bit key (supplied to decompression routine by programmer.) In that case all byte literals decoded as follows:&lt;br /&gt;
&lt;br /&gt;
  byte ^= key; key = _rotr(key, 1);&lt;br /&gt;
&lt;br /&gt;
=== Version 0 ===&lt;br /&gt;
&lt;br /&gt;
This is uncompressed data.&lt;br /&gt;
&lt;br /&gt;
=== Version 1 ===&lt;br /&gt;
&lt;br /&gt;
Decoder source is in [https://github.com/scummvm/scummvm/blob/master/engines/sky/rnc_deco.cpp ScummVM repository].&lt;br /&gt;
&lt;br /&gt;
Bits are packed into bytes and those are interspersed with byte values (like in [[KMVC]] for example).&lt;br /&gt;
&lt;br /&gt;
Data is packed with LZ77 scheme into blocks, each block has three Huffman tables for literal and copy lengths and offsets.&lt;br /&gt;
&lt;br /&gt;
Huffman tables:&lt;br /&gt;
&lt;br /&gt;
  5 bits - number of entries (0-16)&lt;br /&gt;
  4x&amp;lt;number&amp;gt; bits - code lengths&lt;br /&gt;
&lt;br /&gt;
for codes reconstruction and tree reading pleas refer to decoder code.&lt;br /&gt;
&lt;br /&gt;
Block starts with three tables description and 16-bit number of (literal, copy) pairs.&lt;br /&gt;
&lt;br /&gt;
  while (!end) {&lt;br /&gt;
    read literal length table&lt;br /&gt;
    read offset table&lt;br /&gt;
    read copy length table&lt;br /&gt;
    blocks = get_bits(16);&lt;br /&gt;
  &lt;br /&gt;
    while (blocks--) {&lt;br /&gt;
      read_length = get_value(literal_table);&lt;br /&gt;
      while (read_length--)&lt;br /&gt;
        *dst++ = get_byte();&lt;br /&gt;
      if (blocks) {&lt;br /&gt;
        offset = get_value(offset_table);&lt;br /&gt;
        length = get_value(copy_len_table);&lt;br /&gt;
        memmove(dst, dst - offset, length);&lt;br /&gt;
        dst += length;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== Version 2 ===&lt;br /&gt;
&lt;br /&gt;
This seems to be designed to be faster on decoding so it does not use Huffman tables (but it's still LZ77 scheme with the same bitreader).&lt;br /&gt;
&lt;br /&gt;
  get_bits(2); // unused&lt;br /&gt;
  while (!end) {&lt;br /&gt;
    if (!get_bit()) {&lt;br /&gt;
      *dst++ = get_byte();&lt;br /&gt;
    } else {&lt;br /&gt;
      if (!get_bit()) {&lt;br /&gt;
        length = 4 + get_bit();&lt;br /&gt;
        if (get_bit()) {&lt;br /&gt;
          length = (length - 1) * 2 + get_bit();&lt;br /&gt;
          if (length == 9) {&lt;br /&gt;
            length = (get_bits(4) + 3) * 4;&lt;br /&gt;
            for (i = 0; i &amp;lt; length; i++)&lt;br /&gt;
                *dst++ = get_byte();&lt;br /&gt;
            continue;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        offset = get_offset();&lt;br /&gt;
      } else {&lt;br /&gt;
        if (get_bit()) {&lt;br /&gt;
          if (get_bit()) {&lt;br /&gt;
            length = get_byte() + 8;&lt;br /&gt;
            if (length == 8) {&lt;br /&gt;
               get_bit();&lt;br /&gt;
               continue; //dunno why&lt;br /&gt;
            }&lt;br /&gt;
          } else {&lt;br /&gt;
            length = 3;&lt;br /&gt;
          }&lt;br /&gt;
          offset = get_offset();&lt;br /&gt;
        } else {&lt;br /&gt;
          offset = get_byte() + 1;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      memmove(dst, dst - offset, length);&lt;br /&gt;
      dst += length;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Offset is coded like that:&lt;br /&gt;
&lt;br /&gt;
  value = 0;&lt;br /&gt;
  if (get_bit()) {&lt;br /&gt;
    value = get_bit();&lt;br /&gt;
    if (get_bit()) {&lt;br /&gt;
      value = value * 2 + 4 + get_bit();&lt;br /&gt;
      if (!get_bit())&lt;br /&gt;
        value = value * 2 + get_bit();&lt;br /&gt;
    } else if (value == 0)&lt;br /&gt;
      value = get_bit() + 2;&lt;br /&gt;
  }&lt;br /&gt;
  offset = (value &amp;lt;&amp;lt; 8) + get_byte() + 1;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:General Compression Methods]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=PMM&amp;diff=13338</id>
		<title>PMM</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=PMM&amp;diff=13338"/>
		<updated>2011-03-12T16:06:56Z</updated>

		<summary type="html">&lt;p&gt;VAG: rewrite&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extensions: pmm&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/krazy-ivan-pmm/ http://samples.mplayerhq.hu/game-formats/krazy-ivan-pmm/]&lt;br /&gt;
&lt;br /&gt;
The game [http://www.mobygames.com/game/windows/krazy-ivan Krazy Ivan] uses multimedia files with the extension .pmm. Carries encoded 15-bit video along with [[PCM]] or [[DPCM]] (never used) audio track.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
&lt;br /&gt;
File structure follows general [[RIFF]] format, but uses custom chunk names. All numbers are little endian.&lt;br /&gt;
&lt;br /&gt;
File begins with 4 * 3 bytes catalog header:&lt;br /&gt;
&lt;br /&gt;
 u32 fourcc     -- &amp;quot;PIFF&amp;quot;&lt;br /&gt;
 u32 filesize   -- not including fourcc and filesize fields&lt;br /&gt;
 u32 filetype   -- &amp;quot;PXMT&amp;quot; /PXM Type?/&lt;br /&gt;
&lt;br /&gt;
followed by chunks:&lt;br /&gt;
&lt;br /&gt;
 u32 fourcc             -- chunk [[FOURCC]]&lt;br /&gt;
 u32 chunksize          -- not including fourcc and chunksize fields&lt;br /&gt;
 u8  payload[chunksize] -- chunk data&lt;br /&gt;
&lt;br /&gt;
=== PXMH chunk ===&lt;br /&gt;
/PXM Header?/&lt;br /&gt;
Carries general movie information.&lt;br /&gt;
&lt;br /&gt;
 u16 unknown0&lt;br /&gt;
 u16 flags&lt;br /&gt;
 u16 width           -- frame width in blocks&lt;br /&gt;
 u16 height          -- frame height in blocks&lt;br /&gt;
 u16 bwidth          -- block width (always 8)&lt;br /&gt;
 u16 bheight         -- block height (always 8)&lt;br /&gt;
 u16 framerate&lt;br /&gt;
 u16 numframes&lt;br /&gt;
 u32 maxframe        -- size of the largest BODY chunk&lt;br /&gt;
 u8  descrition[32]&lt;br /&gt;
 u16 audiofreq&lt;br /&gt;
 u8  audiotype       -- audio compression format&lt;br /&gt;
 u8  audiochnl&lt;br /&gt;
 ...                 -- the rest is unknown/unused&lt;br /&gt;
&lt;br /&gt;
=== CPAL ===&lt;br /&gt;
8-bit palette. Obsolete.&lt;br /&gt;
&lt;br /&gt;
=== MPAL ===&lt;br /&gt;
Palette? Obsolete.&lt;br /&gt;
&lt;br /&gt;
=== BODY ===&lt;br /&gt;
Contains encoded vide frame. See below.&lt;br /&gt;
&lt;br /&gt;
=== AUDO ===&lt;br /&gt;
Contains audio fragment. See below.&lt;br /&gt;
&lt;br /&gt;
== Video Compression ==&lt;br /&gt;
Vide is encoded as a series of bwidth x bheight blocks (typically, 8x8), which may further be divided in to smaller blocks. Pixel format is 15-bit RGB.&lt;br /&gt;
&lt;br /&gt;
Video payload format:&lt;br /&gt;
&lt;br /&gt;
  u16  codetable_ofs   -- offset of code table bitstream (inside the chunk)&lt;br /&gt;
  u16  pixels_ofs      -- offsets of pixels data (inside the chunk)&lt;br /&gt;
  ...&lt;br /&gt;
  u8   codetable[]     -- bitstream data, read bits from the lowest of each byte&lt;br /&gt;
  u8   pixels[]        -- encoded pixel data (bytes)&lt;br /&gt;
&lt;br /&gt;
Compression is based on selective pixel color components change within the block. To decode single block:&lt;br /&gt;
&lt;br /&gt;
1. Initialize last_pixel to 0&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read the 3-bits color_mask value. This is a bit mask, indicates which pixel components will be changed (bit 0 - Red, 1 - Green, 2 - Blue). Zero value indicates the whole block is unchanged.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Read next bit. If bit is zero, decode pixel and use it to draw the whole (sub)block; otherwise&amp;lt;br&amp;gt;&lt;br /&gt;
4. If subblock size is 2, decode each pixel of subblock and draw it; otherwise&amp;lt;br&amp;gt;&lt;br /&gt;
5. Split the (sub)block on to 4 equial subblocks and process recursively from step 3 (left-right-top-bottom.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
DecodePixel operates as follows:&lt;br /&gt;
&lt;br /&gt;
1. Read next 8-bits pixel_data (from pixels[])&amp;lt;br&amp;gt;&lt;br /&gt;
2. If high bit of pixel_data is set, pixel value is the next entry of pixels[] (lower part) combined with 7 bits of pixel_data (upper part.); otherwise&amp;lt;br&amp;gt;&lt;br /&gt;
3. Color_index = value in bits 5-6 of pixel_data (0 - Blue, 1 - Green, 2 - Red, 3 - Skip), color_value = bits 0-4 of pixel_data. If color_index is Skip, assume pixel value is last_pixel. Otherwise, for each color component selected by color_mask, set it to color_value if it's the same component as specified by color_index, or if color_mask indicates no change of color_index component (this case is used to change two components at once.) Reuse all untouched components from last_pixel.&amp;lt;br&amp;gt;&lt;br /&gt;
4. Set last_pixel to newly decoded pixel value.&lt;br /&gt;
&lt;br /&gt;
== Audio Compression ==&lt;br /&gt;
&lt;br /&gt;
According to audiotype field, audio can be stored in the following formats:&lt;br /&gt;
=== Type 0 - PCM16 ===&lt;br /&gt;
Raw 16-bit [[PCM]] samples.&lt;br /&gt;
=== Type 1 - Packed PCM16 ===&lt;br /&gt;
Only high 8 bits of 16-bits sample stored. I.e. DecodedSample = data &amp;lt;&amp;lt; 8.&lt;br /&gt;
=== Type 2 - DPCM ===&lt;br /&gt;
Decode a sample using the following [[DPCM]] table:&lt;br /&gt;
&lt;br /&gt;
 -32767,-30191,-27818,-25631,-23617,-21760,-20050,-18474,-17021,-15683,-14451,-13315,-12268,-11304,-10415, -9596,&lt;br /&gt;
  -8842, -8147, -7506, -6916, -6373, -5872, -5410, -4985, -4593, -4232, -3899, -3593, -3310, -3050, -2810, -2589,&lt;br /&gt;
  -2386, -2198, -2025, -1866, -1719, -1584, -1460, -1345, -1239, -1142, -1052,  -969,  -893,  -823,  -758,  -698,&lt;br /&gt;
   -643,  -593,  -546,  -503,  -464,  -427,  -393,  -363,  -334,  -308,  -283,  -261,  -241,  -222,  -204,  -188,&lt;br /&gt;
   -173,  -160,  -147,  -135,  -125,  -115,  -106,   -97,   -90,   -83,   -76,   -70,   -65,   -59,   -55,   -50,&lt;br /&gt;
    -46,   -43,   -39,   -36,   -33,   -31,   -28,   -26,   -24,   -22,   -20,   -19,   -17,   -16,   -14,   -13,&lt;br /&gt;
    -12,   -11,   -10,    -9,    -9,    -8,    -7,    -7,    -6,    -6,    -5,    -5,    -4,    -4,    -4,    -3,&lt;br /&gt;
     -3,    -3,    -2,    -2,    -2,    -2,    -2,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     0,&lt;br /&gt;
      1,     1,     1,     1,     1,     1,     1,     1,     2,     2,     2,     2,     2,     3,     3,     3,&lt;br /&gt;
      4,     4,     4,     5,     5,     6,     6,     7,     7,     8,     9,     9,    10,    11,    12,    13,&lt;br /&gt;
     14,    16,    17,    19,    20,    22,    24,    26,    28,    31,    33,    36,    39,    43,    46,    50,&lt;br /&gt;
     55,    59,    65,    70,    76,    83,    90,    97,   106,   115,   125,   135,   147,   160,   173,   188,&lt;br /&gt;
    204,   222,   241,   261,   283,   308,   334,   363,   393,   427,   464,   503,   546,   593,   643,   698,&lt;br /&gt;
    758,   823,   893,   969,  1052,  1142,  1239,  1345,  1460,  1584,  1719,  1866,  2025,  2198,  2386,  2589,&lt;br /&gt;
   2810,  3050,  3310,  3593,  3899,  4232,  4593,  4985,  5410,  5872,  6373,  6916,  7506,  8147,  8842,  9596,&lt;br /&gt;
  10415, 11304, 12268, 13315, 14451, 15683, 17021, 18474, 20050, 21760, 23617, 25631, 27818, 30191, 32767, 32767&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=13334</id>
		<title>DFA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=13334"/>
		<updated>2011-03-09T19:14:47Z</updated>

		<summary type="html">&lt;p&gt;VAG: fix BLCK, update file header&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extensions: dfa&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/ http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/]&lt;br /&gt;
&lt;br /&gt;
A DOS-based game called [http://www.mobygames.com/game/dos/chronomaster Chronomaster] includes files with the extension .dfa which appear to be animation files. All multi-byte numbers are little endian. These files are comprised of chunks with the following format:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    chunk fourcc&lt;br /&gt;
  bytes 4-7    chunk size, not including 12-byte preamble&lt;br /&gt;
  bytes 8-11   chunk type, essentially numeric equivalent of fourcc&lt;br /&gt;
  bytes 12..   chunk payload&lt;br /&gt;
&lt;br /&gt;
A DFA file begins with a 128- (0x80-)byte header:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    file signature: 'DFIA'&lt;br /&gt;
  bytes 6-7    number of frames&lt;br /&gt;
  bytes 8-9    frame width&lt;br /&gt;
  bytes 10-11  frame height&lt;br /&gt;
  bytes 12-15  frame rate&lt;br /&gt;
  bytes 16-19  ?&lt;br /&gt;
  bytes 20-127 unused&lt;br /&gt;
&lt;br /&gt;
Chunk types include:&lt;br /&gt;
&lt;br /&gt;
  EOFR (type 0)    end of frame, empty chunk&lt;br /&gt;
  PAL1 (type 1)    768-byte chunk containing a 6-bit VGA palette components&lt;br /&gt;
  COPY (type 2)    raw frame data&lt;br /&gt;
  TSW1 (type 3)    video frame, intra LZ-coded&lt;br /&gt;
  BDLT (type 4)    video frame, inter RLE-coded bytes&lt;br /&gt;
  WDLT (type 5)    video frame, inter RLE-coded words&lt;br /&gt;
        type 6     not occured in known samples&lt;br /&gt;
  DSW1 (type 7)    video frame, inter LZ-coded&lt;br /&gt;
  BLCK (type 8)    solid frame, fill whole frame with the first byte of payload&lt;br /&gt;
  DDS1 (type 9)    video frame, inter LZ-coded, double-scaled&lt;br /&gt;
&lt;br /&gt;
=== TSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
First four bytes store number of stripes to change, next four bytes - offset inside frame. The rest is stripe data.&lt;br /&gt;
&lt;br /&gt;
Every stripe is coded with 16-bit LSB little-endian words in LZ77-like scheme:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else {&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== BDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to skip in frame before decoding, next two bytes code number of lines to decode.&lt;br /&gt;
&lt;br /&gt;
Every line is coded into segments, first byte of data tells how many segments are there. Every segment is coded as RLE, first byte&lt;br /&gt;
tells how many pixels to skip before decoding segment, second byte is treated as signed value with sign telling if it's copy or run:&lt;br /&gt;
&lt;br /&gt;
  while (segments--) {&lt;br /&gt;
     cur_line_ptr += get_byte();&lt;br /&gt;
     count = (int8_t)get_byte();&lt;br /&gt;
     if (count &amp;gt;= 0)&lt;br /&gt;
         get_buffer(cur_line_ptr, count);&lt;br /&gt;
     else&lt;br /&gt;
         memset(cur_line_ptr, get_byte(), -count);&lt;br /&gt;
     cur_line_ptr += abs(count);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== WDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to decode. Overall decoding is similar to BDLT chunk but with words copy instead of byte copy and different segment handling scheme:&lt;br /&gt;
&lt;br /&gt;
  while (lines--) {&lt;br /&gt;
    stripes = (int16_t)get_le16();&lt;br /&gt;
    while (stripes &amp;amp; 0xC000) {&lt;br /&gt;
      *frame_ptr += -stripes * width;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (stripes &amp;lt; 0) {&lt;br /&gt;
      frame_ptr[width - 1] = stripes &amp;amp; 0xFF;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    line_ptr = frame_ptr;&lt;br /&gt;
    while (stripes--) {&lt;br /&gt;
      line_ptr += get_byte();&lt;br /&gt;
      count = (int8_t)get_byte();&lt;br /&gt;
      if (count &amp;gt; 0) {&lt;br /&gt;
        get_buffer(line_ptr, count * 2);&lt;br /&gt;
        line_ptr += count * 2;&lt;br /&gt;
      } else {&lt;br /&gt;
        val = get_le16();&lt;br /&gt;
        for (i = 0; i &amp;lt; -count * 2; i++) {&lt;br /&gt;
          put_le16(line_ptr, val);&lt;br /&gt;
          line_ptr += 2;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    frame_ptr += width;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== chunk type 6 ===&lt;br /&gt;
&lt;br /&gt;
First four bytes code number of segments, each segment contains number of bytes to skip before decoding, number of bytes to copy and bytes to copy.&lt;br /&gt;
&lt;br /&gt;
=== DSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as TSW1 chunk with the following differences:&lt;br /&gt;
&lt;br /&gt;
* first two bytes code number of stripes&lt;br /&gt;
* if getbit() returned zero, get and test another bit. If that bit is zero too then read literal (two bytes), else read 2-byte number and skip corresponding number of pixels.&lt;br /&gt;
&lt;br /&gt;
=== DDS1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as DSW1 chunk but it decodes in scaled mode - every skip is twice that large, literal is used to set 2x2 block and copying also fills 2x2 block with pixel value:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2 * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
        cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
        cur_frame_pos[width] = cur_frame_pos[width + 1] = cur_frame_pos[-offset];&lt;br /&gt;
        cur_frame_pos += 2;&lt;br /&gt;
      }&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else if (!(bitbuf &amp;amp; (mask &amp;lt;&amp;lt; 1)) {&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
    } else {&lt;br /&gt;
      cur_frame_pos += get_le16() * 2;&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=13333</id>
		<title>DFA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=DFA&amp;diff=13333"/>
		<updated>2011-03-09T19:07:58Z</updated>

		<summary type="html">&lt;p&gt;VAG: /* BDLT chunk */ fix broken algo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extensions: dfa&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/ http://samples.mplayerhq.hu/game-formats/chronomaster-dfa/]&lt;br /&gt;
&lt;br /&gt;
A DOS-based game called [http://www.mobygames.com/game/dos/chronomaster Chronomaster] includes files with the extension .dfa which appear to be animation files. All multi-byte numbers are little endian. These files are comprised of chunks with the following format:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    chunk fourcc&lt;br /&gt;
  bytes 4-7    chunk size, not including 12-byte preamble&lt;br /&gt;
  bytes 8-11   chunk type, essentially numeric equivalent of fourcc&lt;br /&gt;
  bytes 12..   chunk payload&lt;br /&gt;
&lt;br /&gt;
A DFA file begins with a 128- (0x80-)byte header:&lt;br /&gt;
&lt;br /&gt;
  bytes 0-3    file signature: 'DFIA'&lt;br /&gt;
  bytes 4-127  unknown (mostly 0s)&lt;br /&gt;
&lt;br /&gt;
Chunk types include:&lt;br /&gt;
&lt;br /&gt;
  EOFR (type 0)    end of frame, empty chunk&lt;br /&gt;
  PAL1 (type 1)    768-byte chunk containing a 6-bit VGA palette components&lt;br /&gt;
  COPY (type 2)    raw frame data&lt;br /&gt;
  TSW1 (type 3)    video frame, intra LZ-coded&lt;br /&gt;
  BDLT (type 4)    video frame, inter RLE-coded bytes&lt;br /&gt;
  WDLT (type 5)    video frame, inter RLE-coded words&lt;br /&gt;
        type 6     not occured in known samples&lt;br /&gt;
  DSW1 (type 7)    video frame, inter LZ-coded&lt;br /&gt;
  BLCK (type 8)    black frame (fill all frame with zero)&lt;br /&gt;
  DDS1 (type 9)    video frame, inter LZ-coded, double-scaled&lt;br /&gt;
&lt;br /&gt;
=== TSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
First four bytes store number of stripes to change, next four bytes - offset inside frame. The rest is stripe data.&lt;br /&gt;
&lt;br /&gt;
Every stripe is coded with 16-bit LSB little-endian words in LZ77-like scheme:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else {&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
      *cur_frame_pos++ = get_byte();&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== BDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to skip in frame before decoding, next two bytes code number of lines to decode.&lt;br /&gt;
&lt;br /&gt;
Every line is coded into segments, first byte of data tells how many segments are there. Every segment is coded as RLE, first byte&lt;br /&gt;
tells how many pixels to skip before decoding segment, second byte is treated as signed value with sign telling if it's copy or run:&lt;br /&gt;
&lt;br /&gt;
  while (segments--) {&lt;br /&gt;
     cur_line_ptr += get_byte();&lt;br /&gt;
     count = (int8_t)get_byte();&lt;br /&gt;
     if (count &amp;gt;= 0)&lt;br /&gt;
         get_buffer(cur_line_ptr, count);&lt;br /&gt;
     else&lt;br /&gt;
         memset(cur_line_ptr, get_byte(), -count);&lt;br /&gt;
     cur_line_ptr += abs(count);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== WDLT chunk ===&lt;br /&gt;
&lt;br /&gt;
First two bytes code number of lines to decode. Overall decoding is similar to BDLT chunk but with words copy instead of byte copy and different segment handling scheme:&lt;br /&gt;
&lt;br /&gt;
  while (lines--) {&lt;br /&gt;
    stripes = (int16_t)get_le16();&lt;br /&gt;
    while (stripes &amp;amp; 0xC000) {&lt;br /&gt;
      *frame_ptr += -stripes * width;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (stripes &amp;lt; 0) {&lt;br /&gt;
      frame_ptr[width - 1] = stripes &amp;amp; 0xFF;&lt;br /&gt;
      stripes = (int16_t)get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    line_ptr = frame_ptr;&lt;br /&gt;
    while (stripes--) {&lt;br /&gt;
      line_ptr += get_byte();&lt;br /&gt;
      count = (int8_t)get_byte();&lt;br /&gt;
      if (count &amp;gt; 0) {&lt;br /&gt;
        get_buffer(line_ptr, count * 2);&lt;br /&gt;
        line_ptr += count * 2;&lt;br /&gt;
      } else {&lt;br /&gt;
        val = get_le16();&lt;br /&gt;
        for (i = 0; i &amp;lt; -count * 2; i++) {&lt;br /&gt;
          put_le16(line_ptr, val);&lt;br /&gt;
          line_ptr += 2;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    frame_ptr += width;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== chunk type 6 ===&lt;br /&gt;
&lt;br /&gt;
First four bytes code number of segments, each segment contains number of bytes to skip before decoding, number of bytes to copy and bytes to copy.&lt;br /&gt;
&lt;br /&gt;
=== DSW1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as TSW1 chunk with the following differences:&lt;br /&gt;
&lt;br /&gt;
* first two bytes code number of stripes&lt;br /&gt;
* if getbit() returned zero, get and test another bit. If that bit is zero too then read literal (two bytes), else read 2-byte number and skip corresponding number of pixels.&lt;br /&gt;
&lt;br /&gt;
=== DDS1 chunk ===&lt;br /&gt;
&lt;br /&gt;
Almost the same as DSW1 chunk but it decodes in scaled mode - every skip is twice that large, literal is used to set 2x2 block and copying also fills 2x2 block with pixel value:&lt;br /&gt;
&lt;br /&gt;
  mask = 0x10000;&lt;br /&gt;
  while (stripes--) {&lt;br /&gt;
    if (mask == 0x10000) {&lt;br /&gt;
      mask = 1;&lt;br /&gt;
      bitbuf = get_le16();&lt;br /&gt;
    }&lt;br /&gt;
    if (bitbuf &amp;amp; mask) {&lt;br /&gt;
      v = get_le16();&lt;br /&gt;
      offset = (v &amp;amp; 0x1FFF) * 2 * 2;&lt;br /&gt;
      count  = ((v &amp;gt;&amp;gt; 13) + 2) * 2;&lt;br /&gt;
      for (i = 0; i &amp;lt; count; i++) {&lt;br /&gt;
        cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
        cur_frame_pos[width] = cur_frame_pos[width + 1] = cur_frame_pos[-offset];&lt;br /&gt;
        cur_frame_pos += 2;&lt;br /&gt;
      }&lt;br /&gt;
      memmove(cur_frame_pos, cur_frame_pos - offset, count);&lt;br /&gt;
    } else if (!(bitbuf &amp;amp; (mask &amp;lt;&amp;lt; 1)) {&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
      cur_frame_pos[0] = cur_frame_pos[1] =&lt;br /&gt;
      cur_frame_pos[width] = cur_frame_pos[width + 1] = get_byte();&lt;br /&gt;
      cur_frame_pos += 2;&lt;br /&gt;
    } else {&lt;br /&gt;
      cur_frame_pos += get_le16() * 2;&lt;br /&gt;
    }&lt;br /&gt;
    mask &amp;lt;&amp;lt;= 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=RNC_ProPack&amp;diff=13332</id>
		<title>RNC ProPack</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=RNC_ProPack&amp;diff=13332"/>
		<updated>2011-03-09T18:56:23Z</updated>

		<summary type="html">&lt;p&gt;VAG: fix header, add info about encryption, fix broken algo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;RNC is a general data compression library (like [[zlib]]), name probably stands for Rob Northern Compression (got it from [http://code.google.com/p/corsix-th/wiki/RNC here]).&lt;br /&gt;
&lt;br /&gt;
Packer DOS binary, along with assembly decoding modules (barely useable nowdays) can be freely downloaded [http://aminet.net/package/util/pack/RNC_ProPack here].&lt;br /&gt;
&lt;br /&gt;
There are several known variants in the wild, version 1 was employed to compress data files in various games, like Beneath a Steel Sky or Dungeon Keeper, version 2 seems to be used in [[ETV]] codec.&lt;br /&gt;
&lt;br /&gt;
== Header ==&lt;br /&gt;
&lt;br /&gt;
All numbers are stored as big-endian.&lt;br /&gt;
&lt;br /&gt;
  3 bytes   signature &amp;quot;RNC&amp;quot;&lt;br /&gt;
  1 byte    version&lt;br /&gt;
  4 bytes   unpacked data length&lt;br /&gt;
  4 bytes   packed data length&lt;br /&gt;
  2 bytes   CRC-16 of packed data&lt;br /&gt;
  2 bytes   CRC-16 of unpacked data&lt;br /&gt;
  2 bytes   overlap size (used for inplace unpacking)&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
As an extra protection measure against curious hackers compressed data can be encrypted with secret 16-bit key (supplied to decompression routine by programmer.) In that case all byte literals decoded as follows:&lt;br /&gt;
&lt;br /&gt;
  byte ^= key; key = _rotr(key, 1);&lt;br /&gt;
&lt;br /&gt;
=== Version 0 ===&lt;br /&gt;
&lt;br /&gt;
This is uncompressed data.&lt;br /&gt;
&lt;br /&gt;
=== Version 1 ===&lt;br /&gt;
&lt;br /&gt;
Decoder source is in [https://github.com/scummvm/scummvm/blob/master/engines/sky/rnc_deco.cpp ScummVM repository].&lt;br /&gt;
&lt;br /&gt;
Bits are packed into bytes and those are interspersed with byte values (like in [[KMVC]] for example).&lt;br /&gt;
&lt;br /&gt;
Data is packed with LZ77 scheme into blocks, each block has three Huffman tables for literal and copy lengths and offsets.&lt;br /&gt;
&lt;br /&gt;
Huffman tables:&lt;br /&gt;
&lt;br /&gt;
  5 bits - number of entries (0-16)&lt;br /&gt;
  4x&amp;lt;number&amp;gt; bits - code lengths&lt;br /&gt;
&lt;br /&gt;
for codes reconstruction and tree reading pleas refer to decoder code.&lt;br /&gt;
&lt;br /&gt;
Block starts with three tables description and 16-bit number of (literal, copy) pairs.&lt;br /&gt;
&lt;br /&gt;
  while (!end) {&lt;br /&gt;
    read literal length table&lt;br /&gt;
    read offset table&lt;br /&gt;
    read copy length table&lt;br /&gt;
    blocks = get_bits(16);&lt;br /&gt;
  &lt;br /&gt;
    while (blocks--) {&lt;br /&gt;
      read_length = get_value(literal_table);&lt;br /&gt;
      while (read_length--)&lt;br /&gt;
        *dst++ = get_byte();&lt;br /&gt;
      if (blocks) {&lt;br /&gt;
        offset = get_value(offset_table);&lt;br /&gt;
        length = get_value(copy_len_table);&lt;br /&gt;
        memmove(dst, dst - offset, length);&lt;br /&gt;
        dst += length;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== Version 2 ===&lt;br /&gt;
&lt;br /&gt;
This seems to be designed to be faster on decoding so it does not use Huffman tables (but it's still LZ77 scheme with the same bitreader).&lt;br /&gt;
&lt;br /&gt;
  get_bits(2); // unused&lt;br /&gt;
  while (!end) {&lt;br /&gt;
    if (!get_bit()) {&lt;br /&gt;
      *dst++ = get_byte();&lt;br /&gt;
    } else {&lt;br /&gt;
      if (!get_bit()) {&lt;br /&gt;
        length = 4 + get_bit();&lt;br /&gt;
        if (get_bit()) {&lt;br /&gt;
          length = (length - 1) * 2 + get_bit();&lt;br /&gt;
          if (length == 9) {&lt;br /&gt;
            length = (get_bits(4) + 3) * 4;&lt;br /&gt;
            for (i = 0; i &amp;lt; length; i++)&lt;br /&gt;
                *dst++ = get_byte();&lt;br /&gt;
            continue;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        offset = get_offset();&lt;br /&gt;
      } else {&lt;br /&gt;
        if (get_bit()) {&lt;br /&gt;
          if (get_bit()) {&lt;br /&gt;
            length = get_byte() + 8;&lt;br /&gt;
            if (length == 8) {&lt;br /&gt;
               get_bit();&lt;br /&gt;
               continue; //dunno why&lt;br /&gt;
            }&lt;br /&gt;
          } else {&lt;br /&gt;
            length = 3;&lt;br /&gt;
          }&lt;br /&gt;
          offset = get_offset();&lt;br /&gt;
        } else {&lt;br /&gt;
          offset = get_byte() + 1;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      memmove(dst, dst - offset, length);&lt;br /&gt;
      dst += length;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Offset is coded like that:&lt;br /&gt;
&lt;br /&gt;
  value = 0;&lt;br /&gt;
  if (get_bit()) {&lt;br /&gt;
    value = get_bit();&lt;br /&gt;
    if (get_bit()) {&lt;br /&gt;
      value = value * 2 + 4 + get_bit();&lt;br /&gt;
      if (!get_bit())&lt;br /&gt;
        value = value * 2 + get_bit();&lt;br /&gt;
    } else if (value == 0)&lt;br /&gt;
      value = get_bit() + 2;&lt;br /&gt;
  }&lt;br /&gt;
  offset = (value &amp;lt;&amp;lt; 8) + get_byte() + 1;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:General Compression Methods]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=What_codec_shall_I_reverse_engineer_next&amp;diff=13323</id>
		<title>What codec shall I reverse engineer next</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=What_codec_shall_I_reverse_engineer_next&amp;diff=13323"/>
		<updated>2011-03-07T15:26:34Z</updated>

		<summary type="html">&lt;p&gt;VAG: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;With so much to choose from, sometimes we need help deciding what to do next. Here is a list. Its not a wishlist or bug-tracker. Think of this as a choose your own adventure...&lt;br /&gt;
&lt;br /&gt;
* [[Discworld]] Noir&lt;br /&gt;
* [[MSS1]] / [[MSS2]]&lt;br /&gt;
* [[Smush]]&lt;br /&gt;
* [[VP7]]&lt;br /&gt;
* [[Indeo 4]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And if you are better at writing than reversing, you can help by properly documenting / implementing the following (already reversed) codecs:&lt;br /&gt;
&lt;br /&gt;
* [[Gremlin Digital Video]] - document missing features&lt;br /&gt;
* Krazy Ivan [[PMM]] - de-optimize&lt;br /&gt;
* Chronomaster [[DFA]]&lt;br /&gt;
* [[RNC ProPack]] - not directly related to multimedia, but still used by some codecs&lt;br /&gt;
&lt;br /&gt;
Contact me if interested and I'll provide you with neccessary code and information. --[[User:VAG|VAG]] 09:57, 7 March 2011 (EST)&lt;br /&gt;
&lt;br /&gt;
[[Category:FFmpeg]]&lt;/div&gt;</summary>
		<author><name>VAG</name></author>
	</entry>
</feed>