[Speex-dev] memory usage

Alfred E. Heggestad alfredh at sxdesign.com
Sat Feb 19 23:47:35 PST 2005


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>



More information about the Speex-dev mailing list