Skip to content
Snippets Groups Projects
Commit c5e04e4a authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

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.
parent f982b84d
No related branches found
No related tags found
No related merge requests found
......@@ -376,8 +376,8 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con
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 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con
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;
......
......@@ -695,6 +695,8 @@ void downmix_int(const void *_x, float *sub, int subframe, int offset, int C)
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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment