зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1291715 - Add support for 44100 and 48000 Hz sample rates to DtmfInband; r=jesup
The DtmfInband class does not support sample rates above 32000. This adds support for 44100 and 48000. The 'a' coefficients were calculated in python as: int(round(32768*math.cos(2*math.pi*f/fs))) The 'ym2' coefficients were calculated in python as: int(round(16383*math.sin(2*math.pi*f/fs))) where f was in: [697, 770, 852, 941, 1209, 1336, 1477, 1633] and fs was in: [8000, 16000, 32000, 44100, 44800]. The calculated values were slightly off the existing values at 8000 Hz, but agreed at 16000 and 32000 Hz. MozReview-Commit-ID: GIzyUSyecR4 --HG-- extra : rebase_source : 108bdbc492a58f1532a5629680753e7395a916ae
This commit is contained in:
Родитель
684dedad1f
Коммит
7703c636fc
|
@ -34,6 +34,16 @@ const int16_t Dtmf_a_times2Tab32Khz[8]=
|
|||
32462,32394, 32311, 32210, 31849, 31647, 31400, 31098
|
||||
};
|
||||
|
||||
const int16_t Dtmf_a_times2Tab44_1Khz[8]=
|
||||
{
|
||||
32607, 32571, 32527, 32474, 32283, 32176, 32045, 31885
|
||||
};
|
||||
|
||||
const int16_t Dtmf_a_times2Tab48Khz[8]=
|
||||
{
|
||||
32612, 32577, 32534, 32483, 32298, 32194, 32067, 31912
|
||||
};
|
||||
|
||||
// Second table is sin(2*pi*f/fs) in Q14
|
||||
|
||||
const int16_t Dtmf_ym2Tab8Khz[8]=
|
||||
|
@ -53,6 +63,16 @@ const int16_t Dtmf_ym2Tab32Khz[8]=
|
|||
2235, 2468, 2728, 3010, 3853, 4249, 4685, 5164
|
||||
};
|
||||
|
||||
const int16_t Dtmf_ym2Tab44_1Khz[8]=
|
||||
{
|
||||
1624, 1794, 1984, 2190, 2808, 3100, 3422, 3777
|
||||
};
|
||||
|
||||
const int16_t Dtmf_ym2Tab48Khz[8]=
|
||||
{
|
||||
1599, 1766, 1953, 2156, 2765, 3052, 3369, 3719
|
||||
};
|
||||
|
||||
const int16_t Dtmf_dBm0kHz[37]=
|
||||
{
|
||||
16141, 14386, 12821, 11427, 10184, 9077,
|
||||
|
@ -92,7 +112,9 @@ DtmfInband::SetSampleRate(uint16_t frequency)
|
|||
{
|
||||
if (frequency != 8000 &&
|
||||
frequency != 16000 &&
|
||||
frequency != 32000)
|
||||
frequency != 32000 &&
|
||||
frequency != 44100 &&
|
||||
frequency != 48000)
|
||||
{
|
||||
// invalid sample rate
|
||||
assert(false);
|
||||
|
@ -282,6 +304,12 @@ DtmfInband::DtmfFix_generate(int16_t *decoded,
|
|||
} else if (fs==32000) {
|
||||
a_times2Tbl=Dtmf_a_times2Tab32Khz;
|
||||
y2_Table=Dtmf_ym2Tab32Khz;
|
||||
} else if (fs==44100) {
|
||||
a_times2Tbl=Dtmf_a_times2Tab44_1Khz;
|
||||
y2_Table=Dtmf_ym2Tab44_1Khz;
|
||||
} else if (fs==48000) {
|
||||
a_times2Tbl=Dtmf_a_times2Tab48Khz;
|
||||
y2_Table=Dtmf_ym2Tab48Khz;
|
||||
} else {
|
||||
return(-1);
|
||||
}
|
||||
|
|
|
@ -599,6 +599,22 @@ OutputMixer::InsertInbandDtmfTone()
|
|||
{
|
||||
uint16_t sampleRate(0);
|
||||
_dtmfGenerator.GetSampleRate(sampleRate);
|
||||
|
||||
// We're not using a supported sample rate for the DtmfInband generator, so
|
||||
// we won't be able to generate feedback tones.
|
||||
if (!(_audioFrame.sample_rate_hz_ == 8000 ||
|
||||
_audioFrame.sample_rate_hz_ == 16000 ||
|
||||
_audioFrame.sample_rate_hz_ == 32000 ||
|
||||
_audioFrame.sample_rate_hz_ == 44100 ||
|
||||
_audioFrame.sample_rate_hz_ == 48000)) {
|
||||
|
||||
WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, -1),
|
||||
"OutputMixer::InsertInbandDtmfTone() Sample rate"
|
||||
"not supported");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sampleRate != _audioFrame.sample_rate_hz_)
|
||||
{
|
||||
// Update sample rate of Dtmf tone since the mixing frequency changed.
|
||||
|
|
Загрузка…
Ссылка в новой задаче