[ogg-dev] page syncing and magic OggS
Ralph Giles
giles at xiph.org
Thu Dec 7 10:59:29 PST 2006
On Thu, Dec 07, 2006 at 03:18:02PM +0000, Ian Malone wrote:
> Pages have to start with 'OggS', but this could also turn
> up elsewhere in the bitstream, so is there a simple strategy
> using the libogg API to find out which ones are the start of
> pages?
Yes, 'OggS' can occur randomly. So to be more sure, you can parse the
subsequent bytes as a header. Calculate the offset to the start of the
next ogg page and see if the 'OggS' sequence occurs there as well. You
can also verify the CRC for the page as an additional check.
ogg_sync_pageseek() does the CRC check, and scans for the next 'OggS' if
it does not succeed, so by calling it repeatedly you can scan through
the stream finding pages.
Note that ogg_sync_pageout does this automatically. You can check the
return code to identify any holes or corrupt pages in the data stream.
HTH,
-r
More information about the ogg-dev
mailing list