WavPack

From MultimediaWiki
Revision as of 22:02, 23 September 2006 by Kostya (talk | contribs)
Jump to navigation Jump to search

WavPack is an open source lossless audio coding algorithm.

WavPack v.4

File Format

General details of WavPack format can be found in file 'format.txt' in wavpack sources archive. WavPack file consists of blocks each beginning with 'wvpk'. Every block contains all information about sound data - sampling rate, channels, bits per sample, etc. and so-called metadata. Metadata may contain different coefficients using for restoring samples, correction bitstream and actual compressed samples.

Samples coding

Samples are stored in metadata block with ID=0x0A and are packed with modified Rice codes. Decoding process is specified below where get_unary() is the function which returns length of '1'-bits string (i.e. 111110b = 5, 10b = 1).

 n = get_unary();
 if(n >= 2) n = getbits(n);
 set next n values to zero
 n = get_unary();
 if(n == 0){
  base = 0;
  add = median[0] - 1;
  decrease median[0];
 } else if(n == 1){
  base = median[0];
  add = median[1] - 1;
  increase median[0];
  decrease median[1];
 } else {
  base = median[0] + median[1] + median[2] * (n - 2);
  add = median[2] - 1;
  increase median[0];
  increase median[1];
  if(n == 2) derease median[2];
  else increase median[2];
 }
 n = base + getbits(add);
 next value = n;