[Speex-dev] memory usage

Jean-Marc Valin Jean-Marc.Valin at USherbrooke.ca
Sat Feb 19 23:54:50 PST 2005


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.

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.

	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.
> 
> 
-- 
Jean-Marc Valin <Jean-Marc.Valin at USherbrooke.ca>
Université de Sherbrooke



More information about the Speex-dev mailing list