[Flac-dev] FLAC StreamInfo Parsing

Ilia Ternovich ternovich at gmail.com
Tue Jun 22 05:19:26 PDT 2010


Hello!

I'm implementing custom flac metadata parser. Currently the very big
trouble is to parse StreamInfo metadata block.

According to specifications
(http://flac.sourceforge.net/format.html#metadata_block_streaminfo)
we've got 2 bytes fir minBlockSize, 2 bytes for maxBlock size, 3 + 3
bytes for min/max FrameSize.

Now the interesting point -- sampleRate. number of channels, buts per
sample and total samples in stream.

20 + 3 + 5 + 36 == 64 bits == 8 bytes.

To parse sample rate I take 3 bytes then reverse order (windows uses
little endian by default) and finnaly aply left shift by 4.

To parse number of channels I take last byte, apply right shift by 1
then make "AND" by 7dec.

But how can I parse BitsPerSample and Total sample count? They lay in
separate bytes... It's a real painass.


More information about the Flac-dev mailing list