mirror of
https://github.com/xiph/opus.git
synced 2025-05-17 08:58:30 +00:00
Preventing unnecessary stack use when using a large decode buffer
This was causing pseudostack builds to fail because opus_demo uses a 2-second buffer.
This commit is contained in:
parent
9134e96cb2
commit
b76888dc86
1 changed files with 18 additions and 0 deletions
|
@ -722,6 +722,7 @@ int opus_decode_float(OpusDecoder *st, const unsigned char *data,
|
|||
{
|
||||
VARDECL(opus_int16, out);
|
||||
int ret, i;
|
||||
int nb_samples;
|
||||
ALLOC_STACK;
|
||||
|
||||
if(frame_size<=0)
|
||||
|
@ -729,6 +730,14 @@ int opus_decode_float(OpusDecoder *st, const unsigned char *data,
|
|||
RESTORE_STACK;
|
||||
return OPUS_BAD_ARG;
|
||||
}
|
||||
if (data != NULL && len > 0)
|
||||
{
|
||||
nb_samples = opus_decoder_get_nb_samples(st, data, len);
|
||||
if (nb_samples>0)
|
||||
frame_size = IMIN(frame_size, nb_samples);
|
||||
else
|
||||
return OPUS_INVALID_PACKET;
|
||||
}
|
||||
ALLOC(out, frame_size*st->channels, opus_int16);
|
||||
|
||||
ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL, 0);
|
||||
|
@ -749,6 +758,7 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
|
|||
{
|
||||
VARDECL(float, out);
|
||||
int ret, i;
|
||||
int nb_samples;
|
||||
ALLOC_STACK;
|
||||
|
||||
if(frame_size<=0)
|
||||
|
@ -757,6 +767,14 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
|
|||
return OPUS_BAD_ARG;
|
||||
}
|
||||
|
||||
if (data != NULL && len > 0)
|
||||
{
|
||||
nb_samples = opus_decoder_get_nb_samples(st, data, len);
|
||||
if (nb_samples>0)
|
||||
frame_size = IMIN(frame_size, nb_samples);
|
||||
else
|
||||
return OPUS_INVALID_PACKET;
|
||||
}
|
||||
ALLOC(out, frame_size*st->channels, float);
|
||||
|
||||
ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue