Adds missing RESTORE_STACK statements on error paths
Thanks to Vincent Penquerc'h
This commit is contained in:
parent
c0387ff237
commit
c792108829
2 changed files with 40 additions and 5 deletions
|
@ -218,7 +218,10 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
|
||||||
F5 = F10>>1;
|
F5 = F10>>1;
|
||||||
F2_5 = F5>>1;
|
F2_5 = F5>>1;
|
||||||
if (frame_size < F2_5)
|
if (frame_size < F2_5)
|
||||||
|
{
|
||||||
|
RESTORE_STACK;
|
||||||
return OPUS_BUFFER_TOO_SMALL;
|
return OPUS_BUFFER_TOO_SMALL;
|
||||||
|
}
|
||||||
/* Payloads of 1 (2 including ToC) or 0 trigger the PLC/DTX */
|
/* Payloads of 1 (2 including ToC) or 0 trigger the PLC/DTX */
|
||||||
if (len<=1)
|
if (len<=1)
|
||||||
{
|
{
|
||||||
|
@ -253,7 +256,10 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
|
||||||
do {
|
do {
|
||||||
int ret = opus_decode_frame(st, NULL, 0, pcm, F20, 0);
|
int ret = opus_decode_frame(st, NULL, 0, pcm, F20, 0);
|
||||||
if (ret != F20)
|
if (ret != F20)
|
||||||
|
{
|
||||||
|
RESTORE_STACK;
|
||||||
return OPUS_INTERNAL_ERROR;
|
return OPUS_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
pcm += F20*st->channels;
|
pcm += F20*st->channels;
|
||||||
nb_samples += F20;
|
nb_samples += F20;
|
||||||
} while (nb_samples < frame_size);
|
} while (nb_samples < frame_size);
|
||||||
|
@ -767,7 +773,11 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
|
||||||
int ret, i;
|
int ret, i;
|
||||||
ALLOC_STACK;
|
ALLOC_STACK;
|
||||||
|
|
||||||
if(frame_size<0)return OPUS_BAD_ARG;
|
if(frame_size<0)
|
||||||
|
{
|
||||||
|
RESTORE_STACK;
|
||||||
|
return OPUS_BAD_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
ALLOC(out, frame_size*st->channels, float);
|
ALLOC(out, frame_size*st->channels, float);
|
||||||
|
|
||||||
|
|
|
@ -779,15 +779,23 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
|
||||||
st->user_forced_mode = MODE_CELT_ONLY;
|
st->user_forced_mode = MODE_CELT_ONLY;
|
||||||
tmp_len = opus_encode_native(st, pcm+i*(st->channels*st->Fs/50), st->Fs/50, tmp_data+i*bytes_per_frame, bytes_per_frame);
|
tmp_len = opus_encode_native(st, pcm+i*(st->channels*st->Fs/50), st->Fs/50, tmp_data+i*bytes_per_frame, bytes_per_frame);
|
||||||
if (tmp_len<0)
|
if (tmp_len<0)
|
||||||
|
{
|
||||||
|
RESTORE_STACK;
|
||||||
return OPUS_INTERNAL_ERROR;
|
return OPUS_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
ret = opus_repacketizer_cat(&rp, tmp_data+i*bytes_per_frame, tmp_len);
|
ret = opus_repacketizer_cat(&rp, tmp_data+i*bytes_per_frame, tmp_len);
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
|
{
|
||||||
|
RESTORE_STACK;
|
||||||
return OPUS_INTERNAL_ERROR;
|
return OPUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ret = opus_repacketizer_out(&rp, data, out_data_bytes);
|
ret = opus_repacketizer_out(&rp, data, out_data_bytes);
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
|
{
|
||||||
|
RESTORE_STACK;
|
||||||
return OPUS_INTERNAL_ERROR;
|
return OPUS_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
st->user_forced_mode = bak_mode;
|
st->user_forced_mode = bak_mode;
|
||||||
st->user_bandwidth = bak_bandwidth;
|
st->user_bandwidth = bak_bandwidth;
|
||||||
st->force_channels = bak_channels;
|
st->force_channels = bak_channels;
|
||||||
|
@ -949,6 +957,7 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
|
||||||
if( ret ) {
|
if( ret ) {
|
||||||
/*fprintf (stderr, "SILK encode error: %d\n", ret);*/
|
/*fprintf (stderr, "SILK encode error: %d\n", ret);*/
|
||||||
/* Handle error */
|
/* Handle error */
|
||||||
|
RESTORE_STACK;
|
||||||
return OPUS_INTERNAL_ERROR;
|
return OPUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
if (nBytes==0)
|
if (nBytes==0)
|
||||||
|
@ -1124,7 +1133,10 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
|
||||||
celt_encoder_ctl(celt_enc, OPUS_SET_VBR(0));
|
celt_encoder_ctl(celt_enc, OPUS_SET_VBR(0));
|
||||||
err = celt_encode_with_ec(celt_enc, pcm_buf, st->Fs/200, data+nb_compr_bytes, redundancy_bytes, NULL);
|
err = celt_encode_with_ec(celt_enc, pcm_buf, st->Fs/200, data+nb_compr_bytes, redundancy_bytes, NULL);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
{
|
||||||
|
RESTORE_STACK;
|
||||||
return OPUS_INTERNAL_ERROR;
|
return OPUS_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
celt_encoder_ctl(celt_enc, OPUS_GET_FINAL_RANGE(&redundant_rng));
|
celt_encoder_ctl(celt_enc, OPUS_GET_FINAL_RANGE(&redundant_rng));
|
||||||
celt_encoder_ctl(celt_enc, OPUS_RESET_STATE);
|
celt_encoder_ctl(celt_enc, OPUS_RESET_STATE);
|
||||||
}
|
}
|
||||||
|
@ -1147,9 +1159,12 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
|
||||||
{
|
{
|
||||||
ret = celt_encode_with_ec(celt_enc, pcm_buf, frame_size, NULL, nb_compr_bytes, &enc);
|
ret = celt_encode_with_ec(celt_enc, pcm_buf, frame_size, NULL, nb_compr_bytes, &enc);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
RESTORE_STACK;
|
||||||
return OPUS_INTERNAL_ERROR;
|
return OPUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* 5 ms redundant frame for SILK->CELT */
|
/* 5 ms redundant frame for SILK->CELT */
|
||||||
if (redundancy && !celt_to_silk)
|
if (redundancy && !celt_to_silk)
|
||||||
|
@ -1169,7 +1184,10 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
|
||||||
|
|
||||||
err = celt_encode_with_ec(celt_enc, pcm_buf+st->channels*(frame_size-N2), N2, data+nb_compr_bytes, redundancy_bytes, NULL);
|
err = celt_encode_with_ec(celt_enc, pcm_buf+st->channels*(frame_size-N2), N2, data+nb_compr_bytes, redundancy_bytes, NULL);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
{
|
||||||
|
RESTORE_STACK;
|
||||||
return OPUS_INTERNAL_ERROR;
|
return OPUS_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
celt_encoder_ctl(celt_enc, OPUS_GET_FINAL_RANGE(&redundant_rng));
|
celt_encoder_ctl(celt_enc, OPUS_GET_FINAL_RANGE(&redundant_rng));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1212,7 +1230,10 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
|
||||||
if (!st->use_vbr && ret >= 3)
|
if (!st->use_vbr && ret >= 3)
|
||||||
{
|
{
|
||||||
if (pad_frame(data, ret, max_data_bytes))
|
if (pad_frame(data, ret, max_data_bytes))
|
||||||
|
{
|
||||||
|
RESTORE_STACK;
|
||||||
return OPUS_INTERNAL_ERROR;
|
return OPUS_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
ret = max_data_bytes;
|
ret = max_data_bytes;
|
||||||
}
|
}
|
||||||
RESTORE_STACK;
|
RESTORE_STACK;
|
||||||
|
@ -1229,7 +1250,11 @@ int opus_encode_float(OpusEncoder *st, const float *pcm, int frame_size,
|
||||||
VARDECL(opus_int16, in);
|
VARDECL(opus_int16, in);
|
||||||
ALLOC_STACK;
|
ALLOC_STACK;
|
||||||
|
|
||||||
if(frame_size<0)return OPUS_BAD_ARG;
|
if(frame_size<0)
|
||||||
|
{
|
||||||
|
RESTORE_STACK;
|
||||||
|
return OPUS_BAD_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
ALLOC(in, frame_size*st->channels, opus_int16);
|
ALLOC(in, frame_size*st->channels, opus_int16);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue