[Speex-dev] memory usage

Alfred E. Heggestad alfredh at sxdesign.com
Mon Feb 21 23:44:20 PST 2005


On Sun, 2005-02-20 at 02:54 -0500, Jean-Marc Valin wrote:
> Hi Alfred,
> 
> First thing I'd like to ask is whether you're trying to achieve
> real-time performance, as I find it very unlikely that Speex could run
> in real-time on a micro-controller.
> 
well, the Ubicom IP3K is running @250 MHz@:

http://www.ubicom.com/processors/ip3000-family.htm

yes realtime is my goal, for ultra wideband VoIP.

> Regarding bufSize, no you can't just make it the size you like. Now,
> it's possible to decrease the amount of memory allocated if e.g. you
> only use complexity 1. You can also assume that the stack is only
> accessed through the PUSH macro.
> 
thanks, I have managed to move the decoders PCM buffer to a different
DATA segment, reducing the stack size to 4200 bytes. encoder is to
follow.


> 	Jean-Marc
> 
> Le samedi 19 février 2005 à 23:47 -0800, Alfred E. Heggestad a écrit :
> > Hi
> > 
> > I am currently trying to port speex v1.1.6 to a microcontroller with
> > very limited memory (<64Kbyte RAM).
> > 
> > what I found when initialising the encoder, a chunk of 32Kb was
> > attempted to be alloced, which failed:
> > 
> > src/nb_celp.c:
> > 
> > void *nb_encoder_init(const SpeexMode *m)
> > {
> >    /* snip */
> >    st = (EncState*)speex_alloc(sizeof(EncState)+8000*sizeof(spx_sig_t));
> >    /* snip */
> > }
> > 
> > 
> > same goes for the decoder:
> > 
> > void *nb_decoder_init(const SpeexMode *m)
> > {
> >    /* snip */
> >    st = (DecState *)speex_alloc(sizeof(DecState)+4000*sizeof(spx_sig_t));
> >    /* snip */
> > }
> > 
> > I tried to reduce the stacksize from 8000/4000 to say 2000/1000,
> > and reduce buffer size to 160 bytes:
> > 
> > 
> > src/modes.c:
> > 
> > /* Default mode for narrowband */
> > static const SpeexNBMode nb_mode = {
> >    160,    /*frameSize*/
> >    40,     /*subframeSize*/
> >    10,     /*lpcSize*/
> >    640,    /*bufSize*/            <--------- reduce to 160
> > 
> > 
> > this does not work, there are various crashes in strange places which
> > looks like its caused by stack overflow or data corruption.
> > 
> > question is; are there any clean way of reducing memory usage?
> > the stack at the end of the state object, is it only accessed
> > through the PUSH macros? perhaps I could write some wrappers
> > to use Program RAM (PRAM) instead, which is not directly accessible.
> > 
> > 
> > thanks.
> > 
> > 
-- 
Alfred E. Heggestad <alfredh at sxdesign.com>
SX Design



More information about the Speex-dev mailing list