forked from len0rd/rockbox
opus: statically allocate decoder state in iram
Speeds up decoding of a 64kbps test file 26MHz on H300 (cf) and 2MHz on c200 (pp) Change-Id: I2fb4fe6c0a29321087e02fbd17fd1b1eb84e7b57 Signed-off-by: Nils Wallménius <nils@rockbox.org>
This commit is contained in:
parent
706b920b99
commit
270d9eaee8
1 changed files with 10 additions and 2 deletions
|
@ -131,10 +131,13 @@ int opus_decoder_init(OpusDecoder *st, opus_int32 Fs, int channels)
|
||||||
return OPUS_OK;
|
return OPUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define STATIC_DECODER_SIZE 26532 /* 26486 for 32bit, 26532 for 64bit environment */
|
||||||
|
static char s_dec[STATIC_DECODER_SIZE] IBSS_ATTR MEM_ALIGN_ATTR;
|
||||||
|
|
||||||
OpusDecoder *opus_decoder_create(opus_int32 Fs, int channels, int *error)
|
OpusDecoder *opus_decoder_create(opus_int32 Fs, int channels, int *error)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
OpusDecoder *st;
|
OpusDecoder *st = NULL;
|
||||||
if ((Fs!=48000&&Fs!=24000&&Fs!=16000&&Fs!=12000&&Fs!=8000)
|
if ((Fs!=48000&&Fs!=24000&&Fs!=16000&&Fs!=12000&&Fs!=8000)
|
||||||
|| (channels!=1&&channels!=2))
|
|| (channels!=1&&channels!=2))
|
||||||
{
|
{
|
||||||
|
@ -142,7 +145,12 @@ OpusDecoder *opus_decoder_create(opus_int32 Fs, int channels, int *error)
|
||||||
*error = OPUS_BAD_ARG;
|
*error = OPUS_BAD_ARG;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (STATIC_DECODER_SIZE >= opus_decoder_get_size(channels))
|
||||||
|
st = (OpusDecoder *)s_dec;
|
||||||
|
else
|
||||||
st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels));
|
st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels));
|
||||||
|
|
||||||
if (st == NULL)
|
if (st == NULL)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue