[vorbis-dev] some more granulepos questions

Joshua Haberman joshua at haberman.com
Sat Nov 15 19:09:57 PST 2003



I've made a lot of progress on my lossless Vorbis editing project.  I
have a few more questions about granulepos issues I don't quite
understand.

granulepos is a property of Ogg pages, yet it is a field in the
ogg_packet struct.  When reading packets from an Ogg stream, the
granulepos is set to -1 for all packets except the last packet in a
page.  From this I infer that

- for encoding, the granulepos needs to be correctly set for every
packet submitted to the stream because any packet could be the last on a
page.  If it is the last on a page, its granulepos is used for that
page's granulepos.

- for decoding, the stream cannot determine a granulepos for each packet
since it doesn't know anything about the codec, so it uses -1 to
indicate that it doesn't know.  For the last packet on a page, it uses
the page's granulepos.

Q1.  Is this accurate?


----

I want to know the granulepos of individual packets.  It appears that
Ogg cannot provide me this information.  Glancing at vcut, it appears
that I can use the function vorbis_packet_blocksize() to determine the
number of samples contained in a given vorbis packet.  But I have no
idea why the vcut function get_blocksize() adds the packet's block size
to the previous packet's blocksize and divides by 4.

Q2.  How does vcut's get_blocksize() work?

----

The spec says that the stream starts at an offset greater than zero if
there are less samples in the first page than the granulepos of the
first page.  For on-disk streams that have this characteristic, how will
the vorbisfile ov_*_seek() and ov_*_tell() functions behave?  Will they
act as though the file begins at offset 0, or will they expose the >0
starting offset?

Q3.  How does vorbisfile deal with >0 offsets?

Thanks for all the answers you have already provided.

Josh
--- >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