[Speex-dev] ARM7 Speex decoder

Ralph Giles giles at xiph.org
Tue Mar 21 13:41:41 PST 2006

On Tue, Mar 21, 2006 at 09:56:04PM +0100, pberna at iol.it wrote:

> My intention is to read a piece at time of an .ogg file (stored in and external Multimedia card) decompress it and render it on and LPC2000 DAC. Because I don't have enough RAM memory to load the complete ogg file, I must read only a piece of file at certain time, then decompress and render it, and repeat the previous process until the end of the file. The problem is that I don't know what is the minimum file block size that I must consider.

What you appear to be missing is that the speex data packets are 
encapsulated in an Ogg container. You must first parse the Ogg
header to extract the raw packets before passing them to libspeex
with speex_bits_read_from(). It's not clear from your description
that your file_read() function is doing all this.

speexdec uses libogg to do this.

Ogg pages produced by the reference encoder are around 4 kB, but 
by specification Ogg pages can be up to 65 kB in length. libogg
will internally buffer a full page before returning any packet
data for decode, so that's the minimum footprint you would have
to design for.

If you're in a memory contrained environment I'd recommend implementing 
your own ogg parser to pass the data to libspeex directly as it's read 
instead of buffering a whole page for checksum verification. You can 
either compute the checksum incrementally or dispense with it entirely 
and assume libspeex will detect any file corruption. Note that both of 
these are necessarily less robust against damaged files, but it should 
let you process data with an arbitrarily small read buffer.

A compromise would be to use a static 5 kB buffer and verify the crc
only if the page happens to fit, falling back to incremental parsing


More information about the Speex-dev mailing list