[Tremor] bit ordering used in Vorbis

ercole work ercolework
Thu Jul 29 00:30:48 PDT 2004


Hi,

I have a question about the bit ordering used in Vorbis.
While decoding the vorbis bitstream, let's say right at the beginning, if I want to get the first 3 bits of the stream, I'll need to do something like:
my_val = ( (*p) & 0x7);

where p is a C pointer, pointing to the beginning of the data.

Most of the other existing formats (all flavors of MPEG, WMA, AC3, DTS, etc...) do it the other way:
my_val = ( ((*p)>> 5) & 0x7);

It's quite counter-intuitive to handle bits from right to left, and then bytes from left to right...

Let a letter 'A' be the representation of a bit, so:
ABCDEFGH represents a byte (each letter being a bit => 8 bits => 1 byte).

Let's consider the following stream:
ABCDEFGH IJKLMNOP

Getting 11 bits, the 'vorbis way', will give:
ABCDEFGHNOP
(Am I right?)

Other formats (e.g. MP3), would give:
ABCDEFGHIJK


Why such an approach was chosen for vorbis?

Thanks!


---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/tremor/attachments/20040729/894f80de/attachment.html


More information about the Tremor mailing list