Minor redundant frame fixes

This commit is contained in:
Jean-Marc Valin 2011-03-18 16:29:15 -04:00
parent f2c8e5dfee
commit eed33090eb
2 changed files with 4 additions and 3 deletions

View file

@ -214,6 +214,8 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
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;
}

View file

@ -387,7 +387,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
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 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
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);
}