ref: 691f6f931b69e85d2a31838313bdd7d04ba460c0
parent: 78fc664c0c339c5fa73409fca56126cc65452566
author: Jean-Marc Valin <[email protected]>
date: Tue May 31 16:49:41 EDT 2016
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.
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -102,6 +102,8 @@
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;
@@ -1477,7 +1479,7 @@
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;
@@ -1485,7 +1487,7 @@
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)