diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2018-06-14 13:22:48 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2018-06-14 13:22:48 -0400 |
commit | c1c247d7e715100a50ca185948c7336bdd4dfdba (patch) | |
tree | 72fb2842f28cc86fea4ca3a90524cd803dd1919a /src | |
parent | 16160ac68c8296f695c49c9847221608b084b5f9 (diff) | |
download | opus-c1c247d7e715100a50ca185948c7336bdd4dfdba.tar.gz |
Make bandwidth detection more conservative to avoid low-passing frames
Diffstat (limited to 'src')
-rw-r--r-- | src/analysis.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/analysis.c b/src/analysis.c index cdf60dcf..8ee57aa0 100644 --- a/src/analysis.c +++ b/src/analysis.c @@ -242,6 +242,7 @@ void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int float prob_min, prob_max; float vad_prob; int mpos, vpos; + int bandwidth_span; pos = tonal->read_pos; curr_lookahead = tonal->write_pos-tonal->read_pos; @@ -263,6 +264,8 @@ void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int OPUS_COPY(info_out, &tonal->info[pos], 1); tonality_max = tonality_avg = info_out->tonality; tonality_count = 1; + /* Look at the neighbouring frames and pick largest bandwidth found (to be safe). */ + bandwidth_span = 6; /* If possible, look ahead for a tone to compensate for the delay in the tone detector. */ for (i=0;i<3;i++) { @@ -274,6 +277,19 @@ void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int tonality_max = MAX32(tonality_max, tonal->info[pos].tonality); tonality_avg += tonal->info[pos].tonality; tonality_count++; + info_out->bandwidth = IMAX(info_out->bandwidth, tonal->info[pos].bandwidth); + bandwidth_span--; + } + pos = pos0; + /* Look back in time to see if any has a wider bandwidth than the current frame. */ + for (i=0;i<bandwidth_span;i++) + { + pos--; + if (pos < 0) + pos = DETECT_SIZE-1; + if (pos == tonal->write_pos) + break; + info_out->bandwidth = IMAX(info_out->bandwidth, tonal->info[pos].bandwidth); } info_out->tonality = MAX32(tonality_avg/tonality_count, tonality_max-.2f); |