Covox ADPCM: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
(That's all I know about it)
 
No edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 2: Line 2:
* Samples: [http://samples.mplayerhq.hu/A-codecs/CovoxFormats/ http://samples.mplayerhq.hu/A-codecs/CovoxFormats/]
* Samples: [http://samples.mplayerhq.hu/A-codecs/CovoxFormats/ http://samples.mplayerhq.hu/A-codecs/CovoxFormats/]


This is a family of [[ADPCM]] formats used for compressing 8-bit unsigned [[PCM]] for Covox Sound Master. There are 2-,3- and 4-bit ADPCM formats.
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.


== Header ==
== Header ==
File header consists of 16 bytes:
File header consists of 16 bytes:


   FF 55 FF AA FF 55 FF AA
   FF 55 FF AA FF 55 FF AA xx yy pp pp pp pp 00 00
   <type> - 1 byte
   xx - encoding type
   unknown/unused - 7 bytes
  yy - playback rate (rate != sample rate, rather the timer tick rate divisor used for playback)
   pp - unsigned longint meant to indicate unpacked size (mostly unused)
  00 - unknown/unused


Type may be one of the following:
Type may be one of the following:
* 0x08 - raw 8-bit unsigned PCM
 
* 0x82 - 2-bit ADPCM
* 0x01 - 1-bit ADPCM     
* 0x83 - 3-bit ADPCM
* 0x02 - 2-bit ADPCM     
* 0x84 - 4-bit ADPCM
* 0x03 - 3-bit ADPCM     
* 0x04 - 4-bit ADPCM     
* 0x08 - raw 8-bit unsigned PCM      
* 0x81 - 1-bit ADPCM with silence encoding
* 0x82 - 2-bit ADPCM with silence encoding
* 0x83 - 3-bit ADPCM with silence encoding
* 0x84 - 4-bit ADPCM with silence encoding
* 0x88 - 8-bit PCM  with silence encoding
 
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.


== Markers ==
== Markers ==
There are two types of markers known:
There are two types of markers known:


Line 23: Line 36:
* FF AA AA AA - end of sound
* FF AA AA AA - end of sound


== 4-bit ADPCM ==
For 3-bit ADPCM they are cut to 3 bytes (FF 55 55 and FF AA AA respectively).
 
Decoding procedure:
1. read 4 bytes
2. if they make a marker, do action for this marker
3. decode 8 deltas from it by taking high bits from 4 values and shifting them
4. apply these deltas to get decoded values
 
Update procedure:
 
mul = step_table[step] * mult_table[delta & 7];
if(delta & 8)
  val -= mul;
else
  val += mul;
val = clip(val, 0, 0xFFFF);
step = clip(step + step_update_table[delta & 7], 0, 71);
 
Step table:
 
0x0080, 0x008C, 0x0098, 0x00A6, 0x00B5, 0x00C5, 0x00D7, 0x00EB,
0x0100, 0x0117, 0x0130, 0x014C, 0x016A, 0x018B, 0x01AF, 0x01D6,
0x0200, 0x022E, 0x0261, 0x0298, 0x02D4, 0x0316, 0x035D, 0x03AB,
0x0400, 0x045D, 0x04C2, 0x0530, 0x05A8, 0x062B, 0x06BA, 0x0756,
0x0800, 0x08B9, 0x0983, 0x0A60, 0x0B50, 0x0C56, 0x0D74, 0x0EAC,
0x1000, 0x1173, 0x1307, 0x14C0, 0x16A1, 0x18AD, 0x1AE9, 0x1D58,
0x2000, 0x22E5, 0x260E, 0x2980, 0x2D41, 0x315A, 0x35D1, 0x3AB0,
0x4000, 0x45CB, 0x4C1C, 0x52FF, 0x5A82, 0x62B4, 0x6BA2, 0x7560,
0x8000, 0x8B96, 0x9838, 0xA5FF, 0xB505, 0xC567, 0xD745, 0xEAC1
 
Step update table:
 
-8, -6, -4, -2, 2, 4, 8, 16};
Multiplication table:
 
0.5, 1.0, 2.0, 3.0, 4.5, 5.0, 9.0, 12.0};


== 3-bit ADPCM ==
After silence block ADPCM decoding state should be reset.


== 2-bit ADPCM ==
== ADPCM decoding ==


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.


[[Category:Audio Codecs]]
[[Category:Audio Codecs]]
[[Category:ADPCM Audio Codecs]]
[[Category:ADPCM Audio Codecs]]
[[Category:Undiscovered Audio Codecs]]
[[Category:Undiscovered Audio Codecs]]

Latest revision as of 01:11, 16 January 2017

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.

Header

File header consists of 16 bytes:

 FF 55 FF AA FF 55 FF AA xx yy pp pp pp pp 00 00
 xx - encoding type
 yy - playback rate (rate != sample rate, rather the timer tick rate divisor used for playback)
 pp - unsigned longint meant to indicate unpacked size (mostly unused)
 00 - unknown/unused

Type may be one of the following:

  • 0x01 - 1-bit ADPCM
  • 0x02 - 2-bit ADPCM
  • 0x03 - 3-bit ADPCM
  • 0x04 - 4-bit ADPCM
  • 0x08 - raw 8-bit unsigned PCM
  • 0x81 - 1-bit ADPCM with silence encoding
  • 0x82 - 2-bit ADPCM with silence encoding
  • 0x83 - 3-bit ADPCM with silence encoding
  • 0x84 - 4-bit ADPCM with silence encoding
  • 0x88 - 8-bit PCM with silence encoding

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.

Markers

There are two types of markers known:

  • FF 55 55 55 - silence block, next 16-bit little-endian value specifies number of silence samples - 27
  • FF AA AA AA - end of sound

For 3-bit ADPCM they are cut to 3 bytes (FF 55 55 and FF AA AA respectively).

After silence block ADPCM decoding state should be reset.

ADPCM decoding

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.