VocPack

From MultimediaWiki
Jump to navigation Jump to search

From the description, this appears to be one of the earliest lossless codecs: it dates from 1993. Two versions of the encoder/decoder are available on the site listed above

File structure:

 4 bytes - NFVP (probably Nicola Ferioli and VocPack)
 1 byte  - compression method (0 - unsigned 8-bit audio, 1 - signed 8-bit audio, 0x20 - version 2.0)
 4 bytes - number of coded samples
 [v2 only] 1 byte - packed parameters (bit 1 - stereo, bit 2 - 16-bit input, bits 3-5 - number of initial raw bytes)
 [v2 only] 1-33 bytes - zero-terminated original filename
 packed audio data

In both versions audio data is first predicted using adaptive order-2 predictor and then the difference is compressed using context adaptive models and binary arithmetic coder.

VocPack 1.0

This version compresses only 8-bit mono audio.

Prediction process:

 pred = clip((last * lastcoef + last2 * last2coef) >> 10, -128, 127);

Predictor update:

 if last > 0 {
   lastcoef += 5 * diff;
 } else {
   lastcoef -= 5 * diff;
 }
 if last2 > 0 {
   last2coef += 2 * diff;
 } else {
   last2coef -= 2 * diff;
 }
 last2 = last;
 last = sample;

Difference coding uses a set of 64 adaptive models with 256 elements each initially initialised to 1. The next model index is ((uint8_t)prev_decoded_val) >> 2. Each decoded element frequency is updated by adding 256 and if the total sum of frequency reaches 64000 the frequencies are halved as (freq >> 1) + 1.

VocPack 2.0

This version supports 16-bit and stereo audio. In case of stereo channels are coded independently. In case of 16-bit audio low byte of input sample is stored raw and only top byte is coded in a method very similar to version 1.0.

Version 2 predictor uses shift by 9 and the following update method:

 if last > 0 {
   lastcoef += diff * 2;
 } else {
   lastcoef -= diff * 2;
 }
 lastcoef = clip(lastcoef, 500, 1500);
 if last2 > 0 {
   last2coef += diff;
 } else {
   last2coef -= diff;
 }
 last2coef = clip(last2coef, -750, -250);

Difference is coded using a different model based on similar approaches.