ref: eed33090eb67f5937b96b7108f81598254288448
parent: f2c8e5dfee9a1ec16a4b5c54dcd335791d18120e
author: Jean-Marc Valin <[email protected]>
date: Fri Mar 18 12:29:15 EDT 2011
Minor redundant frame fixes
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -214,6 +214,8 @@
else
redundancy_bytes = len - ((ec_tell(&dec)+7)>>3);
len -= redundancy_bytes;
+ if (len<0)
+ return CELT_CORRUPTED_DATA;
/* Shrink decoder because of raw bits */
dec.storage -= redundancy_bytes;
}
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -387,7 +387,7 @@
ec_enc_bit_logp(&enc, redundancy, 12);
if (redundancy)
{
- redundancy_bytes = 40;
+ redundancy_bytes = st->stream_channels*st->bitrate_bps/1600;
ec_enc_bit_logp(&enc, celt_to_silk, 1);
if (st->mode == MODE_HYBRID)
ec_enc_uint(&enc, redundancy_bytes-2, 256);
@@ -406,9 +406,8 @@
if (redundancy && celt_to_silk)
{
celt_encoder_ctl(st->celt_enc, CELT_SET_START_BAND(0));
- /* FIXME: This is wrong -- we need to set the flags properly */
+ /* FIXME: That's OK for now, but we need to set the flags properly */
celt_encoder_ctl(st->celt_enc, CELT_SET_VBR(0));
- /* FIXME: Make sure not to overflow here */
celt_encode(st->celt_enc, pcm_buf, st->Fs/200, data+nb_compr_bytes, redundancy_bytes);
celt_encoder_ctl(st->celt_enc, CELT_RESET_STATE);
}