Skip to content
Snippets Groups Projects
Commit eed33090 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Minor redundant frame fixes

parent f2c8e5df
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment