From efe16c5d470e3d693cc7de1a0cb92a93db3e771c Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Thu, 29 Sep 2011 22:02:37 -0400 Subject: [PATCH] don't allow the user to override the bandwidth so that it's above what Fs allows --- src/opus_encoder.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/opus_encoder.c b/src/opus_encoder.c index d1b48562..be61ba40 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -555,6 +555,9 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size, st->bandwidth = OPUS_BANDWIDTH_WIDEBAND; } + if (st->user_bandwidth != OPUS_AUTO) + st->bandwidth = st->user_bandwidth; + /* Prevents Opus from wasting bits on frequencies that are above the Nyquist rate of the input signal */ if (st->Fs <= 24000 && st->bandwidth > OPUS_BANDWIDTH_SUPERWIDEBAND) @@ -566,8 +569,6 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size, if (st->Fs <= 8000 && st->bandwidth > OPUS_BANDWIDTH_NARROWBAND) st->bandwidth = OPUS_BANDWIDTH_NARROWBAND; - if (st->user_bandwidth != OPUS_AUTO) - st->bandwidth = st->user_bandwidth; /* 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))