Musepack: Difference between revisions
(Some known info about Musepack) |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
There are several variations of Musepack known - SV(stream version) 4-6, 7 and 8. | There are several variations of Musepack known - SV(stream version) 4-6, 7 and 8. | ||
SV 4-6 | SV 4-6 are old and rarely used, SV8 is in beta stage. | ||
== SV7 container format == | == SV7 container format == | ||
Line 41: | Line 41: | ||
== SV8 format == | == SV8 format == | ||
Look here for details: [http://trac.musepack.net/trac/wiki/SV8Specification SV8 Specification] | Look here for details: [http://trac.musepack.net/trac/wiki/SV8Specification SV8 Specification] | ||
== SV8 frame format == | |||
Main differences from SV7: | |||
* keyframes | |||
* bitstream now is not stored in 32 LSB units | |||
* new Huffman codes | |||
'''Quantizer''' reading: | |||
for each non-zero band { | |||
switch(band type){ | |||
case -1: fill all 36 band samples with random values | |||
case 0: do nothing | |||
case 1: read VLC which contains flags for 18 samples, if flag is set, read one bit to fill sample | |||
case 2: read 12 VLCs for 36 band samples | |||
case 3-4: read 18 VLCs for 36 band samples | |||
case 5-8: for each sample read VLC depending on previously decoded sample | |||
default: for each sample read VLC and fixed number of bits | |||
} | |||
} | |||
There is a tool in libmpc for lossless transcoding from SV7 to SV8, as only bitstream format has changed. | |||
[[Category:Audio Codecs]] | [[Category:Audio Codecs]] |
Latest revision as of 00:16, 2 November 2007
Musepack is an open-source lossy audio codec based on MP2. It is a variable bit rate coder intended to produce perceptually transparent encoding.
There are several variations of Musepack known - SV(stream version) 4-6, 7 and 8. SV 4-6 are old and rarely used, SV8 is in beta stage.
SV7 container format
Look here for header format: SV7 Specification The header is followed by frames, each frames is preceded by 20-bit variable containing number of bits in this frame (frames are not byte-aligned)
SV7 frame format
Frame data defines one audio frames - 32 bands with 36 subband samples (total 1152 samples per frame).
All data for bands is stored interleaved - left band first, right band next. Except for band indexes, all data is stored only for bands with index != 0.
Band type (max_bands is stored in file header):
for(i = 0; i <= max_bands; i++){ for(ch = 0; ch < 2; ch++) band[i][ch] = get_vlc(); if(band[i][0] != 0 || band[i][1] != 0) msflag[i] = getbit(); }
Scale index coding method - one VLC for each non-zero band (i.e. band type != 0) Scale indexes - 1-3 VLCs per each non-zero band depending on scale index coding method Quantizer
for each non-zero band { switch(band type){ case -1: fill all 36 band samples with random values case 1: read 12 VLCs for 36 band samples case 2: read 18 VLCs for 36 band samples case 3-7: for each band sample read VLC using table depending on band type case 8-17: for each band sample read (band type - 1) bits default: zero all 36 band samples } }
SV8 format
Look here for details: SV8 Specification
SV8 frame format
Main differences from SV7:
- keyframes
- bitstream now is not stored in 32 LSB units
- new Huffman codes
Quantizer reading:
for each non-zero band { switch(band type){ case -1: fill all 36 band samples with random values case 0: do nothing case 1: read VLC which contains flags for 18 samples, if flag is set, read one bit to fill sample case 2: read 12 VLCs for 36 band samples case 3-4: read 18 VLCs for 36 band samples case 5-8: for each sample read VLC depending on previously decoded sample default: for each sample read VLC and fixed number of bits } }
There is a tool in libmpc for lossless transcoding from SV7 to SV8, as only bitstream format has changed.