ref: f340bba0f23dd04649c9cf308a388cd6c357397c
parent: 71c04dc00c40db580357f6b0bfcd15cb8c88d504
author: Jean-Marc Valin <[email protected]>
date: Thu Oct 27 16:33:48 EDT 2011
Checking error codes internally and return OPUS_INTERNAL_ERROR on failure
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -760,9 +760,15 @@
if (to_celt && i==nb_frames-1)
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);
+ if (tmp_len<0)
+ return OPUS_INTERNAL_ERROR;
ret = opus_repacketizer_cat(rp, tmp_data+i*bytes_per_frame, tmp_len);
+ if (ret<0)
+ return OPUS_INTERNAL_ERROR;
}
ret = opus_repacketizer_out(rp, data, max_data_bytes);
+ if (ret<0)
+ return OPUS_INTERNAL_ERROR;
st->user_forced_mode = bak_mode;
st->user_bandwidth = bak_bandwidth;
@@ -1101,9 +1107,12 @@
/* 5 ms redundant frame for CELT->SILK */
if (redundancy && celt_to_silk)
{
+ int err;
celt_encoder_ctl(celt_enc, CELT_SET_START_BAND(0));
celt_encoder_ctl(celt_enc, OPUS_SET_VBR(0));
- 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)
+ return OPUS_INTERNAL_ERROR;
celt_encoder_ctl(celt_enc, OPUS_GET_FINAL_RANGE(&redundant_rng));
celt_encoder_ctl(celt_enc, OPUS_RESET_STATE);
}
@@ -1129,6 +1138,7 @@
/* 5 ms redundant frame for SILK->CELT */
if (redundancy && !celt_to_silk)
{
+ int err;
unsigned char dummy[2];
int N2, N4;
N2 = st->Fs/200;
@@ -1141,7 +1151,9 @@
/* NOTE: We could speed this up slightly (at the expense of code size) by just adding a function that prefills the buffer */
celt_encode_with_ec(celt_enc, pcm_buf+st->channels*(frame_size-N2-N4), N4, dummy, 2, NULL);
- 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)
+ return OPUS_INTERNAL_ERROR;
celt_encoder_ctl(celt_enc, OPUS_GET_FINAL_RANGE(&redundant_rng));
}