Bug 1376395 - opus: Update to the 1.2.1 release. r=kinetik
New upstream release. Fixes an issue where the encoder would
incorrectly bandlimit signals to 12 kHz.
MozReview-Commit-ID: 91LsUhXDlxT
--- a/media/libopus/README_MOZILLA
+++ b/media/libopus/README_MOZILLA
@@ -3,9 +3,9 @@ IETF Opus audio codec reference implemen
The source in this directory was copied from an opus
repository checkout by running the ./update.sh script.
Any changes made to this version of the source should
be reflected in that script, e.g. by applying patch
files after the copy step.
The upstream repository is https://git.xiph.org/opus.git
-The git tag/revision used was v1.2.
+The git tag/revision used was v1.2.1.
--- a/media/libopus/moz.build
+++ b/media/libopus/moz.build
@@ -15,17 +15,17 @@ EXPORTS.opus += [
]
# We allow warnings for third-party code that can be updated from upstream.
ALLOW_COMPILER_WARNINGS = True
FINAL_LIBRARY = 'gkmedias'
DEFINES['OPUS_BUILD'] = True
-DEFINES['OPUS_VERSION'] = '"v1.2-mozilla"'
+DEFINES['OPUS_VERSION'] = '"v1.2.1-mozilla"'
DEFINES['USE_ALLOCA'] = True
# Don't export symbols
DEFINES['OPUS_EXPORT'] = ''
if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_AS']:
DEFINES['OPUS_ARM_ASM'] = True
DEFINES['OPUS_ARM_EXTERNAL_ASM'] = True
--- a/media/libopus/src/analysis.c
+++ b/media/libopus/src/analysis.c
@@ -658,28 +658,33 @@ static void tonality_analysis(TonalityAn
3) above the PCM quantization noise floor
We use b+1 because the first CELT band isn't included in tbands[]
*/
if (E>.1*bandwidth_mask && E*1e9f > maxE && E > noise_floor*(band_end-band_start))
bandwidth = b+1;
}
/* Special case for the last two bands, for which we don't have spectrum but only
the energy above 12 kHz. */
- {
+ if (tonal->Fs == 48000) {
+ float ratio;
float E = hp_ener*(1.f/(240*240));
+ ratio = tonal->prev_bandwidth==20 ? 0.03f : 0.07f;
#ifdef FIXED_POINT
/* silk_resampler_down2_hp() shifted right by an extra 8 bits. */
E *= 256.f*(1.f/Q15ONE)*(1.f/Q15ONE);
#endif
maxE = MAX32(maxE, E);
tonal->meanE[b] = MAX32((1-alphaE2)*tonal->meanE[b], E);
E = MAX32(E, tonal->meanE[b]);
/* Use a simple follower with 13 dB/Bark slope for spreading function */
bandwidth_mask = MAX32(.05f*bandwidth_mask, E);
- if (E>.1*bandwidth_mask && E*1e9f > maxE && E > noise_floor*160)
+ if (E>ratio*bandwidth_mask && E*1e9f > maxE && E > noise_floor*160)
+ bandwidth = 20;
+ /* This detector is unreliable, so if the bandwidth is close to SWB, assume it's FB. */
+ if (bandwidth >= 17)
bandwidth = 20;
}
if (tonal->count<=2)
bandwidth = 20;
frame_loudness = 20*(float)log10(frame_loudness);
tonal->Etracker = MAX32(tonal->Etracker-.003f, frame_loudness);
tonal->lowECount *= (1-alphaE);
if (frame_loudness < tonal->Etracker-30)
@@ -891,16 +896,17 @@ static void tonality_analysis(TonalityAn
tonal->last_music = tonal->music_prob>.5f;
#ifdef MLP_TRAINING
for (i=0;i<25;i++)
printf("%f ", features[i]);
printf("\n");
#endif
info->bandwidth = bandwidth;
+ tonal->prev_bandwidth = bandwidth;
/*printf("%d %d\n", info->bandwidth, info->opus_bandwidth);*/
info->noisiness = frame_noisiness;
info->valid = 1;
RESTORE_STACK;
}
void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, const void *analysis_pcm,
int analysis_frame_size, int frame_size, int c1, int c2, int C, opus_int32 Fs,
--- a/media/libopus/src/analysis.h
+++ b/media/libopus/src/analysis.h
@@ -50,16 +50,17 @@ typedef struct {
#define TONALITY_ANALYSIS_RESET_START angle
float angle[240];
float d_angle[240];
float d2_angle[240];
opus_val32 inmem[ANALYSIS_BUF_SIZE];
int mem_fill; /* number of usable samples in the buffer */
float prev_band_tonality[NB_TBANDS];
float prev_tonality;
+ int prev_bandwidth;
float E[NB_FRAMES][NB_TBANDS];
float logE[NB_FRAMES][NB_TBANDS];
float lowE[NB_TBANDS];
float highE[NB_TBANDS];
float meanE[NB_TBANDS+1];
float mem[32];
float cmean[8];
float std[9];