From ac9fabc7be6576dc9fed463eeda0c6c3574aa9c9 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Wed, 7 Sep 2016 22:04:49 -0400 Subject: [PATCH] Fixes an internal error in the Opus encoder The encoder would reserve bytes for redundancy and then decide to use CELT, but not use those bytes. --- src/opus_encoder.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/opus_encoder.c b/src/opus_encoder.c index ef464fc5..aa5e73d4 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -1729,6 +1729,13 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ st->mode = MODE_HYBRID; if (st->mode == MODE_HYBRID && curr_bandwidth <= OPUS_BANDWIDTH_WIDEBAND) st->mode = MODE_SILK_ONLY; + /* If we decided to go with CELT, make sure redundancy is off, no matter what + we decided earlier. */ + if (st->mode == MODE_CELT_ONLY) + { + redundancy = 0; + redundancy_bytes = 0; + } /* printf("%d %d %d %d\n", st->bitrate_bps, st->stream_channels, st->mode, curr_bandwidth); */ bytes_target = IMIN(max_data_bytes-redundancy_bytes, st->bitrate_bps * frame_size / (st->Fs * 8)) - 1; -- GitLab