Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2016-06-01 03:49:41 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-06-29 22:21:31 +0300
commite7fcc9b53bf34efaccae79614f1d9d9fb411ab00 (patch)
treeb2acbaeb4b57415f6445d31f0043fd36cb512b0f
parent50a79d6075b163d52ee93c0e37b595da8d8107a1 (diff)
Fixing bandwidth selection hysteresis
Previously, the bandwidth detection could (e.g.) change the bandwidth from fullband to superwideband, and the hysteresis would then cause bandwidth to be stuck in superwideband.
-rw-r--r--src/opus_encoder.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 8dc2e5af..26d773c8 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -102,6 +102,8 @@ struct OpusEncoder {
int prev_channels;
int prev_framesize;
int bandwidth;
+ /* Bandwidth determined automatically from the rate (before any other adjustment) */
+ int auto_bandwidth;
int silk_bw_switch;
/* Sampling rate (at the API level) */
int first;
@@ -1471,7 +1473,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
hysteresis = bandwidth_thresholds[2*(bandwidth-OPUS_BANDWIDTH_MEDIUMBAND)+1];
if (!st->first)
{
- if (st->bandwidth >= bandwidth)
+ if (st->auto_bandwidth >= bandwidth)
threshold -= hysteresis;
else
threshold += hysteresis;
@@ -1479,7 +1481,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
if (equiv_rate >= threshold)
break;
} while (--bandwidth>OPUS_BANDWIDTH_NARROWBAND);
- st->bandwidth = bandwidth;
+ st->bandwidth = st->auto_bandwidth = bandwidth;
/* Prevents any transition to SWB/FB until the SILK layer has fully
switched to WB mode and turned the variable LP filter off */
if (!st->first && st->mode != MODE_CELT_ONLY && !st->silk_mode.inWBmodeWithoutVariableLP && st->bandwidth > OPUS_BANDWIDTH_WIDEBAND)