[ogg-dev] liboggz and packets versus segments ...
giles at xiph.org
Fri Aug 1 16:01:08 PDT 2008
On 31-Jul-08, at 12:26 AM, Warwick Baker wrote:
> The part I don't understand is why the read_packet callback only
> gets invoked on my test file when the full 600 bytes have been
> read, noting that it is written to file as 3 segments on the page
> (lengths, FF, FF and 5A I think it was). But when the sample spx
> file gets read, the read_packet callback gets called for each
> segment, which by the way are all of size 20 bytes, and returns
> only 20 bytes at a time.
Segments aren't exposed by the API, they're just used internally to
partition the data. What liboggz feeds you are *packets* which should
be the exactly the same units that were feed when the file was written.
So if you gave it 600 byte packets writing the file, you get a
callback every 600 bytes reading the file. Speex packets are much
smaller, so you get a callback every 20 bytes (or so) reading a speex
file. It's just maintaining the original packet boundaries,
regardless of how many segments the packets occupy.
More information about the ogg-dev