From c6d0c43df7836e59e34b07ea5c8077718593e708 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin <jmvalin@jmvalin.ca> Date: Mon, 14 Oct 2013 17:33:53 -0400 Subject: [PATCH] Fixes weird LFE bug The LFE encoder would first decide to switch to SILK, and allocated redundancy bytes. Then, it would force CELT because of LFE, but keep the redundancy allocation, and end up with too few bytes, that would end up being padded to the desired size for CBR. --- src/opus_encoder.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/opus_encoder.c b/src/opus_encoder.c index bdacb6bc4..eff0af70c 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -1195,6 +1195,8 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ /* Override the chosen mode to make sure we meet the requested frame size */ if (st->mode != MODE_CELT_ONLY && frame_size < st->Fs/100) st->mode = MODE_CELT_ONLY; + if (st->lfe) + st->mode = MODE_CELT_ONLY; if (st->stream_channels == 1 && st->prev_channels ==2 && st->silk_mode.toMono==0 && st->mode != MODE_CELT_ONLY && st->prev_mode != MODE_CELT_ONLY) @@ -1357,10 +1359,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ if (st->mode == MODE_CELT_ONLY && st->bandwidth == OPUS_BANDWIDTH_MEDIUMBAND) st->bandwidth = OPUS_BANDWIDTH_WIDEBAND; if (st->lfe) - { st->bandwidth = OPUS_BANDWIDTH_NARROWBAND; - st->mode = MODE_CELT_ONLY; - } /* Can't support higher than wideband for >20 ms frames */ if (frame_size > st->Fs/50 && (st->mode == MODE_CELT_ONLY || st->bandwidth > OPUS_BANDWIDTH_WIDEBAND)) -- GitLab