[ogg-dev] Ogg bitwise.c bit tracking

ogg.k.ogg.k at googlemail.com ogg.k.ogg.k at googlemail.com
Wed Feb 6 03:31:33 PST 2008


Hi,

it seems Ogg keeps track of a packet's size at the byte level, rather than
at the bit level (eg, if I encode a packet with just one bit, decode will
think there are 8 bits available). Am I right ?
Not that it's a particularly important issue, since remaining bits will
probably be initialized, but I noticed this while adding some calls to
oggpack_look1 at the end of my decode routines to check that negative was
being returned (eg, the data stream ended where it should), and it didn't.

Also, oggpack_bits, when called with a read buffer, returns the number of
bits read so far, rather than the number of bits still unread, which does
seem counterintuitive (to me): the docs say the routine returns:
"[...] the total number of bits within the current buffer"
which I would read as either the full size of the read buffer, regardless
of what was already read, or the number of bits still in the buffer after
any have been read, rather than the number of bits that have been read so
far from the current buffer.

It does make total sense for write buffers though, so I kinda suspect it
wasn't really intended for read buffers ?


More information about the ogg-dev mailing list