[vorbis-dev] Vorbis packet sizes
John Ripley
jripley at rioaudio.com
Thu Jun 5 03:17:12 PDT 2003
> From: Beni Cherniavsky <cben at techunix.technion.ac.il>
> Sent: 04 June 2003 20:02
>
> John Ripley wrote on 2003-06-04:
>
> > As an optimisation to reading Ogg encapsulated files, I've
> been thinking
> > about a strategy of reading entire packets out of the
> stream, and sending
> > them to the decoder. This has the advantages that:
> >
> > * The packet is just a linear array of bits in memory, with
> length known in
> > advance.
> > * The routine which gets bits out of the packet is then
> trivial and possibly
> > inlined.
> > * There is no possibility of blocking reads in the middle
> of a packet.
> >
> > However, I'm not sure what the upper bound of packet size is.
>
> There is no bound whatsoever on packets. There is a limit on the size
> of a page - just below 64KB. Packets can span multiple pages, which
> is the only limitation to reading entire packets. I/O should be much
> slower than moving around memory anyway.
That's the point, I/O is slow and may block, which then involves a context
switch. If you want the ability to context switch, you suddenly need a
separate stack (or thread if you're running a big OS). If you take all the
I/O out of the decode path, it won't ever need to context switch.
> > Even so, 4KB is still rather large, and I haven't seen packet sizes
> > that large in any file generated by oggenc 1.0.
> >
> Most packets are much smaller but that's the typical page size.
> However the initial setup packets can be larger. I don't know the
> codebook sizes but the comment packet can be up to 2^32 bytes. But
> that much has never seen in the wild ;-).
I worked out the maximum header size once and found it was something like
1TB. I'm not worried about the size of header packets because those aren't
in the "normal" decode path.
> > Is there even a maximum?
>
> Multiplying max page size by page sequence number limit, you can get a
> theoretical limit of packet size but that would be ridiculously big.
> Ogg intentionally supports arbitrarily big packets.
The "unknown" and "arbitrary" upper bounds of Vorbis streams is something I
don't particularly like. However, if you assumed stereo (I'm throwing away
anything with more), 8192 block size, and worst case entropy (all codes are
32 bits), I bet it would still be reasonably small. I'll calculate this when
I have some spare time.
- John Ripley.
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis-dev
mailing list