diff options
Diffstat (limited to 'lib/rbcodec/codecs/libopus')
-rw-r--r-- | lib/rbcodec/codecs/libopus/opus_decoder.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/rbcodec/codecs/libopus/opus_decoder.c b/lib/rbcodec/codecs/libopus/opus_decoder.c index 7103b183b8..3d42bb2e70 100644 --- a/lib/rbcodec/codecs/libopus/opus_decoder.c +++ b/lib/rbcodec/codecs/libopus/opus_decoder.c | |||
@@ -131,10 +131,13 @@ int opus_decoder_init(OpusDecoder *st, opus_int32 Fs, int channels) | |||
131 | return OPUS_OK; | 131 | return OPUS_OK; |
132 | } | 132 | } |
133 | 133 | ||
134 | #define STATIC_DECODER_SIZE 26532 /* 26486 for 32bit, 26532 for 64bit environment */ | ||
135 | static char s_dec[STATIC_DECODER_SIZE] IBSS_ATTR MEM_ALIGN_ATTR; | ||
136 | |||
134 | OpusDecoder *opus_decoder_create(opus_int32 Fs, int channels, int *error) | 137 | OpusDecoder *opus_decoder_create(opus_int32 Fs, int channels, int *error) |
135 | { | 138 | { |
136 | int ret; | 139 | int ret; |
137 | OpusDecoder *st; | 140 | OpusDecoder *st = NULL; |
138 | if ((Fs!=48000&&Fs!=24000&&Fs!=16000&&Fs!=12000&&Fs!=8000) | 141 | if ((Fs!=48000&&Fs!=24000&&Fs!=16000&&Fs!=12000&&Fs!=8000) |
139 | || (channels!=1&&channels!=2)) | 142 | || (channels!=1&&channels!=2)) |
140 | { | 143 | { |
@@ -142,7 +145,12 @@ OpusDecoder *opus_decoder_create(opus_int32 Fs, int channels, int *error) | |||
142 | *error = OPUS_BAD_ARG; | 145 | *error = OPUS_BAD_ARG; |
143 | return NULL; | 146 | return NULL; |
144 | } | 147 | } |
145 | st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels)); | 148 | |
149 | if (STATIC_DECODER_SIZE >= opus_decoder_get_size(channels)) | ||
150 | st = (OpusDecoder *)s_dec; | ||
151 | else | ||
152 | st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels)); | ||
153 | |||
146 | if (st == NULL) | 154 | if (st == NULL) |
147 | { | 155 | { |
148 | if (error) | 156 | if (error) |