Duck DK4 IMA ADPCM: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
* Audio ID: 0x0061
* Audio ID: 0x0061
* Company: [[On2|Duck/On2]]
* Company: [[On2|Duck/On2]]
* Samples: http://samples.mplayerhq.hu/A-codecs/DK4/ (salsa.avi is stereo and virtuafighter2*.avi are mono)


Some Sega Saturn game CDs contain [[Microsoft Audio/Video Interleaved|AVI]] files which store audio using the Duck DK4 [[IMA ADPCM]] algorithm. DK4 data can be decoded using the same algorithm and tables as are used to decode IMA ADPCM data. The name apparently comes from the fact that 4 ADPCM nibbles decode to 4 16-bit PCM samples, in contrast to Duck's [[Duck DK3 IMA ADPCM]] DK3 IMA ADPCM algorithm, in which 3 ADPCM nibbles decode to 4 16-bit PCM samples.
Some Sega Saturn game CDs contain [[Microsoft Audio/Video Interleaved|AVI]] files which store audio using the Duck DK4 [[IMA ADPCM]] algorithm. DK4 data can be decoded using the same algorithm and tables as are used to decode IMA ADPCM data. The name apparently comes from the fact that 4 ADPCM nibbles decode to 4 16-bit PCM samples, in contrast to Duck's [[Duck DK3 IMA ADPCM]] DK3 IMA ADPCM algorithm, in which 3 ADPCM nibbles decode to 4 16-bit PCM samples.
Line 32: Line 33:
[[Category:ADPCM Audio Codecs]]
[[Category:ADPCM Audio Codecs]]
[[Category:IMA ADPCM Audio Codecs]]
[[Category:IMA ADPCM Audio Codecs]]
[[Category:Game Formats]]

Latest revision as of 12:14, 16 July 2008

Some Sega Saturn game CDs contain AVI files which store audio using the Duck DK4 IMA ADPCM algorithm. DK4 data can be decoded using the same algorithm and tables as are used to decode IMA ADPCM data. The name apparently comes from the fact that 4 ADPCM nibbles decode to 4 16-bit PCM samples, in contrast to Duck's Duck DK3 IMA ADPCM DK3 IMA ADPCM algorithm, in which 3 ADPCM nibbles decode to 4 16-bit PCM samples.

The length of a single block of DK4 data is encoded in the nBlockAlign field of an AVI file's WAVEFORMATEX header. The chunk encoding format is very similar to Microsoft IMA ADPCM. If the DK4 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 initial predictor is placed directly into the output as the first PCM sample. The remaining bytes in the chunk are the IMA nibbles. Each byte is decoded top nibble first (bits 7-4), then bottom nibble as follows:

   byte0 byte1 byte2 byte3 ...
    n0n1  n2n3  n4n5  n6n7 ... 

If the DK4 data is stereo, a chunk begins with two preambles, one for the left audio channel and one for the right audio 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 initial left and right channel predictors are placed directly into the output as the first PCM samples for each channel. The remaining bytes in the chunk are the IMA nibbles. For each byte, the top nibble (bits 7-4) corresponds to the left channel and the bottom nibble corresponds to the right channel:

byte0 byte1 byte2 byte3 ...
 L0R0  L1R1  L2R2  L3R3 ...