隽 徐
2006-Aug-29 04:01 UTC
[Vorbis-dev] How can I seek in Ogg Vorbis file, but not using Vorbisfile library?
Hello, All. I am making an Ogg Vorbis decoder based on Tremor. The Vorbisfile library provides a high-level API which enables us to seek in the file, but it needs to declare a pointer to OggVorbis_File structure. Because I am supposed not to use file, so I can't use the ov_pcm_seek() or ov_raw_seek() functions to seek in the file. For decoding an Ogg Vorbis file, I first put it in a buffer, then use API provided by libogg and libvorbis to decode it, and put the PCM in ouput buffer. Now I have a problem, how to seek in the Ogg Vorbis file not using Vorbisfile library? That means, I can only use API provided by libogg and libvorbis libraries, and I didn't find an example. I hope someone can help me to solve this problem. And an example will be most grateful. Thank you. Best wishes, Susan --------------------------------- Mp3???-??????? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/vorbis-dev/attachments/20060829/cdf1b49e/attachment.html
Ian Malone
2006-Aug-29 07:59 UTC
[Vorbis-dev] How can I seek in Ogg Vorbis file, but not using Vorbisfile library?
On 29/08/06, ? ? <china_xujun@yahoo.com.cn> wrote:> > Hello, All. > > I am making an Ogg Vorbis decoder based on Tremor. The Vorbisfile library > provides a high-level API which enables us to seek in the file, but it needs > to declare a pointer to OggVorbis_File structure. > > Because I am supposed not to use file, so I can't use the ov_pcm_seek() or > ov_raw_seek() functions to seek in the file. For decoding an Ogg Vorbis > file, I first put it in a buffer, then use API provided by libogg and > libvorbis to decode it, and put the PCM in ouput buffer. > > Now I have a problem, how to seek in the Ogg Vorbis file not using > Vorbisfile library? That means, I can only use API provided by libogg and > libvorbis libraries, and I didn't find an example. > > I hope someone can help me to solve this problem. And an example will be > most grateful. >You may want to investigate how libvorbisfile does its search. IIRC the typical strategy is to bisection search, jump in the Ogg stream, try to get page synced and get a packet, then check the granulepos. I don't have an example for this though. Alternatively you could; implement call-backs which read from your buffer, this shouldn't be too much work, or build a list of pages when you start with pertinent data (granulepos, offset) and use that to speed up your search (you should be able to find the page before the one containing your desired granulepos). -- imalone
Ralph Giles
2006-Aug-29 10:04 UTC
[Vorbis-dev] How can I seek in Ogg Vorbis file, but not using Vorbisfile library?
On Tue, Aug 29, 2006 at 07:01:24PM +0800, ? ? wrote:> Because I am supposed not to use file, so I can't use the ov_pcm_seek() or ov_raw_seek() functions to seek in the file. For decoding an Ogg Vorbis file, I first put it in a buffer, then use API provided by libogg and libvorbis to decode it, and put the PCM in ouput buffer.You can use ov_open_callbacks() to supply your own read/write/seek functions for reading from memory instead of a file. This is the simplest way to do what you want.> Now I have a problem, how to seek in the Ogg Vorbis file not using Vorbisfile library? That means, I can only use API provided by libogg and libvorbis libraries, and I didn't find an example.Well, vorbisfile.c in the Tremor source is obviously such an example. You could see what it does. :) The seek algorithm is a little complicated, but basically: The stream is divided into Ogg pages, each has a serial number indicating which logical stream it belongs to, and a granulepos which can be mapped to a timestamp if you understand the format of the stream data. So you binary search for the time you want, using a table of known sign posts, and known mappings from granulepos to time for each known stream serial number. Generally to build the known mappings table for each serial number you also have to binary search for the chain boundaries. Vorbisfile does this when it opens the file, but in theory you could do it on the fly. Hope that helps, -r
隽 徐
2006-Sep-02 08:47 UTC
[Vorbis-dev] How can I seek in Ogg Vorbis file, but not using Vorbisfile library?
Hello, All. I am making an Ogg Vorbis decoder based on Tremor. The Vorbisfile library provides a high-level API which enables us to seek in the file, but it needs to declare a pointer to OggVorbis_File structure. Because I am supposed not to use file, so I can't use the ov_pcm_seek() or ov_raw_seek() functions to seek in the file. For decoding an Ogg Vorbis file, I first put it in a buffer, then use API provided by libogg and libvorbis to decode it, and put the PCM in ouput buffer. Now I have a problem, how to seek in the Ogg Vorbis file not using Vorbisfile library? That means, I can only use API provided by libogg and libvorbis libraries, and I didn't find an example. I hope someone can help me to solve this problem. And an example will be most grateful. Thank you. Best wishes, Susan __________________________________________________ ??????????????? http://cn.mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/vorbis-dev/attachments/20060829/a28c8572/attachment.htm