ref: c5e04e4aa4112131424c5c8a68d07998c895324e
parent: f982b84d1e0a5787526bd6ca650d27a0162c2134
author: Jean-Marc Valin <[email protected]>
date: Tue Mar 12 07:24:53 EDT 2013
Makes bandwidth detection less aggressive. The original code was causing parts of a sine sweep to be completely dropped due to the 300 Hz margin and the hysteresis. Also, fixes scaling for the analysis downmix when the input is 16-bit PCM.
--- a/src/analysis.c
+++ b/src/analysis.c
@@ -376,8 +376,8 @@
float E=0;
int band_start, band_end;
/* Keep a margin of 300 Hz for aliasing */
- band_start = extra_bands[b]+3;
- band_end = extra_bands[b+1]+3;
+ band_start = extra_bands[b];
+ band_end = extra_bands[b+1];
for (i=band_start;i<band_end;i++)
{
float binE = out[i].r*out[i].r + out[N-i].r*out[N-i].r
@@ -569,11 +569,11 @@
printf("%f ", features[i]);
printf("\n");*/
- if (bandwidth<=12 || (bandwidth==13 && tonal->opus_bandwidth == OPUS_BANDWIDTH_NARROWBAND))
+ if (bandwidth<=12)
tonal->opus_bandwidth = OPUS_BANDWIDTH_NARROWBAND;
- else if (bandwidth<=14 || (bandwidth==15 && tonal->opus_bandwidth == OPUS_BANDWIDTH_MEDIUMBAND))
+ else if (bandwidth<=14)
tonal->opus_bandwidth = OPUS_BANDWIDTH_MEDIUMBAND;
- else if (bandwidth<=16 || (bandwidth==17 && tonal->opus_bandwidth == OPUS_BANDWIDTH_WIDEBAND))
+ else if (bandwidth<=16)
tonal->opus_bandwidth = OPUS_BANDWIDTH_WIDEBAND;
else if (bandwidth<=18)
tonal->opus_bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND;
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -695,6 +695,8 @@
for (c=1;c<C;c++)
for (j=0;j<subframe;j++)
sub[j] += x[(j+offset)*C+c];
+ for (j=0;j<subframe;j++)
+ sub[j] *= (1.f/32768);
}
int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs,