<?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=Trixter</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=Trixter"/>
	<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php/Special:Contributions/Trixter"/>
	<updated>2026-05-03T21:04:06Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Covox_ADPCM&amp;diff=15265</id>
		<title>Covox ADPCM</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Covox_ADPCM&amp;diff=15265"/>
		<updated>2017-01-16T08:11:53Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Company: [[Covox]]&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/A-codecs/CovoxFormats/ http://samples.mplayerhq.hu/A-codecs/CovoxFormats/]&lt;br /&gt;
&lt;br /&gt;
This is a family of [[ADPCM]] formats used for compressing 8-bit unsigned [[PCM]].  They were invented by Covox for use with the Covox Speech Thing, Sound Master, and other Covox sound output devices.  There are 2-,3- and 4-bit ADPCM formats.&lt;br /&gt;
&lt;br /&gt;
== Header ==&lt;br /&gt;
&lt;br /&gt;
File header consists of 16 bytes:&lt;br /&gt;
&lt;br /&gt;
  FF 55 FF AA FF 55 FF AA xx yy pp pp pp pp 00 00&lt;br /&gt;
  xx - encoding type&lt;br /&gt;
  yy - playback rate (rate != sample rate, rather the timer tick rate divisor used for playback)&lt;br /&gt;
  pp - unsigned longint meant to indicate unpacked size (mostly unused)&lt;br /&gt;
  00 - unknown/unused&lt;br /&gt;
&lt;br /&gt;
Type may be one of the following:&lt;br /&gt;
&lt;br /&gt;
* 0x01 - 1-bit ADPCM      &lt;br /&gt;
* 0x02 - 2-bit ADPCM      &lt;br /&gt;
* 0x03 - 3-bit ADPCM      &lt;br /&gt;
* 0x04 - 4-bit ADPCM      &lt;br /&gt;
* 0x08 - raw 8-bit unsigned PCM        &lt;br /&gt;
* 0x81 - 1-bit ADPCM with silence encoding&lt;br /&gt;
* 0x82 - 2-bit ADPCM with silence encoding&lt;br /&gt;
* 0x83 - 3-bit ADPCM with silence encoding&lt;br /&gt;
* 0x84 - 4-bit ADPCM with silence encoding&lt;br /&gt;
* 0x88 - 8-bit PCM   with silence encoding&lt;br /&gt;
&lt;br /&gt;
The first 8 bytes are a unique code guaranteed not to show up inside the rest of file.  This means that multiple PCM files can be concatenated together and the locations found by looking for the headers.&lt;br /&gt;
&lt;br /&gt;
== Markers ==&lt;br /&gt;
&lt;br /&gt;
There are two types of markers known:&lt;br /&gt;
&lt;br /&gt;
* FF 55 55 55 - silence block, next 16-bit little-endian value specifies number of silence samples - 27&lt;br /&gt;
* FF AA AA AA - end of sound&lt;br /&gt;
&lt;br /&gt;
For 3-bit ADPCM they are cut to 3 bytes (FF 55 55 and FF AA AA respectively).&lt;br /&gt;
&lt;br /&gt;
After silence block ADPCM decoding state should be reset.&lt;br /&gt;
&lt;br /&gt;
== ADPCM decoding ==&lt;br /&gt;
&lt;br /&gt;
The Covox method of ADPCM does not match other methods; please see the SPUTTER source code by Adrienne Cousins for one implementation of how to decode Covox ADPCM.&lt;br /&gt;
&lt;br /&gt;
[[Category:Audio Codecs]]&lt;br /&gt;
[[Category:ADPCM Audio Codecs]]&lt;br /&gt;
[[Category:Undiscovered Audio Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=15149</id>
		<title>Creative 8 bits ADPCM</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=15149"/>
		<updated>2015-02-02T15:24:21Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Company: [[Creative]]&lt;br /&gt;
&lt;br /&gt;
These ADPCM schemes are used in [[Creative_Voice|Creative VOC]] files. The only reference decoder is a hardware one: the Creative Sound Blaster (Pro). So this documentation is not based on reverse engineering. It's based on wild guessing and empirical tests but gives good enough results.  &lt;br /&gt;
&lt;br /&gt;
'''(Note:  The source at https://github.com/joncampbell123/doslib/blob/master/hw/sndsb/sndsb.c claims that this information is incorrect -- this wiki article should be revised to be closer to accurate.)'''&lt;br /&gt;
&lt;br /&gt;
There are three different variation of this codec, which pack samples to either 4, 2.6 or 2 bits. The 2.6 scheme means that every byte is composed of 3 samples of 3 bits for the first and the second and 2 bits for the last.&lt;br /&gt;
&lt;br /&gt;
The three different schemes use the same algorithm with different initial parameters.&lt;br /&gt;
&lt;br /&gt;
=== Initialization ===&lt;br /&gt;
&lt;br /&gt;
The first byte is a raw (not compressed) sample, used as the initial value for prdiction.&lt;br /&gt;
&lt;br /&gt;
step is initialized to 0.&lt;br /&gt;
&lt;br /&gt;
shift is initialized to 2 for 2 bits scheme and to 0 else.&lt;br /&gt;
&lt;br /&gt;
limit is initialized to 5 for 4 bits samples, 3 for 3 bits samples and 1 for 2 bits samples.&lt;br /&gt;
&lt;br /&gt;
=== Decoding ===&lt;br /&gt;
&lt;br /&gt;
Every packed sample is composed of a sign bit (the most significant bit), and a value (the other bits). Let's define sign as 1 when the sign bit is 0 and -1 when the sign bit is 1. Now you can decode a packed sample with the following operation&lt;br /&gt;
 sample = prediction + sign * (value &amp;lt;&amp;lt; (step + shift))&lt;br /&gt;
sample have to be clamped to fit into an unsigned byte.&lt;br /&gt;
&lt;br /&gt;
Then prediction is updated to the new sample value, and step is updated using this algorithm:&lt;br /&gt;
 if (value &amp;gt;= limit)&lt;br /&gt;
   step++;&lt;br /&gt;
 else if (value == 0)&lt;br /&gt;
   step--;&lt;br /&gt;
step must be clamped into the 0..3 range.&lt;br /&gt;
&lt;br /&gt;
== External sites == &lt;br /&gt;
&lt;br /&gt;
* The DOSBox source contains code that claims to decode Creative ADPCM as well, but that code has not yet been verified against the information on this page.&lt;br /&gt;
&lt;br /&gt;
* The VOCEDIT 2 (VEDIT2.EXE) program that came with the Sound Blaster Pro can be used to compress 8-bit PCM .VOC files into all Creative 8-bit ADPCM variants, making it applicable for a reverse-engineering exercise.  The same software might be able to unpack packed files as well but this has not been verified.  Download link found at VOGONs at http://www.vogons.org/viewtopic.php?t=8634&lt;br /&gt;
&lt;br /&gt;
[[Category:Audio Codecs]]&lt;br /&gt;
[[Category:ADPCM Audio Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=XDC_(8088_Domination)&amp;diff=15105</id>
		<title>XDC (8088 Domination)</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=XDC_(8088_Domination)&amp;diff=15105"/>
		<updated>2014-08-14T18:27:10Z</updated>

		<summary type="html">&lt;p&gt;Trixter: Created page with &amp;quot;* Extension: xdv * Website: http://x86dc.wordpress.com  XDC is an(other) academic project by Jim Leonard, a.k.a. Trixter. The goal of the project was to play full screen, FM...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: xdv&lt;br /&gt;
* Website: http://x86dc.wordpress.com&lt;br /&gt;
&lt;br /&gt;
XDC is an(other) academic project by Jim Leonard, a.k.a. Trixter. The goal of the project was to play full screen, [[FMV|full motion video]] on an original IBM PC utilizing the PC's CGA graphics mode. The specs of the &amp;quot;original IBM PC&amp;quot; included:&lt;br /&gt;
&lt;br /&gt;
* Intel 8088 CPU running at 4.77 MHz&lt;br /&gt;
* CGA graphics mode: 16KB framebuffer, one video page, limited color&lt;br /&gt;
* Sound Blaster audio&lt;br /&gt;
&lt;br /&gt;
XDC stands for X86 Delta Compiler, as its method of operation produces executable code for each video frame, as opposed to traditional codecs which output compressed data.  By outputting code instead of data, XDC avoids unnecessary CPU processing normally associated with the load-decompress-translate-update tasks of other codecs.  Decompression is performed by CALLing the frame data, where it directly alters the contents of the CGA frame buffer.&lt;br /&gt;
&lt;br /&gt;
An earlier version of this system was the basis of the award-winning demo &amp;quot;8088 Domination&amp;quot; in 2014.&lt;br /&gt;
&lt;br /&gt;
== XDV File Format ==&lt;br /&gt;
The [https://github.com/MobyGamer/XDC/blob/master/XDC_GLOB.PAS header] is stored in the github repository for the project:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;'XDCV'     - 4 bytes, header signature&lt;br /&gt;
numpackets - 2 bytes, word value, number of packets that follow header&lt;br /&gt;
largestpacket - 2 byte, word value, size in bytes of largest packet in the file&lt;br /&gt;
achunksize - 2 bytes, word value, size of each audio chunk.&lt;br /&gt;
             This is always a fixed value even when compressed audio formats&lt;br /&gt;
             are in use, because each audio compression method produces&lt;br /&gt;
             fixed-size output chunks.&lt;br /&gt;
samprate   - 2 bytes, word value, playback sample rate in Hz&lt;br /&gt;
vidmode    - 1 byte, 1=160x200x16 composite CGA, 2=640x200x2 (others to follow?)&lt;br /&gt;
numbcols   - 1 byte, width of screenmode in byte columns (ie. 80)&lt;br /&gt;
numprows   - 1 byte, height of screenmode in pixel rows (ie. 200)&lt;br /&gt;
features   - 1 byte, bitfield, reserved for special handling:&lt;br /&gt;
padding    - rest of header is padded to the first sector boundary (512)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Features&amp;quot; are currently unused.&lt;br /&gt;
&lt;br /&gt;
After the header, comes one or more audio+video &amp;quot;packets&amp;quot; with the&lt;br /&gt;
following structure:&lt;br /&gt;
&lt;br /&gt;
  0..end of videochunk&lt;br /&gt;
  ...unknown # of padding...&lt;br /&gt;
  audiochunk..end of packet&lt;br /&gt;
&lt;br /&gt;
The very beginning of the packet is the video chunk, which is of a&lt;br /&gt;
variable size.  The very end of the packet is the audio chunk, which can&lt;br /&gt;
easily be found by seeking backwards from the end &amp;quot;achunksize&amp;quot; bytes.&lt;br /&gt;
All packets are aligned to sector boundaries (ie. the nearest 512-byte&lt;br /&gt;
boundary).  The data in the packet between the video and audio chunks is&lt;br /&gt;
undefined (although likely filled with 0).&lt;br /&gt;
&lt;br /&gt;
Video playback framerate is derived by the audio sample rate divided by the&lt;br /&gt;
audio chunk size.  It is possible (in fact, likely) that neither the framerate&lt;br /&gt;
or audio sample rate will be a common/expected value.  For example, samplerate&lt;br /&gt;
could have been adjusted during creation from 32Khz to 32008Hz to avoid drift,&lt;br /&gt;
or the framerate could be a non-integral number like 29.97 or 23.976.&lt;br /&gt;
&lt;br /&gt;
Packets are padded to the nearest sector boundary (512-byte boundary).  At the&lt;br /&gt;
end of an XDV stream is an index that stores the size of each packet in&lt;br /&gt;
sectors, one value per byte.  (For example: A (tiny) stream that has&lt;br /&gt;
numpackets=4 would have, at EOF-4, 4 bytes, one for each packet to read, with&lt;br /&gt;
each value multiplied by 512 to get the packet length.)  Loading the index is&lt;br /&gt;
as easy as reading [numpackets] from the header and then seeking to&lt;br /&gt;
EOF-[numpackets], then reading [numpackets] bytes.  This index must obviously&lt;br /&gt;
be loaded prior to playback so that the player knows how much data to load&lt;br /&gt;
from disk for each packet.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video format operates in CGA graphics mode, which is an interlaced framebuffer utilizing 16KB of RAM.  Each byte can represent 1-bit, 2-bit, or 4-bit graphics with 2, 4, or 16 colors respectively.  &lt;br /&gt;
&lt;br /&gt;
The interlaced memory arrangement represents even lines starting at offset 0, then odd lines starting at offset 8192.  Only lines 0 through 199 are visible; extra data in the framebuffer outside of the first 200 lines is not displayed.&lt;br /&gt;
&lt;br /&gt;
=== Data Resources ===&lt;br /&gt;
&lt;br /&gt;
* http://trixter.oldskool.org/2014/06/19/8088-domination-post-mortem-part-1/&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, mono, 8-bit [[PCM]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15090</id>
		<title>Category:Platform-Dependent Codecs</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15090"/>
		<updated>2014-07-25T21:23:59Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;List of all codecs that were designed or engineered for a specific hardware platform.&lt;br /&gt;
&lt;br /&gt;
This sub-category describes &amp;quot;one-off&amp;quot; implementations that demonstrate [[FMV]] on a specific vintage, homebrew, or console platform.  The category is meant to denote any platform not typically designed to be capable of decoding or displaying FMV (ie. limited color palette, limited memory, very slow CPU, no mass-storage device, etc.)&lt;br /&gt;
&lt;br /&gt;
Said codecs have highly platform-dependent implementations and limitations that make them mostly unsuitable for more general-purpose use.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=15089</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=15089"/>
		<updated>2014-07-25T21:21:18Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: SGA&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/segacd/sga/ http://samples.mplayerhq.hu/game-formats/segacd/sga/]&lt;br /&gt;
&lt;br /&gt;
SGA is a chunk-based multimedia file format used primarily in games by [[Digital Pictures]] for the [[Sega CD]] console system. Early versions of the format store uncompressed video frames, while later revisions add features such as [[LZ]] compression, tile maps, and overlapping chunks. The extension for SGA files is usually &amp;quot;.SGA&amp;quot;, but some files from ''Supreme Warrior'' have the extensions &amp;quot;.CLP&amp;quot; and &amp;quot;.PT1&amp;quot;, and some files from ''Slam City with Scottie Pippen'' have extensions that include numbers (e.g. &amp;quot;.SG0&amp;quot;, &amp;quot;.S37&amp;quot;, etc.). Variations of the format are found in versions of Digital Pictures games for [[DOS]] PCs and the [[3DO]]. In those versions all video and audio is stored in large, monolithic files rather than individual files.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All multi-byte numbers in a SGA file are big-endian, since the Sega Genesis and Sega CD both use big-endian Motorola 68000 CPUs.&lt;br /&gt;
&lt;br /&gt;
There are three known methods of storing data in SGA files:&lt;br /&gt;
&lt;br /&gt;
(1) In the majority of files, each chunk is stored using 2048 byte sectors due to the nature of CD storage. The first sector in the file contains 2048 bytes of data, each subsequent sectors contain a 2 byte header specifying how much of the chunk is left followed by 2046 bytes of data. One item to be aware of is if the value of the header is zero then to skip the next 2046 bytes and check the next header. (I'm presuming this has something to do with padding the CD for faster loading?)&lt;br /&gt;
&lt;br /&gt;
(2) Some files, in particular the audio-only files in ''Night Trap'' (all variations), do not use length indicators at the start of sectors. The files contain strictly chunk headers and data.&lt;br /&gt;
&lt;br /&gt;
(3) Later versions of the SGA format, as seen in ''Slam City with Scottie Pippen'', ''Prize Fighter'', and ''Supreme Warriors'', introduced a scheme in which chunks can overlap/interrupt other chunks. In this type of file, each sector begins with a two-byte sector header, with the top four bits set to a non-zero value, which we might call the chunk index. If the following twelve bits are set to zero, then we are at the start of a new chunk using the current index. If the following twelve bits are non-zero, then we are looking at a length value, similar to previous formats. A decoder written to handle this type of file would have to keep track of multiple chunks simultaneously. Videos used in ''Slam City'' use a container chunk (type F1) which generally contains a video chunk followed by an audio chunk. Videos in ''Supreme Warrior'' begin with what appears to be a global header (type F0) in addition to the F1 container chunk, but at present it is unknown how to interpret the metadata. There is also another chunk type, F2, whose use is presently unknown. F2 chunks can also exist in separate files of the extension &amp;quot;.F2&amp;quot;. So far, all that it known about F2 chunks is that they often contain what appear to be filenames.&lt;br /&gt;
&lt;br /&gt;
Most SGA files do not contain a global header, but have headers for each chunk. In files of type (1) and (2), headers are never split across sector boundaries. In files of type (3), chunk headers can be split across sector boundaries as long as they are contained within a chunk of type F1. Chunks are word aligned, can contain video or audio. The basic header is 4 bytes long, and is shared by all chunk types.&lt;br /&gt;
&lt;br /&gt;
 Byte  Description&lt;br /&gt;
 ----  -----------&lt;br /&gt;
 0     Chunk type &lt;br /&gt;
 1     Stream index (Sewer Shark in particular uses this for its branching path-based gameplay)&lt;br /&gt;
 2-3   Payload length&lt;br /&gt;
&lt;br /&gt;
This is followed by more metadata:&lt;br /&gt;
 &lt;br /&gt;
 Byte  Description&lt;br /&gt;
 ----  -----------&lt;br /&gt;
 4-7   Time in [[SMPTE]] format&lt;br /&gt;
&lt;br /&gt;
Video chunks for the Sega CD contain the following metadata:&lt;br /&gt;
&lt;br /&gt;
 Byte  Description&lt;br /&gt;
 ----  -----------&lt;br /&gt;
 8     Data flags&lt;br /&gt;
 9     Palette count (1-4)&lt;br /&gt;
&lt;br /&gt;
A value of 1 for the topmost bit of byte 8 means that the chunk uses a tile map. Data for the tile map immediately follows the tile data. Each entry in the tile map is two bytes long, and consists of a tile index and flags for features such as vertical and horizontal flipping. Bits 3 and the lowermost bit 1 are usually set to 1, although their exact purpose is unknown. There may be some connection between bit 1 and tilemaps, though, since tilemap behavior seems to change when the bit is not set.&lt;br /&gt;
Metadata in video chunks for the Sega CD 32X are as follows:&lt;br /&gt;
&lt;br /&gt;
 Byte  Description&lt;br /&gt;
 ----  -----------&lt;br /&gt;
 8     Palette start offset (usually 1)&lt;br /&gt;
 9     Palette update size (a value of 0 means use existing palette)&lt;br /&gt;
&lt;br /&gt;
Then more metadata (both Sega CD and Sega CD 32X):&lt;br /&gt;
&lt;br /&gt;
 Byte  Description&lt;br /&gt;
 ----  -----------&lt;br /&gt;
 10    tiles per column&lt;br /&gt;
 11    tiles per row&lt;br /&gt;
&lt;br /&gt;
In overlay chunk types D1 (and possibly D4), byte 10 indicates the number of tiles in the chunk, and byte 11 indicates the length the data for what are assumed to be codes that specify the layout of the tiles. Since each tile takes up 32 bytes, the length of the tile data is equal to the value in byte 10 * 32. Tile data is immediately followed by layout codes, which as of this writing are yet to be deciphered.&lt;br /&gt;
&lt;br /&gt;
Certain types of video chunks contain additional metadata, which is detailed below in the sections related to the various chunk types.&lt;br /&gt;
&lt;br /&gt;
Audio chunks have the following metadata:&lt;br /&gt;
&lt;br /&gt;
 Byte  Description&lt;br /&gt;
 ----  -----------&lt;br /&gt;
 8-9   Sample rate&lt;br /&gt;
 10    (Probably) Number of channels / bytes per sample (usually 1)&lt;br /&gt;
 11    Unknown (usually 0)&lt;br /&gt;
&lt;br /&gt;
== Chunk Types ==&lt;br /&gt;
Some known chunk types are:&lt;br /&gt;
&lt;br /&gt;
* $81: encoded video (used in most Sega CD 32X games by Digital Pictures)&lt;br /&gt;
* $A1: audio, sign/magnitude 8-bit PCM&lt;br /&gt;
* $C1: uncompressed video (used in Night Trap SCD, Sewer Shark, Corpse Killer SCD, and others)&lt;br /&gt;
* $C2: compressed video (used in Corpse Killer SCD, Slam City with Scottie Pippen, and others?)&lt;br /&gt;
* $C4: compressed? video (used in Slam City with Scottie Pippen)&lt;br /&gt;
* $C6: compressed video (used in Night Trap SCD &amp;quot;DPLOGO.SGA&amp;quot;, Sewer Shark, Make My Video C&amp;amp;C, and others)&lt;br /&gt;
* $C7: compressed video (used in Prize Fighter and others)&lt;br /&gt;
* $C8: compressed video (used in Sewer Shark, Make My Video C&amp;amp;C, and others)&lt;br /&gt;
* $CB: compressed video (used in Prize Fighter, Double Switch &amp;quot;DPLOGO.SGA&amp;quot;, Corpse Killer 32X)&lt;br /&gt;
* $CD: compressed video (used in Double Switch)&lt;br /&gt;
* $D1: uncompressed overlay video (used in Sewer Shark when killing a Ratigator(TM), etc)&lt;br /&gt;
* $D4: compressed? overlay video (used in Corpse Killer SCD/32X for the zombies)&lt;br /&gt;
* $E7: (un)compressed video (used in the Make My Video series)&lt;br /&gt;
* $E8: compressed video (used in Ground Zero Texas)&lt;br /&gt;
* $E9: compressed video (used in Ground Zero Texas)&lt;br /&gt;
* $F0: container for other chunks (used in Slam City with Scottie Pippen)&lt;br /&gt;
* $F1: container for other chunks (used in Slam City with Scottie Pippen)&lt;br /&gt;
* $F2: metadata of unknown use&lt;br /&gt;
&lt;br /&gt;
As of this writing, the format and compression of the following types are generally understood: 81, A1, C1, C6, C7, C8, CB, CD, E7, and F1.&lt;br /&gt;
&lt;br /&gt;
== Encoded Video $81 ==&lt;br /&gt;
This type of video is probably most appropriately called &amp;quot;encoded&amp;quot; rather than &amp;quot;compressed&amp;quot;. Video frames of this type are represented with a series of codes that indicate the size, color, and pixel layout of the graphics to be drawn, rather than, for example, LZSS encoded byte streams as in previous versions of SGA files.&lt;br /&gt;
&lt;br /&gt;
The encoding scheme has been completely reverse-engineered, and a functional decoder has been written. A detailed description of the codes will be added at a later time.&lt;br /&gt;
&lt;br /&gt;
== Audio $A1 ==&lt;br /&gt;
Audio sample rate can be determined in the following way (for NTSC systems only?):&lt;br /&gt;
&lt;br /&gt;
SamplesPerSecond = ((Byte 8 &amp;lt;&amp;lt; 8) + Byte 9) * SEGA_CD_PCM_INCREMENT&lt;br /&gt;
&lt;br /&gt;
SEGA_CD_PCM_INCREMENT is ~15.8945723, and is calculated as SEGA_CD_PCM_FREQUENCY_MAX / 2048&lt;br /&gt;
&lt;br /&gt;
SEGA_CD_PCM_FREQUENCY_MAX is ~32552.084, and is calculated as SEGA_CD_CPU_FREQUENCY / 384&lt;br /&gt;
&lt;br /&gt;
SEGA_CD_CPU_FREQUENCY is 12500000, and is calculated as SEGA_CD_CRYSTAL_FREQUENCY / 4&lt;br /&gt;
&lt;br /&gt;
SEGA_CD_CRYSTAL_FREQUENCY is 50000000&lt;br /&gt;
&lt;br /&gt;
The sample rate can also be used to determine the frame rate of video by using the formula SamplesPerSecond / NumSamples, where NumSamples is the length of the audio data in the audio chunk.&lt;br /&gt;
&lt;br /&gt;
== Uncompressed Video $C1 ==&lt;br /&gt;
For compatibility with the Genesis' video hardware, video frames in this format (and all its derivatives) are made up of linear 8x8 pixel tiles. Each pixel consists of a 4-bit (one nibble) palette index, thus each tile takes up 32 bytes. The length of the tile data can be calculated as tilesPerColumn * tilesPerRow * 32.&lt;br /&gt;
&lt;br /&gt;
Palette data immediately follows the tile data. Each palette is 18 bytes long. Palettes are stored in an unusual format. As the genesis normally uses either RGB or BGR stored in nibbles (even though only the top 3 bits are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bitmap={1,2,4}&lt;br /&gt;
&lt;br /&gt;
 For bit=0 to 2&lt;br /&gt;
    for color=0 to 15&lt;br /&gt;
        red[color]+=Top Most Bit of Data *bitmap[bit]&lt;br /&gt;
    next&lt;br /&gt;
 next&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Repeat for green and blue.&lt;br /&gt;
&lt;br /&gt;
Reading 2 bits for each tile, determines which of the 4 palettes to use.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 For Row=0 to RowMax&lt;br /&gt;
    For Col=0 to ColMax&lt;br /&gt;
        PalMap[Row*ColMax+Col]=Top 2 Bits of data&lt;br /&gt;
    Next&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When drawing a tile you would select the palette based upon PalMap. Note that palette maps for 2 palette frames use only 1 bit per palette map entry vs 2 bits for 3 or 4 palettes.&lt;br /&gt;
&lt;br /&gt;
If a frame has a tilemap, the tilemap immediately follows the palette data. Each tilemap entry is 16 bits long, and so the length of the tilemap in bytes is tilesPerColumn * tilesPerRow * 2. Tilemaps also contain palette information, and so frames with tilemaps do not contain a separate palette map. The top 4 bits of a tilemap entry indicate the palette index of the tile, and the remaining 12 bits indicate the index of the tile itself.&lt;br /&gt;
&lt;br /&gt;
== Compressed Video $C6, $C7, $C8 ==&lt;br /&gt;
Chunks in this format contain the same basic elements as chunks of type C1 (tiles, palette, palette map, tilemap, etc), but are compressed in LZSS format. The compressed data are comprised of several 34 byte LZSS blocks. Each block contains a one word (2 bytes) tag of compression flags followed by 16 words of data.&lt;br /&gt;
&lt;br /&gt;
The tag is read in bits, starting with the most significant (left most) bit. For each bit set to 0, there is an uncompressed word literal. For each bit set to 1, the following word is a displacement/length reference in the following format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;LLLD DDDD DDDD DDDD&lt;br /&gt;
&lt;br /&gt;
L = Amount of words to copy (amount of bytes to copy * 2)&lt;br /&gt;
D = Displacement&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may be calculated as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;for count = 0 to top 3 bits of LZ word * 2&lt;br /&gt;
   data[current + count] = data[current + count - last 13 bits of LZ word]&lt;br /&gt;
next&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the displacement, unlike the copy amount, is based on &amp;lt;em&amp;gt;bytes&amp;lt;/em&amp;gt;, not words. Also, the displacement does not have to be word aligned.&lt;br /&gt;
&lt;br /&gt;
After the entire tag is read, the next flag block is read, and the process continues. The sequence ends when an reference word's top three bits are all zeros.&lt;br /&gt;
&lt;br /&gt;
In C7 format chunks, the top three bits represent the amount of words to copy minus one. Any decoder that implements C7 decoding must take this into account.&lt;br /&gt;
&lt;br /&gt;
Most chunks in C6, and all chunks C8 and E7 formats require that adjacent pixels in even-numbered lines be swapped for frames to be correctly displayed. The exact reason for this is unclear, although since Sega CD video often contains a lot of checkerboard dithering, swapping pixels would eliminate the checkerboard patterns and lead to higher amounts of identical/redundant data, thus leading to more efficient compression. There is currently no known way to determine which C6 chunks require pixel swapping, however, it seems that pixel swapping only occurs in C6 frames that use fewer than 3 palettes and that do not use a tilemap.&lt;br /&gt;
&lt;br /&gt;
== Compressed Video $CB, $CD, $E7 ==&lt;br /&gt;
Like other compressed chunk formats, chunks in this format consist of several 34 byte LZSS blocks. Each block contains a one word (2 bytes) tag of compression flags followed by 16 words of data.&lt;br /&gt;
&lt;br /&gt;
For each bit set to 1, the following word is a displacement/length reference in the following format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;LLLL DDDD DDDD DDDD&lt;br /&gt;
&lt;br /&gt;
L = Amount of words to copy minus one (amount of bytes to copy * 2)&lt;br /&gt;
D = Displacement&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may be calculated as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;for count = 0 to (top 4 bits of LZ word + 1) * 2&lt;br /&gt;
   data[current + count] = data[current + count - last 12 bits of LZ word]&lt;br /&gt;
next&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Chunks of type E7 are used in the Make My Video series, and contain three subframes, which are stacked on top of each other to complete the whole frame. C7 chunks have an additional six bytes of metadata containing three 16-bit values. The topmost bit of each value indicates whether the data for that frame is raw (1) or compressed (0). The remaining 15 bits represent the length of the data for the subframe, with an apparent maximum value of 0x1500. The data for each subframe immediately follows the metadata in order, which is followed by 180 bytes of palette data in the usual format.&lt;br /&gt;
&lt;br /&gt;
== Games Using SGA ==&lt;br /&gt;
* Night Trap&lt;br /&gt;
* Sewer Shark&lt;br /&gt;
* Power Factory Featuring C&amp;amp;C Music Factory&lt;br /&gt;
* Make My Video series&lt;br /&gt;
* Ground Zero: Texas&lt;br /&gt;
* Prize Fighter&lt;br /&gt;
* [http://www.mobygames.com/game/sega-cd/double-switch Double Switch]&lt;br /&gt;
* Slam City with Scottie Pippen&lt;br /&gt;
* Corpse Killer&lt;br /&gt;
* Supreme Warrior&lt;br /&gt;
&lt;br /&gt;
== Decoders/Converters ==&lt;br /&gt;
* A decoder has been written that can currently decode SGA files from Night Trap (SCD and 32X), Sewer Shark (including stream selection), Corpse Killer (SCD and 32X), Prize Fighter, Double Switch, as well as various other games, and convert them to AVI format files. It has yet to be released to the public.&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15088</id>
		<title>Category:Platform-Dependent Codecs</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15088"/>
		<updated>2014-07-25T21:18:56Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;List of all codecs that were designed or engineered for a specific hardware platform.  &lt;br /&gt;
&lt;br /&gt;
This sub-category describes &amp;quot;one-off&amp;quot; implementations that demonstrate [[FMV]] on a specific vintage, homebrew, or console platform.  The category is meant to denote any platform not typically designed to be capable of decoding or displaying FMV (ie. limited color palette, limited memory, very slow CPU, no mass-storage device, etc.)&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15087</id>
		<title>8088 Corruption TMV</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15087"/>
		<updated>2014-07-25T14:51:24Z</updated>

		<summary type="html">&lt;p&gt;Trixter: /* Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: tmv&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
For a description of the basic method, see [[8088 Corruption DAT]].&lt;br /&gt;
&lt;br /&gt;
== TMV File Format ==&lt;br /&gt;
&lt;br /&gt;
TMV files have the following header:&lt;br /&gt;
&lt;br /&gt;
 'TMAV'     - 4 bytes, header signature&lt;br /&gt;
 samplerate - 2 bytes, word value, playback sample rate&lt;br /&gt;
 chunksize  - 2 bytes, word value, audio chunk size per frame&lt;br /&gt;
 compmethod - 1 byte, specifies the compression method (currently only 0)&lt;br /&gt;
 charcols   - 1 byte, number of text chars across (currently always 40)&lt;br /&gt;
 charrows   - 1 byte, number of text chars down (currently always 25)&lt;br /&gt;
 features   - bitfield, reserved for special handling:&lt;br /&gt;
&lt;br /&gt;
The features bitfield was never used in practice, so its settings are undocumented.&lt;br /&gt;
&lt;br /&gt;
To get the playback rate of the file, divide the samplerate by the audio chunk size.  For example, a '''samplerate''' of 22050 divided by an audio '''chunksize''' of 735 gives 22050/735=30, so the playback framerate of the file is 30.&lt;br /&gt;
&lt;br /&gt;
The remainder of the data after the header is made up of frames consisting of video+audio data, repeating until the end of the file is reached.  Each frame consists of the video data and then immediately afterward is the audio data.  The video data is of size ('''charcols*charrows'''*2) and the audio data is of size '''chunksize'''.&lt;br /&gt;
&lt;br /&gt;
While '''charcols''' and '''charrows''' can be any non-zero value, all TMV files as of 20140724 have targeted CGA's 40x25 text mode.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
&lt;br /&gt;
For details on the video format, consult [[8088 Corruption DAT]]&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at the rate specified in the header.&lt;br /&gt;
&lt;br /&gt;
== Data Resources ==&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15086</id>
		<title>8088 Corruption TMV</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15086"/>
		<updated>2014-07-24T15:12:35Z</updated>

		<summary type="html">&lt;p&gt;Trixter: /* TMV File Format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: tmv&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
For a description of the basic method, see [[8088 Corruption DAT]].&lt;br /&gt;
&lt;br /&gt;
== TMV File Format ==&lt;br /&gt;
&lt;br /&gt;
TMV files have the following header:&lt;br /&gt;
&lt;br /&gt;
 'TMAV'     - 4 bytes, header signature&lt;br /&gt;
 samplerate - 2 bytes, word value, playback sample rate&lt;br /&gt;
 chunksize  - 2 bytes, word value, audio chunk size per frame&lt;br /&gt;
 compmethod - 1 byte, specifies the compression method (currently only 0)&lt;br /&gt;
 charcols   - 1 byte, number of text chars across (currently always 40)&lt;br /&gt;
 charrows   - 1 byte, number of text chars down (currently always 25)&lt;br /&gt;
 features   - bitfield, reserved for special handling:&lt;br /&gt;
&lt;br /&gt;
The features bitfield was never used in practice, so its settings are undocumented.&lt;br /&gt;
&lt;br /&gt;
To get the playback rate of the file, divide the samplerate by the audio chunk size.  For example, a '''samplerate''' of 22050 divided by an audio '''chunksize''' of 735 gives 22050/735=30, so the playback framerate of the file is 30.&lt;br /&gt;
&lt;br /&gt;
The remainder of the data after the header is made up of frames consisting of video+audio data, repeating until the end of the file is reached.  Each frame consists of the video data and then immediately afterward is the audio data.  The video data is of size ('''charcols*charrows'''*2) and the audio data is of size '''chunksize'''.&lt;br /&gt;
&lt;br /&gt;
While '''charcols''' and '''charrows''' can be any non-zero value, all TMV files as of 20140724 have targeted CGA's 40x25 text mode.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
&lt;br /&gt;
For details on the video format, consult [[8088 Corruption DAT]]&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at the rate specified in the header.&lt;br /&gt;
&lt;br /&gt;
== Data Resources ==&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15085</id>
		<title>8088 Corruption TMV</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15085"/>
		<updated>2014-07-24T15:11:57Z</updated>

		<summary type="html">&lt;p&gt;Trixter: /* TMV File Format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: tmv&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
For a description of the basic method, see [[8088 Corruption DAT]].&lt;br /&gt;
&lt;br /&gt;
== TMV File Format ==&lt;br /&gt;
&lt;br /&gt;
TMV files have the following header:&lt;br /&gt;
&lt;br /&gt;
 'TMAV'     - 4 bytes, header signature&lt;br /&gt;
 samplerate - 2 bytes, word value, playback sample rate&lt;br /&gt;
 chunksize  - 2 bytes, word value, audio chunk size per frame&lt;br /&gt;
 compmethod - 1 byte, specifies the compression method (currently only 0)&lt;br /&gt;
 charcols   - 1 byte, number of text chars across (currently always 40)&lt;br /&gt;
 charrows   - 1 byte, number of text chars down (currently always 25)&lt;br /&gt;
 features   - bitfield, reserved for special handling:&lt;br /&gt;
&lt;br /&gt;
The features bitfield was never used in practice, so its settings are undocumented.&lt;br /&gt;
&lt;br /&gt;
To get the playback rate of the file, divide the samplerate by the audio chunk size.  For example, a '''samplerate''' of 22050 divided by an audio '''chunksize''' of 735 gives 22050/735=30, so the playback framerate of the file is 30.&lt;br /&gt;
&lt;br /&gt;
The remainder of the data after the header is made up of frames consisting of video+audio data, repeating until the end of the file is reached.  Each frame consists of the video data and then immediately afterward is the audio data.  The video data is of size ('''charcols*charrows'''*2) and the audio data is of size '''chunksize'''.&lt;br /&gt;
&lt;br /&gt;
While charcols and charrows can be any non-zero value, all TMV files as of 20140724 have targeted CGA's 40x25 text mode.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
&lt;br /&gt;
For details on the video format, consult [[8088 Corruption DAT]]&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at the rate specified in the header.&lt;br /&gt;
&lt;br /&gt;
== Data Resources ==&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_DAT&amp;diff=15083</id>
		<title>8088 Corruption DAT</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_DAT&amp;diff=15083"/>
		<updated>2014-07-22T20:10:16Z</updated>

		<summary type="html">&lt;p&gt;Trixter: /* Data Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: dat&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
8088 Corruption is the name of a somewhat academic project by one Jim Leonard, a.k.a. Trixter. The goal of the project was to play full screen, [[FMV|full motion video]] on an original IBM PC. The specs of the &amp;quot;original IBM PC&amp;quot; included:&lt;br /&gt;
&lt;br /&gt;
* Intel 8088 CPU running at 4.77 MHz&lt;br /&gt;
* CGA video&lt;br /&gt;
* original Sound Blaster audio&lt;br /&gt;
&lt;br /&gt;
The result of the project was an FMV data file (8088_COR.DAT) encoded in a particular format as well as a playback program that runs on the original IBM PC. However, by understanding the format of the data, it is possible to create decoders for other platforms.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Corruption&amp;quot; system was expanded to include support for variable playback rates and audio rates, which the current and final version of the system.  This addition is documented at [[8088 Corruption TMV]].&lt;br /&gt;
&lt;br /&gt;
== DAT File Format ==&lt;br /&gt;
The 8088_COR.DAT data file is a sequence of data frames without any header. All playback parameters are implicit to the format. Each data frame is 2735 bytes long. The first 2000 bytes of the frame represent the video data and the last 735 bytes are the audio data. The total size of the data file ought to be divisible by 2735.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video format operates in a CGA text mode using the CGA's hardwired palette and 8x8 BIOS font. Frames are presented at a rate of 30 per second. The video coding necessarily acts as a [[Vector Quantization|vector quantizer]] with the 8x8 BIOS font acting as a vector codebook. Each frame is comprised of 40x25=1000 text cells, or vectors. Each vector is represented by a pair of bytes. The first byte is an codebook index, a.k.a. an index into the 8x8 font table. The second byte of the pair represents the attributes. The upper 4 bits (7-4) of the attribute represent the background color and the lower 4 bits (3-0) represent the foreground color.&lt;br /&gt;
&lt;br /&gt;
=== Data Resources ===&lt;br /&gt;
&lt;br /&gt;
* http://www.archive.org/details/8088CorruptionExplained&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at 22050 Hz. Each frame contains 735 PCM bytes which happens to be the quotient of 22050/30.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15082</id>
		<title>8088 Corruption TMV</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15082"/>
		<updated>2014-07-22T20:08:06Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: tmv&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
For a description of the basic method, see [[8088 Corruption DAT]].&lt;br /&gt;
&lt;br /&gt;
== TMV File Format ==&lt;br /&gt;
&lt;br /&gt;
TMV files have the following header:&lt;br /&gt;
&lt;br /&gt;
 'TMAV'     - 4 bytes, header signature&lt;br /&gt;
 samplerate - 2 bytes, word value, playback sample rate&lt;br /&gt;
 chunksize  - 2 bytes, word value, audio chunk size per frame&lt;br /&gt;
 compmethod - 1 byte, specifies the compression method (currently only 0)&lt;br /&gt;
 charcols   - 1 byte, number of text chars across (currently always 40)&lt;br /&gt;
 charrows   - 1 byte, number of text chars down (currently always 25)&lt;br /&gt;
 features   - bitfield, reserved for special handling:&lt;br /&gt;
&lt;br /&gt;
The features bitfield was never used in practice, so its settings are undocumented.&lt;br /&gt;
&lt;br /&gt;
To get the playback rate of the file, divide the samplerate by the audio chunk size.  For example, a '''samplerate''' of 22050 divided by an audio '''chunksize''' of 735 gives 22050/735=30, so the playback framerate of the file is 30.&lt;br /&gt;
&lt;br /&gt;
The remainder of the data after the header is made up of frames consisting of video+audio data, repeating until the end of the file is reached.  Each frame consists of the video data and then immediately afterward is the audio data.  The video data is of size ('''charcols*charrows'''*2) and the audio data is of size '''chunksize'''.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
&lt;br /&gt;
For details on the video format, consult [[8088 Corruption DAT]]&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at the rate specified in the header.&lt;br /&gt;
&lt;br /&gt;
== Data Resources ==&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15081</id>
		<title>8088 Corruption TMV</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15081"/>
		<updated>2014-07-22T20:06:16Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: tmv&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
For a description of the basic method, see [[8088 Corruption DAT]].&lt;br /&gt;
&lt;br /&gt;
== TMV File Format ==&lt;br /&gt;
&lt;br /&gt;
TMV files have the following header:&lt;br /&gt;
&lt;br /&gt;
 'TMAV'     - 4 bytes, header signature&lt;br /&gt;
 samplerate - 2 bytes, word value, playback sample rate&lt;br /&gt;
 chunksize  - 2 bytes, word value, audio chunk size per frame&lt;br /&gt;
 compmethod - 1 byte, specifies the compression method (currently only 0)&lt;br /&gt;
 charcols   - 1 byte, number of text chars across (currently always 40)&lt;br /&gt;
 charrows   - 1 byte, number of text chars down (currently always 25)&lt;br /&gt;
 features   - bitfield, reserved for special handling:&lt;br /&gt;
&lt;br /&gt;
The features bitfield was never used.&lt;br /&gt;
&lt;br /&gt;
To get the playback rate of the file, divide the samplerate by the audio chunk size.  For example, a '''samplerate''' of 22050 divided by an audio '''chunksize''' of 735 gives 22050/735=30, so the playback framerate of the file is 30.&lt;br /&gt;
&lt;br /&gt;
The remainder of the data after the header is made up of frames consisting of video+audio data, repeating until the end of the file is reached.  Each frame consists of the video data and then immediately afterward is the audio data.  The video data is of size ('''charcols*charrows'''*2) and the audio data is of size '''chunksize'''.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
&lt;br /&gt;
For details on the video format, consult [[8088 Corruption DAT]]&lt;br /&gt;
&lt;br /&gt;
=== Data Resources ===&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at the rate specified in the header.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15080</id>
		<title>8088 Corruption TMV</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15080"/>
		<updated>2014-07-22T20:02:16Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: tmv&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
For a description of the basic method, see [[8088 Corruption DAT]].&lt;br /&gt;
&lt;br /&gt;
== TMV File Format ==&lt;br /&gt;
&lt;br /&gt;
TMV files have the following header:&lt;br /&gt;
&lt;br /&gt;
 'TMAV'     - 4 bytes, header signature&lt;br /&gt;
 samplerate - 2 bytes, word value, playback sample rate&lt;br /&gt;
 chunksize  - 2 bytes, word value, audio chunk size per frame&lt;br /&gt;
 compmethod - 1 byte, specifies the compression method (currently only 0)&lt;br /&gt;
 charcols   - 1 byte, number of text chars across (currently always 40)&lt;br /&gt;
 charrows   - 1 byte, number of text chars down (currently always 25)&lt;br /&gt;
 features   - bitfield, reserved for special handling:&lt;br /&gt;
&lt;br /&gt;
The features bitfield was never used.&lt;br /&gt;
&lt;br /&gt;
To get the playback rate of the file, divide the samplerate by the audio chunk size.  For example, a samplerate of 22050 divided by an audio chunk size of 735 gives 22050/735=30, so the playback framerate of the file is 30.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
&lt;br /&gt;
For details on the video format, consult [[8088 Corruption DAT]]&lt;br /&gt;
&lt;br /&gt;
=== Data Resources ===&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at the rate specified in the header.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15079</id>
		<title>8088 Corruption TMV</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_TMV&amp;diff=15079"/>
		<updated>2014-07-22T19:45:02Z</updated>

		<summary type="html">&lt;p&gt;Trixter: Created page with &amp;quot;* Extension: tmv * Website: http://www.oldskool.org/pc/8088_Corruption  For a description of the basic file format and method, see 8088 Corruption DAT.  == TMV File Format...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: tmv&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
For a description of the basic file format and method, see [[8088 Corruption DAT]].&lt;br /&gt;
&lt;br /&gt;
== TMV File Format ==&lt;br /&gt;
&lt;br /&gt;
TMV files have the following header:&lt;br /&gt;
&lt;br /&gt;
 'TMAV'     - 4 bytes, header signature&lt;br /&gt;
 samplerate - 2 bytes, word value, playback sample rate&lt;br /&gt;
 chunksize  - 2 bytes, word value, audio chunk size per frame&lt;br /&gt;
 compmethod - 1 byte, specifies the compression method (currently only 0)&lt;br /&gt;
 charcols   - 1 byte, number of text chars across (currently always 40)&lt;br /&gt;
 charrows   - 1 byte, number of text chars down (currently always 25)&lt;br /&gt;
 features   - bitfield, reserved for special handling:&lt;br /&gt;
&lt;br /&gt;
The features bitfield was never used.&lt;br /&gt;
&lt;br /&gt;
To get the playback rate of the file, divide the samplerate by the audio chunk size.  For example, a samplerate of 22050 divided by an audio chunk size of 735 gives 22050/735=30, so the playback framerate of the file is 30.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
&lt;br /&gt;
For details on the video format, consult [[8088 Corruption DAT]]&lt;br /&gt;
&lt;br /&gt;
=== Data Resources ===&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at the rate specified in the header.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_DAT&amp;diff=15078</id>
		<title>8088 Corruption DAT</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_DAT&amp;diff=15078"/>
		<updated>2014-07-22T19:31:42Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: dat&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
8088 Corruption is the name of a somewhat academic project by one Jim Leonard, a.k.a. Trixter. The goal of the project was to play full screen, [[FMV|full motion video]] on an original IBM PC. The specs of the &amp;quot;original IBM PC&amp;quot; included:&lt;br /&gt;
&lt;br /&gt;
* Intel 8088 CPU running at 4.77 MHz&lt;br /&gt;
* CGA video&lt;br /&gt;
* original Sound Blaster audio&lt;br /&gt;
&lt;br /&gt;
The result of the project was an FMV data file (8088_COR.DAT) encoded in a particular format as well as a playback program that runs on the original IBM PC. However, by understanding the format of the data, it is possible to create decoders for other platforms.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Corruption&amp;quot; system was expanded to include support for variable playback rates and audio rates, which the current and final version of the system.  This addition is documented at [[8088 Corruption TMV]].&lt;br /&gt;
&lt;br /&gt;
== DAT File Format ==&lt;br /&gt;
The 8088_COR.DAT data file is a sequence of data frames without any header. All playback parameters are implicit to the format. Each data frame is 2735 bytes long. The first 2000 bytes of the frame represent the video data and the last 735 bytes are the audio data. The total size of the data file ought to be divisible by 2735.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video format operates in a CGA text mode using the CGA's hardwired palette and 8x8 BIOS font. Frames are presented at a rate of 30 per second. The video coding necessarily acts as a [[Vector Quantization|vector quantizer]] with the 8x8 BIOS font acting as a vector codebook. Each frame is comprised of 40x25=1000 text cells, or vectors. Each vector is represented by a pair of bytes. The first byte is an codebook index, a.k.a. an index into the 8x8 font table. The second byte of the pair represents the attributes. The upper 4 bits (7-4) of the attribute represent the background color and the lower 4 bits (3-0) represent the foreground color.&lt;br /&gt;
&lt;br /&gt;
=== Data Resources ===&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at 22050 Hz. Each frame contains 735 PCM bytes which happens to be the quotient of 22050/30.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Caimans_Video_Codec_For_GBA&amp;diff=15077</id>
		<title>Caimans Video Codec For GBA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Caimans_Video_Codec_For_GBA&amp;diff=15077"/>
		<updated>2014-07-21T18:08:29Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Website/Samples: http://www.caimans.net/gbavideo/&lt;br /&gt;
&lt;br /&gt;
Caimans Video Codec for GBA is a video codec optimized for playback on the [[Nintendo Gameboy Advance]] handheld gaming console.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;br /&gt;
[[Category:Undiscovered Video Codecs]]&lt;br /&gt;
[[Category:Undiscovered Game Formats]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15076</id>
		<title>Category:Platform-Dependent Codecs</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15076"/>
		<updated>2014-07-21T17:00:51Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;List of all codecs that were designed or engineered for a specific hardware platform.  &lt;br /&gt;
&lt;br /&gt;
This sub-category is meant to describe &amp;quot;one-off&amp;quot; implementations that demonstrate [[FMV]] on a vintage or homebrew platform, or any platform not typically capable of decoding or displaying FMV.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15075</id>
		<title>Category:Platform-Dependent Codecs</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15075"/>
		<updated>2014-07-21T15:58:56Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;List of all codecs that were designed or engineered for a specific hardware platform.  &lt;br /&gt;
&lt;br /&gt;
This sub-category is meant to describe &amp;quot;one-off&amp;quot; implementations typically demonstrating [[FMV]] on a vintage or homebrew platform, or on any platform not typically capable of decoding or displaying FMV.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15074</id>
		<title>Category:Platform-Dependent Codecs</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15074"/>
		<updated>2014-07-21T15:58:34Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;List of all codecs that were designed or engineered for a specific hardware platform.  &lt;br /&gt;
&lt;br /&gt;
This sub-category is meant to describe &amp;quot;one-off&amp;quot; implementations typically demonstrating [[FMV]] on a vintage or homebrew platform, or on any platform not typically capable of decoding or displaying [FMV].&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15073</id>
		<title>Category:Platform-Dependent Codecs</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15073"/>
		<updated>2014-07-21T15:58:04Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;List of all codecs that were designed or engineered for a specific hardware platform.  &lt;br /&gt;
&lt;br /&gt;
This sub-category is meant to describe &amp;quot;one-off&amp;quot; implementations typically demonstrating FMV on a vintage or homebrew platform, or on any platform not typically capable of decoding or displaying FMV.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15072</id>
		<title>Category:Platform-Dependent Codecs</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Category:Platform-Dependent_Codecs&amp;diff=15072"/>
		<updated>2014-07-21T15:01:03Z</updated>

		<summary type="html">&lt;p&gt;Trixter: Created page with &amp;quot;List of all codecs that were designed or engineered for a specific hardware platform.  These are typically &amp;quot;one-off&amp;quot; implementations meant to demonstrate FMV on a vintage or h...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;List of all codecs that were designed or engineered for a specific hardware platform.  These are typically &amp;quot;one-off&amp;quot; implementations meant to demonstrate FMV on a vintage or homebrew platform, or on a platform without native video support.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_DAT&amp;diff=15071</id>
		<title>8088 Corruption DAT</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_DAT&amp;diff=15071"/>
		<updated>2014-07-21T14:57:29Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: dat&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
8088 Corruption is the name of a somewhat academic project by one Jim Leonard, a.k.a. Trixter. The goal of the project was to play full screen, [[FMV|full motion video]] on an original IBM PC. The specs of the &amp;quot;original IBM PC&amp;quot; included:&lt;br /&gt;
&lt;br /&gt;
* Intel 8088 CPU running at 4.77 MHz&lt;br /&gt;
* CGA video&lt;br /&gt;
* original Sound Blaster audio&lt;br /&gt;
&lt;br /&gt;
The result of the project was an FMV data file (8088_COR.DAT) encoded in a particular format as well as a playback program that runs on the original IBM PC. However, by understanding the format of the data, it is possible to create decoders for other platforms.&lt;br /&gt;
&lt;br /&gt;
== DAT File Format ==&lt;br /&gt;
The 8088_COR.DAT data file is a sequence of data frames without any header. All playback parameters are implicit to the format. Each data frame is 2735 bytes long. The first 2000 bytes of the frame represent the video data and the last 735 bytes are the audio data. The total size of the data file ought to be divisible by 2735.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video format operates in a CGA text mode using the CGA's hardwired palette and 8x8 BIOS font. Frames are presented at a rate of 30 per second. The video coding necessarily acts as a [[Vector Quantization|vector quantizer]] with the 8x8 BIOS font acting as a vector codebook. Each frame is comprised of 40x25=1000 text cells, or vectors. Each vector is represented by a pair of bytes. The first byte is an codebook index, a.k.a. an index into the 8x8 font table. The second byte of the pair represents the attributes. The upper 4 bits (7-4) of the attribute represent the background color and the lower 4 bits (3-0) represent the foreground color.&lt;br /&gt;
&lt;br /&gt;
=== Data Resources ===&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at 22050 Hz. Each frame contains 735 PCM bytes which happens to be the quotient of 22050/30.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-Dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_DAT&amp;diff=15070</id>
		<title>8088 Corruption DAT</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_DAT&amp;diff=15070"/>
		<updated>2014-07-21T14:52:58Z</updated>

		<summary type="html">&lt;p&gt;Trixter: Undo revision 15069 by Trixter (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: dat&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
8088 Corruption is the name of a somewhat academic project by one Jim Leonard, a.k.a. Trixter. The goal of the project was to play full screen, [[FMV|full motion video]] on an original IBM PC. The specs of the &amp;quot;original IBM PC&amp;quot; included:&lt;br /&gt;
&lt;br /&gt;
* Intel 8088 CPU running at 4.77 MHz&lt;br /&gt;
* CGA video&lt;br /&gt;
* original Sound Blaster audio&lt;br /&gt;
&lt;br /&gt;
The result of the project was an FMV data file (8088_COR.DAT) encoded in a particular format as well as a playback program that runs on the original IBM PC. However, by understanding the format of the data, it is possible to create decoders for other platforms.&lt;br /&gt;
&lt;br /&gt;
== DAT File Format ==&lt;br /&gt;
The 8088_COR.DAT data file is a sequence of data frames without any header. All playback parameters are implicit to the format. Each data frame is 2735 bytes long. The first 2000 bytes of the frame represent the video data and the last 735 bytes are the audio data. The total size of the data file ought to be divisible by 2735.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video format operates in a CGA text mode using the CGA's hardwired palette and 8x8 BIOS font. Frames are presented at a rate of 30 per second. The video coding necessarily acts as a [[Vector Quantization|vector quantizer]] with the 8x8 BIOS font acting as a vector codebook. Each frame is comprised of 40x25=1000 text cells, or vectors. Each vector is represented by a pair of bytes. The first byte is an codebook index, a.k.a. an index into the 8x8 font table. The second byte of the pair represents the attributes. The upper 4 bits (7-4) of the attribute represent the background color and the lower 4 bits (3-0) represent the foreground color.&lt;br /&gt;
&lt;br /&gt;
=== Data Resources ===&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at 22050 Hz. Each frame contains 735 PCM bytes which happens to be the quotient of 22050/30.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=8088_Corruption_DAT&amp;diff=15069</id>
		<title>8088 Corruption DAT</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=8088_Corruption_DAT&amp;diff=15069"/>
		<updated>2014-07-21T14:50:14Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: dat&lt;br /&gt;
* Website: http://www.oldskool.org/pc/8088_Corruption&lt;br /&gt;
&lt;br /&gt;
8088 Corruption is the name of a somewhat academic project by one Jim Leonard, a.k.a. Trixter. The goal of the project was to play full screen, [[FMV|full motion video]] on an original IBM PC. The specs of the &amp;quot;original IBM PC&amp;quot; included:&lt;br /&gt;
&lt;br /&gt;
* Intel 8088 CPU running at 4.77 MHz&lt;br /&gt;
* CGA video&lt;br /&gt;
* original Sound Blaster audio&lt;br /&gt;
&lt;br /&gt;
The result of the project was an FMV data file (8088_COR.DAT) encoded in a particular format as well as a playback program that runs on the original IBM PC. However, by understanding the format of the data, it is possible to create decoders for other platforms.&lt;br /&gt;
&lt;br /&gt;
== DAT File Format ==&lt;br /&gt;
The 8088_COR.DAT data file is a sequence of data frames without any header. All playback parameters are implicit to the format. Each data frame is 2735 bytes long. The first 2000 bytes of the frame represent the video data and the last 735 bytes are the audio data. The total size of the data file ought to be divisible by 2735.&lt;br /&gt;
&lt;br /&gt;
== Video Format ==&lt;br /&gt;
The video format operates in a CGA text mode using the CGA's hardwired palette and 8x8 BIOS font. Frames are presented at a rate of 30 per second. The video coding necessarily acts as a [[Vector Quantization|vector quantizer]] with the 8x8 BIOS font acting as a vector codebook. Each frame is comprised of 40x25=1000 text cells, or vectors. Each vector is represented by a pair of bytes. The first byte is an codebook index, a.k.a. an index into the 8x8 font table. The second byte of the pair represents the attributes. The upper 4 bits (7-4) of the attribute represent the background color and the lower 4 bits (3-0) represent the foreground color.&lt;br /&gt;
&lt;br /&gt;
=== Data Resources ===&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Color_Graphics_Adapter#The_CGA_color_palette&lt;br /&gt;
* http://multimedia.cx/CGA_FONT.8X8&lt;br /&gt;
&lt;br /&gt;
== Audio Format ==&lt;br /&gt;
The audio format used in 8088 Corruption is simply unsigned, 8-bit [[PCM]] played at 22050 Hz. Each frame contains 735 PCM bytes which happens to be the quotient of 22050/30.&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Platform-dependent Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=14610</id>
		<title>Creative 8 bits ADPCM</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=14610"/>
		<updated>2013-08-27T18:34:05Z</updated>

		<summary type="html">&lt;p&gt;Trixter: /* External sites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Company: [[Creative]]&lt;br /&gt;
&lt;br /&gt;
These ADPCM schemes are used in [[Creative_Voice|Creative VOC]] files. The only reference decoder is a hardware one: the Creative Sound Blaster (Pro). So this documentation is not based on reverse engineering. It's based on wild guessing and empirical tests but gives good enough results.  &lt;br /&gt;
&lt;br /&gt;
There are three different variation of this codec, which pack samples to either 4, 2.6 or 2 bits. The 2.6 scheme means that every byte is composed of 3 samples of 3 bits for the first and the second and 2 bits for the last.&lt;br /&gt;
&lt;br /&gt;
The three different schemes use the same algorithm with different initial parameters.&lt;br /&gt;
&lt;br /&gt;
=== Initialization ===&lt;br /&gt;
&lt;br /&gt;
The first byte is a raw (not compressed) sample, used as the initial value for prdiction.&lt;br /&gt;
&lt;br /&gt;
step is initialized to 0.&lt;br /&gt;
&lt;br /&gt;
shift is initialized to 2 for 2 bits scheme and to 0 else.&lt;br /&gt;
&lt;br /&gt;
limit is initialized to 5 for 4 bits samples, 3 for 3 bits samples and 1 for 2 bits samples.&lt;br /&gt;
&lt;br /&gt;
=== Decoding ===&lt;br /&gt;
&lt;br /&gt;
Every packed sample is composed of a sign bit (the most significant bit), and a value (the other bits). Let's define sign as 1 when the sign bit is 0 and -1 when the sign bit is 1. Now you can decode a packed sample with the following operation&lt;br /&gt;
 sample = prediction + sign * (value &amp;lt;&amp;lt; (step + shift))&lt;br /&gt;
sample have to be clamped to fit into an unsigned byte.&lt;br /&gt;
&lt;br /&gt;
Then prediction is updated to the new sample value, and step is updated using this algorithm:&lt;br /&gt;
 if (value &amp;gt;= limit)&lt;br /&gt;
   step++;&lt;br /&gt;
 else if (value == 0)&lt;br /&gt;
   step--;&lt;br /&gt;
step must be clamped into the 0..3 range.&lt;br /&gt;
&lt;br /&gt;
== External sites == &lt;br /&gt;
&lt;br /&gt;
* The DOSBox source contains code that claims to decode Creative ADPCM as well, but that code has not yet been verified against the information on this page.&lt;br /&gt;
&lt;br /&gt;
* The VOCEDIT 2 (VEDIT2.EXE) program that came with the Sound Blaster Pro can be used to compress 8-bit PCM .VOC files into all Creative 8-bit ADPCM variants, making it applicable for a reverse-engineering exercise.  The same software might be able to unpack packed files as well but this has not been verified.  Download link found at VOGONs at http://www.vogons.org/viewtopic.php?t=8634&lt;br /&gt;
&lt;br /&gt;
[[Category:Audio Codecs]]&lt;br /&gt;
[[Category:ADPCM Audio Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=14609</id>
		<title>Creative 8 bits ADPCM</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=14609"/>
		<updated>2013-08-27T18:31:39Z</updated>

		<summary type="html">&lt;p&gt;Trixter: /* External sites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Company: [[Creative]]&lt;br /&gt;
&lt;br /&gt;
These ADPCM schemes are used in [[Creative_Voice|Creative VOC]] files. The only reference decoder is a hardware one: the Creative Sound Blaster (Pro). So this documentation is not based on reverse engineering. It's based on wild guessing and empirical tests but gives good enough results.  &lt;br /&gt;
&lt;br /&gt;
There are three different variation of this codec, which pack samples to either 4, 2.6 or 2 bits. The 2.6 scheme means that every byte is composed of 3 samples of 3 bits for the first and the second and 2 bits for the last.&lt;br /&gt;
&lt;br /&gt;
The three different schemes use the same algorithm with different initial parameters.&lt;br /&gt;
&lt;br /&gt;
=== Initialization ===&lt;br /&gt;
&lt;br /&gt;
The first byte is a raw (not compressed) sample, used as the initial value for prdiction.&lt;br /&gt;
&lt;br /&gt;
step is initialized to 0.&lt;br /&gt;
&lt;br /&gt;
shift is initialized to 2 for 2 bits scheme and to 0 else.&lt;br /&gt;
&lt;br /&gt;
limit is initialized to 5 for 4 bits samples, 3 for 3 bits samples and 1 for 2 bits samples.&lt;br /&gt;
&lt;br /&gt;
=== Decoding ===&lt;br /&gt;
&lt;br /&gt;
Every packed sample is composed of a sign bit (the most significant bit), and a value (the other bits). Let's define sign as 1 when the sign bit is 0 and -1 when the sign bit is 1. Now you can decode a packed sample with the following operation&lt;br /&gt;
 sample = prediction + sign * (value &amp;lt;&amp;lt; (step + shift))&lt;br /&gt;
sample have to be clamped to fit into an unsigned byte.&lt;br /&gt;
&lt;br /&gt;
Then prediction is updated to the new sample value, and step is updated using this algorithm:&lt;br /&gt;
 if (value &amp;gt;= limit)&lt;br /&gt;
   step++;&lt;br /&gt;
 else if (value == 0)&lt;br /&gt;
   step--;&lt;br /&gt;
step must be clamped into the 0..3 range.&lt;br /&gt;
&lt;br /&gt;
== External sites == &lt;br /&gt;
&lt;br /&gt;
* The DOSBox source contains code that claims to decode Creative ADPCM as well, but that code has not yet been verified against the information on this page.&lt;br /&gt;
&lt;br /&gt;
* The VOCEDIT2 program that came with the Sound Blaster Pro can be used to compress 8-bit PCM .VOC files into all Creative 8-bit ADPCM variants, making it applicable for a reverse-engineering exercise.  The same software might be able to unpack packed files as well but this has not been verified.&lt;br /&gt;
&lt;br /&gt;
[[Category:Audio Codecs]]&lt;br /&gt;
[[Category:ADPCM Audio Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=14414</id>
		<title>Creative 8 bits ADPCM</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=14414"/>
		<updated>2013-03-08T18:58:20Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Company: [[Creative]]&lt;br /&gt;
&lt;br /&gt;
These ADPCM schemes are used in [[Creative_Voice|Creative VOC]] files. The only reference decoder is a hardware one: the Creative Sound Blaster (Pro). So this documentation is not based on reverse engineering. It's based on wild guessing and empirical tests but gives good enough results.  &lt;br /&gt;
&lt;br /&gt;
There are three different variation of this codec, which pack samples to either 4, 2.6 or 2 bits. The 2.6 scheme means that every byte is composed of 3 samples of 3 bits for the first and the second and 2 bits for the last.&lt;br /&gt;
&lt;br /&gt;
The three different schemes use the same algorithm with different initial parameters.&lt;br /&gt;
&lt;br /&gt;
=== Initialization ===&lt;br /&gt;
&lt;br /&gt;
The first byte is a raw (not compressed) sample, used as the initial value for prdiction.&lt;br /&gt;
&lt;br /&gt;
step is initialized to 0.&lt;br /&gt;
&lt;br /&gt;
shift is initialized to 2 for 2 bits scheme and to 0 else.&lt;br /&gt;
&lt;br /&gt;
limit is initialized to 5 for 4 bits samples, 3 for 3 bits samples and 1 for 2 bits samples.&lt;br /&gt;
&lt;br /&gt;
=== Decoding ===&lt;br /&gt;
&lt;br /&gt;
Every packed sample is composed of a sign bit (the most significant bit), and a value (the other bits). Let's define sign as 1 when the sign bit is 0 and -1 when the sign bit is 1. Now you can decode a packed sample with the following operation&lt;br /&gt;
 sample = prediction + sign * (value &amp;lt;&amp;lt; (step + shift))&lt;br /&gt;
sample have to be clamped to fit into an unsigned byte.&lt;br /&gt;
&lt;br /&gt;
Then prediction is updated to the new sample value, and step is updated using this algorithm:&lt;br /&gt;
 if (value &amp;gt;= limit)&lt;br /&gt;
   step++;&lt;br /&gt;
 else if (value == 0)&lt;br /&gt;
   step--;&lt;br /&gt;
step must be clamped into the 0..3 range.&lt;br /&gt;
&lt;br /&gt;
== External sites == &lt;br /&gt;
&lt;br /&gt;
* The DOSBox source contains code that claims to decode Creative ADPCM as well, but that code has not yet been verified against the information on this page.&lt;br /&gt;
&lt;br /&gt;
[[Category:Audio Codecs]]&lt;br /&gt;
[[Category:ADPCM Audio Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Indeo_3&amp;diff=13507</id>
		<title>Indeo 3</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Indeo_3&amp;diff=13507"/>
		<updated>2011-06-21T17:49:27Z</updated>

		<summary type="html">&lt;p&gt;Trixter: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* FourCC: IV31, IV32&lt;br /&gt;
* Company: [[Intel]], [[Ligos]]&lt;br /&gt;
* Technical Description: http://www.csse.monash.edu.au/~timf/videocodec/indeo3.txt ([[Mirrored Files|mirrored]])&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/V-codecs/IV32/&lt;br /&gt;
* Partial specification: http://multimedia.cx/mirror/5386232.pdf&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Indeo Video 3 is a proprietary video compression algorithm developed by [[Intel]]. It is primarily used to encode video in&lt;br /&gt;
AVI files. The format was seen commonly since 1992 after the release of Windows 3.1 and was superseded by Indeo Video Interactive version 4 and 5 (see [[Indeo 4]] and [[Indeo 5]]). &lt;br /&gt;
&lt;br /&gt;
There are several versions of this codec (R3.1, R3.2) but the version R3.2 (FOURCC 'IV32') is the most common. There is a support for this codec for all major platforms (Windows, Macintosh, Linux).&lt;br /&gt;
&lt;br /&gt;
This document focuses on principles necessary to implement an Indeo Video 3 decoder.&lt;br /&gt;
&lt;br /&gt;
== Decoder specification ==&lt;br /&gt;
&lt;br /&gt;
=== Coding techniques ===&lt;br /&gt;
&lt;br /&gt;
Indeo Video 3 employs [[Subsampling|color subsampling]], [[Differential_Coding|differential coding]], [[Vector_Quantization|vector quantization]], [[Run_Length_Encoding|run-lenght coding]] and [[Motion_Compensation|motion compensation]] to achieve its compression.&lt;br /&gt;
&lt;br /&gt;
=== Supported picture dimensions ===&lt;br /&gt;
&lt;br /&gt;
Indeo3 has the following size restrictions:&lt;br /&gt;
 width:  16...640 pixels&lt;br /&gt;
 height: 16...480 pixels&lt;br /&gt;
All picture dimensions must be a multiple of 4.&lt;br /&gt;
&lt;br /&gt;
=== Internal pixel format ===&lt;br /&gt;
&lt;br /&gt;
Indeo Video 3 operates completely in the YUV color space. It uses a special downsampled case of the [[YCbCr 4:1:0|YVU 4:1:0]] format where pixel are represented using only 7 bits. The downsampling is done in the encoder by applying the right shifting on pixel values after color conversion and subsampling. Thus, both encoder and decoder operate internally on pixel values in the range of 0-127. This was done in order to permit the software-based SIMD processing (see [[#Software vector operations|software vector operations]]).&lt;br /&gt;
&lt;br /&gt;
Additionaly the upsampling is needed in the decoder. After each plane was decoded, the pixel values shall be shifted one bit left to convert them back to 8-bit values.&lt;br /&gt;
&lt;br /&gt;
=== Software vector operations ===&lt;br /&gt;
&lt;br /&gt;
Indeo3 is built upon the so-called &amp;quot;softSIMD&amp;quot; technique, which allows an emulation of the vector operations purely in software. As this codec was developed there was no processors equipped with a SIMD instruction set, therefore the &amp;quot;softSIMD&amp;quot; can significally boost performance.&lt;br /&gt;
&lt;br /&gt;
In a processor with explicit SIMD (single instruction, multiply data) support, one operation is executed on two or more data sets to produce multiple outputs. The basic idea of the &amp;quot;softSIMD&amp;quot; is to treat the processor registers as containing multiple data words; for example, a 32-bit register can be treated as containing four 8-bit data words.&lt;br /&gt;
&lt;br /&gt;
The examples below illustrate how the &amp;quot;softSIMD&amp;quot; is implemented in Indeo3:&lt;br /&gt;
&lt;br /&gt;
 Example 1: Adding two delta values to two pixels at once&lt;br /&gt;
  &lt;br /&gt;
 src_pixels = 0x20202020; // predicted pixels&lt;br /&gt;
 delta      = 0x0000FE01; // low-order bits contain two delta values: -2 and +1&lt;br /&gt;
 dst_pixels = src_pixels + delta; // dst_pixels contains 0x20201E21 now&lt;br /&gt;
&lt;br /&gt;
 Example 2: Adding four delta values to four pixels at once&lt;br /&gt;
  &lt;br /&gt;
 src_pixels = 0x20202020; // predicted pixels&lt;br /&gt;
 delta      = 0xFE030201; // delta values: -2, +3, +2 and +1&lt;br /&gt;
 dst_pixels = src_pixels + delta; // dst_pixels contains 0x1E232221 now&lt;br /&gt;
&lt;br /&gt;
 Example 3: Averaging four pixels at once&lt;br /&gt;
  &lt;br /&gt;
 dst_pixels = ((src_pixels1 + src_pixels2) &amp;gt;&amp;gt; 1) &amp;amp; 0x7F7F7F7F;&lt;br /&gt;
&lt;br /&gt;
=== Internal picture representation ===&lt;br /&gt;
&lt;br /&gt;
Each picture (frame) is divided into following pieces: planes, strips, cells and blocks.&lt;br /&gt;
&lt;br /&gt;
Each frame consists of three planes: Y, V and U.&lt;br /&gt;
&lt;br /&gt;
Each plane can be segmented into one or more vertical strips depends on picture width. A strip is a region of the image being encoded as self-contained section. A strip has fixed width (160 pixels for luminance and 40 pixels for chrominance). Its height is always the same as the height of the picture. Large pictures shall be encoded in several strips. This makes the encoder/decoder simplier and faster. The following example shows a typical picture segmentation (sizes are given for the luminance plane; for chrominance ones those must be divided by 4):&lt;br /&gt;
&lt;br /&gt;
 if the width of the image &amp;lt;= 160:	there is only one strip which width is &amp;lt;= 160&lt;br /&gt;
 if the width of the image &amp;gt; 160:	there are two strips: 160 + (pic_width % 160)&lt;br /&gt;
 if the width of the image &amp;gt; 320:	there are three strips: 160 + 160 + (pic_width % 320)&lt;br /&gt;
 if the width of the image &amp;gt; 480:	there are four strips: 160 + 160 + 160 + (pic_width % 480)&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;%&amp;quot; in the examples above denotes the &amp;quot;MOD&amp;quot; operation.&lt;br /&gt;
&lt;br /&gt;
Each strip is encoded with either intra-frame or inter-frame prediction. Inter-frame prediction is obtained by applying motion estimation.&lt;br /&gt;
&lt;br /&gt;
Each strip will be further segmented into cells using [[#Binary tree segmentation|binary tree image segmentation]]. Each cell consists of blocks in the raster order. All blocks in a cell share the same quantizations parameters: quantization mode and delta table index.&lt;br /&gt;
&lt;br /&gt;
Available block sizes are 4x4, 4x8 and 8x8 pixels. The size of the block is determined during the encoding process according with energy of the cell. Blocks are quantized using adaptive vector quantization and the resulting bytecodes are packed into the compressed bitstream.&lt;br /&gt;
&lt;br /&gt;
=== Binary tree segmentation ===&lt;br /&gt;
&lt;br /&gt;
Binary tree segmentation is performed by splitting a region in half horizontally or vertically, and then possibly&lt;br /&gt;
splitting each of the resulting sub-regions in half and so on until the desired segmentation (suitable for&lt;br /&gt;
quantization) is achieved. The resulting structure is referred to as a &amp;quot;binary tree&amp;quot; because each node which is&lt;br /&gt;
not a terminal node is being splitted to form two subbranches. The top node of the tree represents the entire strip.&lt;br /&gt;
Each time a region is split, two new nodes are formed. The terminal node of the tree (i.e. which has no branches) will be encoded  using vector quantization and run-length encoding.&lt;br /&gt;
&lt;br /&gt;
=== Picture header ===&lt;br /&gt;
&lt;br /&gt;
Picture header of indeo3 consists of the frame header and the bitstream header.&lt;br /&gt;
&lt;br /&gt;
==== Frame header ====&lt;br /&gt;
&lt;br /&gt;
This header is undocumented in the mentioned patent but its structure is very easy to understand:&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;
! size !! name !! comments&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || frame_number || frame number starting with &amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD  || unknown1 || seems to be always &amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || check_sum || checksum used for identifying indeo3 streams. Obtained as follows: [[#frame_number|frame_number]] XOR [[#unknown1|unknown1]] XOR [[#frame_size|frame_size]] XOR 'FRMH'.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || frame_size || size of frame data in bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Bitstream header ====&lt;br /&gt;
&lt;br /&gt;
A good description of this header is given in the patent mentioned above. The table below explains it with some additional comments:&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;
! size !! name !! value(s) !! comments&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | WORD || dec_version || always = 0x20 || indicates decoder version. Values other than 0x20 seem to be unsupported.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | WORD  || frame_flags ||&lt;br /&gt;
* bit 0 =&amp;gt; &amp;quot;1&amp;quot; indicates a periodic INTRA (key) frame.&lt;br /&gt;
* bit 1 =&amp;gt; &amp;quot;1&amp;quot; indicates the use of the YVU9 8-bit pixel format. Unsupported by all known indeo3 decoders.&lt;br /&gt;
* bit 2 =&amp;gt; &amp;quot;1&amp;quot; indicates a INTRA (key) frame, either periodic or random one.&lt;br /&gt;
* bit 3 =&amp;gt; &amp;quot;1&amp;quot; tells that the next frame is an INTRA frame.&lt;br /&gt;
* bit 4 =&amp;gt; &amp;quot;1&amp;quot; horizontal motion vectors have the halfpel resolution.&lt;br /&gt;
* bit 5 =&amp;gt; &amp;quot;1&amp;quot; vertical motion vectors have the halfpel resolution.&lt;br /&gt;
* bit 6 =&amp;gt; unused.&lt;br /&gt;
* bit 7 =&amp;gt; reserved.&lt;br /&gt;
* bit 8 =&amp;gt; this frame is a droppable INTER frame.&lt;br /&gt;
* bit 9 =&amp;gt; buffer selector: 0 - primary, 1 - secondary.&lt;br /&gt;
* bits 10...15 are reserved.&lt;br /&gt;
|| frame flags. Bit 0 is the LSB.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || data_size || value of &amp;quot;128&amp;quot; indicates a NULL (sync) frame. || size of the bitstream in bits.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | BYTE || cb_offset || || offset for selecting VQ tables for the modes 1 and 4 (see below).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | BYTE || reserved1 || || should be ignored.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | WORD || checksum || || introduced for debugging. Unfortunately all known encoders set this field to &amp;quot;0&amp;quot; making it unusable.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | WORD || height || || height of the coded picture.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | WORD || width || || width of the coded picture.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || y_offset || || offset to the data of the luminance plane from the beginning of this header.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || v_offset || || offset to the data of the chroma v plane from the beginning of this header.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || u_offset || || offset to the data of the chroma u plane from the beginning of this header.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || reserved2 || || should be ignored.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 16 bytes || alt_quant || each byte indicates a pair of the VQ tables:&lt;br /&gt;
* bits 0...3 =&amp;gt; secondary table index&lt;br /&gt;
* bits 4...7 =&amp;gt; primary table index&lt;br /&gt;
|| VQ table set should be used with the modes 1 and 4.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Plane data ====&lt;br /&gt;
&lt;br /&gt;
Each plane data has the following format:&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;
! size !! name !! condition !! comments&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || num_vectors || || number of motion vectors if any. Contains &amp;quot;0&amp;quot; for INTRA frames.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | [[#num_vectors|num_vectors]] * 2  || mc_vectors || present only if [[#num_vectors|num_vectors]] != 0&lt;br /&gt;
|| array of motion vectors. Each entry contains two signed bytes. First one is the vertical component, second one is the horizontal component.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | variable || vq_data || || binary tree codes interleaved with cell data.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The plane data itself stores a binary tree segmentation interleaved with VQ codes for each cell and usually looks like this:&lt;br /&gt;
&lt;br /&gt;
 binary tree codes for selecting the size of the cell 0&lt;br /&gt;
 VQ codes for the cell 0&lt;br /&gt;
 binary tree codes for selecting the size of the cell 1&lt;br /&gt;
 VQ codes for the cell 1&lt;br /&gt;
 ...&lt;br /&gt;
 binary tree codes for selecting the size of the cell n&lt;br /&gt;
 VQ codes for the cell n&lt;br /&gt;
&lt;br /&gt;
The C-pseudocode example [[#Parsing binary tree codes|here]] shows how to parse the binary tree segmentation properly.&lt;br /&gt;
&lt;br /&gt;
==== VQ data codes ====&lt;br /&gt;
&lt;br /&gt;
The VQ data for each cell contains one-byte VQ codes of the following three types:&lt;br /&gt;
&lt;br /&gt;
* '''DYAD''': this indicates a two-byte delta applied to two pixels at once.&lt;br /&gt;
* '''QUAD''': this indicates a four-byte delta applied to four pixels at once.&lt;br /&gt;
* '''RLE_ESC''': one of the special run-length codes (see below).&lt;br /&gt;
&lt;br /&gt;
Each 4x4 block is coded using 8 dyads. The following table shows the order of dyads and their pixels in a block:&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;
! line !! pixels of the dyad 1 !! pixels of the dyad 0&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 0 || 3, 2 || 1, 0&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 1 || 7, 6 || 5, 4&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2 || 11, 10 || 9, 8&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3 || 15, 14 || 13, 12&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
According with the table above a 4x4 block can be coded using 8 codes of the type &amp;quot;DYAD&amp;quot; as follows:&lt;br /&gt;
&lt;br /&gt;
 code 0 for the dyad 0, line 0&lt;br /&gt;
 code 1 for the dyad 1, line 0&lt;br /&gt;
 code 2 for the dyad 0, line 1&lt;br /&gt;
 code 3 for the dyad 1, line 1&lt;br /&gt;
 code 4 for the dyad 0, line 2&lt;br /&gt;
 code 5 for the dyad 1, line 2&lt;br /&gt;
 code 6 for the dyad 0, line 3&lt;br /&gt;
 code 7 for the dyad 1, line 3&lt;br /&gt;
&lt;br /&gt;
Two dyads can form a quad (four-byte delta). In this case the corresponding line will be coded using only one code of the type &amp;quot;QUAD&amp;quot;. The following example shows a valid block encoding intermixing both &amp;quot;DYAD&amp;quot; and &amp;quot;QUAD&amp;quot; codes:&lt;br /&gt;
&lt;br /&gt;
 code 0, type = DYAD for the dyad 0, line 0&lt;br /&gt;
 code 1, type = DYAD for the dyad 1, line 0&lt;br /&gt;
 code 2, type = QUAD for the dyads 0 and 1, line 1&lt;br /&gt;
 code 3, type = DYAD for the dyad 0, line 2&lt;br /&gt;
 code 4, type = DYAD for the dyad 1, line 2&lt;br /&gt;
 code 5, type = QUAD for the dyads 0 and 1, line 3&lt;br /&gt;
&lt;br /&gt;
As we've seen above a line in a 4x4 block can be coded using either two codes of the type &amp;quot;DYAD&amp;quot; or one code of the type &amp;quot;QUAD&amp;quot;. All other combinations are forbidden. The following example shows an invalid encoding intermixing both &amp;quot;DYAD&amp;quot; and &amp;quot;QUAD&amp;quot; codes:&lt;br /&gt;
&lt;br /&gt;
 code 0, type = DYAD for the dyad 0, line 0&lt;br /&gt;
 code 1, type = QUAD --------&amp;gt; ERROR!!!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Run-length codes =====&lt;br /&gt;
&lt;br /&gt;
Values 0xF8...0xFF of the VQ data codes are reserved for the special run-length codes. Their generalized meaning is described in the table below:&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;
! name !! value !! description !! valid for lines&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FF || 0xFF || apply null delta to all lines up to the 2nd line || 0&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FE || 0xFE || apply null delta to all lines up to the 3rd line || 0 and 1&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FD || 0xFD || apply null delta to all remaining lines of this block || 0, 1 and 2&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FC || 0xFC || apply null delta to all remaining lines of this block and to whole next block || all&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FB || 0xFB, counter || apply null delta to n blocks/skip n blocks. The &amp;quot;counter&amp;quot; is a byte and should be interpreted as follows:&lt;br /&gt;
* bits 0...4 =&amp;gt; number of blocks to process&lt;br /&gt;
* bit 5      =&amp;gt; 0 - copy blocks, 1 - mark blocks as skipped&lt;br /&gt;
* bits 6 and 7 are unused and should be set to &amp;quot;0&amp;quot;&lt;br /&gt;
|| all&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FA || 0xFA ||&lt;br /&gt;
* INTRA: mark this block as skipped&lt;br /&gt;
* INTER: copy data from the corresponding reference block&lt;br /&gt;
|| 0&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_F9 || 0xF9 ||&lt;br /&gt;
* INTRA: mark this block and the next one as skipped&lt;br /&gt;
* INTER: copy data from the corresponding two reference blocks&lt;br /&gt;
|| 0&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_F8 || 0xF8 || seems to be never used ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depends on coding mode, block size and block type there are some variations in the processing of this codes. For a detailed description see the explanation of the VQ coding modes below.&lt;br /&gt;
&lt;br /&gt;
== Pseudocode examples ==&lt;br /&gt;
&lt;br /&gt;
=== Parsing binary tree codes ===&lt;br /&gt;
&lt;br /&gt;
The C-pseudocode example below shows how to parse the binary tree segmentation properly:&lt;br /&gt;
&lt;br /&gt;
 #define H_SPLIT 0&lt;br /&gt;
 #define V_SPLIT 1&lt;br /&gt;
 #define INTRA   2&lt;br /&gt;
 #define INTER   3&lt;br /&gt;
 #define VQ_NULL 2&lt;br /&gt;
 #define VQ_DATA 3&lt;br /&gt;
 &lt;br /&gt;
 STRIP_WIDTH = 160 pixels for luma and 40 pixels for chroma planes;&lt;br /&gt;
 &lt;br /&gt;
 current_cell.position = (0,0);&lt;br /&gt;
 current_cell.dimensions = plane.dimensions;&lt;br /&gt;
 current_cell.tree = MC_TREE;&lt;br /&gt;
 current_cell.type = INTRA;&lt;br /&gt;
 &lt;br /&gt;
 while (binary tree not exhausted)&lt;br /&gt;
 {&lt;br /&gt;
     btree_code = get 2-bit binary tree code from bitstream;&lt;br /&gt;
     switch (btree_code) {&lt;br /&gt;
         if (current_cell.tree == MC_TREE) {&lt;br /&gt;
             case H_SPLIT:&lt;br /&gt;
                 split current cell into two vertical subcells and push them onto stack;&lt;br /&gt;
                 break;&lt;br /&gt;
             case V_SPLIT:&lt;br /&gt;
                 if (current_cell.width &amp;gt;= STRIP_WIDTH)&lt;br /&gt;
                     split current strip into two horizontal strips and push them onto stack;&lt;br /&gt;
                 else&lt;br /&gt;
                     split current cell into two horizontal subcells and push them onto stack;&lt;br /&gt;
                 break;&lt;br /&gt;
             case INTRA:&lt;br /&gt;
                 current_cell.type = INTRA;&lt;br /&gt;
                 current_cell.tree = VQ_TREE;&lt;br /&gt;
                 break;&lt;br /&gt;
             case INTER:&lt;br /&gt;
                 current_cell.type = INTER;&lt;br /&gt;
                 current_cell.tree = VQ_TREE;&lt;br /&gt;
                 current_cell.vec_indx = get next byte from bitstream;&lt;br /&gt;
                 break;&lt;br /&gt;
         } else { // VQ_TREE&lt;br /&gt;
             case H_SPLIT:&lt;br /&gt;
                 split current cell into two vertical subcells and push them onto stack;&lt;br /&gt;
                 break;&lt;br /&gt;
             case V_SPLIT:&lt;br /&gt;
                 if (current_cell.width &amp;gt;= STRIP_WIDTH)&lt;br /&gt;
                     split current strip into two horizontal strips and push them onto stack;&lt;br /&gt;
                 else&lt;br /&gt;
                     split current cell into two horizontal subcells and push them onto stack;&lt;br /&gt;
                 break;&lt;br /&gt;
             case VQ_NULL:&lt;br /&gt;
                 code = get 2-bit binary tree code from bitstream;&lt;br /&gt;
                 if (code == 0)&lt;br /&gt;
                     copy data from the referenced cell into current one;&lt;br /&gt;
                 else if (code == 1)&lt;br /&gt;
                     mark current cell as skipped;&lt;br /&gt;
                 else&lt;br /&gt;
                     return error &amp;quot;invalid null code&amp;quot;;&lt;br /&gt;
                 pop current cell from stack;&lt;br /&gt;
                 break;&lt;br /&gt;
             case VQ_DATA:&lt;br /&gt;
                 decode VQ data for current cell;&lt;br /&gt;
                 pop current cell from stack;&lt;br /&gt;
                 place binary tree data pointer to next byte after decoded data;&lt;br /&gt;
                 break;&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
[[Category:Video Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Indeo_3&amp;diff=13506</id>
		<title>Indeo 3</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Indeo_3&amp;diff=13506"/>
		<updated>2011-06-21T17:48:52Z</updated>

		<summary type="html">&lt;p&gt;Trixter: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* FourCC: IV31, IV32&lt;br /&gt;
* Company: [[Intel]], [[Ligos]]&lt;br /&gt;
* Technical Description: http://www.csse.monash.edu.au/~timf/videocodec/indeo3.txt ([[Mirrored Files|mirrored]])&lt;br /&gt;
* Samples: http://samples.mplayerhq.hu/V-codecs/IV32/&lt;br /&gt;
* Partial specification: http://multimedia.cx/mirror/5386232.pdf&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Indeo Video 3 is a proprietary video compression algorithm developed by [[Intel]]. It is primarily used to encode video in&lt;br /&gt;
AVI files. The format was seen commonly since 1992 around the release of Windows 3.1 and was superseded by Indeo Video Interactive version 4 and 5 (see [[Indeo 4]] and [[Indeo 5]]). &lt;br /&gt;
&lt;br /&gt;
There are several versions of this codec (R3.1, R3.2) but the version R3.2 (FOURCC 'IV32') is the most common. There is a support for this codec for all major platforms (Windows, Macintosh, Linux).&lt;br /&gt;
&lt;br /&gt;
This document focuses on principles necessary to implement an Indeo Video 3 decoder.&lt;br /&gt;
&lt;br /&gt;
== Decoder specification ==&lt;br /&gt;
&lt;br /&gt;
=== Coding techniques ===&lt;br /&gt;
&lt;br /&gt;
Indeo Video 3 employs [[Subsampling|color subsampling]], [[Differential_Coding|differential coding]], [[Vector_Quantization|vector quantization]], [[Run_Length_Encoding|run-lenght coding]] and [[Motion_Compensation|motion compensation]] to achieve its compression.&lt;br /&gt;
&lt;br /&gt;
=== Supported picture dimensions ===&lt;br /&gt;
&lt;br /&gt;
Indeo3 has the following size restrictions:&lt;br /&gt;
 width:  16...640 pixels&lt;br /&gt;
 height: 16...480 pixels&lt;br /&gt;
All picture dimensions must be a multiple of 4.&lt;br /&gt;
&lt;br /&gt;
=== Internal pixel format ===&lt;br /&gt;
&lt;br /&gt;
Indeo Video 3 operates completely in the YUV color space. It uses a special downsampled case of the [[YCbCr 4:1:0|YVU 4:1:0]] format where pixel are represented using only 7 bits. The downsampling is done in the encoder by applying the right shifting on pixel values after color conversion and subsampling. Thus, both encoder and decoder operate internally on pixel values in the range of 0-127. This was done in order to permit the software-based SIMD processing (see [[#Software vector operations|software vector operations]]).&lt;br /&gt;
&lt;br /&gt;
Additionaly the upsampling is needed in the decoder. After each plane was decoded, the pixel values shall be shifted one bit left to convert them back to 8-bit values.&lt;br /&gt;
&lt;br /&gt;
=== Software vector operations ===&lt;br /&gt;
&lt;br /&gt;
Indeo3 is built upon the so-called &amp;quot;softSIMD&amp;quot; technique, which allows an emulation of the vector operations purely in software. As this codec was developed there was no processors equipped with a SIMD instruction set, therefore the &amp;quot;softSIMD&amp;quot; can significally boost performance.&lt;br /&gt;
&lt;br /&gt;
In a processor with explicit SIMD (single instruction, multiply data) support, one operation is executed on two or more data sets to produce multiple outputs. The basic idea of the &amp;quot;softSIMD&amp;quot; is to treat the processor registers as containing multiple data words; for example, a 32-bit register can be treated as containing four 8-bit data words.&lt;br /&gt;
&lt;br /&gt;
The examples below illustrate how the &amp;quot;softSIMD&amp;quot; is implemented in Indeo3:&lt;br /&gt;
&lt;br /&gt;
 Example 1: Adding two delta values to two pixels at once&lt;br /&gt;
  &lt;br /&gt;
 src_pixels = 0x20202020; // predicted pixels&lt;br /&gt;
 delta      = 0x0000FE01; // low-order bits contain two delta values: -2 and +1&lt;br /&gt;
 dst_pixels = src_pixels + delta; // dst_pixels contains 0x20201E21 now&lt;br /&gt;
&lt;br /&gt;
 Example 2: Adding four delta values to four pixels at once&lt;br /&gt;
  &lt;br /&gt;
 src_pixels = 0x20202020; // predicted pixels&lt;br /&gt;
 delta      = 0xFE030201; // delta values: -2, +3, +2 and +1&lt;br /&gt;
 dst_pixels = src_pixels + delta; // dst_pixels contains 0x1E232221 now&lt;br /&gt;
&lt;br /&gt;
 Example 3: Averaging four pixels at once&lt;br /&gt;
  &lt;br /&gt;
 dst_pixels = ((src_pixels1 + src_pixels2) &amp;gt;&amp;gt; 1) &amp;amp; 0x7F7F7F7F;&lt;br /&gt;
&lt;br /&gt;
=== Internal picture representation ===&lt;br /&gt;
&lt;br /&gt;
Each picture (frame) is divided into following pieces: planes, strips, cells and blocks.&lt;br /&gt;
&lt;br /&gt;
Each frame consists of three planes: Y, V and U.&lt;br /&gt;
&lt;br /&gt;
Each plane can be segmented into one or more vertical strips depends on picture width. A strip is a region of the image being encoded as self-contained section. A strip has fixed width (160 pixels for luminance and 40 pixels for chrominance). Its height is always the same as the height of the picture. Large pictures shall be encoded in several strips. This makes the encoder/decoder simplier and faster. The following example shows a typical picture segmentation (sizes are given for the luminance plane; for chrominance ones those must be divided by 4):&lt;br /&gt;
&lt;br /&gt;
 if the width of the image &amp;lt;= 160:	there is only one strip which width is &amp;lt;= 160&lt;br /&gt;
 if the width of the image &amp;gt; 160:	there are two strips: 160 + (pic_width % 160)&lt;br /&gt;
 if the width of the image &amp;gt; 320:	there are three strips: 160 + 160 + (pic_width % 320)&lt;br /&gt;
 if the width of the image &amp;gt; 480:	there are four strips: 160 + 160 + 160 + (pic_width % 480)&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;%&amp;quot; in the examples above denotes the &amp;quot;MOD&amp;quot; operation.&lt;br /&gt;
&lt;br /&gt;
Each strip is encoded with either intra-frame or inter-frame prediction. Inter-frame prediction is obtained by applying motion estimation.&lt;br /&gt;
&lt;br /&gt;
Each strip will be further segmented into cells using [[#Binary tree segmentation|binary tree image segmentation]]. Each cell consists of blocks in the raster order. All blocks in a cell share the same quantizations parameters: quantization mode and delta table index.&lt;br /&gt;
&lt;br /&gt;
Available block sizes are 4x4, 4x8 and 8x8 pixels. The size of the block is determined during the encoding process according with energy of the cell. Blocks are quantized using adaptive vector quantization and the resulting bytecodes are packed into the compressed bitstream.&lt;br /&gt;
&lt;br /&gt;
=== Binary tree segmentation ===&lt;br /&gt;
&lt;br /&gt;
Binary tree segmentation is performed by splitting a region in half horizontally or vertically, and then possibly&lt;br /&gt;
splitting each of the resulting sub-regions in half and so on until the desired segmentation (suitable for&lt;br /&gt;
quantization) is achieved. The resulting structure is referred to as a &amp;quot;binary tree&amp;quot; because each node which is&lt;br /&gt;
not a terminal node is being splitted to form two subbranches. The top node of the tree represents the entire strip.&lt;br /&gt;
Each time a region is split, two new nodes are formed. The terminal node of the tree (i.e. which has no branches) will be encoded  using vector quantization and run-length encoding.&lt;br /&gt;
&lt;br /&gt;
=== Picture header ===&lt;br /&gt;
&lt;br /&gt;
Picture header of indeo3 consists of the frame header and the bitstream header.&lt;br /&gt;
&lt;br /&gt;
==== Frame header ====&lt;br /&gt;
&lt;br /&gt;
This header is undocumented in the mentioned patent but its structure is very easy to understand:&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;
! size !! name !! comments&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || frame_number || frame number starting with &amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD  || unknown1 || seems to be always &amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || check_sum || checksum used for identifying indeo3 streams. Obtained as follows: [[#frame_number|frame_number]] XOR [[#unknown1|unknown1]] XOR [[#frame_size|frame_size]] XOR 'FRMH'.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || frame_size || size of frame data in bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Bitstream header ====&lt;br /&gt;
&lt;br /&gt;
A good description of this header is given in the patent mentioned above. The table below explains it with some additional comments:&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;
! size !! name !! value(s) !! comments&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | WORD || dec_version || always = 0x20 || indicates decoder version. Values other than 0x20 seem to be unsupported.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | WORD  || frame_flags ||&lt;br /&gt;
* bit 0 =&amp;gt; &amp;quot;1&amp;quot; indicates a periodic INTRA (key) frame.&lt;br /&gt;
* bit 1 =&amp;gt; &amp;quot;1&amp;quot; indicates the use of the YVU9 8-bit pixel format. Unsupported by all known indeo3 decoders.&lt;br /&gt;
* bit 2 =&amp;gt; &amp;quot;1&amp;quot; indicates a INTRA (key) frame, either periodic or random one.&lt;br /&gt;
* bit 3 =&amp;gt; &amp;quot;1&amp;quot; tells that the next frame is an INTRA frame.&lt;br /&gt;
* bit 4 =&amp;gt; &amp;quot;1&amp;quot; horizontal motion vectors have the halfpel resolution.&lt;br /&gt;
* bit 5 =&amp;gt; &amp;quot;1&amp;quot; vertical motion vectors have the halfpel resolution.&lt;br /&gt;
* bit 6 =&amp;gt; unused.&lt;br /&gt;
* bit 7 =&amp;gt; reserved.&lt;br /&gt;
* bit 8 =&amp;gt; this frame is a droppable INTER frame.&lt;br /&gt;
* bit 9 =&amp;gt; buffer selector: 0 - primary, 1 - secondary.&lt;br /&gt;
* bits 10...15 are reserved.&lt;br /&gt;
|| frame flags. Bit 0 is the LSB.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || data_size || value of &amp;quot;128&amp;quot; indicates a NULL (sync) frame. || size of the bitstream in bits.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | BYTE || cb_offset || || offset for selecting VQ tables for the modes 1 and 4 (see below).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | BYTE || reserved1 || || should be ignored.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | WORD || checksum || || introduced for debugging. Unfortunately all known encoders set this field to &amp;quot;0&amp;quot; making it unusable.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | WORD || height || || height of the coded picture.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | WORD || width || || width of the coded picture.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || y_offset || || offset to the data of the luminance plane from the beginning of this header.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || v_offset || || offset to the data of the chroma v plane from the beginning of this header.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || u_offset || || offset to the data of the chroma u plane from the beginning of this header.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || reserved2 || || should be ignored.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 16 bytes || alt_quant || each byte indicates a pair of the VQ tables:&lt;br /&gt;
* bits 0...3 =&amp;gt; secondary table index&lt;br /&gt;
* bits 4...7 =&amp;gt; primary table index&lt;br /&gt;
|| VQ table set should be used with the modes 1 and 4.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Plane data ====&lt;br /&gt;
&lt;br /&gt;
Each plane data has the following format:&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;
! size !! name !! condition !! comments&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | DWORD || num_vectors || || number of motion vectors if any. Contains &amp;quot;0&amp;quot; for INTRA frames.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | [[#num_vectors|num_vectors]] * 2  || mc_vectors || present only if [[#num_vectors|num_vectors]] != 0&lt;br /&gt;
|| array of motion vectors. Each entry contains two signed bytes. First one is the vertical component, second one is the horizontal component.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | variable || vq_data || || binary tree codes interleaved with cell data.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The plane data itself stores a binary tree segmentation interleaved with VQ codes for each cell and usually looks like this:&lt;br /&gt;
&lt;br /&gt;
 binary tree codes for selecting the size of the cell 0&lt;br /&gt;
 VQ codes for the cell 0&lt;br /&gt;
 binary tree codes for selecting the size of the cell 1&lt;br /&gt;
 VQ codes for the cell 1&lt;br /&gt;
 ...&lt;br /&gt;
 binary tree codes for selecting the size of the cell n&lt;br /&gt;
 VQ codes for the cell n&lt;br /&gt;
&lt;br /&gt;
The C-pseudocode example [[#Parsing binary tree codes|here]] shows how to parse the binary tree segmentation properly.&lt;br /&gt;
&lt;br /&gt;
==== VQ data codes ====&lt;br /&gt;
&lt;br /&gt;
The VQ data for each cell contains one-byte VQ codes of the following three types:&lt;br /&gt;
&lt;br /&gt;
* '''DYAD''': this indicates a two-byte delta applied to two pixels at once.&lt;br /&gt;
* '''QUAD''': this indicates a four-byte delta applied to four pixels at once.&lt;br /&gt;
* '''RLE_ESC''': one of the special run-length codes (see below).&lt;br /&gt;
&lt;br /&gt;
Each 4x4 block is coded using 8 dyads. The following table shows the order of dyads and their pixels in a block:&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;
! line !! pixels of the dyad 1 !! pixels of the dyad 0&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 0 || 3, 2 || 1, 0&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 1 || 7, 6 || 5, 4&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2 || 11, 10 || 9, 8&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3 || 15, 14 || 13, 12&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
According with the table above a 4x4 block can be coded using 8 codes of the type &amp;quot;DYAD&amp;quot; as follows:&lt;br /&gt;
&lt;br /&gt;
 code 0 for the dyad 0, line 0&lt;br /&gt;
 code 1 for the dyad 1, line 0&lt;br /&gt;
 code 2 for the dyad 0, line 1&lt;br /&gt;
 code 3 for the dyad 1, line 1&lt;br /&gt;
 code 4 for the dyad 0, line 2&lt;br /&gt;
 code 5 for the dyad 1, line 2&lt;br /&gt;
 code 6 for the dyad 0, line 3&lt;br /&gt;
 code 7 for the dyad 1, line 3&lt;br /&gt;
&lt;br /&gt;
Two dyads can form a quad (four-byte delta). In this case the corresponding line will be coded using only one code of the type &amp;quot;QUAD&amp;quot;. The following example shows a valid block encoding intermixing both &amp;quot;DYAD&amp;quot; and &amp;quot;QUAD&amp;quot; codes:&lt;br /&gt;
&lt;br /&gt;
 code 0, type = DYAD for the dyad 0, line 0&lt;br /&gt;
 code 1, type = DYAD for the dyad 1, line 0&lt;br /&gt;
 code 2, type = QUAD for the dyads 0 and 1, line 1&lt;br /&gt;
 code 3, type = DYAD for the dyad 0, line 2&lt;br /&gt;
 code 4, type = DYAD for the dyad 1, line 2&lt;br /&gt;
 code 5, type = QUAD for the dyads 0 and 1, line 3&lt;br /&gt;
&lt;br /&gt;
As we've seen above a line in a 4x4 block can be coded using either two codes of the type &amp;quot;DYAD&amp;quot; or one code of the type &amp;quot;QUAD&amp;quot;. All other combinations are forbidden. The following example shows an invalid encoding intermixing both &amp;quot;DYAD&amp;quot; and &amp;quot;QUAD&amp;quot; codes:&lt;br /&gt;
&lt;br /&gt;
 code 0, type = DYAD for the dyad 0, line 0&lt;br /&gt;
 code 1, type = QUAD --------&amp;gt; ERROR!!!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Run-length codes =====&lt;br /&gt;
&lt;br /&gt;
Values 0xF8...0xFF of the VQ data codes are reserved for the special run-length codes. Their generalized meaning is described in the table below:&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;
! name !! value !! description !! valid for lines&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FF || 0xFF || apply null delta to all lines up to the 2nd line || 0&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FE || 0xFE || apply null delta to all lines up to the 3rd line || 0 and 1&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FD || 0xFD || apply null delta to all remaining lines of this block || 0, 1 and 2&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FC || 0xFC || apply null delta to all remaining lines of this block and to whole next block || all&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FB || 0xFB, counter || apply null delta to n blocks/skip n blocks. The &amp;quot;counter&amp;quot; is a byte and should be interpreted as follows:&lt;br /&gt;
* bits 0...4 =&amp;gt; number of blocks to process&lt;br /&gt;
* bit 5      =&amp;gt; 0 - copy blocks, 1 - mark blocks as skipped&lt;br /&gt;
* bits 6 and 7 are unused and should be set to &amp;quot;0&amp;quot;&lt;br /&gt;
|| all&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_FA || 0xFA ||&lt;br /&gt;
* INTRA: mark this block as skipped&lt;br /&gt;
* INTER: copy data from the corresponding reference block&lt;br /&gt;
|| 0&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_F9 || 0xF9 ||&lt;br /&gt;
* INTRA: mark this block and the next one as skipped&lt;br /&gt;
* INTER: copy data from the corresponding two reference blocks&lt;br /&gt;
|| 0&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | RLE_ESC_F8 || 0xF8 || seems to be never used ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depends on coding mode, block size and block type there are some variations in the processing of this codes. For a detailed description see the explanation of the VQ coding modes below.&lt;br /&gt;
&lt;br /&gt;
== Pseudocode examples ==&lt;br /&gt;
&lt;br /&gt;
=== Parsing binary tree codes ===&lt;br /&gt;
&lt;br /&gt;
The C-pseudocode example below shows how to parse the binary tree segmentation properly:&lt;br /&gt;
&lt;br /&gt;
 #define H_SPLIT 0&lt;br /&gt;
 #define V_SPLIT 1&lt;br /&gt;
 #define INTRA   2&lt;br /&gt;
 #define INTER   3&lt;br /&gt;
 #define VQ_NULL 2&lt;br /&gt;
 #define VQ_DATA 3&lt;br /&gt;
 &lt;br /&gt;
 STRIP_WIDTH = 160 pixels for luma and 40 pixels for chroma planes;&lt;br /&gt;
 &lt;br /&gt;
 current_cell.position = (0,0);&lt;br /&gt;
 current_cell.dimensions = plane.dimensions;&lt;br /&gt;
 current_cell.tree = MC_TREE;&lt;br /&gt;
 current_cell.type = INTRA;&lt;br /&gt;
 &lt;br /&gt;
 while (binary tree not exhausted)&lt;br /&gt;
 {&lt;br /&gt;
     btree_code = get 2-bit binary tree code from bitstream;&lt;br /&gt;
     switch (btree_code) {&lt;br /&gt;
         if (current_cell.tree == MC_TREE) {&lt;br /&gt;
             case H_SPLIT:&lt;br /&gt;
                 split current cell into two vertical subcells and push them onto stack;&lt;br /&gt;
                 break;&lt;br /&gt;
             case V_SPLIT:&lt;br /&gt;
                 if (current_cell.width &amp;gt;= STRIP_WIDTH)&lt;br /&gt;
                     split current strip into two horizontal strips and push them onto stack;&lt;br /&gt;
                 else&lt;br /&gt;
                     split current cell into two horizontal subcells and push them onto stack;&lt;br /&gt;
                 break;&lt;br /&gt;
             case INTRA:&lt;br /&gt;
                 current_cell.type = INTRA;&lt;br /&gt;
                 current_cell.tree = VQ_TREE;&lt;br /&gt;
                 break;&lt;br /&gt;
             case INTER:&lt;br /&gt;
                 current_cell.type = INTER;&lt;br /&gt;
                 current_cell.tree = VQ_TREE;&lt;br /&gt;
                 current_cell.vec_indx = get next byte from bitstream;&lt;br /&gt;
                 break;&lt;br /&gt;
         } else { // VQ_TREE&lt;br /&gt;
             case H_SPLIT:&lt;br /&gt;
                 split current cell into two vertical subcells and push them onto stack;&lt;br /&gt;
                 break;&lt;br /&gt;
             case V_SPLIT:&lt;br /&gt;
                 if (current_cell.width &amp;gt;= STRIP_WIDTH)&lt;br /&gt;
                     split current strip into two horizontal strips and push them onto stack;&lt;br /&gt;
                 else&lt;br /&gt;
                     split current cell into two horizontal subcells and push them onto stack;&lt;br /&gt;
                 break;&lt;br /&gt;
             case VQ_NULL:&lt;br /&gt;
                 code = get 2-bit binary tree code from bitstream;&lt;br /&gt;
                 if (code == 0)&lt;br /&gt;
                     copy data from the referenced cell into current one;&lt;br /&gt;
                 else if (code == 1)&lt;br /&gt;
                     mark current cell as skipped;&lt;br /&gt;
                 else&lt;br /&gt;
                     return error &amp;quot;invalid null code&amp;quot;;&lt;br /&gt;
                 pop current cell from stack;&lt;br /&gt;
                 break;&lt;br /&gt;
             case VQ_DATA:&lt;br /&gt;
                 decode VQ data for current cell;&lt;br /&gt;
                 pop current cell from stack;&lt;br /&gt;
                 place binary tree data pointer to next byte after decoded data;&lt;br /&gt;
                 break;&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
[[Category:Video Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Scream_Tracker_3_Module&amp;diff=13280</id>
		<title>Scream Tracker 3 Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Scream_Tracker_3_Module&amp;diff=13280"/>
		<updated>2011-02-04T18:40:43Z</updated>

		<summary type="html">&lt;p&gt;Trixter: Adlib hardware has two modes: 9 melodic, or 6 melodic+5 drums.  ST3 only supports 9 melodic.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: s3m&lt;br /&gt;
A normally 16-channel module format for MS-DOS on the PC, it can also support OPL2 FM synthesis (9 melodic channels). While the format itself can technically support 32 channels, only the 25 mentioned have any meaning assigned to them, and they are usually not all used at the same time.&lt;br /&gt;
&lt;br /&gt;
Aspects which are easy to get wrong with this format are in '''bold text'''.&lt;br /&gt;
&lt;br /&gt;
Unless otherwise specified, this information pertains to Scream Tracker v3.21's play routine.&lt;br /&gt;
&lt;br /&gt;
==File Format==&lt;br /&gt;
&lt;br /&gt;
The format is little-endian (least significant byte first). A &amp;quot;byte&amp;quot; is 8 bits, a &amp;quot;word&amp;quot; is 16 bits, and a &amp;quot;dword&amp;quot; (double word) is 32 bits. Hex values will be denoted with &amp;quot;0x&amp;quot;. A parapointer points to pp*16 in the file due to the DOS nature of the format.&lt;br /&gt;
&lt;br /&gt;
Note that if some parts of the format are inconsistent, it's usually best to let it slip, as ST3 itself will allegedly for instance load instruments which don't have the &amp;quot;SCRS&amp;quot; / &amp;quot;SCRI&amp;quot; mark.&lt;br /&gt;
&lt;br /&gt;
*28 bytes: module name, NUL-terminated, NUL-padded.&lt;br /&gt;
*Byte: 0x1A.&lt;br /&gt;
*Byte: 16 (0x10) to indicate this is a Scream Tracker 3 module.&lt;br /&gt;
*2 reserved bytes, should be set to 0x00.&lt;br /&gt;
*6 words, denoting the following:&lt;br /&gt;
**Order count&lt;br /&gt;
**Instrument count&lt;br /&gt;
**Pattern count&lt;br /&gt;
**Flags&lt;br /&gt;
***Bit 0 (pre-3.01 ONLY): ST2 vibrato ''(effect unknown)''.&lt;br /&gt;
***Bit 1 (pre-3.01 ONLY): ST2 tempo ''(effect unknown)''.&lt;br /&gt;
***Bit 3 (pre-3.01 ONLY): Amiga slides ''(effect unknown)''.&lt;br /&gt;
***Bit 4: 0-vol optimisations - turn off looping notes which have a zero volume for more than(?) 2 rows.&lt;br /&gt;
***Bit 5: Amiga limits (limit periods to confine to 113 &amp;lt;= x &amp;lt;= 856).&lt;br /&gt;
***Bit 6 (pre-3.01 ONLY): Enable filter / sfx with SB ''(effect unknown)''.&lt;br /&gt;
***Bit 7: ST3.00 volume slides ('''automatically enabled if tracker version is &amp;lt;= 0x1300''') - if enabled, ''all'' volume slides occur ''every'' tick.&lt;br /&gt;
***Bit 8: Special custom data in file (uses &amp;quot;Special&amp;quot; field)&lt;br /&gt;
*Tracker version&lt;br /&gt;
**0x1xyy == Scream Tracker x.yy&lt;br /&gt;
**0x2xyy == Imago Orpheus x.yy&lt;br /&gt;
**0x3xyy == Impulse Tracker x.yy&lt;br /&gt;
**0x4xyy == Schism Tracker (version numbering scheme is different)&lt;br /&gt;
**0x5xyy == OpenMPT&lt;br /&gt;
*File format information&lt;br /&gt;
**1 == signed samples (horribly, horribly old)&lt;br /&gt;
**2 == unsigned samples&lt;br /&gt;
**Anything else is invalid and ST3 will not load the file(?).&lt;br /&gt;
*4 byte string: &amp;quot;SCRM&amp;quot;&lt;br /&gt;
*6 bytes, denoting the following:&lt;br /&gt;
**Global volume (range 0 &amp;lt;= x &amp;lt;= 64) which is used in calculating individual channel volumes '''and is nasty.'''&lt;br /&gt;
**Initial speed (ticks per row / TPR) - '''if 0 ''or 255'', it is ignored''' and 6 is used instead. The value of 255 is very unusual as AFF (set speed to 0xFF == 255) still works.&lt;br /&gt;
**Initial tempo - if '''less than 33, it is ignored''' and 125 is used instead.&lt;br /&gt;
**Mixing volume (range 16 &amp;lt;= x &amp;lt;= 127) which is only used for Sound Blaster. '''It is multiplied by 11/8 when stereo is on.'''&lt;br /&gt;
**Ultra-click removal which is only used for Gravis Ultrasound. ST3.21's interface only allows inputting of values 8, 12, or 16. Allegedly this is the number of GUS channels to allocate to guarantee that this value / 2 channels will play w/o clicks.&lt;br /&gt;
**Default pan value flag, if equal to 252 then load the default panning values at the end of the header, otherwise don't bother.&lt;br /&gt;
*8 reserved bytes, should be set to 0x00, although some trackers write stuff in here.&lt;br /&gt;
*1 parapointer: &amp;quot;Special&amp;quot;, used to point to &amp;quot;special custom data&amp;quot; which is not used in ST 3.01 or later. ST3.21's TECH.DOC refers to ExtHead which is not mentioned anywhere else. This should be safe to ignore.&lt;br /&gt;
*32 bytes indicating channel settings, as follows:&lt;br /&gt;
**If bit 8 is set, this channel is enabled.&lt;br /&gt;
**The lower 7 bits indicate the channel type:&lt;br /&gt;
***0 &amp;lt;= x &amp;lt;= 7: Left PCM channel 1-8 (Lx)&lt;br /&gt;
***8 &amp;lt;= x &amp;lt;= 15: Right PCM channel 1-8 (Rx)&lt;br /&gt;
***16 &amp;lt;= x &amp;lt;= 24: Adlib/OPL2 #1 melody (Ax)&lt;br /&gt;
***25 &amp;lt;= x &amp;lt;= 29: Adlib/OPL2 #1 drums (A_, where _ can be one of {''(TODO: look this up''}) - ''is this used?''&lt;br /&gt;
***Immediately after Adlib/OPL2 #1, there's some provision for a second OPL2 chip, although this does not appear to be supported / used.&lt;br /&gt;
**'''It is possible to map two pattern channels to the same output channel, which allows for some quirks. This is NOT supported by virtually any player other than ST3 itself.''' pys3m supports it, but is very obscure and quite slow. '''WARNING:''' Despite being less useful than you might expect, there ARE reasons why people would do this!&lt;br /&gt;
*Order list: series of bytes indicating pattern indices.&lt;br /&gt;
*Instrument parapointer list: series of parapointers pointing to instruments.&lt;br /&gt;
*Pattern parapointer list: series of parapointers pointing to patterns.&lt;br /&gt;
*OPTIONAL: Panning list: Entries are as follows:&lt;br /&gt;
**Bits 6 and 7 are reserved.&lt;br /&gt;
**Bit 5(?): If set, use the value specified, otherwise use default (7 for mono, 3(L) / C(R) for stereo).&lt;br /&gt;
**Bits 0-3: Specified panning value if default not used.&lt;br /&gt;
&lt;br /&gt;
''TODO: ST3.21's TECH.DOC should cover instruments.''&lt;br /&gt;
&lt;br /&gt;
==Playback Notes==&lt;br /&gt;
&lt;br /&gt;
Note w/o sample results in retriggering the note without resetting the volume.&lt;br /&gt;
&lt;br /&gt;
Sample w/o note results in resetting the volume and ''switching samples'' w/o retriggering the note. If the C4 speeds differ, this could potentially be out of tune as it does not convert the internal period values. If the note is off, it will stay off - it will not retrigger.&lt;br /&gt;
&lt;br /&gt;
Vibrato and tremolo have a full cycle length of 256, though Hxy and Rxy use x*4 and y*4 as their parameters.&lt;br /&gt;
&lt;br /&gt;
Base clock is 14317056 Hz. When calculating a note's period, use the following table:&lt;br /&gt;
&lt;br /&gt;
  C    C#   D    D#   E    F    F#   G    G#   A   A#   A&lt;br /&gt;
 1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,907&lt;br /&gt;
&lt;br /&gt;
and calculate the period like so:&lt;br /&gt;
&lt;br /&gt;
 period = 8363 * 16 * (note &amp;gt;&amp;gt; octave) / middle_c_frequency_of_instrument&lt;br /&gt;
&lt;br /&gt;
''Theoretically'', both the period and the volume have &amp;quot;stored&amp;quot; values and &amp;quot;active&amp;quot; values.&lt;br /&gt;
&lt;br /&gt;
'''Volumes actually peak at 63''', and not 64. Setting the volume to 64 will actually make it go to 63.&lt;br /&gt;
&lt;br /&gt;
However, on '''adlib channels''', if the default volume is 64, it will use 64. Any further operations on the volume will clip it to within the 0-63 range.&lt;br /&gt;
&lt;br /&gt;
Many effects use the '''latest nonzero effect parameter encountered''', as noted a bit further below.&lt;br /&gt;
&lt;br /&gt;
===Multiple channel mapping quirk===&lt;br /&gt;
'''It is possible to map two pattern channels to one output channel.''' However, it is rather quirky, but usable.&lt;br /&gt;
&lt;br /&gt;
Note that '''only the last pattern channel's effects are used'''.&lt;br /&gt;
&lt;br /&gt;
''TODO: document this quirk in detail.''&lt;br /&gt;
&lt;br /&gt;
==Effects==&lt;br /&gt;
&lt;br /&gt;
''TODO the rest''&lt;br /&gt;
&lt;br /&gt;
Effects marked with a % use '''the latest nonzero effect parameter to show up'''. Effects with a * have their own memory.&lt;br /&gt;
&lt;br /&gt;
===Axx===&lt;br /&gt;
Set speed. If the parameter '''is 0''', the effect is '''ignored'''.&lt;br /&gt;
&lt;br /&gt;
===Bxx===&lt;br /&gt;
Order jump.&lt;br /&gt;
&lt;br /&gt;
===Cxx===&lt;br /&gt;
Row jump.&lt;br /&gt;
&lt;br /&gt;
===Dxy (%)===&lt;br /&gt;
Volume slide. If one of the values are 0, then we slide on all nonzero ticks. If one of the values are F, then we slide on all zero ticks. That means that '''D0F slides down 15 on all ticks and DF0 slides up 15 on all ticks'''.&lt;br /&gt;
&lt;br /&gt;
However, if fast slides are enabled (if they are set as a flag or the version is &amp;lt;= 0x1300), then, unless we're doing a fineslide, we slide on all ticks.&lt;br /&gt;
&lt;br /&gt;
When we do a volume slide, we slide the active volume '''without modifying the stored volume'''.&lt;br /&gt;
&lt;br /&gt;
The checking order is not the same as ImpulseTracker.&lt;br /&gt;
''TODO: Nail the checking order. D13 for instance slides down 3.''&lt;br /&gt;
&lt;br /&gt;
Here's a full detailed description of all possible cases (0x00..0xFF) and how both Scream Tracker and Impulse Tracker handle them:&lt;br /&gt;
*D0x, 1 &amp;lt;= x &amp;lt;= 0xE: slide down by x on all nonzero ticks. Also slide on tick 0, if fast slides are enabled.&lt;br /&gt;
*Dx0, 1 &amp;lt;= x &amp;lt;= 0xE: slide up by x on all nonzero ticks. Also slide on tick 0, if fast slides are enabled.&lt;br /&gt;
*DFx, 1 &amp;lt;= x &amp;lt;= 0xE: slide down by x on tick 0.&lt;br /&gt;
*DxF, 1 &amp;lt;= x &amp;lt;= 0xE: slide up by x on tick 0.&lt;br /&gt;
*DFF: slide up by 15 on tick 0.&lt;br /&gt;
*D0F: slide down by 15 on all ticks. Not affected at all by the fast slides flag.&lt;br /&gt;
*DF0: slide up by 15 on all ticks. Not affected at all by the fast slides flag.&lt;br /&gt;
*Dxy, 1 &amp;lt;= x &amp;lt;= 0xE, 1 &amp;lt;= y &amp;lt;= 0xE: Scream Tracker treats it as a slide down by y, i.e. equivalent to D0y. Impulse Tracker does nothing.&lt;br /&gt;
*D00: Scream Tracker uses the last nonzero effect parameter in the channel. Impulse Tracker uses the last nonzero value used for Dxx, Kxx or Lxx in the channel.&lt;br /&gt;
&lt;br /&gt;
===Exx (%)===&lt;br /&gt;
Slide down.&lt;br /&gt;
&lt;br /&gt;
===Fxx (%)===&lt;br /&gt;
Slide up.&lt;br /&gt;
&lt;br /&gt;
===Gxx (*)===&lt;br /&gt;
Slide to note.&lt;br /&gt;
&lt;br /&gt;
===Hxy (*)===&lt;br /&gt;
Vibrato. This effect '''shares memory''' with '''Uxy'''.&lt;br /&gt;
&lt;br /&gt;
===Ixy (%)===&lt;br /&gt;
Tremor. ''TODO: this effect is weird.''&lt;br /&gt;
&lt;br /&gt;
(Looking through what's released of the ST3 playback source code, tremor is not retriggered if there's a Dxy effect, or something like that, but this needs to be clarified.)&lt;br /&gt;
&lt;br /&gt;
===Jxy (%)===&lt;br /&gt;
Arpeggio. ''TODO: this effect is weird.''&lt;br /&gt;
&lt;br /&gt;
===Kxy (%)===&lt;br /&gt;
H00 + Dxy.&lt;br /&gt;
&lt;br /&gt;
The volume slide, performed by this effect differs from Dxy in the following ways:&lt;br /&gt;
* '''Does not support fine volume slides.'''&lt;br /&gt;
* '''Not affected by the fast volume slides flag.''' Always acts as if the flag is not set, even when it is.&lt;br /&gt;
* '''KF0''' and '''K0F do not slide on tick 0'''.&lt;br /&gt;
&lt;br /&gt;
===Lxy (%)===&lt;br /&gt;
G00 + Dxy.&lt;br /&gt;
&lt;br /&gt;
The volume slide '''differs from Dxy'''. See '''Kxy''' for details.&lt;br /&gt;
&lt;br /&gt;
===Oxx (*)===&lt;br /&gt;
Set sample offset.&lt;br /&gt;
&lt;br /&gt;
===Qxy (%)===&lt;br /&gt;
Retrigger note every y ticks with volume modifier x.&lt;br /&gt;
&lt;br /&gt;
Values for x:&lt;br /&gt;
*0: 0&lt;br /&gt;
*1: -1&lt;br /&gt;
*2: -2&lt;br /&gt;
*3: -4&lt;br /&gt;
*4: -8&lt;br /&gt;
*5: -16&lt;br /&gt;
*6: *2/3&lt;br /&gt;
*7: *1/2&lt;br /&gt;
*8: ?&lt;br /&gt;
*9: 1&lt;br /&gt;
*A: 2&lt;br /&gt;
*B: 4&lt;br /&gt;
*C: 8&lt;br /&gt;
*D: 16&lt;br /&gt;
*E: *3/2&lt;br /&gt;
*F: *2&lt;br /&gt;
&lt;br /&gt;
'''6 isn't exactly *2/3.''' It seems to use the following table:&lt;br /&gt;
&lt;br /&gt;
  TwoThirds: array [0..63] of Byte =&lt;br /&gt;
  ( 0,  0,  1,  1,  2,  3,  3,  4,  5,  5,  6,  6,  7,  8,  8,  9,&lt;br /&gt;
   10, 10, 11, 11, 12, 13, 13, 14, 15, 15, 16, 16, 17, 18, 18, 19,&lt;br /&gt;
   20, 20, 21, 21, 22, 23, 23, 24, 25, 25, 26, 26, 27, 28, 28, 29,&lt;br /&gt;
   30, 30, 31, 31, 32, 33, 33, 34, 35, 35, 36, 36, 37, 38, 38, 39);&lt;br /&gt;
&lt;br /&gt;
This effect changes only the active volume, '''without modifying the stored volume.'''&lt;br /&gt;
&lt;br /&gt;
===Rxy (%)===&lt;br /&gt;
Tremolo. x*4 is speed, y*4 is depth. This effect is screwy, but not as screwy as previously documented.&lt;br /&gt;
&lt;br /&gt;
*Get xy from the '''latest nonzero effect parameter''' to appear in the channel.&lt;br /&gt;
*'''On tick 1''' (the '''second''' tick of the row) set the active volume to '''the stored volume plus''' (depth * value) / (max_amplitude * 2) (Rxy peaks at 32 in each direction), and for each '''nonzero''' tick increase the tremolo position by the speed. '''The stored volume is untouched.'''&lt;br /&gt;
*'''If the song speed (not tremolo speed, but song speed - ticks per row) is 1, the active volume is also untouched. It is not set to the stored volume!'''&lt;br /&gt;
*'''Tremolo will not work if the stored volume is 0 (or 64 - adlib only).'''&lt;br /&gt;
&lt;br /&gt;
===Sxy===&lt;br /&gt;
Miscellaneous effects.&lt;br /&gt;
&lt;br /&gt;
''TODO: check what value xy is taken for Sxy''&lt;br /&gt;
&lt;br /&gt;
====S0x====&lt;br /&gt;
Set filter. Not implemented in Scream Tracker 3.&lt;br /&gt;
&lt;br /&gt;
====S1x====&lt;br /&gt;
Set glissando control.&lt;br /&gt;
&lt;br /&gt;
====S2x====&lt;br /&gt;
Set finetune.&lt;br /&gt;
&lt;br /&gt;
====S3x====&lt;br /&gt;
Set vibrato waveform.&lt;br /&gt;
&lt;br /&gt;
====S4x====&lt;br /&gt;
Set tremolo waveform.&lt;br /&gt;
&lt;br /&gt;
====S8x====&lt;br /&gt;
Set panning position. Scream Tracker 3 supports this only on the Gravis Ultrasound.&lt;br /&gt;
&lt;br /&gt;
====SAx====&lt;br /&gt;
Old stereo control? Not implemented in Scream Tracker 3.21?&lt;br /&gt;
&lt;br /&gt;
====SBx====&lt;br /&gt;
Loop pattern.&lt;br /&gt;
&lt;br /&gt;
====SCx====&lt;br /&gt;
Note cut after x ticks.&lt;br /&gt;
&lt;br /&gt;
*If '''the argument is 0''', the effect '''is ignored'''.&lt;br /&gt;
*When the note is cut, the volume is '''not''' set to 0. Instead playback is temporarily '''frozen''' and may be '''resumed by a following Exx, Fxx, Gxx, Hxx, Jxx, Kxx, Lxx or Uxx command'''.&lt;br /&gt;
&lt;br /&gt;
====SDx====&lt;br /&gt;
Note delay for x ticks.&lt;br /&gt;
&lt;br /&gt;
====SEx====&lt;br /&gt;
Pattern delay for x rows.&lt;br /&gt;
&lt;br /&gt;
====SFx====&lt;br /&gt;
FunkRepeat. Not implemented in Scream Tracker 3.&lt;br /&gt;
&lt;br /&gt;
===Txx===&lt;br /&gt;
Set tempo. If the parameter is '''less than 33''', the effect is '''ignored'''.&lt;br /&gt;
&lt;br /&gt;
===Uxy (*)===&lt;br /&gt;
Fine vibrato. This effect '''shares memory''' with '''Hxy'''.&lt;br /&gt;
&lt;br /&gt;
===Vxx===&lt;br /&gt;
Set global volume. This effect has several quirks:&lt;br /&gt;
&lt;br /&gt;
*Normally, it does not affect events on the same row, where the effect is set. However, '''there are some exceptions to that rule''', read below for details.&lt;br /&gt;
*It does not affect past notes, that are still playing, unless '''their volume is changed''', which '''applies the new global volume to that voice''' as well.&lt;br /&gt;
*This effect '''is actually processed on tick 1 (that is the second tick)''' of the row. This has several consequences:&lt;br /&gt;
**The effect '''doesn't do anything''', if '''the current speed is 1'''.&lt;br /&gt;
**The effect '''is applied to notes on the current row, that have a note delay effect''' (SDx with x &amp;gt;= 1). For notes on the same row '''that have a note delay of 1 tick''', the effect is only applied to '''channels, that are processed after''' the channel with the set global volume effect. For notes on the same row that have a '''note delay of 2 ticks or more''', the effect is applied '''regardless of the relative position of the channel''' in the processing order. ''TODO: Document the processing order, since it isn't very obvious (I think it's L1, L2, ..., L8, R1, R2, ..., R8, but I'm not 100% sure).''&lt;br /&gt;
**The effect '''is also applied''' on the same row if anything sets the volume '''on tick 1''' or '''tick 2''' (depends on processing order), like the '''Dxx effect''' (when doing a non-fine slide, of course).&lt;br /&gt;
*Vxx with parameter '''values higher than 0x40''' is '''ignored'''.&lt;br /&gt;
&lt;br /&gt;
[[Category: Music Pattern Formats]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Covox_ADPCM&amp;diff=7572</id>
		<title>Covox ADPCM</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Covox_ADPCM&amp;diff=7572"/>
		<updated>2007-04-04T23:50:20Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Company: [[Covox]]&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/A-codecs/CovoxFormats/ http://samples.mplayerhq.hu/A-codecs/CovoxFormats/]&lt;br /&gt;
&lt;br /&gt;
This is a family of [[ADPCM]] formats used for compressing 8-bit unsigned [[PCM]].  They were invented by Covox for use with the Covox Speech Thing, Sound Master, and other Covox sound output devices.  There are 2-,3- and 4-bit ADPCM formats.&lt;br /&gt;
&lt;br /&gt;
== Header ==&lt;br /&gt;
&lt;br /&gt;
File header consists of 16 bytes:&lt;br /&gt;
&lt;br /&gt;
  FF 55 FF AA FF 55 FF AA xx yy pp pp pp pp 00 00&lt;br /&gt;
  xx - encoding type&lt;br /&gt;
  yy - playback rate (rate != sample rate, rather the timer tick rate divisor used for playback)&lt;br /&gt;
  pp - unsigned longint meant to indicate unpacked size (mostly unused)&lt;br /&gt;
  00 - unknown/unused&lt;br /&gt;
&lt;br /&gt;
Type may be one of the following:&lt;br /&gt;
&lt;br /&gt;
* 0x01 - 1-bit ADPCM      &lt;br /&gt;
* 0x02 - 2-bit ADPCM      &lt;br /&gt;
* 0x03 - 3-bit ADPCM      &lt;br /&gt;
* 0x04 - 4-bit ADPCM      &lt;br /&gt;
* 0x08 - raw 8-bit unsigned PCM        &lt;br /&gt;
* 0x81 - 1-bit ADPCM with silence encoding&lt;br /&gt;
* 0x82 - 2-bit ADPCM with silence encoding&lt;br /&gt;
* 0x83 - 3-bit ADPCM with silence encoding&lt;br /&gt;
* 0x84 - 4-bit ADPCM with silence encoding&lt;br /&gt;
* 0x88 - 8-bit PCM   with silence encoding&lt;br /&gt;
&lt;br /&gt;
The first 8 bytes are a unique code guaranteed not to show up inside the rest of file.  This means that multiple PCM files can be concatenated together and the locations found by looking for the headers.&lt;br /&gt;
&lt;br /&gt;
== Markers ==&lt;br /&gt;
&lt;br /&gt;
There are two types of markers known:&lt;br /&gt;
&lt;br /&gt;
* FF 55 55 55 - silence block, next 16-bit little-endian value specifies number of silence samples - 27&lt;br /&gt;
* FF AA AA AA - end of sound&lt;br /&gt;
&lt;br /&gt;
For 3-bit ADPCM they are cut to 3 bytes (FF 55 55 and FF AA AA respectively).&lt;br /&gt;
&lt;br /&gt;
After silence block ADPCM decoding state should be reset.&lt;br /&gt;
&lt;br /&gt;
== ADPCM decoding ==&lt;br /&gt;
&lt;br /&gt;
This is generalized decoding procedure for all know ADPCM variants. &amp;lt;i&amp;gt;n&amp;lt;/i&amp;gt; will denote the number of bits used in ADPCM (&amp;lt;i&amp;gt;n&amp;lt;/i&amp;gt;=2 for 2-bit ADPCM, etc).&lt;br /&gt;
&lt;br /&gt;
Decoding procedure:&lt;br /&gt;
# look at the next 3 or 4 bytes, if they make a marker, do action for this marker&lt;br /&gt;
# read &amp;lt;i&amp;gt;n&amp;lt;/i&amp;gt; bytes&lt;br /&gt;
# decode 8 deltas from them by taking high bits from &amp;lt;i&amp;gt;n&amp;lt;/i&amp;gt; values and shifting them&lt;br /&gt;
# apply these deltas to get decoded values&lt;br /&gt;
&lt;br /&gt;
Update procedure:&lt;br /&gt;
&lt;br /&gt;
 high_bit = 1 &amp;lt;&amp;lt; (n-1);&lt;br /&gt;
 low_bits = (1 &amp;lt;&amp;lt; (n-1)) - 1;&lt;br /&gt;
 mul = step_table[step] * mult_table[delta &amp;amp; low_bits];&lt;br /&gt;
 if(delta &amp;amp; high_bit)&lt;br /&gt;
  val -= mul;&lt;br /&gt;
 else &lt;br /&gt;
  val += mul;&lt;br /&gt;
 val = clip(val, 0, 0xFFFF);&lt;br /&gt;
 step = clip(step + step_update_table[delta &amp;amp; low_bits], 0, step_max);&lt;br /&gt;
&lt;br /&gt;
== ADPCM Tables ==&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;
! Value !! 4-bit ADPCM !! 3-bit ADPCM !! 2-bit ADPCM&lt;br /&gt;
|-&lt;br /&gt;
| Max. step value || 72 || 96 || 80&lt;br /&gt;
|-&lt;br /&gt;
| Step update table&lt;br /&gt;
| -8, -6, -4, -2, 2, 4, 8, 16&lt;br /&gt;
| -4, -2, 4, 16&lt;br /&gt;
| -6, 6&lt;br /&gt;
|-&lt;br /&gt;
| Multiplication table&lt;br /&gt;
| 0.5, 1.0, 2.0, 3.0, 4.5, 5.0, 9.0, 12.0&lt;br /&gt;
| 1.0, 1.5, 2.0, 2.5&lt;br /&gt;
| 1.0, 3.0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Step table (it has much more values than needed):&lt;br /&gt;
&lt;br /&gt;
 0x0080, 0x008C, 0x0098, 0x00A6, 0x00B5, 0x00C5, 0x00D7, 0x00EB,&lt;br /&gt;
 0x0100, 0x0117, 0x0130, 0x014C, 0x016A, 0x018B, 0x01AF, 0x01D6,&lt;br /&gt;
 0x0200, 0x022E, 0x0261, 0x0298, 0x02D4, 0x0316, 0x035D, 0x03AB,&lt;br /&gt;
 0x0400, 0x045D, 0x04C2, 0x0530, 0x05A8, 0x062B, 0x06BA, 0x0756,&lt;br /&gt;
 0x0800, 0x08B9, 0x0983, 0x0A60, 0x0B50, 0x0C56, 0x0D74, 0x0EAC,&lt;br /&gt;
 0x1000, 0x1173, 0x1307, 0x14C0, 0x16A1, 0x18AD, 0x1AE9, 0x1D58,&lt;br /&gt;
 0x2000, 0x22E5, 0x260E, 0x2980, 0x2D41, 0x315A, 0x35D1, 0x3AB0,&lt;br /&gt;
 0x4000, 0x45CB, 0x4C1C, 0x52FF, 0x5A82, 0x62B4, 0x6BA2, 0x7560,&lt;br /&gt;
 0x8000, 0x8B96, 0x9838, 0xA5FF, 0xB505, 0xC567, 0xD745, 0xEAC1,&lt;br /&gt;
 &lt;br /&gt;
 0x00C0, 0x00D1, 0x00E4, 0x00F9, 0x0110, 0x0128, 0x0143, 0x0160,&lt;br /&gt;
 0x0180, 0x01A3, 0x01C9, 0x01F2, 0x021F, 0x0250, 0x0286, 0x02C0,&lt;br /&gt;
 0x0300, 0x0346, 0x0391, 0x03E4, 0x043E, 0x04A0, 0x050C, 0x0581,&lt;br /&gt;
 0x0600, 0x068B, 0x0723, 0x07C8, 0x087C, 0x0941, 0x0A17, 0x0B01,&lt;br /&gt;
 0x0C00, 0x0D16, 0x0E45, 0x0F90, 0x10F8, 0x1282, 0x142E, 0x1602,&lt;br /&gt;
 0x1800, 0x1A2C, 0x1C8A, 0x1F20, 0x21F1, 0x2503, 0x285D, 0x2C04,&lt;br /&gt;
 &lt;br /&gt;
 0x0240, 0x0274, 0x02AD, 0x02EB, 0x032F, 0x0378, 0x03C9, 0x0420,&lt;br /&gt;
 0x0480, 0x04E8, 0x055A, 0x05D6, 0x065D, 0x06F1, 0x0791, 0x0841,&lt;br /&gt;
 0x0900, 0x09D1, 0x0AB4, 0x0BAC, 0x0CBA, 0x0DE1, 0x0F23, 0x1082,&lt;br /&gt;
 0x1200, 0x13A1, 0x1568, 0x1758, 0x1975, 0x1BC3, 0x1E46, 0x2103,&lt;br /&gt;
 0x2400, 0x2742, 0x2AD0, 0x2EB0, 0x32E9, 0x3785, 0x3C8B, 0x4206,&lt;br /&gt;
 0x4800, 0x4E84, 0x559F, 0x5D5F, 0x65D3, 0x6F0A, 0x7917, 0x840C,&lt;br /&gt;
 &lt;br /&gt;
 0x02C0, 0x0300, 0x0345, 0x0391, 0x03E4, 0x043E, 0x04A0, 0x050B,&lt;br /&gt;
 0x0580, 0x05FF, 0x068A, 0x0722, 0x07C7, 0x087B, 0x0940, 0x0A16,&lt;br /&gt;
 0x0B00, 0x0BFF, 0x0D15, 0x0E44, 0x0F8E, 0x10F7, 0x1280, 0x142D,&lt;br /&gt;
 0x1600, 0x17FE, 0x1A2A, 0x1C88, 0x1F1D, 0x21EE, 0x2500, 0x2859,&lt;br /&gt;
 0x2C00, 0x2FFB, 0x3453, 0x3910, 0x3E3A, 0x43DB, 0x4A00, 0x50B2,&lt;br /&gt;
 0x5800, 0x5FF7, 0x68A6, 0x721F, 0x7C73, 0x87B7, 0x93FF, 0xA165,&lt;br /&gt;
 &lt;br /&gt;
 0x03C0, 0x0417, 0x0476, 0x04DD, 0x054E, 0x05C9, 0x064F, 0x06E1,&lt;br /&gt;
 0x0780, 0x082E, 0x08EB, 0x09BA, 0x0A9B, 0x0B91, 0x0C9D, 0x0DC1,&lt;br /&gt;
 0x0F00, 0x105C, 0x11D7, 0x1374, 0x1537, 0x1722, 0x193A, 0x1B83,&lt;br /&gt;
 0x1E00, 0x20B7, 0x23AD, 0x26E8, 0x2A6D, 0x2E44, 0x3274, 0x3705,&lt;br /&gt;
 0x3C00, 0x416E, 0x475A, 0x4DCF, 0x54DA, 0x5C88, 0x64E8, 0x6E0A,&lt;br /&gt;
 0x7800, 0x82DC, 0x8EB4, 0x9B9F, 0xA9B5, 0xB911, 0xC9D1, 0xDC15&lt;br /&gt;
&lt;br /&gt;
[[Category:Audio Codecs]]&lt;br /&gt;
[[Category:ADPCM Audio Codecs]]&lt;br /&gt;
[[Category:Undiscovered Audio Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=7571</id>
		<title>Creative 8 bits ADPCM</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=7571"/>
		<updated>2007-04-04T23:20:51Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Company: [[Creative]]&lt;br /&gt;
&lt;br /&gt;
These ADPCM schemes are used in [[Creative_Voice|Creative VOC]] files. The only reference decoder is a hardware one: the Creative Sound Blaster (Pro). So this documentation is not based on reverse engineering. It's based on wild guessing and empirical tests but gives good enough results.  &lt;br /&gt;
&lt;br /&gt;
There are three different variation of this codec, which pack samples to either 4, 2.6 or 2 bits. The 2.6 scheme means that every byte is composed of 3 samples of 3 bits for the first and the second and 2 bits for the last.&lt;br /&gt;
&lt;br /&gt;
The three different schemes use the same algorithm with different initial parameters.&lt;br /&gt;
&lt;br /&gt;
=== Initialization ===&lt;br /&gt;
&lt;br /&gt;
The first byte is a raw (not compressed) sample, used as the initial value for prdiction.&lt;br /&gt;
&lt;br /&gt;
step is initialized to 0.&lt;br /&gt;
&lt;br /&gt;
shift is initialized to 2 for 2 bits scheme and to 0 else.&lt;br /&gt;
&lt;br /&gt;
limit is initialized to 5 for 4 bits samples, 3 for 3 bits samples and 1 for 2 bits samples.&lt;br /&gt;
&lt;br /&gt;
=== Decoding ===&lt;br /&gt;
&lt;br /&gt;
Every packed sample is composed of a sign bit (the most significant bit), and a value (the other bits). Let's define sign as 1 when the sign bit is 0 and -1 when the sign bit is 1. Now you can decode a packed sample with the following operation&lt;br /&gt;
 sample = prediction + sign * (value &amp;lt;&amp;lt; (step + shift))&lt;br /&gt;
sample have to be clamped to fit into an unsigned byte.&lt;br /&gt;
&lt;br /&gt;
Then prediction is updated to the new sample value, and step is updated using this algorithm:&lt;br /&gt;
 if (value &amp;gt;= limit)&lt;br /&gt;
   step++;&lt;br /&gt;
 else if (value == 0)&lt;br /&gt;
   step--;&lt;br /&gt;
step must be clamped into the 0..3 range.&lt;br /&gt;
&lt;br /&gt;
== External sites == &lt;br /&gt;
&lt;br /&gt;
* The DOSBox source contains code that claims to decode Creative ADPCM as well, but that code has not yet been verified against the information on this page.&lt;br /&gt;
&lt;br /&gt;
[[Category:Audio Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=7570</id>
		<title>Creative 8 bits ADPCM</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Creative_8_bits_ADPCM&amp;diff=7570"/>
		<updated>2007-04-04T23:20:11Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Company: [[Creative]]&lt;br /&gt;
&lt;br /&gt;
These ADPCM schemes are used in [[Creative_Voice|Creative VOC]] files. The only reference decoder is a hardware one: the Creative Sound Blaster (Pro). So this documentation is not based on reverse engineering. It's based on wild guessing and empirical tests but gives good enough results.  (Ed. note:  The DOSBox source contains code that claims to decode Creative ADPCM as well, but that code has not yet been verified against the information on this page.)&lt;br /&gt;
&lt;br /&gt;
There are three different variation of this codec, which pack samples to either 4, 2.6 or 2 bits. The 2.6 scheme means that every byte is composed of 3 samples of 3 bits for the first and the second and 2 bits for the last.&lt;br /&gt;
&lt;br /&gt;
The three different schemes use the same algorithm with different initial parameters.&lt;br /&gt;
&lt;br /&gt;
=== Initialization ===&lt;br /&gt;
&lt;br /&gt;
The first byte is a raw (not compressed) sample, used as the initial value for prdiction.&lt;br /&gt;
&lt;br /&gt;
step is initialized to 0.&lt;br /&gt;
&lt;br /&gt;
shift is initialized to 2 for 2 bits scheme and to 0 else.&lt;br /&gt;
&lt;br /&gt;
limit is initialized to 5 for 4 bits samples, 3 for 3 bits samples and 1 for 2 bits samples.&lt;br /&gt;
&lt;br /&gt;
=== Decoding ===&lt;br /&gt;
&lt;br /&gt;
Every packed sample is composed of a sign bit (the most significant bit), and a value (the other bits). Let's define sign as 1 when the sign bit is 0 and -1 when the sign bit is 1. Now you can decode a packed sample with the following operation&lt;br /&gt;
 sample = prediction + sign * (value &amp;lt;&amp;lt; (step + shift))&lt;br /&gt;
sample have to be clamped to fit into an unsigned byte.&lt;br /&gt;
&lt;br /&gt;
Then prediction is updated to the new sample value, and step is updated using this algorithm:&lt;br /&gt;
 if (value &amp;gt;= limit)&lt;br /&gt;
   step++;&lt;br /&gt;
 else if (value == 0)&lt;br /&gt;
   step--;&lt;br /&gt;
step must be clamped into the 0..3 range.&lt;br /&gt;
&lt;br /&gt;
[[Category:Audio Codecs]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Creative_Voice&amp;diff=2188</id>
		<title>Creative Voice</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Creative_Voice&amp;diff=2188"/>
		<updated>2006-02-11T09:42:31Z</updated>

		<summary type="html">&lt;p&gt;Trixter: /* Block type 0x08: Extra info */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: voc&lt;br /&gt;
* Company: [[Creative]]&lt;br /&gt;
&lt;br /&gt;
The VOC file format was created by Creative and is generally associated with their 8-bit line of cards (Sound Blaster, Sound Blaster Pro).  While initially limited to unsigned 8-bit PCM and ADPCM data, the VOC format was eventually expanded to handle 16-bit formats with the introduction of Creative's 16-bit cards, as well as a-law and u-law companded formats.&lt;br /&gt;
&lt;br /&gt;
This file format is composed of a file header followed by one or more data block.&lt;br /&gt;
All integers are Little Endian.&lt;br /&gt;
&lt;br /&gt;
== Main header ==&lt;br /&gt;
&lt;br /&gt;
 bytes 0-18   Identifier string containing: Creative Voice File&lt;br /&gt;
 byte  19     0x1A (EOF). This is belived to be used to abort printing of file&lt;br /&gt;
 bytes 20-21  Total size of this main header (usually 0x001A)&lt;br /&gt;
 bytes 22-23  Version number, calculated as (major&amp;lt;&amp;lt;8)|minor&lt;br /&gt;
                major is usually 0x01&lt;br /&gt;
                minor is usually 0x0A or 0x14&lt;br /&gt;
 bytes 24-25  Validity check. This must be equal to ~version + 0x1234&lt;br /&gt;
&lt;br /&gt;
== Data blocks ==&lt;br /&gt;
&lt;br /&gt;
All the different data blocks begin with a common header:&lt;br /&gt;
&lt;br /&gt;
 byte  0      block type&lt;br /&gt;
 bytes 1-3    block size (NOT including this common header)&lt;br /&gt;
&lt;br /&gt;
The data following this common block header depends on the block type.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x00: Terminator ===&lt;br /&gt;
&lt;br /&gt;
This is a special block type as it's common header don't contain any size field. It indicate the end of the file. It is not mandatory (you can reach EOF without encountering this block type).&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x01: Sound data ===&lt;br /&gt;
&lt;br /&gt;
 byte  0      frequency divisor&lt;br /&gt;
 byte  1      codec id&lt;br /&gt;
 bytes 2..n   the audio data&lt;br /&gt;
&lt;br /&gt;
The sample rate is defined as&lt;br /&gt;
 1000000/(256 - frequency_divisor)&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x02: Sound data continuation ===&lt;br /&gt;
&lt;br /&gt;
 bytes 2..n    the audio data&lt;br /&gt;
&lt;br /&gt;
This block uses the same codec parameters as the previous &amp;quot;Sound data&amp;quot; block.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x03: Silence ===&lt;br /&gt;
&lt;br /&gt;
 bytes 0-1    length of the silence - 1 (unit is sample)&lt;br /&gt;
 byte  2      frequency divisor&lt;br /&gt;
&lt;br /&gt;
The sample rate is defined as&lt;br /&gt;
 1000000/(256 - frequency_divisor)&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x04: Marker ===&lt;br /&gt;
&lt;br /&gt;
 bytes 0-1    the mark value&lt;br /&gt;
&lt;br /&gt;
This can be used by the software to synchronize the sound with an animation.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x05: Text ===&lt;br /&gt;
&lt;br /&gt;
 bytes 0..n   zero terminated string&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x06: Repeat start ===&lt;br /&gt;
&lt;br /&gt;
 bytes 0-1    repeat count - 1&lt;br /&gt;
&lt;br /&gt;
The sound data following this block and up to the next Repeat end block is repeated count+1 times.&lt;br /&gt;
When count == 0xFFFF this means endless repetitions.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x07: Repeat end ===&lt;br /&gt;
&lt;br /&gt;
Empty block which terminate a repeat section.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x08: Extra info ===&lt;br /&gt;
&lt;br /&gt;
 bytes 0-1    frequency divisor&lt;br /&gt;
 byte  2      codec id&lt;br /&gt;
 byte  3      channels number - 1&lt;br /&gt;
&lt;br /&gt;
The sample rate is defined as&lt;br /&gt;
 256000000/(nb_channels * (65536 - frequency_divisor))&lt;br /&gt;
&lt;br /&gt;
This block must be followed by a &amp;quot;Sound data&amp;quot; block, and it supercedes its codec parameters.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x09: Sound data (New format) ===&lt;br /&gt;
&lt;br /&gt;
This block type is probably only valid in version 1.20 (0x0114) or greater files.&lt;br /&gt;
&lt;br /&gt;
 bytes 0-3    sample rate&lt;br /&gt;
 byte  4      bits per sample&lt;br /&gt;
 byte  5      channels number&lt;br /&gt;
 bytes 6-7    codec_id&lt;br /&gt;
 bytes 8-11   reserved&lt;br /&gt;
 bytes 12..n  the audio data&lt;br /&gt;
&lt;br /&gt;
== Supported codec ids ==&lt;br /&gt;
&lt;br /&gt;
   0x00  8 bits unsigned PCM&lt;br /&gt;
   0x01  4 bits to 8 bits Creative ADPCM&lt;br /&gt;
   0x02  3 bits to 8 bits Creative ADPCM (AKA 2.6 bits)&lt;br /&gt;
   0x03  2 bits to 8 bits Creative ADPCM&lt;br /&gt;
   0x04  16 bits signed PCM&lt;br /&gt;
   0x06  alaw&lt;br /&gt;
   0x07  ulaw&lt;br /&gt;
 0x0200  4 bits to 16 bits Creative ADPCM (only valid in block type 0x09)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Creative_Voice&amp;diff=2187</id>
		<title>Creative Voice</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Creative_Voice&amp;diff=2187"/>
		<updated>2006-02-11T09:41:29Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: voc&lt;br /&gt;
* Company: [[Creative]]&lt;br /&gt;
&lt;br /&gt;
The VOC file format was created by Creative and is generally associated with their 8-bit line of cards (Sound Blaster, Sound Blaster Pro).  While initially limited to unsigned 8-bit PCM and ADPCM data, the VOC format was eventually expanded to handle 16-bit formats with the introduction of Creative's 16-bit cards, as well as a-law and u-law companded formats.&lt;br /&gt;
&lt;br /&gt;
This file format is composed of a file header followed by one or more data block.&lt;br /&gt;
All integers are Little Endian.&lt;br /&gt;
&lt;br /&gt;
== Main header ==&lt;br /&gt;
&lt;br /&gt;
 bytes 0-18   Identifier string containing: Creative Voice File&lt;br /&gt;
 byte  19     0x1A (EOF). This is belived to be used to abort printing of file&lt;br /&gt;
 bytes 20-21  Total size of this main header (usually 0x001A)&lt;br /&gt;
 bytes 22-23  Version number, calculated as (major&amp;lt;&amp;lt;8)|minor&lt;br /&gt;
                major is usually 0x01&lt;br /&gt;
                minor is usually 0x0A or 0x14&lt;br /&gt;
 bytes 24-25  Validity check. This must be equal to ~version + 0x1234&lt;br /&gt;
&lt;br /&gt;
== Data blocks ==&lt;br /&gt;
&lt;br /&gt;
All the different data blocks begin with a common header:&lt;br /&gt;
&lt;br /&gt;
 byte  0      block type&lt;br /&gt;
 bytes 1-3    block size (NOT including this common header)&lt;br /&gt;
&lt;br /&gt;
The data following this common block header depends on the block type.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x00: Terminator ===&lt;br /&gt;
&lt;br /&gt;
This is a special block type as it's common header don't contain any size field. It indicate the end of the file. It is not mandatory (you can reach EOF without encountering this block type).&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x01: Sound data ===&lt;br /&gt;
&lt;br /&gt;
 byte  0      frequency divisor&lt;br /&gt;
 byte  1      codec id&lt;br /&gt;
 bytes 2..n   the audio data&lt;br /&gt;
&lt;br /&gt;
The sample rate is defined as&lt;br /&gt;
 1000000/(256 - frequency_divisor)&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x02: Sound data continuation ===&lt;br /&gt;
&lt;br /&gt;
 bytes 2..n    the audio data&lt;br /&gt;
&lt;br /&gt;
This block uses the same codec parameters as the previous &amp;quot;Sound data&amp;quot; block.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x03: Silence ===&lt;br /&gt;
&lt;br /&gt;
 bytes 0-1    length of the silence - 1 (unit is sample)&lt;br /&gt;
 byte  2      frequency divisor&lt;br /&gt;
&lt;br /&gt;
The sample rate is defined as&lt;br /&gt;
 1000000/(256 - frequency_divisor)&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x04: Marker ===&lt;br /&gt;
&lt;br /&gt;
 bytes 0-1    the mark value&lt;br /&gt;
&lt;br /&gt;
This can be used by the software to synchronize the sound with an animation.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x05: Text ===&lt;br /&gt;
&lt;br /&gt;
 bytes 0..n   zero terminated string&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x06: Repeat start ===&lt;br /&gt;
&lt;br /&gt;
 bytes 0-1    repeat count - 1&lt;br /&gt;
&lt;br /&gt;
The sound data following this block and up to the next Repeat end block is repeated count+1 times.&lt;br /&gt;
When count == 0xFFFF this means endless repetitions.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x07: Repeat end ===&lt;br /&gt;
&lt;br /&gt;
Empty block which terminate a repeat section.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x08: Extra info ===&lt;br /&gt;
&lt;br /&gt;
 bytes 0-1    frequency divisor&lt;br /&gt;
 byte  2      codec id&lt;br /&gt;
 byte  3      channels number - 1&lt;br /&gt;
&lt;br /&gt;
The sample rate is defined as&lt;br /&gt;
 256000000/(nb_channels * (65536 - frequency_divisor))&lt;br /&gt;
&lt;br /&gt;
This block must be followed by a &amp;quot;Sound data&amp;quot; block, and it super-seeds its codec parameters.&lt;br /&gt;
&lt;br /&gt;
=== Block type 0x09: Sound data (New format) ===&lt;br /&gt;
&lt;br /&gt;
This block type is probably only valid in version 1.20 (0x0114) or greater files.&lt;br /&gt;
&lt;br /&gt;
 bytes 0-3    sample rate&lt;br /&gt;
 byte  4      bits per sample&lt;br /&gt;
 byte  5      channels number&lt;br /&gt;
 bytes 6-7    codec_id&lt;br /&gt;
 bytes 8-11   reserved&lt;br /&gt;
 bytes 12..n  the audio data&lt;br /&gt;
&lt;br /&gt;
== Supported codec ids ==&lt;br /&gt;
&lt;br /&gt;
   0x00  8 bits unsigned PCM&lt;br /&gt;
   0x01  4 bits to 8 bits Creative ADPCM&lt;br /&gt;
   0x02  3 bits to 8 bits Creative ADPCM (AKA 2.6 bits)&lt;br /&gt;
   0x03  2 bits to 8 bits Creative ADPCM&lt;br /&gt;
   0x04  16 bits signed PCM&lt;br /&gt;
   0x06  alaw&lt;br /&gt;
   0x07  ulaw&lt;br /&gt;
 0x0200  4 bits to 16 bits Creative ADPCM (only valid in block type 0x09)&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Id_RoQ_DPCM&amp;diff=2131</id>
		<title>Id RoQ DPCM</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Id_RoQ_DPCM&amp;diff=2131"/>
		<updated>2006-02-06T00:14:25Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[RoQ]] multimedia files store audio in a DPCM format. A chunk of RoQ DPCM data is laid out as (all multi-byte numbers are little-endian):&lt;br /&gt;
&lt;br /&gt;
 bytes 0-1    chunk ID: 0x1020 for mono data, 0x1021 for stereo data&lt;br /&gt;
 bytes 2-5    chunk size, not including 8-byte preamble&lt;br /&gt;
 bytes 6-7    initial predictor(s)&lt;br /&gt;
 bytes 8..n   DPCM bytes &lt;br /&gt;
&lt;br /&gt;
If the block is mono data, each byte represents the square root of the difference between the last PCM sample and the current PCM sample. To decode the audio, follow this process:&lt;br /&gt;
&lt;br /&gt;
 if (current DPCM byte &amp;lt; 128)&lt;br /&gt;
   next PCM sample = last PCM sample + (128-current DPCM byte) * (128-current DPCM byte)&lt;br /&gt;
 else&lt;br /&gt;
   next PCM sample = last PCM sample - ((current DPCM byte) * (current DPCM byte)) &lt;br /&gt;
&lt;br /&gt;
Trivially, this process can be optimized by precalculating the squares of all 256 possible DPCM bytes. If the audio data is stereo, the 16-bit predictor encodes both the initial right and left predictors. After decoding the little-endian 16-bit predictor number, the upper 8 bits (bits 15-8) are the upper 8 bits of the initial left channel predictor. The lower 8 bits are the upper 8 bits of the initial right channel predictor. The DPCM bytes are decoded in the same manner as for mono data except that left and right DPCM bytes are interleaved.&lt;br /&gt;
&lt;br /&gt;
[[Category:Audio Codecs]]&lt;br /&gt;
[[Category:DPCM Audio Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Wing_Commander_III_MVE_Video_Codec&amp;diff=1620</id>
		<title>Wing Commander III MVE Video Codec</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Wing_Commander_III_MVE_Video_Codec&amp;diff=1620"/>
		<updated>2006-01-18T07:03:54Z</updated>

		<summary type="html">&lt;p&gt;Trixter: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This document is based on the document 'Description Of The Origin Xan Video Codec' by Mike Melanson and Mario Brito found at [http://multimedia.cx/xan-format.txt http://multimedia.cx/xan-format.txt].''&lt;br /&gt;
&lt;br /&gt;
In 1994, Origin published the third installment of their popular Wing Commander space flight combat simulation games, [http://www.mobygames.com/game/dos/wing-commander-iii-heart-of-the-tiger Wing Commander III: Heart of the Tiger]. The game is distributed as 4 CD-ROMs and the underlying story was driven by a lot of full motion video (FMV). The FMV is transported in a [[Wing Commander III MVE|custom file format with the extension mve]] (see the references for more information on this format). The video data in these files is compressed with a custom, unidentified video codec (referred to here as the WC3 codec).&lt;br /&gt;
&lt;br /&gt;
The WC3 codec is a computationally simple video codec that is designed to compress frames of RGB video data at a nominal resolution of 320x165 pixels. The coding method embodies both intraframes (keyframes) and interframes. The algorithm relies on variations of run-length coding and textbook Huffman coding. For interframe compression, the algorithm uses run-based motion compensation. This varies from usual MC methods which are block-based.&lt;br /&gt;
&lt;br /&gt;
== Unpacking Algorithm ==&lt;br /&gt;
&lt;br /&gt;
The WC3 video codec relies on the following bytewise unpacking algorithm taking an output buffer and an input buffer:&lt;br /&gt;
&lt;br /&gt;
 wc3_unpack(unsigned char *dest, unsigned char *src):&lt;br /&gt;
   x = next byte&lt;br /&gt;
   if bit 7 of x is 0:&lt;br /&gt;
     offset = next byte&lt;br /&gt;
     /* x: 0aabbbcc */&lt;br /&gt;
     size = bottom 2 bits of x (0..3) (this represents bits 'cc')&lt;br /&gt;
     bytecopy size bytes from src to dest&lt;br /&gt;
     size = (x &amp;amp; 0x1C) &amp;gt;&amp;gt; 2 + 3 (this represents bits 'bbb')&lt;br /&gt;
     bytecopy size bytes from current pos - ((x &amp;amp; 0x60) &amp;lt;&amp;lt; 3) + offset + 1&lt;br /&gt;
   else if bit 6 of x is 0:&lt;br /&gt;
     fetch next byte from stream as byte1&lt;br /&gt;
     fetch next byte from stream as byte2&lt;br /&gt;
     size = top 2 bits of byte1 (0..3)&lt;br /&gt;
     bytecopy size bytes from src to dest&lt;br /&gt;
     size = bottom 6 bits of x + 4 (range: 4..67)&lt;br /&gt;
     bytecopy size bytes from dest - ((byte1 &amp;amp; 0x3F) &amp;lt;&amp;lt; 8) + byte2 + 1&lt;br /&gt;
   else if bit 5 of x is 0:&lt;br /&gt;
     fetch next byte from stream as byte1&lt;br /&gt;
     fetch next byte from stream as byte2&lt;br /&gt;
     fetch next byte from stream as byte3&lt;br /&gt;
     size = bottom 2 bits of x (0..3)&lt;br /&gt;
     bytecopy size bytes from src to dest&lt;br /&gt;
     size = byte3 + 5 + ((x &amp;amp; 0xC) &amp;lt;&amp;lt; 6);&lt;br /&gt;
     bytecopy (dest,&lt;br /&gt;
       dest - ((((x &amp;amp; 0x10) &amp;gt;&amp;gt; 4) &amp;lt;&amp;lt; 0x10) + 1 + (byte1 &amp;lt;&amp;lt; 8) + byte2),&lt;br /&gt;
       size);&lt;br /&gt;
   else (this means one of the top 3 bits was 1)&lt;br /&gt;
     size = (x &amp;amp; 0x1F) * 4 + 4&lt;br /&gt;
     if size &amp;gt; 0x70&lt;br /&gt;
     break&lt;br /&gt;
     copy size bytes from src to dest&lt;br /&gt;
&lt;br /&gt;
This process is repeated in a loop until the break in the else case. On the way out, copy (x &amp;amp; 3) bytes from src to dest. &lt;br /&gt;
&lt;br /&gt;
An important note about the preceding pseudocode description: When the code says that a 'bytecopy' operation is to be performed from buffer a to buffer b, neither a memcpy nor a memmove call will do. The reason is that the bytecopy function is often used to copy between overlapping memory regions. It is not uncommon for dest to equal (src + 1). This has the net effect of turning 'A' into 'AAAAAA...&amp;quot;. This function was originally implemented on x86 microprocessors as a 'repz stosb' instruction, which means to store a string by byte repeatedly.&lt;br /&gt;
&lt;br /&gt;
== WC3 Codec Format ==&lt;br /&gt;
&lt;br /&gt;
The [[Wing Commander III MVE]] file format packages sequences of video and audio frames together marked by SHOT chunks. Each SHOT chunk has a 768-byte RGB palette specified in the file header. The file demuxer must make the appropriate palette available to the video decoder when a new SHOT begins.&lt;br /&gt;
&lt;br /&gt;
A chunk of WC3 Xan data is formatted as follows:&lt;br /&gt;
&lt;br /&gt;
 header  |  segment 1  | segment 2  |  segment 3  | segment 4&lt;br /&gt;
&lt;br /&gt;
The header contains offsets to each of the segments within the chunk:&lt;br /&gt;
* Segment 1 contains Huffman-coded image compression codes. &lt;br /&gt;
* Segment 2 contains auxiliary size information. &lt;br /&gt;
* Segment 3 contains interframe motion vectors. &lt;br /&gt;
* Segment 4 contains raw or compressed palettized video data.&lt;br /&gt;
&lt;br /&gt;
The chunk header is always 8 bytes long. The on-disk data format for a chunk header is:&lt;br /&gt;
&lt;br /&gt;
 bytes 0-1   absolute offset of segment 1 within chunk (always offset 8)&lt;br /&gt;
 bytes 2-3   absolute offset of segment 2 within chunk&lt;br /&gt;
 bytes 4-5   absolute offset of segment 3 within chunk&lt;br /&gt;
 bytes 6-7   absolute offset of segment 4 within chunk&lt;br /&gt;
&lt;br /&gt;
All of the 16-bit segment offsets are stored in little endian byte order. Note that the offset of segment 3 within an intracoded chunk (keyframe) ought to be 0x0000 as there are no motion vectors for an intraframe.&lt;br /&gt;
&lt;br /&gt;
The first step in decoding a frame involves decoding the Huffman codes in segment 1 in order to decode the compression codes. The segment is laid out as follows:&lt;br /&gt;
&lt;br /&gt;
 byte 0       number of values in the Huffman tree (should be 22)&lt;br /&gt;
 bytes 1..44  Huffman tree table&lt;br /&gt;
 bytes 45..   Huffman-coded data.&lt;br /&gt;
&lt;br /&gt;
There are 22 values in the Huffman tree since there are 22 possible compression codes (0..21) used to assemble the final output frame. Actually, there is one more value found in the table (22) that signals&lt;br /&gt;
the end of the Huffman stream. The root of the Huffman tree is at the last byte of the table. Bits in the bytes of the Huffman-coded bits are coded right-to-left.&lt;br /&gt;
&lt;br /&gt;
Assumng the Huffman tree table is stored in huff[44] where the bytes are indexed 0..43, and the root node is at index 43. The decoding algorithm is:&lt;br /&gt;
&lt;br /&gt;
 while (value @ current node index != 22)&lt;br /&gt;
   if the next bit in the coded stream is 0&lt;br /&gt;
     move current node index to (current node index - 22)&lt;br /&gt;
   else&lt;br /&gt;
     move current node index to (current node index - 1)&lt;br /&gt;
   if (value &amp;lt; 22)&lt;br /&gt;
     decompression code found, place in output buffer and reset the&lt;br /&gt;
     current index to the root node&lt;br /&gt;
&lt;br /&gt;
After decoding the compression codes, check the first byte of segment 2 to see if the raw pixel data needs to be decoded. If the first byte equals 0x02, pass the remainder of the buffer through the wc3_unpack function. Otherwise, use the data from the second byte forward as the pixel data.&lt;br /&gt;
&lt;br /&gt;
The final step builds the frame and uses data from all 4 segments. The algorithm operates as follows (assuming a palettized output buffer that is width * height bytes in size):&lt;br /&gt;
&lt;br /&gt;
 flag = 0&lt;br /&gt;
 index = 0&lt;br /&gt;
 while index &amp;lt; frame size (width * height):&lt;br /&gt;
   x = next compression code in segment 1&lt;br /&gt;
   size = 0&lt;br /&gt;
   if x is 0, toggle flag and goto next iteration&lt;br /&gt;
   if x is 1..8, size = x&lt;br /&gt;
   if x is 12..18, size += (x - 10) (net effect: add 2..8)&lt;br /&gt;
   if x if 9 or 19, size = next byte in segment 2&lt;br /&gt;
   if x is 10 or 20, size = the next BE_16 number in segment 2&lt;br /&gt;
   if x is 11 or 21, size = the next BE_24 number in segment 2&lt;br /&gt;
   if x &amp;lt; 12:&lt;br /&gt;
     toggle flag&lt;br /&gt;
     if flag is 1, run is unchanged from previous frame:&lt;br /&gt;
       for each count in size, copy pixel from same index in previous&lt;br /&gt;
       frame&lt;br /&gt;
     else /* flag is 0 */:&lt;br /&gt;
       for each count in size, copy the next pixel in segment 4 to the&lt;br /&gt;
       output&lt;br /&gt;
   else:&lt;br /&gt;
     motion byte = next byte in segment 3&lt;br /&gt;
     x = top nibble of motion byte&lt;br /&gt;
     y = bottom nibble of motion byte&lt;br /&gt;
     sign-extend the nibbles in x and y&lt;br /&gt;
     copy size bytes from the position referenced by (x, y) in the&lt;br /&gt;
     previous frame to the current frame&lt;br /&gt;
     reset flag&lt;br /&gt;
&lt;br /&gt;
Note that BE_16 means a 16-bit number in big endian format, and BE_24 means a 24-bit number in big endian format.&lt;br /&gt;
&lt;br /&gt;
== Codec Trivia ==&lt;br /&gt;
&lt;br /&gt;
Origin originally advertised a 486/33 and 2X (300KB/s) CDROM drive as the minimum requirements for playing the video.  However, video playback functions perfectly on a 386/40 (about 20% slower than a 486/33) and, with few exceptions, plays just fine on a 1X (150KB/s) CDROM drive.  This suggests that Origin was either being conservative with requirements in an effort to ward off anticipated tech support calls caused by flaky clones (a common occurance, unfortunately), or possibly had originally targeted 1X CDROM drives but had to go over the 150KB/s datarate in a few scenes due to low picture quality.&lt;br /&gt;
&lt;br /&gt;
(For the curious, the scenes that don't quite make the 1X datarate cut are scenes where more than 30% of the scene is changing in every frame, such as the spaceflight sequences in the introduction, or scenes that take place in the hanger.)&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Codecs]]&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>Trixter</name></author>
	</entry>
</feed>