[Flac-dev] FLAC StreamInfo Parsing

Ilia Ternovich ternovich at gmail.com
Tue Jun 22 21:27:18 PDT 2010


Thank you very much! But how to deal with endianness in the case of
bit stream? Some blocks (for example MinBlockSize) require 16bits
(simply swap first and second), some block (e.g.MinFrameSize) require
3 byte-array to be reverted.

Finally totalSamples is stored in 5 bytes ( only last 4 bits from
first one byte are used). It was a real issue to make it little-endian
(here is how I did it:
http://code.google.com/p/sharpflac/source/browse/trunk/SharpFlac/Blocks/StreamInfo.cs).

So to make stream little endian, I can't simple get each 4 bytes of
the stream one by one and revert them...

Anyways I've managed to decode StreamInfo, VorbisComments,SeekPoints
and Application blocks without bitStream implementation. But I'd be
really pleased if anyone pointed me out how to deal with endianness.

Thank you!


2010/6/23 Brian Willoughby <brianw at sounds.wa.com>:
>
> On Jun 22, 2010, at 07:21, Ivailo Karamanolev wrote:
>> Hello Ilia,
>>
>> The FLAC format by nature is not a byte stream, it's a bit stream.
>> Therefore, in order to parse it you need too build a bit-reading
>> infrastructure. Eg. a class that accepts a byte stream, implements
>> buffering, etc, etc, and supports reading a specified number of
>> bits, not bytes as you are used to. There is quite a lot of bit
>> logic there, but nothing too scary.
>
> Ivailo is correct.  You'll note, Ilia, that other compressed formats
> such as MPEG and MP3 also have bit streams, so you might find other
> open source examples of bit parsing.
>
> Brian Willoughby
> Sound Consulting
>
> _______________________________________________
> Flac-dev mailing list
> Flac-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/flac-dev
>


More information about the Flac-dev mailing list