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

Fixes two minor issues found in random testing at ridiculously low rate.

- When it cannot produce the rate it's being asked, the encoder now
  returns a "PLC packet"
- Makes it possible to use the CELT PLC for more than 20 ms
parent bbfc9c9e
No related branches found
No related tags found
No related merge requests found
......@@ -246,6 +246,20 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
}
}
/* For CELT/hybrid PLC of more than 20 ms, do multiple calls */
if (data==NULL && frame_size > F20 && mode != MODE_SILK_ONLY)
{
int nb_samples = 0;
do {
int ret = opus_decode_frame(st, NULL, 0, pcm, F20, 0);
if (ret != F20)
return OPUS_INTERNAL_ERROR;
pcm += F20*st->channels;
nb_samples += F20;
} while (nb_samples < frame_size);
RESTORE_STACK;
return frame_size;
}
ALLOC(pcm_transition, F5*st->channels, opus_val16);
if (data!=NULL && st->prev_mode > 0 && (
......
......@@ -479,6 +479,11 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
RESTORE_STACK;
return OPUS_BAD_ARG;
}
if (max_data_bytes<=0)
{
RESTORE_STACK;
return OPUS_BAD_ARG;
}
silk_enc = (char*)st+st->silk_enc_offset;
celt_enc = (CELTEncoder*)((char*)st+st->celt_enc_offset);
......@@ -490,6 +495,22 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
st->bitrate_bps = user_bitrate_to_bitrate(st, frame_size, max_data_bytes);
frame_rate = st->Fs/frame_size;
if (max_data_bytes<3 || st->bitrate_bps < 3*frame_rate*8
|| (frame_rate<50 && (max_data_bytes*frame_rate<300 || st->bitrate_bps < 2400)))
{
int tocmode = st->mode;
if (tocmode==0)
tocmode = MODE_SILK_ONLY;
if (frame_rate>100)
tocmode = MODE_CELT_ONLY;
if (frame_rate < 50)
tocmode = MODE_SILK_ONLY;
data[0] = gen_toc(tocmode, frame_rate,
st->bandwidth == 0 ? OPUS_BANDWIDTH_NARROWBAND : st->bandwidth,
st->stream_channels);
RESTORE_STACK;
return 1;
}
if (!st->use_vbr)
{
int cbrBytes;
......
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