Microsoft IMA ADPCM

From MultimediaWiki
Jump to navigation Jump to search
  • Audio ID: 0x0011
  • FOURCC: 'm', 's', 0x00, 0x11
  • Company: Microsoft
  • wFormatTag ID: WAVE_FORMAT_DVI_ADPCM
  • 'short' ID: DVI_ADPCM
  • ACM Codec: 'imaadp32.acm' (included in Windows 95+)

A Microsoft media file (this includes WAV, AVI, and ASF) that is encoded with IMA ADPCM data has an audio format number of 0x11. The file will have a WAVEFORMATEX structure in its header which contains a field named nBlockAlign. This field reveals the size of a block of IMA-encoded data.

Note that Microsoft IMA data can also occur in Apple Quicktime files using the fourcc 'msx0x11'. In this case, a WAVEFORMATEX header will be attached to the Quicktime file's audio stsd atom.

If the IMA data is monaural, an individual chunk of data begins with the following preamble:

bytes 0-1:   initial predictor (in little-endian format)
byte 2:      initial index
byte 3:      unknown, usually 0 and is probably reserved 

The remaining bytes in the chunk are the IMA nibbles. Each byte is decoded bottom nibble first, then top nibble as follows:

byte0 byte1 byte2 byte3 ...
 n1n0  n3n2  n5n4  n7n6 ... 

If the IMA data is stereo, a chunk begins with two preambles, one for the left audio channel and one for the right channel:

bytes 0-1:   initial predictor (in little-endian format) for left channel
byte 2:      initial index for left channel
byte 3:      unknown, usually 0 and is probably reserved
bytes 4-5:   initial predictor (in little-endian format) for right channel
byte 6:      initial index (for right channel)
byte 7:      unknown, usually 0 and is probably reserved 

The remaining bytes in the chunk are the IMA nibbles. The first 4 bytes, or 8 nibbles, belong to the left channel and the next 4 bytes belong to the right channel. This interleaving continues until the end of the chunk:

byte0 byte1 byte2 byte3 ...
 n1n0  n3n2  n5n4  n7n6 ...(left channel)
byte4 byte5 byte6 byte7 ...
 n1n0  n3n2  n5n4  n7n6 ...(right channel)