= SV8 specification draft = == File header == || '''Field''' || '''length (bits)''' || '''Value''' || || Magic || 24 || "MP+" || || Version || 8 || 0x08 || This file header allow old mpc readers to stop decoding at this point, without crashing. == Block formating == All blocks are formated using Key / Length / Value.[[BR]] Key is 16 bits long. It's the block ID.[[BR]] Length is a variable size field using the same values as [http://www.matroska.org/technical/specs/index.html matroska] :[[BR]] {{{ bits, big-endian 1xxx xxxx - value 0 to 2^7-2 01xx xxxx xxxx xxxx - value 0 to 2^14-2 001x xxxx xxxx xxxx xxxx xxxx - value 0 to 2^21-2 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^28-2 ... }}} The length is the size of the block in bytes, including the key and size fields. So the minimum length of a block is 3 bytes.[[BR]] The value is the block content. Its size can be 0.[[BR]] All unused bits in a block MUST be 0.[[BR]] || '''Field''' || '''length (bits)''' || '''Value''' || || Key || 16 || "EX" || || Length || n*8; 0 < n < 9 || 0x1A || || Value || Lentgh * 8 || "exemple" || == Stream information block == This block key is "SI".[[BR]] This block contain the informations needed to decode the stream. This block is mandatory and must be written before the first audio block.[[BR]] || '''Field''' || '''length (bits)''' || '''Value''' || '''comment''' || || CRC || 32 || || CRC 32 of the block (this field excluded). 0 = invalid || || Sample count || n*8; 0 < n < 9 || || number of samples in the stream. 0 = unknow || || Max used bands || 4 || || maximum number of bands used in the file || || Sample Frequency || 4 || || see table below || || Channel count || 4 || || number of channels in the stream || || Audio block frames || 4 || 1..16 || number of frames in an audio block is : 2^Value || || IS used || 1 || || Klemm specification suggest to use the number of band always using IS ? || || MS used || 1 || || || || True gapless || 1 || || always 1 ? || || PNS used || 1 || || || || unused || 4 || || must be 0 || Frequency table || '''Value''' || '''Frequency (Hz)''' || || 0 || 44100 || || 1 || 48000 || || 2 || 37800 || || 3 || 32000 || || 4 || 96000 || The CRC used in this block needs to be define. == Replay gain block == This block key is "RG".[[BR]] This block contains replay gain datas. If this block exists, it must be written before the first audio block.[[BR]] A log scale must be used to store the values.[[BR]] || '''Field''' || '''length (bits)''' || '''Value''' || '''comment''' || || Title gain || 16 || || The loudness calculated for the title, ''and not the gain that the player must apply'' || || Title peak || 16 || || || || Album gain || 16 || || The loudness calculated for the album || || Album peak || 16 || || || || Version || 8 || || The replay gain version || == Encoder infomations == This block key is "EI". || '''Field''' || '''length (bits)''' || '''Value''' || '''comment''' || || profile used || 4 || 0..15 || || || unused || 4 || || || || encoder version || 8 || || || {{{ Encoder version * 100 (106 = 1.06) EncoderVersion % 10 == 0 Release (1.0) EncoderVersion % 2 == 0 Beta (1.06) EncoderVersion % 2 == 1 Alpha (1.05a...z) }}} == Audio block == This block key is "AB".[[BR]] This block contain audio frames. The first frame is a key frame.[[BR]] The seek elements allow to jump back or forward. The block size can be used to seek 1 block forward.[[BR]] Seek block nb should be ( - means offset is negative) :[[BR]] 2 -2 3 -3 2 -2 4 -4 2 -2 3 -3 2 -2 5 -5 2 -2 3 -3 2 -2 4 -4 2 -2 3 -3 6 -6 2 -2 ...[[BR]] so 2 -> 2, 3 -> 3 ... and -2 -> -2, -3 -> -3 ...[[BR]] Allow to seek back and forward in O(ln(n)) time without a seeking table.[[BR]] || '''Field''' || '''length (bits)''' || '''Value''' || '''comment''' || || seek block nb || 4 || 2..17 || the number of blocks that can be skiped is 2^Value || || seek offset || 28 || -2^27..2^27-1 || number of bytes to jump the blocks from the beginning of this block. 0 = invalid || || audio frames || ? || || ||