Dave Brown
2006-Sep-14 07:55 UTC
[Vorbis] ov_open_callbacks() performance & memory requirements
Hi guys, I'm writing a sample playback engine using vorbisfile, but I've hit a performance problem - hoping someone here can help! I'm using ov_open_callbacks() to decode memory-based ogg files. It works OK, but when I call ov_open_callbacks() approximately 300k of memory is used (presumably to initialise the decoder). It also takes some time to execute ov_open_callbacks() - the read & seek functions are being called a huge number of times, even for a tiny 10k ogg file. My sample engine needs to load a large number of small audio files. This gives me two problems - first, it's taking too long to initialise all those files with ov_open_callbacks(), and secondly I'm running out of memory! For example, 100 x 10k files needs a thumping 29MB of memory. Is there anything I can do to speed up ov_open_callbacks() or reduce it's memory requirement? Many thanks, Dave.
Michael Smith
2006-Sep-14 07:58 UTC
[Vorbis] ov_open_callbacks() performance & memory requirements
On 9/14/06, Dave Brown <dave@db-audioware.com> wrote:> Hi guys, > > I'm writing a sample playback engine using vorbisfile, but I've hit a > performance problem - hoping someone here can help! > > I'm using ov_open_callbacks() to decode memory-based ogg files. It works > OK, but when I call ov_open_callbacks() approximately 300k of memory is > used (presumably to initialise the decoder). It also takes some time to > execute ov_open_callbacks() - the read & seek functions are being called > a huge number of times, even for a tiny 10k ogg file.If you have very small files, perhaps you're not interested in being able to seek around them. Returning failure from your seek callback is fine, and will disable seeking; that'll probably speed things up somewhat. As for memory use: not much you can do with that implementation, the libvorbis decoder is simply fairly memory-intensive. You could look at changing to use the tremor-lowmem vorbis decoder, which is specifically designed to minimise memory use. Mike
Ralph Giles
2006-Sep-14 21:38 UTC
[Vorbis] ov_open_callbacks() performance & memory requirements
On Thu, Sep 14, 2006 at 03:55:05PM +0100, Dave Brown wrote:> My sample engine needs to load a large number of small audio files. This > gives me two problems - first, it's taking too long to initialise all > those files with ov_open_callbacks(), and secondly I'm running out of > memory! For example, 100 x 10k files needs a thumping 29MB of memory.Two other things you can try, in addition to Mike's suggestions: It's legal to concatenate ogg files, and libvorbisfile will handle that, so you can try concatenating the encoded data and only having one decoder context. This should reduce your memory footprint significantly, but will add the cpu/latency cost of seeking when you switch clips within a decoder context. Another thing you can try to do is concatentate the *input* files and compress them as a single stream (perhaps with some padding at the joins). Then you have a single logical ogg stream. Use a custom cue table to seek in that for clip selection. This is save the overhead of the chain mapping as well as reducing the number of decoder contexts. These both assume seeking, of course, but are both also applicable to using the Tremor decoder Mike mentioned. HTH, -r
Reasonably Related Threads
- ov_open_callbacks
- Initializing vorbis using ov_open_callbacks fail with OV_ENOTVORBIS. But why?
- ov_open_callbacks takes so much time to open 210 MB OGG file
- Ogg files versus Ogg streams
- Continued:How can I seek in Ogg Vorbis file, but not using Vorbisfile library?