[Matroska-devel] Re: WavPack hybrid

Steve Lhomme steve.lhomme at free.fr
Wed Dec 22 13:57:40 CET 2004

dbryant at impulse.net a écrit :
> For mono or stereo WavPack files, each block holds some number of mono or
> stereo samples. You don't really need the whole block to start decoding
> samples, but the standard library does suck in a whole block before it
> starts decoding. The "tiny" decoder reads the data as it decodes because it
> is designed to work with very little memory. The regular library could be
> set up this way also, but would only work for stereo or mono audio.
> For multichannel audio the samples are split into seperate blocks. So, for
> example, for 5.1 audio we use 4 blocks for each group of samples:
> block 1:  front left + front right (stereo)   INITIAL_BLOCK flag is set
> block 2:  center (mono)
> block 3:  subwoofer (mono)
> block 4:  back left + back right (stereo)  FINAL_BLOCK flag is set
> This interleaving is handled by the WavPack library on encode and decode and
> is transparent to the caller. The actual data that the application sends or
> receives is six 32-bit words for each sample.
> However, on decode all 4 blocks must be read into memory by the decoder
> because it needs to be decoding all 4 in parallel to be able to reconstruct
> the original data. That's why I say that the minimum "chunk" of WavPack data
> that is independently decodable is a single block for mono or stereo, or a
> sequence of blocks for multichannel (from INITIIAL_BLOCK to FINAL_BLOCK).
> In mono or stereo streams every WavPack blocks has both flags set. Also
> note that for multichannel streams the WavPack encoder puts fewer samples
> in each block so that the total size that needs to be pulled into memory is
> not any larger that standard audio.

OK, I think I understand. Do you have a sample 5.1 file that I could 
debug with ? I'm not sure how to produce one...

 From what I saw in the WavPack files I produced (stereo) the 
INITIAL_BLOCK is set on the first frame and FINAL_BLOCK is set on the 
last one. And so the same flags have different meanings for multichannel 
files ?

> During encoding the application can put exactly how many sample in each
> block as desired. Once encoded however, the blocks can not easily be split
> up at different points (although for lossless you could easily re-encode).

Yes. This is no problem for us. We check the number of samples for each 
block and generate the timecode & duration accordingly.


More information about the Matroska-devel mailing list