diff --git a/lib/rbcodec/codecs/libopus/opus_decoder.c b/lib/rbcodec/codecs/libopus/opus_decoder.c index 9113638a00..5808bc0544 100644 --- a/lib/rbcodec/codecs/libopus/opus_decoder.c +++ b/lib/rbcodec/codecs/libopus/opus_decoder.c @@ -156,6 +156,10 @@ int opus_decoder_init(OpusDecoder *st, opus_int32 Fs, int channels) return OPUS_OK; } +/* Rockbox optimization */ +#define STATIC_DECODER_SIZE 26548 /* 26548 for 2ch 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) { int ret; @@ -167,7 +171,11 @@ OpusDecoder *opus_decoder_create(opus_int32 Fs, int channels, int *error) *error = OPUS_BAD_ARG; return NULL; } - st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels)); + if (STATIC_DECODER_SIZE >= opus_decoder_get_size(channels)) + st = (OpusDecoder *)s_dec; + else + st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels)); + if (st == NULL) { if (error)