From bfad28185c9016cc21282e0839ac4b891cb87970 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin <jmvalin@jmvalin.ca> Date: Tue, 25 Oct 2011 13:46:35 -0400 Subject: [PATCH] Adjusts the bandwidth thresholds depending on complexity and CBR --- src/opus_encoder.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 6a50a5170..3c496cc40 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -639,7 +639,17 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size, const opus_int32 *voice_bandwidth_thresholds, *music_bandwidth_thresholds; opus_int32 bandwidth_thresholds[8]; int bandwidth = OPUS_BANDWIDTH_FULLBAND; + opus_int32 equiv_rate2; + equiv_rate2 = equiv_rate; + if (st->mode != MODE_CELT_ONLY) + { + /* Adjust the threshold +/- 10% depending on complexity */ + equiv_rate2 = equiv_rate2 * (45+st->silk_mode.complexity)/50; + /* CBR is less efficient by ~1 kb/s */ + if (!st->use_vbr) + equiv_rate2 -= 1000; + } if (st->channels==2 && st->force_channels!=1) { voice_bandwidth_thresholds = stereo_voice_bandwidth_thresholds; @@ -665,7 +675,7 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size, else threshold += hysteresis; } - if (equiv_rate >= threshold) + if (equiv_rate2 >= threshold) break; } while (--bandwidth>OPUS_BANDWIDTH_NARROWBAND); st->bandwidth = bandwidth; -- GitLab