Bug 1497552 - Remove support for 44100 Hz in dtmf_tone_generator; r=padenot
authorDan Minor <dminor@mozilla.com>
Thu, 29 Nov 2018 12:59:01 +0000
changeset 505147 8ea04ec01e9905d4714aa01ade891d552c56a3a6
parent 505146 eb07312cfbe868780ebed84fc83e5a5470e81fb4
child 505148 6c5424f777093578ce457708056e2f0d72c6b5e4
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1497552, 44100
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1497552 - Remove support for 44100 Hz in dtmf_tone_generator; r=padenot Assertions in NetEqImpl::SetSampleRateAndChannels prevent us from requesting tones at 44100 Hz, so this code can be safely removed. Differential Revision: https://phabricator.services.mozilla.com/D12982
media/webrtc/trunk/webrtc/modules/audio_coding/neteq/dtmf_tone_generator.cc
media/webrtc/trunk/webrtc/modules/audio_coding/neteq/dtmf_tone_generator.h
--- a/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/dtmf_tone_generator.cc
+++ b/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/dtmf_tone_generator.cc
@@ -31,72 +31,64 @@
 #include "modules/audio_coding/neteq/dtmf_tone_generator.h"
 
 #include "rtc_base/arraysize.h"
 #include "rtc_base/checks.h"
 
 namespace webrtc {
 
 // The filter coefficient a = 2*cos(2*pi*f/fs) for the low frequency tone, for
-// sample rates fs = {8000, 16000, 32000, 44100, 48000} Hz, and events 0 through 15.
+// sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0 through 15.
 // Values are in Q14.
-const int DtmfToneGenerator::kCoeff1[NumDtmfSampleRates][16] = {
+const int DtmfToneGenerator::kCoeff1[4][16] = {
     { 24219, 27980, 27980, 27980, 26956, 26956, 26956, 25701, 25701, 25701,
       24219, 24219, 27980, 26956, 25701, 24219 },
     { 30556, 31548, 31548, 31548, 31281, 31281, 31281, 30951, 30951, 30951,
       30556, 30556, 31548, 31281, 30951, 30556 },
     { 32210, 32462, 32462, 32462, 32394, 32394, 32394, 32311, 32311, 32311,
       32210, 32210, 32462, 32394, 32311, 32210 },
-    { 32474, 32607, 32607, 32607, 32571, 32571, 32571, 32527, 32527, 32527,
-      32474, 32474, 32607, 32571, 32527, 32474 },
     { 32520, 32632, 32632, 32632, 32602, 32602, 32602, 32564, 32564, 32564,
       32520, 32520, 32632, 32602, 32564, 32520 } };
 
 // The filter coefficient a = 2*cos(2*pi*f/fs) for the high frequency tone, for
-// sample rates fs = {8000, 16000, 32000, 44100, 48000} Hz, and events 0 through 15.
+// sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0 through 15.
 // Values are in Q14.
-const int DtmfToneGenerator::kCoeff2[NumDtmfSampleRates][16] = {
+const int DtmfToneGenerator::kCoeff2[4][16] = {
     { 16325, 19073, 16325, 13085, 19073, 16325, 13085, 19073, 16325, 13085,
       19073, 13085, 9315, 9315, 9315, 9315},
     { 28361, 29144, 28361, 27409, 29144, 28361, 27409, 29144, 28361, 27409,
       29144, 27409, 26258, 26258, 26258, 26258},
     { 31647, 31849, 31647, 31400, 31849, 31647, 31400, 31849, 31647, 31400,
       31849, 31400, 31098, 31098, 31098, 31098},
-    { 32176, 32283, 32176, 32045, 32283, 32176, 32045, 32283, 32176, 32045,
-      32283, 32045, 31885, 31885, 31885, 31885},
     { 32268, 32359, 32268, 32157, 32359, 32268, 32157, 32359, 32268, 32157,
       32359, 32157, 32022, 32022, 32022, 32022} };
 
 // The initialization value x[-2] = sin(2*pi*f/fs) for the low frequency tone,
-// for sample rates fs = {8000, 16000, 32000, 44100, 48000} Hz, and events 0-15.
+// for sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0-15.
 // Values are in Q14.
-const int DtmfToneGenerator::kInitValue1[NumDtmfSampleRates][16] = {
+const int DtmfToneGenerator::kInitValue1[4][16] = {
     { 11036, 8528, 8528, 8528, 9315, 9315, 9315, 10163, 10163, 10163, 11036,
       11036, 8528, 9315, 10163, 11036},
     { 5918, 4429, 4429, 4429, 4879, 4879, 4879, 5380, 5380, 5380, 5918, 5918,
       4429, 4879, 5380, 5918},
     { 3010, 2235, 2235, 2235, 2468, 2468, 2468, 2728, 2728, 2728, 3010, 3010,
       2235, 2468, 2728, 3010},
-    { 2190, 1624, 1624, 1624, 1794, 1794, 1794, 1984, 1984, 1984, 2190, 2190,
-      1624, 1794, 1984, 2190},
     { 2013, 1493, 1493, 1493, 1649, 1649, 1649, 1823, 1823, 1823, 2013, 2013,
       1493, 1649, 1823, 2013 } };
 
 // The initialization value x[-2] = sin(2*pi*f/fs) for the high frequency tone,
-// for sample rates fs = {8000, 16000, 32000, 44100, 48000} Hz, and events 0-15.
+// for sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0-15.
 // Values are in Q14.
-const int DtmfToneGenerator::kInitValue2[NumDtmfSampleRates][16] = {
+const int DtmfToneGenerator::kInitValue2[4][16] = {
     { 14206, 13323, 14206, 15021, 13323, 14206, 15021, 13323, 14206, 15021,
       13323, 15021, 15708, 15708, 15708, 15708},
     { 8207, 7490, 8207, 8979, 7490, 8207, 8979, 7490, 8207, 8979, 7490, 8979,
       9801, 9801, 9801, 9801},
     { 4249, 3853, 4249, 4685, 3853, 4249, 4685, 3853, 4249, 4685, 3853, 4685,
       5164, 5164, 5164, 5164},
-    { 3100, 2808, 3100, 3422, 3778, 2808, 3100, 3422, 3778, 2808, 3100, 3422,
-      3778, 3778, 3778, 3778},
     { 2851, 2582, 2851, 3148, 2582, 2851, 3148, 2582, 2851, 3148, 2582, 3148,
       3476, 3476, 3476, 3476} };
 
 // Amplitude multipliers for volume values 0 through 63, corresponding to
 // 0 dBm0 through -63 dBm0. Values are in Q14.
 // for a in range(0, 64):
 //   print round(16141.0 * 10**(-float(a)/20))
 const int DtmfToneGenerator::kAmplitude[64] = {
@@ -121,20 +113,18 @@ int DtmfToneGenerator::Init(int fs, int 
   initialized_ = false;
   size_t fs_index;
   if (fs == 8000) {
     fs_index = 0;
   } else if (fs == 16000) {
     fs_index = 1;
   } else if (fs == 32000) {
     fs_index = 2;
-  } else if (fs == 44100) {
+  } else if (fs == 48000) {
     fs_index = 3;
-  } else if (fs == 48000) {
-    fs_index = 4;
   } else {
     RTC_NOTREACHED();
     fs_index = 1;  // Default to 8000 Hz.
   }
 
   if (event < 0 || event > 15) {
     return kParameterError;  // Invalid event number.
   }
--- a/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/dtmf_tone_generator.h
+++ b/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/dtmf_tone_generator.h
@@ -12,46 +12,36 @@
 #define MODULES_AUDIO_CODING_NETEQ_DTMF_TONE_GENERATOR_H_
 
 #include "modules/audio_coding/neteq/audio_multi_vector.h"
 #include "rtc_base/constructormagic.h"
 #include "typedefs.h"  // NOLINT(build/include)
 
 namespace webrtc {
 
-const int NumDtmfSampleRates = 5;
-const int DtmfSampleRates[NumDtmfSampleRates] = {
-  8000,
-  16000,
-  32000,
-  44100,
-  48000
-};
-
 // This class provides a generator for DTMF tones.
 class DtmfToneGenerator {
  public:
   enum ReturnCodes {
     kNotInitialized = -1,
     kParameterError = -2,
   };
 
   DtmfToneGenerator();
   virtual ~DtmfToneGenerator() {}
   virtual int Init(int fs, int event, int attenuation);
   virtual void Reset();
   virtual int Generate(size_t num_samples, AudioMultiVector* output);
   virtual bool initialized() const;
 
  private:
-  static const int kCoeff1[NumDtmfSampleRates][16];  // 1st oscillator model coefficient table.
-  static const int kCoeff2[NumDtmfSampleRates][16];  // 2nd oscillator model coefficient table.
-  static const int kInitValue1[NumDtmfSampleRates][16];  // Initialization for 1st oscillator.
-  static const int kInitValue2[NumDtmfSampleRates][16];  // Initialization for 2nd oscillator.
-
+  static const int kCoeff1[4][16];  // 1st oscillator model coefficient table.
+  static const int kCoeff2[4][16];  // 2nd oscillator model coefficient table.
+  static const int kInitValue1[4][16];  // Initialization for 1st oscillator.
+  static const int kInitValue2[4][16];  // Initialization for 2nd oscillator.
   static const int kAmplitude[64];  // Amplitude for 0 through -63 dBm0.
   static const int16_t kAmpMultiplier = 23171;  // 3 dB attenuation (in Q15).
 
   bool initialized_;            // True if generator is initialized properly.
   int coeff1_;                  // 1st oscillator coefficient for this event.
   int coeff2_;                  // 2nd oscillator coefficient for this event.
   int amplitude_;               // Amplitude for this event.
   int16_t sample_history1_[2];  // Last 2 samples for the 1st oscillator.